BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TSegmentCurl.cxx
Go to the documentation of this file.
1#include "TrkReco/TSegmentCurl.h"
2
3#define inline
4
5TSegmentCurl::TSegmentCurl( const unsigned superLayerId, const unsigned max )
6 : m_MaxLocalLayerId( max ), m_superLayerId( superLayerId ), m_flagOfUpdate( true ) {
7 m_list.removeAll();
8 for ( unsigned i = 0; i < 4; ++i )
9 {
10 m_seqOfLayer[i] = m_sizeOfLayer[i] = 0;
11 m_layer[i].removeAll();
12 }
13}
14
16 : m_flagOfUpdate( s.m_flagOfUpdate )
17 , m_list( s.m_list )
18 , m_MaxLocalLayerId( s.m_MaxLocalLayerId )
19 , m_superLayerId( s.m_superLayerId )
20 , m_maxSeq( s.m_maxSeq )
21 , m_layerIdOfMaxSeq( s.m_layerIdOfMaxSeq )
22 , m_numOfSeqOneLayer( s.m_numOfSeqOneLayer )
23 , m_numOfLargeSeqLayer( s.m_numOfLargeSeqLayer ) {
24 for ( unsigned i = 0; i < 4; ++i )
25 {
26 m_seqOfLayer[i] = s.m_seqOfLayer[i];
27 m_sizeOfLayer[i] = s.m_sizeOfLayer[i];
28 m_layer[i] = s.m_layer[i];
29 }
30}
31
33 : m_flagOfUpdate( s->m_flagOfUpdate )
34 , m_list( s->m_list )
35 , m_MaxLocalLayerId( s->m_MaxLocalLayerId )
36 , m_superLayerId( s->m_superLayerId )
37 , m_maxSeq( s->m_maxSeq )
38 , m_layerIdOfMaxSeq( s->m_layerIdOfMaxSeq )
39 , m_numOfSeqOneLayer( s->m_numOfSeqOneLayer )
40 , m_numOfLargeSeqLayer( s->m_numOfLargeSeqLayer ) {
41 for ( unsigned i = 0; i < 4; ++i )
42 {
43 m_seqOfLayer[i] = s->m_seqOfLayer[i];
44 m_sizeOfLayer[i] = s->m_sizeOfLayer[i];
45 m_layer[i] = s->m_layer[i];
46 }
47}
48
50 m_list.removeAll();
51 for ( unsigned i = 0; i < 4; ++i ) { m_layer[i].removeAll(); }
52}
53
54inline const unsigned TSegmentCurl::maxLocalLayerId( void ) const { return m_MaxLocalLayerId; }
55
56inline const unsigned TSegmentCurl::superLayerId( void ) const { return m_superLayerId; }
57
58inline const unsigned TSegmentCurl::seqOfLayer( const unsigned i ) {
59 if ( m_flagOfUpdate ) update();
60 return m_seqOfLayer[i];
61}
62
63inline const unsigned TSegmentCurl::sizeOfLayer( const unsigned i ) {
64 if ( m_flagOfUpdate ) update();
65 return m_sizeOfLayer[i];
66}
67
68inline const unsigned TSegmentCurl::maxLocalLayerId( const unsigned i ) {
69 m_MaxLocalLayerId = i;
70 return m_MaxLocalLayerId;
71}
72
73inline const unsigned TSegmentCurl::superLayerId( const unsigned i ) {
74 m_superLayerId = i;
75 return m_superLayerId;
76}
77
78inline void TSegmentCurl::append( TMLink& e ) {
79 m_flagOfUpdate = true;
80 m_layer[e.hit()->wire()->localLayerId()].append( e );
81 m_list.append( e );
82}
83
84inline void TSegmentCurl::append( TMLink* e ) {
85 m_flagOfUpdate = true;
86 m_layer[e->hit()->wire()->localLayerId()].append( e );
87 m_list.append( e );
88}
89
91 m_flagOfUpdate = true;
92 for ( unsigned i = 0; i < e.length(); ++i )
93 m_layer[e[i]->hit()->wire()->localLayerId()].append( e[i] );
94 m_list.append( e );
95}
96
97inline void TSegmentCurl::remove( TMLink& e ) {
98 m_flagOfUpdate = true;
99 m_layer[e.hit()->wire()->localLayerId()].remove( e );
100 m_list.remove( e );
101}
102
103inline void TSegmentCurl::remove( TMLink* e ) {
104 m_flagOfUpdate = true;
105 m_layer[e->hit()->wire()->localLayerId()].remove( e );
106 m_list.remove( e );
107}
108
110 m_flagOfUpdate = true;
111 for ( unsigned i = 0; i < e.length(); ++i )
112 m_layer[e[i]->hit()->wire()->localLayerId()].remove( e[i] );
113 m_list.remove( e );
114}
115
116inline void TSegmentCurl::removeAll( void ) {
117 m_flagOfUpdate = true;
118 m_list.removeAll();
119 for ( unsigned i = 0; i < 4; ++i ) { m_layer[i].removeAll(); }
120}
121
122inline const unsigned TSegmentCurl::maxSeq( void ) const {
123 // I try to use non-const member.
124 // If this method is bad, other methods are necessary.
125 TSegmentCurl* const localThis = const_cast<TSegmentCurl* const>( this );
126 if ( m_flagOfUpdate ) localThis->update();
127 return m_maxSeq;
128}
129
130inline const unsigned TSegmentCurl::layerIdOfMaxSeq( void ) {
131 if ( m_flagOfUpdate ) update();
132 return m_layerIdOfMaxSeq;
133}
134
135inline const unsigned TSegmentCurl::numOfSeqOneLayer( void ) {
136 if ( m_flagOfUpdate ) update();
137 return m_numOfSeqOneLayer;
138}
139
140inline const unsigned TSegmentCurl::numOfLargeSeqLayer( void ) {
141 if ( m_flagOfUpdate ) update();
142 return m_numOfLargeSeqLayer;
143}
144
146 if ( m_list.length() == 0 )
147 {
148 m_flagOfUpdate = false;
149 return;
150 }
151 m_maxSeq = m_layerIdOfMaxSeq = 0;
152 m_numOfSeqOneLayer = m_numOfLargeSeqLayer = 0;
153 for ( unsigned i = 0; i <= m_MaxLocalLayerId; ++i )
154 {
155 m_sizeOfLayer[i] = m_layer[i].length();
156 calcuSeq( i );
157 if ( m_seqOfLayer[i] >= m_maxSeq )
158 {
159 m_maxSeq = m_seqOfLayer[i];
160 m_layerIdOfMaxSeq = i;
161 }
162 if ( m_seqOfLayer[i] == 1 ) ++m_numOfSeqOneLayer;
163 if ( m_seqOfLayer[i] >= TCURL_LARGE_SEQUENCE ) ++m_numOfLargeSeqLayer;
164 }
165
166 m_flagOfUpdate = false;
167}
168
170 if ( this == &s ) return *this;
171
172 m_flagOfUpdate = s.m_flagOfUpdate;
173 m_list = s.m_list;
174 m_MaxLocalLayerId = s.m_MaxLocalLayerId;
175 m_superLayerId = s.m_superLayerId;
176
177 m_maxSeq = s.m_maxSeq;
178 m_layerIdOfMaxSeq = s.m_layerIdOfMaxSeq;
179 m_numOfSeqOneLayer = s.m_numOfSeqOneLayer;
180 m_numOfLargeSeqLayer = s.m_numOfLargeSeqLayer;
181
182 for ( unsigned i = 0; i < 4; ++i )
183 {
184 m_seqOfLayer[i] = s.m_seqOfLayer[i];
185 m_sizeOfLayer[i] = s.m_sizeOfLayer[i];
186 m_layer[i] = s.m_layer[i];
187 }
188
189 return *this;
190}
191
192#if defined( __GNUG__ )
193int sortByWireSerialNumber( const TMLink** a, const TMLink** b ) {
194 if ( ( *a )->hit()->wire()->id() < ( *b )->hit()->wire()->id() ) { return 1; }
195 else if ( ( *a )->hit()->wire()->id() == ( *b )->hit()->wire()->id() ) { return 0; }
196 else { return -1; }
197}
198#else
199extern "C" int sortByWireSerialNumber( const void* av, const void* bv ) {
200 const TMLink** a( (const TMLink**)av );
201 const TMLink** b( (const TMLink**)bv );
202 if ( ( *a )->hit()->wire()->id() < ( *b )->hit()->wire()->id() ) { return 1; }
203 else if ( ( *a )->hit()->wire()->id() == ( *b )->hit()->wire()->id() ) { return 0; }
204 else { return -1; }
205}
206#endif
207
208void TSegmentCurl::calcuSeq( unsigned i ) {
209 //...exception
210 if ( i > m_MaxLocalLayerId )
211 {
212 m_seqOfLayer[i] = 0;
213 return;
214 }
215 unsigned size = m_layer[i].length();
216 if ( size < 1 )
217 {
218 m_seqOfLayer[i] = 0;
219 return;
220 }
221 if ( size == 1 )
222 {
223 m_seqOfLayer[i] = 1;
224 return;
225 }
226
227 //...initialize
228 m_layer[i].sort( sortByWireSerialNumber );
229 unsigned seq = 1;
230 unsigned maxSeq = 0;
231 unsigned layerIdForWires = m_layer[i][0]->hit()->wire()->layerId();
232
233 //...calculation
234 // if(m_layer[i][0]->hit()->wire()->localId() ==
235 // static_cast<unsigned>(wires(m_superLayerId)-1) &&
236 if ( m_layer[i][0]->hit()->wire()->localId() ==
237 static_cast<unsigned>( wires( layerIdForWires ) - 1 ) &&
238 m_layer[i][size - 1]->hit()->wire()->localId() == 0 )
239 {
240 for ( unsigned j = 0; j < size - 1; ++j )
241 {
242 if ( m_layer[i][j]->hit()->wire()->localIdForMinus() - 1 ==
243 m_layer[i][j + 1]->hit()->wire()->localId() )
244 { ++seq; }
245 else { break; }
246 if ( j == size - 2 ) goto loop;
247 }
248 ++seq;
249 for ( unsigned j = size - 1; j > 0; --j )
250 {
251 if ( m_layer[i][j]->hit()->wire()->localIdForPlus() + 1 ==
252 m_layer[i][j - 1]->hit()->wire()->localId() )
253 { ++seq; }
254 else { break; }
255 }
256 loop:
257 if ( seq > maxSeq ) maxSeq = seq;
258 }
259 seq = 1;
260 for ( unsigned j = 0; j < size - 1; ++j )
261 {
262 if ( m_layer[i][j]->hit()->wire()->localIdForMinus() - 1 ==
263 m_layer[i][j + 1]->hit()->wire()->localId() )
264 { ++seq; }
265 else
266 {
267 if ( seq > maxSeq ) maxSeq = seq;
268 seq = 1;
269 }
270 }
271 if ( seq > maxSeq ) maxSeq = seq;
272
273 //...set and return
274 m_seqOfLayer[i] = maxSeq;
275 return;
276}
277
278/*unsigned
279TSegmentCurl::wires(const unsigned superLayerId) const
280{
281 // input - super layer id#(0-10)
282 // output - # of its super layer
283 if(superLayerId == 0)return 64;
284 if(superLayerId == 1)return 80;
285 if(superLayerId == 2)return 96;
286 if(superLayerId == 3)return 128;
287 if(superLayerId == 4)return 144;
288 if(superLayerId == 5)return 160;
289 if(superLayerId == 6)return 192;
290 if(superLayerId == 7)return 208;
291 if(superLayerId == 8)return 240;
292 if(superLayerId == 9)return 256;
293 if(superLayerId == 10)return 288;
294
295 std::cerr << "Error in the SegmentCurl(wires)." << std::endl;
296 return 0;
297}*/
298unsigned TSegmentCurl::wires( const unsigned LayerId ) const {
299 // input - layer id#(0-422)
300 // output - # of its layer
301 if ( LayerId == 0 ) return 40;
302 if ( LayerId == 1 ) return 44;
303 if ( LayerId == 2 ) return 48;
304 if ( LayerId == 3 ) return 56;
305 if ( LayerId == 4 ) return 64;
306 if ( LayerId == 5 ) return 72;
307 if ( LayerId == 6 || LayerId == 7 ) return 80;
308 if ( LayerId == 8 || LayerId == 9 ) return 76;
309 if ( LayerId == 10 || LayerId == 11 ) return 88;
310 if ( LayerId == 12 || LayerId == 13 ) return 100;
311 if ( LayerId == 14 || LayerId == 15 ) return 112;
312 if ( LayerId == 16 || LayerId == 17 ) return 128;
313 if ( LayerId == 18 || LayerId == 19 ) return 140;
314 if ( LayerId < 24 ) return 160;
315 if ( LayerId < 28 ) return 176;
316 if ( LayerId < 32 ) return 208;
317 if ( LayerId < 36 ) return 240;
318 if ( LayerId < 40 ) return 256;
319 if ( LayerId < 43 ) return 288;
320
321 std::cerr << "Error in the SegmentCurl(wires)." << std::endl;
322 return 0;
323}
324
325void TSegmentCurl::dump( void ) {
326 // std::cout.form(" Hep idhep mother mcPX mcPY mcPZ mcE mcMass\n");
327 // std::cout.form(" %3d % 4d % 4d % 2.2f % 2.2f % 2.2f % 2.2f % 2.3f\n",
328 // hepID, partID, mothID, mcpx, mcpy, mcpz, mce, mcmass);
329
330 std::cout << "=====Segment for Curling Track Finder=====" << std::endl;
331 std::cout << "List Size = " << m_list.length() << std::endl;
332 std::cout << "Flag of Update = " << m_flagOfUpdate
333 << ", Max Local Layer ID = " << m_MaxLocalLayerId
334 << ", Super Layer ID = " << m_superLayerId << std::endl;
335 std::cout << "Max Seq. = " << m_maxSeq << ", Its Layer ID = " << m_layerIdOfMaxSeq
336 << std::endl;
337 std::cout << "# of Seq = 1 Layer = " << m_numOfSeqOneLayer
338 << ", # of Large Seq. Layer = " << m_numOfLargeSeqLayer << std::endl;
339 // std::cout.form(" ID | Seq. of Layer | Size of Layer | Local ID List\n");
340 std::cout << "ID | Seq. of Layer | Size of Layer | Local ID List" << std::endl;
341 for ( unsigned i = 0; i < 4; ++i )
342 {
343 // std::cout.form(" %1d | %2d | %2d |", i, m_seqOfLayer[i],
344 // m_sizeOfLayer[i]);
345 std::cout << i << " | " << m_seqOfLayer[i] << " | " << m_sizeOfLayer[i] << " | ";
346 for ( unsigned j = 0, size = m_layer[i].length(); j < size; ++j )
347 std::cout << m_layer[i][j]->hit()->wire()->localId() << ", ";
348 std::cout << std::endl;
349 }
350}
#define max(a, b)
XmlRpcServer s
int sortByWireSerialNumber(const void *av, const void *bv)
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
unsigned localLayerId(void) const
returns local layer id in a super layer.
void remove(TMLink &)
void append(TMLink &)
const unsigned numOfLargeSeqLayer(void)
const unsigned numOfSeqOneLayer(void)
const unsigned layerIdOfMaxSeq(void)
void dump(void)
const unsigned sizeOfLayer(const unsigned)
TSegmentCurl(const unsigned superLayerId=9999, const unsigned max=9999)
unsigned wires(const unsigned) const
void update(void)
const unsigned maxSeq(void) const
const unsigned superLayerId(void) const
const unsigned maxLocalLayerId(void) const
const unsigned seqOfLayer(const unsigned)
void removeAll(void)
TSegmentCurl & operator=(const TSegmentCurl &)