siscone is hosted by Hepforge, IPPP Durham

The SISCone Jet Algorithm

Version 3.0.6



SISCone 3.0.6
reference.cpp
1
2// File: reference.cpp //
3// Description: source file for checkxor management (Creference class) //
4// This file is part of the SISCone project. //
5// For more details, see http://projects.hepforge.org/siscone //
6// //
7// Copyright (c) 2006 Gavin Salam and Gregory Soyez //
8// //
9// This program is free software; you can redistribute it and/or modify //
10// it under the terms of the GNU General Public License as published by //
11// the Free Software Foundation; either version 2 of the License, or //
12// (at your option) any later version. //
13// //
14// This program is distributed in the hope that it will be useful, //
15// but WITHOUT ANY WARRANTY; without even the implied warranty of //
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
17// GNU General Public License for more details. //
18// //
19// You should have received a copy of the GNU General Public License //
20// along with this program; if not, write to the Free Software //
21// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
22// //
23// $Revision:: $//
24// $Date:: $//
26
27#include "reference.h"
28#include "ranlux.h"
29#include <stdlib.h>
30
31namespace siscone{
32
33/*******************************************************
34 * Creference implementation *
35 * references used for checksums. *
36 * *
37 * This class implements some reference variable *
38 * that can be used for checksums. Those checksums *
39 * are useful to disentengle between contents of two *
40 * cones without looking into their explicit particle *
41 * contents. *
42 *******************************************************/
43
44// default constructor
47 ref[0] = ref[1] = ref[2] = 0;
48}
49
50 //static unsigned int reference_bit = 1;
51
52// create a random reference
53//---------------------------
55// ref[0] = reference_bit;
56// ref[1] = 0;
57// ref[2] = 0;
58// reference_bit <<= 1;
59
60 unsigned int r1 = ranlux_get();
61 unsigned int r2 = ranlux_get();
62 unsigned int r3 = ranlux_get();
63 unsigned int r4 = ranlux_get();
64 // since ranlux only produces 24 bits, take r4 and add 8 bits
65 // from it to each of r1,r2, r3 to get 3*32 bits.
66 ref[0] = r1+((r4 & 0x00ff0000) << 8);
67 ref[1] = r2+((r4 & 0x0000ff00) << 16);
68 ref[2] = r3+((r4 & 0x000000ff) << 24);
69
70 if (is_empty()) randomize();
71}
72
73// test emptyness
74//----------------
76 return (ref[0]==0) && (ref[1]==0) && (ref[2]==0);
77}
78
79// test non-emptyness
80//--------------------
82 return (ref[0]!=0) || (ref[1]!=0) || (ref[2]!=0);
83}
84
85// assignment of reference
86//-------------------------
88 ref[0] = r.ref[0];
89 ref[1] = r.ref[1];
90 ref[2] = r.ref[2];
91 return *this;
92}
93
94// addition of reference
95//-----------------------
97 Creference tmp = *this;
98 return tmp+=r;
99}
100
101// incrementation of reference
102//-----------------------------
104 ref[0] ^= r.ref[0];
105 ref[1] ^= r.ref[1];
106 ref[2] ^= r.ref[2];
107 return *this;
108}
109
110// decrementation of reference
111//-----------------------------
113 ref[0] ^= r.ref[0];
114 ref[1] ^= r.ref[1];
115 ref[2] ^= r.ref[2];
116 return *this;
117}
118
119}
120
references used for checksums.
Definition: reference.h:43
Creference operator+(const Creference &r)
addition of reference
Definition: reference.cpp:96
bool is_empty()
test emptyness
Definition: reference.cpp:75
Creference & operator=(const Creference &r)
assignment of reference
Definition: reference.cpp:87
Creference()
default constructor
Definition: reference.cpp:46
void randomize()
create a random reference
Definition: reference.cpp:54
Creference & operator+=(const Creference &r)
incrementation of reference
Definition: reference.cpp:103
bool not_empty()
test non-emptyness
Definition: reference.cpp:81
Creference & operator-=(const Creference &r)
decrementation of reference
Definition: reference.cpp:112
unsigned int ref[3]
actual data for the reference
Definition: reference.h:72

The SISCone project has been developed by Gavin Salam and Gregory Soyez
Documentation generated on Tue Jun 20 2023 18:08:37 for SISCone by  Doxygen 1.9.4