BOSS 7.0.1
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
5
6TSegmentCurl::TSegmentCurl(const unsigned superLayerId,
7 const unsigned max)
8 : m_MaxLocalLayerId(max), m_superLayerId(superLayerId), m_flagOfUpdate(true)
9{
10 m_list.removeAll();
11 for(unsigned i=0;i<4;++i){
12 m_seqOfLayer[i] = m_sizeOfLayer[i] = 0;
13 m_layer[i].removeAll();
14 }
15}
16
17
19 : m_flagOfUpdate(s.m_flagOfUpdate), m_list(s.m_list), m_MaxLocalLayerId(s.m_MaxLocalLayerId), m_superLayerId(s.m_superLayerId),
20 m_maxSeq(s.m_maxSeq), m_layerIdOfMaxSeq(s.m_layerIdOfMaxSeq), m_numOfSeqOneLayer(s.m_numOfSeqOneLayer),
21 m_numOfLargeSeqLayer(s.m_numOfLargeSeqLayer)
22{
23 for(unsigned i=0;i<4;++i){
24 m_seqOfLayer[i] = s.m_seqOfLayer[i];
25 m_sizeOfLayer[i] = s.m_sizeOfLayer[i];
26 m_layer[i] = s.m_layer[i];
27 }
28}
29
30
32 : m_flagOfUpdate(s->m_flagOfUpdate), m_list(s->m_list), m_MaxLocalLayerId(s->m_MaxLocalLayerId), m_superLayerId(s->m_superLayerId),
33 m_maxSeq(s->m_maxSeq), m_layerIdOfMaxSeq(s->m_layerIdOfMaxSeq), m_numOfSeqOneLayer(s->m_numOfSeqOneLayer),
34 m_numOfLargeSeqLayer(s->m_numOfLargeSeqLayer)
35{
36 for(unsigned i=0;i<4;++i){
37 m_seqOfLayer[i] = s->m_seqOfLayer[i];
38 m_sizeOfLayer[i] = s->m_sizeOfLayer[i];
39 m_layer[i] = s->m_layer[i];
40 }
41}
42
43
45{
46 m_list.removeAll();
47 for(unsigned i=0;i<4;++i){
48 m_layer[i].removeAll();
49 }
50}
51
52
53inline
54const unsigned
56{
57 return m_MaxLocalLayerId;
58}
59
60
61inline
62const unsigned
64{
65 return m_superLayerId;
66}
67
68
69inline
70const unsigned
71TSegmentCurl::seqOfLayer(const unsigned i)
72{
73 if(m_flagOfUpdate)update();
74 return m_seqOfLayer[i];
75}
76
77
78inline
79const unsigned
81{
82 if(m_flagOfUpdate)update();
83 return m_sizeOfLayer[i];
84}
85
86
87inline
88const unsigned
90{
91 m_MaxLocalLayerId = i;
92 return m_MaxLocalLayerId;
93}
94
95
96inline
97const unsigned
99{
100 m_superLayerId = i;
101 return m_superLayerId;
102}
103
104
105inline
106void
108{
109 m_flagOfUpdate = true;
110 m_layer[e.hit()->wire()->localLayerId()].append(e);
111 m_list.append(e);
112}
113
114
115inline
116void
118{
119 m_flagOfUpdate = true;
120 m_layer[e->hit()->wire()->localLayerId()].append(e);
121 m_list.append(e);
122}
123
124
125inline
126void
128{
129 m_flagOfUpdate = true;
130 for(unsigned i = 0; i < e.length(); ++i)
131 m_layer[e[i]->hit()->wire()->localLayerId()].append(e[i]);
132 m_list.append(e);
133}
134
135
136inline
137void
139{
140 m_flagOfUpdate = true;
141 m_layer[e.hit()->wire()->localLayerId()].remove(e);
142 m_list.remove(e);
143}
144
145
146inline
147void
149{
150 m_flagOfUpdate = true;
151 m_layer[e->hit()->wire()->localLayerId()].remove(e);
152 m_list.remove(e);
153}
154
155
156inline
157void
159{
160 m_flagOfUpdate = true;
161 for(unsigned i = 0; i < e.length(); ++i)
162 m_layer[e[i]->hit()->wire()->localLayerId()].remove(e[i]);
163 m_list.remove(e);
164}
165
166
167inline
168void
170{
171 m_flagOfUpdate = true;
172 m_list.removeAll();
173 for(unsigned i=0;i<4;++i){
174 m_layer[i].removeAll();
175 }
176}
177
178
179inline
180const unsigned
182{
183 // I try to use non-const member.
184 // If this method is bad, other methods are necessary.
185 TSegmentCurl * const localThis = const_cast<TSegmentCurl * const>(this);
186 if(m_flagOfUpdate)localThis->update();
187 return m_maxSeq;
188}
189
190
191inline
192const unsigned
194{
195 if(m_flagOfUpdate)update();
196 return m_layerIdOfMaxSeq;
197}
198
199
200inline
201const unsigned
203{
204 if(m_flagOfUpdate)update();
205 return m_numOfSeqOneLayer;
206}
207
208
209inline
210const unsigned
212{
213 if(m_flagOfUpdate)update();
214 return m_numOfLargeSeqLayer;
215}
216
217
218void
220{
221 if(m_list.length() == 0){
222 m_flagOfUpdate = false;
223 return;
224 }
225 m_maxSeq = m_layerIdOfMaxSeq = 0;
226 m_numOfSeqOneLayer = m_numOfLargeSeqLayer = 0;
227 for(unsigned i = 0; i <= m_MaxLocalLayerId; ++i){
228 m_sizeOfLayer[i] = m_layer[i].length();
229 calcuSeq(i);
230 if(m_seqOfLayer[i] >= m_maxSeq){
231 m_maxSeq = m_seqOfLayer[i];
232 m_layerIdOfMaxSeq = i;
233 }
234 if(m_seqOfLayer[i] == 1)++m_numOfSeqOneLayer;
235 if(m_seqOfLayer[i] >= TCURL_LARGE_SEQUENCE)++m_numOfLargeSeqLayer;
236 }
237
238 m_flagOfUpdate = false;
239}
240
241
244{
245 if(this == &s)return *this;
246
247 m_flagOfUpdate = s.m_flagOfUpdate;
248 m_list = s.m_list;
249 m_MaxLocalLayerId = s.m_MaxLocalLayerId;
250 m_superLayerId = s.m_superLayerId;
251
252 m_maxSeq = s.m_maxSeq;
253 m_layerIdOfMaxSeq = s.m_layerIdOfMaxSeq;
254 m_numOfSeqOneLayer = s.m_numOfSeqOneLayer;
255 m_numOfLargeSeqLayer = s.m_numOfLargeSeqLayer;
256
257 for(unsigned i=0;i<4;++i){
258 m_seqOfLayer[i] = s.m_seqOfLayer[i];
259 m_sizeOfLayer[i] = s.m_sizeOfLayer[i];
260 m_layer[i] = s.m_layer[i];
261 }
262
263 return *this;
264}
265
266#if defined(__GNUG__)
267int
268sortByWireSerialNumber( const TMLink **a, const TMLink **b )
269{
270 if( (*a)->hit()->wire()->id() < (*b)->hit()->wire()->id() ){
271 return 1;
272 }else if( (*a)->hit()->wire()->id() == (*b)->hit()->wire()->id() ){
273 return 0;
274 }else{
275 return -1;
276 }
277}
278#else
279extern "C" int
280sortByWireSerialNumber( const void *av, const void *bv )
281{
282 const TMLink **a((const TMLink **)av);
283 const TMLink **b((const TMLink **)bv);
284 if( (*a)->hit()->wire()->id() < (*b)->hit()->wire()->id() ){
285 return 1;
286 }else if( (*a)->hit()->wire()->id() == (*b)->hit()->wire()->id() ){
287 return 0;
288 }else{
289 return -1;
290 }
291}
292#endif
293
294void
295TSegmentCurl::calcuSeq(unsigned i)
296{
297 //...exception
298 if(i > m_MaxLocalLayerId){
299 m_seqOfLayer[i] = 0;
300 return;
301 }
302 unsigned size = m_layer[i].length();
303 if(size < 1){
304 m_seqOfLayer[i] = 0;
305 return;
306 }
307 if(size == 1){
308 m_seqOfLayer[i] = 1;
309 return;
310 }
311
312 //...initialize
313 m_layer[i].sort(sortByWireSerialNumber);
314 unsigned seq = 1;
315 unsigned maxSeq = 0;
316 unsigned layerIdForWires = m_layer[i][0]->hit()->wire()->layerId();
317
318 //...calculation
319// if(m_layer[i][0]->hit()->wire()->localId() == static_cast<unsigned>(wires(m_superLayerId)-1) &&
320 if(m_layer[i][0]->hit()->wire()->localId() == static_cast<unsigned>(wires(layerIdForWires)-1) &&
321 m_layer[i][size-1]->hit()->wire()->localId() == 0){
322 for(unsigned j=0;j<size-1;++j){
323 if(m_layer[i][j]->hit()->wire()->localIdForMinus()-1 ==
324 m_layer[i][j+1]->hit()->wire()->localId()){
325 ++seq;
326 }else{
327 break;
328 }
329 if(j == size-2)goto loop;
330 }
331 ++seq;
332 for(unsigned j=size-1;j>0;--j){
333 if(m_layer[i][j]->hit()->wire()->localIdForPlus()+1 ==
334 m_layer[i][j-1]->hit()->wire()->localId()){
335 ++seq;
336 }else{
337 break;
338 }
339 }
340 loop:
341 if(seq > maxSeq)maxSeq = seq;
342 }
343 seq = 1;
344 for(unsigned j=0;j<size-1;++j){
345 if(m_layer[i][j]->hit()->wire()->localIdForMinus()-1 ==
346 m_layer[i][j+1]->hit()->wire()->localId()){
347 ++seq;
348 }else{
349 if(seq > maxSeq)maxSeq = seq;
350 seq = 1;
351 }
352 }
353 if(seq > maxSeq)maxSeq = seq;
354
355 //...set and return
356 m_seqOfLayer[i] = maxSeq;
357 return;
358}
359
360
361/*unsigned
362TSegmentCurl::wires(const unsigned superLayerId) const
363{
364 // input - super layer id#(0-10)
365 // output - # of its super layer
366 if(superLayerId == 0)return 64;
367 if(superLayerId == 1)return 80;
368 if(superLayerId == 2)return 96;
369 if(superLayerId == 3)return 128;
370 if(superLayerId == 4)return 144;
371 if(superLayerId == 5)return 160;
372 if(superLayerId == 6)return 192;
373 if(superLayerId == 7)return 208;
374 if(superLayerId == 8)return 240;
375 if(superLayerId == 9)return 256;
376 if(superLayerId == 10)return 288;
377
378 std::cerr << "Error in the SegmentCurl(wires)." << std::endl;
379 return 0;
380}*/
381unsigned
382TSegmentCurl::wires(const unsigned LayerId) const
383{
384 // input - layer id#(0-422)
385 // output - # of its layer
386 if(LayerId == 0)return 40;
387 if(LayerId == 1)return 44;
388 if(LayerId == 2)return 48;
389 if(LayerId == 3)return 56;
390 if(LayerId == 4)return 64;
391 if(LayerId == 5)return 72;
392 if(LayerId == 6 || LayerId == 7) return 80;
393 if(LayerId == 8 || LayerId == 9) return 76;
394 if(LayerId == 10|| LayerId == 11)return 88;
395 if(LayerId == 12|| LayerId == 13)return 100;
396 if(LayerId == 14|| LayerId == 15)return 112;
397 if(LayerId == 16|| LayerId == 17)return 128;
398 if(LayerId == 18|| LayerId == 19)return 140;
399 if(LayerId < 24)return 160;
400 if(LayerId < 28)return 176;
401 if(LayerId < 32)return 208;
402 if(LayerId < 36)return 240;
403 if(LayerId < 40)return 256;
404 if(LayerId < 43)return 288;
405
406 std::cerr << "Error in the SegmentCurl(wires)." << std::endl;
407 return 0;
408}
409
410void
412{
413 //std::cout.form(" Hep idhep mother mcPX mcPY mcPZ mcE mcMass\n");
414 //std::cout.form(" %3d % 4d % 4d % 2.2f % 2.2f % 2.2f % 2.2f % 2.3f\n",
415 //hepID, partID, mothID, mcpx, mcpy, mcpz, mce, mcmass);
416
417 std::cout << "=====Segment for Curling Track Finder=====" << std::endl;
418 std::cout << "List Size = " << m_list.length() << std::endl;
419 std::cout << "Flag of Update = " << m_flagOfUpdate
420 << ", Max Local Layer ID = " << m_MaxLocalLayerId
421 << ", Super Layer ID = " << m_superLayerId << std::endl;
422 std::cout << "Max Seq. = " << m_maxSeq << ", Its Layer ID = " << m_layerIdOfMaxSeq << std::endl;
423 std::cout << "# of Seq = 1 Layer = " << m_numOfSeqOneLayer
424 << ", # of Large Seq. Layer = " << m_numOfLargeSeqLayer << std::endl;
425 //std::cout.form(" ID | Seq. of Layer | Size of Layer | Local ID List\n");
426 std::cout << "ID | Seq. of Layer | Size of Layer | Local ID List" << std::endl;
427 for(unsigned i=0;i<4;++i){
428 //std::cout.form(" %1d | %2d | %2d |", i, m_seqOfLayer[i], m_sizeOfLayer[i]);
429 std::cout << i << " | " << m_seqOfLayer[i] << " | " << m_sizeOfLayer[i] << " | ";
430 for(unsigned j = 0, size = m_layer[i].length(); j < size; ++j)
431 std::cout << m_layer[i][j]->hit()->wire()->localId() << ", ";
432 std::cout << std::endl;
433 }
434}
XmlRpcServer s
Definition: HelloServer.cpp:11
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(void)
TSegmentCurl(const unsigned superLayerId=9999, const unsigned max=9999)
Definition: TSegmentCurl.cxx:6
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 &)