Class Reference for E1039 Core & Analysis Software
PatternDB.cxx
Go to the documentation of this file.
1 
9 #include "PatternDB.h"
10 
11 #include <cmath>
12 
13 // matching resolution 1: exact; 2: nearest neighbor; ...
14 #define _RESOLUTION1_ 1
15 #define _RESOLUTION2_ 1
16 #define _RESOLUTION3_ 1
17 
20 
22 
23 bool TrackletKey::operator == (const TrackletKey & k) const {
24 
25 // if(St==0 and X==78 and U==104 and V==93) {
26 // std::cout << "TrackletKey::operator == " << std::endl;
27 // std::cout << k << std::endl;
28 // }
29 
30  if (St == PatternDB::DC1
31  and St == k.St
32  and abs(X - k.X) < _RESOLUTION1_
33  and abs(U - k.U) < _RESOLUTION1_
34  and abs(V - k.V) < _RESOLUTION1_
35  ) return true;
36  if (St == PatternDB::DC2
37  and St == k.St
38  and abs(X - k.X) < _RESOLUTION2_
39  and abs(U - k.U) < _RESOLUTION2_
40  and abs(V - k.V) < _RESOLUTION2_
41  ) return true;
42  if ( (St == PatternDB::DC3p or St == PatternDB::DC3m)
43  and St == k.St
44  and abs(X - k.X) < _RESOLUTION3_
45  and abs(U - k.U) < _RESOLUTION3_
46  and abs(V - k.V) < _RESOLUTION3_
47  ) return true;
48 
49  return false;
50 }
51 
52 bool TrackletKey::operator != (const TrackletKey & k) const {
53  if ((*this) == k) return false;
54  return true;
55 }
56 
57 bool TrackletKey::operator < (const TrackletKey & k) const {
58 
59  if((*this) == k) return false;
60  else {
61  if (St<k.St) return true;
62  else if(St==k.St and X<k.X) return true;
63  else if(St==k.St and X==k.X and U<k.U) return true;
64  else if(St==k.St and X==k.X and U==k.U and V<k.V) return true;
65  }
66 
67 // if (St<k.St) return true;
68 // else if(St==k.St) {
69 // if(St==PatternDB::DC1) {
70 // if(X<k.X-(_RESOLUTION1_-1)) return true;
71 // else if(abs(X-k.X)<_RESOLUTION1_ and U<k.U-(_RESOLUTION1_-1)) return true;
72 // else if(abs(X-k.X)<_RESOLUTION1_ and abs(U-k.U)<_RESOLUTION1_ and V<k.V-(_RESOLUTION1_-1)) return true;
73 // } else if(St==PatternDB::DC2) {
74 // if(X<k.X-(_RESOLUTION2_-1)) return true;
75 // else if(abs(X-k.X)<_RESOLUTION2_ and U<k.U-(_RESOLUTION2_-1)) return true;
76 // else if(abs(X-k.X)<_RESOLUTION2_ and abs(U-k.U)<_RESOLUTION2_ and V<k.V-(_RESOLUTION2_-1)) return true;
77 // } else if(St==PatternDB::DC3p or St==PatternDB::DC3m) {
78 // if(X<k.X-(_RESOLUTION3_-1)) return true;
79 // else if(abs(X-k.X)<_RESOLUTION3_ and U<k.U-(_RESOLUTION3_-1)) return true;
80 // else if(abs(X-k.X)<_RESOLUTION3_ and abs(U-k.U)<_RESOLUTION3_ and V<k.V-(_RESOLUTION3_-1)) return true;
81 // }
82 // }
83 
84  return false;
85 }
86 
88 {}
89 
90 void PatternDB::identify(std::ostream& os) const {
91  os
92  << "PatternDB::identify: "
93  << " St1 size: " << St1.size()
94  << " St2 size: " << St2.size()
95  << " St3 size: " << St3.size()
96  << " St23 size: " << St23.size()
97  << " St123 size: " << St123.size()
98  << std::endl;
99 }
100 
101 int PatternDB::isValid() const {
102  if (
103  St1.size()>0 or
104  St2.size()>0 or
105  St3.size()>0 or
106  St23.size()>0
107  ) return true;
108 
109  return false;
110 }
111 
112 //void PatternDB::print(const TrackletKey &key)
113 //{
130 //
131 //
132 // std::cout
133 // <<"TrackletKey: "
134 // << " {"
135 // << ((key.k0>>24) & 255) << ", "
136 // << ((key.k0>>16) & 255) << ", "
137 // << ((key.k0>>8) & 255) << ", "
138 // << ((key.k0) & 255)
139 // << "} "
140 // << " {"
141 // << ((key.k1>>24) & 255) << ", "
142 // << ((key.k1>>16) & 255) << ", "
143 // << ((key.k1>>8) & 255) << ", "
144 // << ((key.k1) & 255)
145 // << "} "
146 // << " {" << key.k0 << ", " << key.k1 << "} "
147 // << std::endl;
148 //}
149 
150 //void PatternDB::print(const PartTrackKey &key)
151 //{
152 // std::cout <<"PartTrackKey: " << std::endl;
153 // PatternDB::print(key.k0);
154 // PatternDB::print(key.k1);
155 //}
156 
158  identify();
159  int i=0;
160  for(auto key : St1) {
161  std::cout << key << std::endl;
162  ++i;
163  //if(i>100) break;
164  }
165 }
#define _RESOLUTION1_
Definition: PatternDB.cxx:14
#define _RESOLUTION2_
Definition: PatternDB.cxx:15
#define _RESOLUTION3_
Definition: PatternDB.cxx:16
ClassImp(PdbCalChan)
PatternDB interface objects.
Definition: PatternDB.h:117
std::set< TrackletKey > St2
Definition: PatternDB.h:143
static const TrackletKey ERR_KEY
Definition: PatternDB.h:124
virtual int isValid() const
isValid returns non zero if object contains vailid data
Definition: PatternDB.cxx:101
std::set< GlobTrackKey > St123
Definition: PatternDB.h:146
void print()
Definition: PatternDB.cxx:157
std::set< PartTrackKey > St23
Definition: PatternDB.h:145
std::set< TrackletKey > St1
Definition: PatternDB.h:142
std::set< TrackletKey > St3
Definition: PatternDB.h:144
virtual void identify(std::ostream &os=std::cout) const
Definition: PatternDB.cxx:90
unsigned char St
Definition: PatternDB.h:27
bool operator==(const TrackletKey &k) const
unsigned char U
Definition: PatternDB.h:29
bool operator<(const TrackletKey &k) const
Definition: PatternDB.cxx:57
unsigned char X
Definition: PatternDB.h:28
bool operator!=(const TrackletKey &k) const
Definition: PatternDB.cxx:52
unsigned char V
Definition: PatternDB.h:30