BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TConformalFinder.cxx
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TConformalFinder.cxx,v 1.49 2022/01/28 22:04:42 maqm Exp $
3//-----------------------------------------------------------------------------
4// Filename : TConformalFinder.cc
5// Section : Tracking
6// Owner : Yoshi Iwasaki
7// Email : yoshihito.iwasaki@kek.jp
8//-----------------------------------------------------------------------------
9// Description : A class to find tracks with the conformal method.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12// TConformalLink removed. TSegment added.
13//-----------------------------------------------------------------------------
14
15#include <algorithm>
16#include <string.h>
17// #include "CLHEP/String/Strings.h"
18// #include "basf/basfshm.h"
19#include "TrkReco/TCircle.h"
20#include "TrkReco/TConformalFinder.h"
21#include "TrkReco/TConformalFinder0.h"
22#include "TrkReco/THistogram.h"
23#include "TrkReco/TMDC.h"
24#include "TrkReco/TMDCTsf.h"
25#include "TrkReco/TMDCUtil.h"
26#include "TrkReco/TMDCWireHitMC.h"
27#include "TrkReco/TMLine.h"
28#include "TrkReco/TTrack.h"
29#include "TrkReco/TTrackHEP.h"
30#include "TrkReco/TTrackManager.h"
31
32#ifdef TRKRECO_DEBUG
33unsigned TConformalFinder::_stage = ConformalOutside;
34#endif
35#ifdef TRKRECO_WINDOW
36# include "TrkReco/TWindow.h"
37#endif
38
39// extern BasfSharedMem * BASF_Sharedmem;
40
41static const float PI2 = 2. * M_PI;
42static const float WIDTH[] = { PI2 / 40,
43 PI2 / 64, // the first two are stereo, tighter would be better
44 // for noise? Liu
45 PI2 / 76, PI2 / 100, PI2 / 128, PI2 / 160, PI2 / 176, PI2 / 208,
46 PI2 / 240, PI2 / 256, PI2 / 288 };
47
48std::string TConformalFinder::version( void ) const { return "3.03"; }
49
50TConformalFinder::TConformalFinder( unsigned fastFinder, unsigned slowFinder,
51 unsigned perfectSegmentFinding, float maxSigma,
52 float maxSigmaStereo, float salvageLevel,
53 unsigned minNLinksForSegment, unsigned minNCoreLinks,
54 unsigned minNSegments, unsigned salvageLoadWidth,
55 unsigned stereoMode, unsigned stereoLoadWidth,
56 float szSegmentDistance, float szLinkDistance,
57 unsigned fittingFlag )
58 : _fastFinder( fastFinder )
59 , _slowFinder( slowFinder )
60 , _doT0Reset( false )
61 , _perfectSegmentFinding( perfectSegmentFinding )
62 , _segmentSeparation( 4 )
63 , _minNLinksForSegment( minNLinksForSegment )
64 , _minNLinksForSegmentInRefine( 2 )
65 , // 3, 20060307
66 _maxNLinksForSegment( 8 )
67 , _maxWidthForSegment( 4 )
68 , _minNCoreLinks( minNCoreLinks )
69 , _minNSegments( minNSegments )
70 , _minUsedFractionSlow2D( 0.5 )
71 , _salvageLoadWidth( salvageLoadWidth )
72 , _stereoMode( stereoMode )
73 , _stereoLoadWidth( stereoLoadWidth )
74 , _appendLoad( 2 )
75 , _maxSigma2( maxSigma )
76 , _T0ResetDone( false )
77 , _builder( "conformal builder", maxSigma, maxSigmaStereo, salvageLevel, szSegmentDistance,
78 szLinkDistance, fittingFlag )
79 , _s( 0 )
80 , m_pmgnIMF( nullptr )
81#ifdef TRKRECO_WINDOW
82 , _rphiWindow( "rphi window" )
83#endif
84{
85 _linkMaxDistance[0] = 0.02;
86 _linkMaxDistance[1] = 0.025;
87 _linkMaxDistance[2] = 0.025;
88 _linkMinDirAngle[0] = 0.97; // 0.98
89 _linkMinDirAngle[1] = 0.95; // 0.97
90 _linkMinDirAngle[2] = 0.95; // 0.97
91 // BASF_Sharedmem->allocate("TrkConfSum", sizeof(struct summary));
92}
93
95
96void TConformalFinder::dump( const std::string& msg, const std::string& pre ) const {
97 if ( msg.find( "state" ) != std::string::npos )
98 {
99 std::cout << pre;
100 TFinderBase::dump( msg );
101 std::cout << pre;
102 std::cout << "#axial=" << _hits[0].length();
103 std::cout << ",#stereo=" << _hits[1].length();
104 }
105 if ( msg.find( "summary" ) != std::string::npos ||
106 msg.find( "detail" ) != std::string::npos )
107 {
108 /* struct summary s;
109 // bzero((char *) & s, sizeof(struct summary));
110 memset((char *) & s, 0, sizeof(struct summary));
111 for (int i = 0; i < BASF_Sharedmem->nprocess(); i++) {
112 int size;
113 struct summary & r = * (struct summary *)
114 BASF_Sharedmem->get_pointer(i, "TrkConfSum", & size);
115 s._nEvents += r._nEvents;
116 s._nTracksFast3D += r._nTracksFast3D;
117 s._nTracksSlow3D += r._nTracksSlow3D;
118 s._nTracksFast2D += r._nTracksFast2D;
119 s._nTracksSlow2D += r._nTracksSlow2D;
120 s._nTracksFast2DBadQuality += r._nTracksFast2DBadQuality;
121 s._nTracksSlow2DBadQuality += r._nTracksSlow2DBadQuality;
122 }
123
124 std::cout << pre
125 << "all events : " << s._nEvents << std::endl;
126 std::cout << pre
127 << "fast 3D tracks : "
128 << s._nTracksFast3D << std::endl;
129 std::cout << pre
130 << "fast 2D tracks(line failed) : "
131 << s._nTracksFast2D << std::endl;
132 std::cout << pre
133 << "fast 2D tracks(3D failed) : "
134 << s._nTracksFast2DBadQuality << std::endl;
135 std::cout << pre
136 << "slow 3D tracks : "
137 << s._nTracksSlow3D << std::endl;
138 std::cout << pre
139 << "slow 2D tracks(line failed) : "
140 << s._nTracksSlow2D << std::endl;
141 std::cout << pre
142 << "slow 2D tracks(3D failed) : "
143 << s._nTracksSlow2DBadQuality << std::endl;
144 */
145 }
146}
147
149 for ( unsigned i = 0; i < 3; i++ )
150 {
151 if ( i == 2 ) HepAListDeleteAll( _allHits[i] );
152 else _allHits[i].removeAll();
153 _hits[i].removeAll();
154 _unused[i].removeAll();
155 }
156 for ( unsigned i = 0; i < 2; i++ )
157 {
158 for ( unsigned j = 0; j < 6; j++ )
159 {
160#ifdef TRKRECO_DEBUG_DETAIL
161 cout << "_allSegments length = " << _allSegments[i][j].length()
162 << " _allUnused length = " << _allUnused[i][j].length() << endl;
163#endif
164 HepAListDeleteAll( _allSegments[i][j] );
165 _allUnused[i][j].removeAll();
166 }
167 }
168 _2DTracks.removeAll();
169 _3DTracks.removeAll();
170}
171
172void TConformalFinder::selectGoodHits( void ) {
173 for ( unsigned i = 0; i < 2; i++ )
174 {
175 unsigned n = _allHits[i].length();
176 for ( unsigned j = 0; j < n; j++ )
177 {
178 unsigned state = _allHits[i][j]->hit()->state();
179 // if (_allHits[i][j]->hit()->reccdc()->tdc>800) continue;
180 // if ((state & WireHitIsolated) && (state & WireHitContinuous)) //tmp...
181 // if ((state & WireHitIsolated))
182 _hits[i].append( _allHits[i][j] );
183 // else
184 _unused[i].append( _allHits[i][j] );
185 }
186 }
187 _hits[2].append( _hits[0] );
188 _hits[2].append( _hits[1] );
189 _unused[2].append( _unused[0] );
190 _unused[2].append( _unused[1] );
191
192#ifdef TRKRECO_WINDOW
193 _rphiWindow.clear();
194 _rphiWindow.skip( false );
195 _rphiWindow.skipAllWindow( false );
196 _rphiWindow.append( _allHits[2] );
197 _rphiWindow.append( _hits[2], leda_pink );
198// _rphiWindow.skip(true);
199// _rphiWindow.skipAllWindow(true);
200#endif
201}
202
203void TConformalFinder::findSegments( void ) {
204
205 //...Create lists of links for each super layer...
206 AList<TMLink> links[11];
207 unsigned n = _hits[2].length();
208 for ( unsigned i = 0; i < n; i++ )
209 {
210 TMLink& l = *_hits[2][i];
211 links[l.wire()->superLayerId()].append( l );
212 }
213
214 //...Create phi hists...
215 THistogram* hist[11];
216 /* hist[0] = new THistogram(64);
217 hist[1] = new THistogram(80);
218 hist[2] = new THistogram(96);
219 hist[3] = new THistogram(128);
220 hist[4] = new THistogram(144);
221 hist[5] = new THistogram(160);
222 hist[6] = new THistogram(176);
223 hist[7] = new THistogram(208);
224 hist[8] = new THistogram(240);
225 hist[9] = new THistogram(256);
226 hist[10] = new THistogram(288);
227 */
228 hist[0] = new THistogram( 56 );
229 hist[1] = new THistogram( 80 );
230 hist[2] = new THistogram( 88 );
231 hist[3] = new THistogram( 112 );
232 hist[4] = new THistogram( 140 );
233 hist[5] = new THistogram( 160 );
234 hist[6] = new THistogram( 176 );
235 hist[7] = new THistogram( 208 );
236 hist[8] = new THistogram( 240 );
237 hist[9] = new THistogram( 256 );
238 hist[10] = new THistogram( 288 );
239
240 for ( unsigned i = 0; i < 11; i++ )
241 {
242 // unsigned superLayerId = i / 2;
243 // unsigned id = i % 2;
244 unsigned superLayerId;
245 unsigned id;
246 switch ( i )
247 {
248 case 0:
249 superLayerId = 0;
250 id = 1;
251 break;
252 case 1:
253 superLayerId = 1;
254 id = 1;
255 break;
256 case 2:
257 superLayerId = 0;
258 id = 0;
259 break;
260 case 3:
261 superLayerId = 1;
262 id = 0;
263 break;
264 case 4:
265 superLayerId = 2;
266 id = 0;
267 break;
268 case 5:
269 superLayerId = 2;
270 id = 1;
271 break;
272 case 6:
273 superLayerId = 3;
274 id = 1;
275 break;
276 case 7:
277 superLayerId = 4;
278 id = 1;
279 break;
280 case 8:
281 superLayerId = 5;
282 id = 1;
283 break;
284 case 9:
285 superLayerId = 3;
286 id = 0;
287 break;
288 case 10:
289 superLayerId = 4;
290 id = 0;
291 break;
292 default: break;
293 }
294 // hist[i]->fillX(links[i]);
295 hist[i]->fillPhi( links[i] );
296
297 //...Segment finding...
298 AList<TSegment> tmp = hist[i]->segments();
299
300 //...Remove bad segments...
301 unsigned n = tmp.length();
302 if ( id == 0 )
303 {
304 AList<TSegment> bad;
305 for ( unsigned j = 0; j < n; j++ )
306 {
307 TSegment* s = tmp[j];
308 if ( s->links().length() < _minNLinksForSegment ) bad.append( s );
309 else if ( s->links().length() > _maxNLinksForSegment ) bad.append( s );
310 // else if (Width(s->links()) > _maxWidthForSegment)
311 // bad.append(s);
312 }
313 tmp.remove( bad );
314 for ( unsigned j = 0; j < bad.length(); j++ )
315 {
316 _unused[id].append( bad[j]->links() );
317 _unused[2].append( bad[j]->links() );
318 }
319 HepAListDeleteAll( bad );
320 n = tmp.length();
321 }
322
323 //...Classify segments...
324 // if (n > 1) {
325 // for (unsigned k = 0; k < (n - 1); k++) {
326 // TSegment & s0 = * tmp[k];
327 // bool ok = true;
328 // for (unsigned l = k + 1; l < n; l++) {
329 // TSegment & s1 = * tmp[l];
330 // int distance =
331 // abs(InnerMost(s0.links())->wire()->localIdDifference(
332 // * InnerMost(s1.links())->wire()));
333 // if (distance < _segmentSeparation) {
334 // s0.state(s0.state() | TSegmentCrowd);
335 // s1.state(s1.state() | TSegmentCrowd);
336 // }
337 // }
338 // }
339 // }
340
341 //...Store them...
342 _allSegments[id][superLayerId].append( tmp );
343 _allUnused[id][superLayerId] = _allSegments[id][superLayerId];
344 delete hist[i];
345 }
346
347#ifdef TRKRECO_DEBUG_DETAIL
348 std::cout << "... segment finding finished" << std::endl;
349#endif
350}
351
352void TConformalFinder::linkSegments( unsigned level ) {
353 //...Clear old links...
354 unsigned superLayer = 5;
355 while ( --superLayer )
356 {
357 AList<TSegment>& segments = _allUnused[0][superLayer];
358 unsigned n = segments.length();
359 // cout<<"SL: "<<superLayer<<"; segments.length:"<<n<<endl;
360 for ( unsigned i = 0; i < n; i++ )
361 {
362 TSegment& base = *segments[i];
363#ifdef TRKRECO_DEBUG
364 if ( base.tracks().length() )
365 {
366 std::cout << "TConformalFinder::linkSegments !!! segment has ";
367 std::cout << "an assignment to track(s)" << std::endl;
368 }
369#endif
370 base.innerLinks().removeAll();
371 base.outerLinks().removeAll();
372 }
373 }
374
375 //...Super layer loop...
376 superLayer = 5;
377 while ( --superLayer )
378 {
379 AList<TSegment>& segments = _allUnused[0][superLayer];
380 AList<TSegment>& targets = _allUnused[0][superLayer - 1];
381 AList<TSegment>& targets2 = _allUnused[0][superLayer - 2];
382 unsigned n = segments.length();
383 for ( unsigned i = 0; i < n; i++ )
384 {
385 TSegment& base = *segments[i];
386#ifdef TRKRECO_DEBUG
387 if ( base.tracks().length() )
388 {
389 std::cout << "TConformalFinder::linkSegments !!! segment has ";
390 std::cout << "an assignment to track(s)" << std::endl;
391 }
392#endif
393
394 const HepPoint3D& p = base.position();
395 HepVector3D v = base.direction();
396 // std::cout<<"superlayer "<<superLayer<<" link length
397 //"<<base.outerLinks().length()<<std::endl;
398 if ( base.outerLinks().length() == 1 ) v = p - OuterMostUniqueLink( base )->position();
399 // if (base.outerLinks().length() == 1)
400 // v = p - base.outerLinks()[0]->position();
401 // if (base.outerLinks().length() == 1)
402 // v = direction(base);
403
404 AList<TSegment>& candidates = base.innerLinks();
405 TSegment* best = link( base, p, v, targets, candidates, level );
406 if ( ( best == NULL ) && ( level > 0 ) && ( superLayer > 1 ) )
407 { best = link( base, p, v, targets2, candidates, level ); }
408 if ( best ) candidates.insert( best );
409 // base.dump("hits");
410 // if(best)best->dump("hits");
411
412 unsigned m = candidates.length();
413 for ( unsigned j = 0; j < m; j++ ) candidates[j]->outerLinks().append( base );
414 }
415 }
416
417 // check innerLinks. Liuqg
418 /* superLayer = 5;
419 while(--superLayer){
420 //cout<<"SuperLayer: "<<superLayer<<endl;
421 AList<TSegment> & segments = _allUnused[0][superLayer];
422 unsigned n = segments.length();
423 for (unsigned k = 0; k < n; k++) {
424 TSegment & base = * segments[k];
425 int inners = base.innerLinks().length();
426 if (inners<2) continue;
427 AList<TSegment> badList;
428 for(int i = 0; i < inners; ++i){
429 for(int j = i+1; j < inners; ++j){
430 AList<TMLink> links = base.innerLinks()[j]->links();
431 AList<TMLink> multiLinks;
432 for (int k = 0; k < links.length(); ++k){
433 TMLink & l = * links[k];
434 if (base.innerLinks()[i]->links().hasMember(l)) multiLinks.append(l);
435 }
436 if (multiLinks.length() < 2) continue;
437 int nHits[4];
438 int multiLayers = 0;
439 for (int k = 0; k < multiLinks.length(); ++k)
440 ++nHits[multiLinks[k]->hit()->wire()->localLayerId()];
441 for (int k = 0; k < 4; ++k)
442 if (nHits[k] > 0) ++multiLayers;
443 if(multiLayers >= 2 && (links.length() > base.innerLinks()[i]->links().length()))
444 badList.append(base.innerLinks()[i]);
445 else if (multiLayers >= 2) badList.append( base.innerLinks()[j]);
446 else continue;
447 }
448 }
449 base.innerLinks().remove(badList);
450 }
451 }*/
452
453#ifdef TRKRECO_DEBUG
454 superLayer = 5;
455 while ( --superLayer )
456 {
457 cout << "SuperLayer: " << superLayer << endl;
458 AList<TSegment>& segments = _allUnused[0][superLayer];
459 unsigned n = segments.length();
460 for ( unsigned i = 0; i < n; i++ )
461 {
462 TSegment& base = *segments[i];
463 cout << "Layer: " << base.links()[0]->hit()->wire()->layerId()
464 << " Local: " << base.links()[0]->hit()->wire()->localId()
465 << " innerSeg: " << base.innerLinks().length() << endl;
466 }
467 }
468#endif
469
470#ifdef TRKRECO_WINDOW
471 // _rphiWindow.skipAllWindow(false);
472 displayStatus( "Conf::linkSegments ... results" );
473 _rphiWindow.wait();
474#endif
475}
476
477void TConformalFinder::resolveSegments( AList<TTrack>& trackCandidates ) const {
478#ifdef TRKRECO_DEBUG
479 std::cout << "... resolving assignments" << std::endl;
480#endif
481
482 //...Pick up segments which has multiple assignments...
483 AList<TSegment> multi;
484 unsigned n = trackCandidates.length();
485 for ( unsigned i = 0; i < n; i++ )
486 {
487 TTrack& t = *trackCandidates[i];
488 AList<TSegment>& segments = t.segments();
489 unsigned nS = segments.length();
490 for ( unsigned j = 0; j < nS; j++ )
491 {
492 if ( segments[j]->tracks().length() > 1 ) multi.append( segments[j] );
493 }
494 }
495 multi.purge();
496
497 //...Resolve assignments...
498 n = multi.length();
499 for ( unsigned i = 0; i < n; i++ )
500 {
501 TSegment& s = *multi[i];
502 const AList<TTrack>& tracks = s.tracks();
503 unsigned nT = tracks.length();
504
505 //...Check TMLink overlap...
506 AList<TMLink> multiLinks;
507 const AList<TMLink>& links = s.links();
508 unsigned nL = links.length();
509 for ( unsigned j = 0; j < nL; j++ )
510 {
511 TMLink& l = *links[j];
512 bool overlap = false;
513 for ( unsigned k = 0; k < nT; k++ )
514 {
515 TTrack& t = *tracks[k];
516 if ( t.links().hasMember( l ) ) overlap = true;
517 }
518 multiLinks.append( l );
519 }
520 multiLinks.purge();
521
522#ifdef TRKRECO_DEBUG
523 std::cout << " segment : ";
524 s.dump( "hits sort flag" );
525 std::cout << " # of assigned tracks = " << nT << std::endl;
526 std::cout << " # of overlap TMLinks = " << multiLinks.length();
527 std::cout << std::endl;
528#endif
529 //...Select the closest...
530 nL = multiLinks.length();
531 for ( unsigned j = 0; j < nL; j++ )
532 {
533 TMLink& l = *multiLinks[j];
534 ////std::cout <<"multiLinks "<<nL<<" "<<j<<" "<<&l<< std::endl;
535 // if( nullptr == &l ) {
536 // std::cout <<"yzhang debug 720 skip TMLink == 0 multiLinks "<< std::endl;
537 // continue;
538 // }
539
540 float bestDiff = 999999999.;
541 TTrack* best = NULL;
542 for ( unsigned k = 0; k < nT; k++ )
543 {
544 TTrack& t = *tracks[k];
545 t.approach( l );
546 float distance = ( l.positionOnWire() - l.positionOnTrack() ).mag();
547 float diff = fabs( distance - l.hit()->drift() );
548 if ( diff < bestDiff )
549 {
550 bestDiff = diff;
551 best = &t;
552 }
553 }
554
555 for ( unsigned k = 0; k < nT; k++ )
556 {
557 TTrack& t = *tracks[k];
558 if ( &t == best ) continue;
559 t.remove( l );
560 }
561
562#ifdef TRKRECO_DEBUG
563 {
564 std::cout << " " << l.wire()->name() << " -> ";
565 std::cout << best->name() << std::endl;
566 }
567#endif
568 }
569 }
570}
571
572AList<TSegment> TConformalFinder::removeBadSegments( TTrack& t ) const {
573#ifdef TRKRECO_DEBUG
574 std::cout << "... removing bad segments : # used seg = ";
575 std::cout << t.segments().length() << std::endl;
576#endif
577#ifdef TRKRECO_DEBUG_DETAIL
578 for ( unsigned i = 0; i < t.segments().length(); i++ )
579 t.segments()[i]->dump( "hits sort flag", " " );
580#endif
581
582 const AList<TSegment>& segments = t.segments();
583 AList<TSegment> bads;
584 unsigned used = 0;
585 TSegment* innerMost;
586 unsigned n = segments.length();
587 for ( unsigned i = 0; i < n; i++ )
588 {
589 TSegment& s = *segments[i];
590 AList<TMLink> links = Links( s, t );
591 unsigned nLinks = links.length();
592
593 unsigned nCores = Cores( links ).length();
594 unsigned nCoresSegment = s.nCores();
595 // if (nCores < _minNCoreLinks) {
596 // if (nCores < (nCoresSegment / 2)) {
597 if ( ( nCores < _minNCoreLinks ) && ( nCores < ( ( nCoresSegment + 1 ) / 2 ) ) )
598 {
599 bads.append( s );
600 continue;
601 }
602
603 unsigned id = segments[i]->superLayerId();
604 used |= ( 1 << id );
605 if ( !id ) innerMost = &s;
606 }
607
608 // //...Check used super layers...
609 // n = segments.length();
610 // for (unsigned i = 0; i < n; i++)
611 // if ((used & 0x155) == 0x101)
612 // bads.append(innerMost);
613
614 if ( !bads.length() ) return bads;
615
616#ifdef TRKRECO_DEBUG
617 std::cout << " bad segments : # = " << bads.length() << std::endl;
618#endif
619
620 n = bads.length();
621 for ( unsigned i = 0; i < n; i++ )
622 {
623 TSegment& s = *bads[i];
624
625#ifdef TRKRECO_DEBUG
626 AList<TMLink> links = Links( s, t );
627 unsigned nLinks = links.length();
628 unsigned nCores = Cores( links ).length();
629 std::cout << " # used links = " << nLinks;
630 std::cout << ", # used cores = " << nCores << std::endl;
631 s.dump( "hits sort flag", " " );
632#endif
633
634 s.tracks().remove( t );
635 t.segments().remove( s );
636 t.remove( s.links() );
637 }
638
639 //...Refit...
640 t.fit();
641
642#ifdef TRKRECO_DEBUG
643 std::cout << "... refitting" << std::endl;
644 t.dump( "detail", "2nd> " );
645#endif
646
647 return bads;
648}
649
650TSegment* TConformalFinder::link( const TSegment& base, const HepPoint3D& p,
651 const HepVector3D& v, const AList<TSegment>& candidates,
652 AList<TSegment>& alternatives, unsigned level ) const {
653 std::cout << std::fixed << std::setprecision( 6 ); // yzhang debug for 720
654
655#ifdef TRKRECO_DEBUG
656 std::cout << " link : base = " << std::endl;
657 base.dump( "vector hits mc sort", "-> " );
658 std::cout << " p=" << p << ", v=" << v.unit() << std::endl;
659#endif
660
661 //...Parameters...
662 // static const float maxDistance = 0.02;
663 // static const float minDirAngle = 0.97;
664
665 //...Candidate loop...
666 unsigned n = candidates.length();
667 float maxAngle = -999.;
668 float minDistance = _linkMaxDistance[level];
669 float maxDirAngle = _linkMinDirAngle[level];
670
671 TSegment* best = NULL;
672 for ( unsigned j = 0; j < n; j++ )
673 {
674 TSegment& current = *candidates[j];
675
676#ifdef TRKRECO_DEBUG_DETAIL
677 current.dump( "vector hits mc sort", " " );
678 std::cout << " dist,dirAngle,angle=" << current.distance( p, v );
679 std::cout << "," << ( ( current.position() - p ).unit() ).dot( v.unit() );
680 std::cout << "," << v.dot( current.direction() ) << std::endl;
681#endif
682 float distance = current.distance( p, v );
683 // cout<<"current, Layer: "<<current.links()[0]->hit()->wire()->layerId()
684 // <<" local: "<<current.links()[0]->hit()->wire()->localId()<<endl;
685 // cout<<" distance of segs = "<<distance<<" limit =
686 // "<<_linkMaxDistance[level]<<endl;
687 if ( distance > _linkMaxDistance[level] ) continue;
688
689 HepVector3D dir = ( current.position() - p );
690 if ( dir.x() > M_PI ) dir.setX( dir.x() - PI2 );
691 else if ( dir.x() < -M_PI ) dir.setX( PI2 + dir.x() );
692
693 float dirAngle = dir.unit().dot( v.unit() );
694 // cout<<" dirAngle of segs = "<<dirAngle<<" limit =
695 // "<<_linkMinDirAngle[level]<<endl;
696 if ( dirAngle < _linkMinDirAngle[level] ) continue; // tmp for tsf
697
698 // if (distance < minDistance) {
699 // minDistance = distance;
700 // best = & current;
701 // }
702 if ( dirAngle > maxDirAngle )
703 {
704 maxDirAngle = dirAngle;
705 best = &current;
706 }
707 alternatives.append( current );
708 }
709
710#ifdef TRKRECO_DEBUG
711 std::cout << " # of best + alternatives = " << alternatives.length() << std::endl;
712 if ( best )
713 {
714 std::cout << " Best is ";
715 best->dump( "hits" );
716 }
717#endif
718
719 alternatives.remove( best );
720 std::cout << std::defaultfloat; // yzhang debug for 720
721 if ( best ) return best;
722 return NULL;
723}
724
725void TConformalFinder::deleteTrack( TTrack& t ) const {
726 const AList<TSegment>& segments = t.segments();
727 unsigned n = segments.length();
728 for ( unsigned i = 0; i < n; i++ )
729 {
730 TSegment& s = *segments[i];
731 s.tracks().remove( t );
732 }
733
734 delete &t;
735}
736
737void TConformalFinder::removeUsedSegments( const AList<TTrack>& tracks ) {
738 unsigned n = tracks.length();
739 for ( unsigned i = 0; i < n; i++ )
740 {
741 TTrack& t = *tracks[i];
742 AList<TSegment>& segments = t.segments();
743 AList<TSegment> toBeRemoved;
744 unsigned nS = segments.length();
745 for ( unsigned j = 0; j < nS; j++ )
746 {
747 TSegment& s = *segments[j];
748 unsigned sId = s.superLayerId();
749 // unsigned as = sId % 2;
750 // unsigned id = sId / 2;
751 unsigned as = 1; // add initialize 25-05-15
752 unsigned id = 0; // add initialize 25-05-15
753 switch ( sId )
754 {
755 case 0:
756 as = 1;
757 id = 0;
758 break;
759 case 1:
760 as = 1;
761 id = 1;
762 break;
763 case 2:
764 as = 0;
765 id = 0;
766 break;
767 case 3:
768 as = 0;
769 id = 1;
770 break;
771 case 4:
772 as = 0;
773 id = 2;
774 break;
775 case 5:
776 as = 1;
777 id = 2;
778 break;
779 case 6:
780 as = 1;
781 id = 3;
782 break;
783 case 7:
784 as = 1;
785 id = 4;
786 break;
787 case 8:
788 as = 1;
789 id = 5;
790 break;
791 case 9:
792 as = 0;
793 id = 3;
794 break;
795 case 10:
796 as = 0;
797 id = 4;
798 break;
799 default: break;
800 }
801
802 //...Check used links...
803 AList<TMLink> links = Links( s, t );
804 if ( links.length() == 0 )
805 {
806 s.tracks().remove( t );
807 toBeRemoved.append( s );
808#ifdef TRKRECO_DEBUG
809 std::cout << "!!! why this happends???" << std::endl;
810 std::cout << " no used link" << std::endl;
811#endif
812 continue;
813 }
814
815 //...Remove from lists...
816 _allUnused[as][id].remove( s );
817
818 //...Remove incoming links...
819 const AList<TSegment>& outers = s.outerLinks();
820 unsigned nO = outers.length();
821 // std::cout << " >>> removing outer links" << std::endl;
822 // s.dump("hits", " To ");
823 for ( unsigned i = 0; i < nO; i++ )
824 {
825 outers[i]->innerLinks().remove( s );
826 // outers[i]->dump("hits", " From ");
827 }
828
829 //...Remaining hits...
830 AList<TMLink> unused = s.links();
831 unused.remove( links );
832 s.remove( unused );
833 unsigned nUnused = unused.length();
834
835 //...Create new segment if too many remaining links...
836 /* if (nUnused < _minNLinksForSegment) {
837 for (unsigned k = 0; k < nUnused; k++) {
838 _unused[as].append(unused[k]);
839 _unused[2].append(unused[k]);
840 }
841 }
842 else {
843 TSegment * ss = new TSegment(unused);
844 AList<TSegment> newSegments = ss->split(); //tmp for tsf
845 if (newSegments.length() == 0) {
846 ss->solveDualHits();
847 newSegments.append(ss);
848 for (unsigned k = 0; k < nO; k++)
849 outers[k]->innerLinks().append(ss);
850 }
851 else {
852 delete ss;
853 }
854 _allUnused[as][id].append(newSegments);
855 _allSegments[as][id].append(newSegments);
856 }
857 */
858 }
859 segments.remove( toBeRemoved );
860 }
861}
862
863void TConformalFinder::updateTLinks( AList<TTrack>& tracks ) {
864 unsigned n = tracks.length();
865 for ( unsigned i = 0; i < n; i++ )
866 {
867 const AList<TMLink>& links = tracks[i]->links();
868 unsigned nL = links.length();
869 for ( unsigned j = 0; j < nL; j++ )
870 {
871 TMLink& l = *links[j];
872 tracks[i]->approach( l );
873 }
874 }
875}
876
878 AList<TTrack>& tracks, AList<TTrack>& tracks2D ) {
879#ifdef TRKRECO_DEBUG
880 _stage = ConformalInitialization;
881#endif
882
883 static bool first = true;
884 if ( first )
885 {
886 first = false;
887 int size;
888 // _s = (struct summary *)
889 // BASF_Sharedmem->get_pointer(BASF_Sharedmem->get_id(),
890 // "TrkConfSum",
891 // & size);
892 }
893
894 //...For debug...
895 if ( debugLevel() > 1 )
896 {
897 std::cout << name() << " ... processing"
898 << " axial=" << axial.length() << ",stereo=" << stereo.length()
899 << ",tracks=" << tracks.length() << std::endl;
900 }
901
902 //...Create TMLinks with conformal position...
903 // TConformalFinder0::conformalTransformation(ORIGIN, axial, _allHits[0]);
904 // TConformalFinder0::conformalTransformation(ORIGIN, stereo, _allHits[1]);
905 // for Tsf
908 _allHits[2].append( _allHits[0] );
909 _allHits[2].append( _allHits[1] );
910
911 //...Select good hits...
912 selectGoodHits();
913#ifdef TRKRECO_DEBUG
914 cout << "axial Hits:" << _allHits[0].length() << " good axial hits:" << _hits[0].length()
915 << endl
916 << "stereo Hits:" << _allHits[1].length() << " good setero hits:" << _hits[1].length()
917 << endl;
918#endif
919
920 //...Segment finding...
921 if ( _perfectSegmentFinding ) findSegmentsPerfect();
922 else
923 // findSegments();
924 findSegmentsTsf();
925
926#ifdef TRKRECO_DEBUG
927 cout << "axial Seg: " << _allSegments[0][0].length() << ", " << _allSegments[0][1].length()
928 << ", " << _allSegments[0][2].length() << ", " << _allSegments[0][3].length() << ", "
929 << _allSegments[0][4].length() << ", " << _allSegments[0][5].length()
930 << " stereo Seg: " << _allSegments[1][0].length() << ", "
931 << _allSegments[1][1].length() << ", " << _allSegments[1][2].length() << ", "
932 << _allSegments[1][3].length() << ", " << _allSegments[1][4].length() << ", "
933 << _allSegments[1][5].length() << endl;
934
935 for ( int i = 0; i < 2; ++i )
936 {
937 if ( i == 0 ) cout << "Axial......" << endl;
938 else cout << "Stereo......" << endl;
939 for ( int j = 0; j < 6; ++j )
940 {
941 for ( int k = 0; k < _allSegments[i][j].length(); ++k )
942 {
943 cout << "SL(a/s): " << j << " seeds in Seg" << k << ": "
944 << _allSegments[i][j][k]->links().length() << endl;
945 for ( int kk = 0; kk < _allSegments[i][j][k]->links().length(); ++kk )
946 cout << " layerId: " << _allSegments[i][j][k]->links()[kk]->hit()->wire()->layerId()
947 << " localId: "
948 << _allSegments[i][j][k]->links()[kk]->hit()->wire()->localId() << endl;
949 }
950 }
951 }
952#endif
953
954 //...Fast finding...
955 unsigned level = 0;
956 _T0ResetDone = false;
957 if ( _fastFinder )
958 {
959 linkSegments( level );
960 fastFinding2D( level );
961 updateTLinks( _2DTracks );
962
963 //...T0 reset here...
964 if ( _doT0Reset )
965 {
966 std::cout << "TConformalFinder ... T0 reset is done" << std::endl;
967 _T0ResetDone = true;
968 return 0;
969 }
970
971#ifdef TRKRECO_WINDOW
972 _rphiWindow.skip( false );
973#endif
974 fastFinding3D( level );
975 updateTLinks( _2DTracks );
976 updateTLinks( _3DTracks );
977
978#ifdef TRKRECO_WINDOW
979 _rphiWindow.skip( false );
980 displayTracks( _2DTracks, _allUnused, "all 2D after fast level 0" );
981 displayTracks( _3DTracks, _allUnused, "all 3D after fast level 0" );
982#endif // TRKRECO_WINDOW
983
984 //...Fast finding again...
985 level = 1;
986 linkSegments( level );
987 fastFinding2D( level );
988 updateTLinks( _2DTracks );
989
990#ifdef TRKRECO_WINDOW
991 _rphiWindow.skip( false );
992#endif
993 fastFinding3D( level );
994 updateTLinks( _2DTracks );
995 updateTLinks( _3DTracks );
996
997#ifdef TRKRECO_WINDOW
998 _rphiWindow.skip( false );
999 displayTracks( _2DTracks, _allUnused, "all 2D after fast level 1" );
1000 displayTracks( _3DTracks, _allUnused, "all 3D after fast level 1" );
1001#endif // TRKRECO_WINDOW
1002 }
1003
1004 //...Slow finding...
1005 if ( _slowFinder )
1006 {
1007 level = 2;
1008 linkSegments( level );
1009 slowFinding2D( level );
1010 updateTLinks( _2DTracks );
1011#ifdef TRKRECO_WINDOW
1012 _rphiWindow.skip( false );
1013// _rphiWindow.skipAllWindow(false);
1014#endif
1015 fastFinding3D( level );
1016 updateTLinks( _2DTracks );
1017 updateTLinks( _3DTracks );
1018
1019#ifdef TRKRECO_WINDOW
1020 _rphiWindow.skip( false );
1021 // _rphiWindow.skipAllWindow(false);
1022 displayTracks( _2DTracks, _allUnused, "all 2D after slow level 2" );
1023 displayTracks( _3DTracks, _allUnused, "all 3D after slow level 2" );
1024#endif // TRKRECO_WINDOW
1025 }
1026
1027#ifdef TRKRECO_DEBUG
1028 int zsltrk = _2DTracks.length();
1029 std::cout << name() << " ... # 3D tracks = " << _3DTracks.length()
1030 << ", # 2D tracks = " << _2DTracks.length() << std::endl;
1031 for ( unsigned i = 0; i < zsltrk; i++ )
1032 {
1033 // _2DTracks[i]->dump();
1034 cout << "pt:" << _2DTracks[i]->pt() << " impact:" << _2DTracks[i]->impact() << endl;
1035 // nTrack->fill(0., 1.0);
1036 }
1037#endif
1038
1039 //...Mask hits with bad chisq...
1040 TTrackManager::maskBadHits( _3DTracks, _maxSigma2 );
1041
1042 tracks2D = _2DTracks;
1043 tracks = _3DTracks;
1044 for ( int i = 0; i < _3DTracks.length(); i++ )
1045 {
1046 _3DTracks[i]->finder( TrackOldConformalFinder );
1047 _3DTracks[i]->setFinderType( 2 );
1048 }
1049#ifdef TRKRECO_DEBUG
1050 // if (_3DTracks.length() == 0) {
1051 // cout<<"3D failed: 2D length = "<<_2DTracks.length()<<endl;
1052 for ( int nn = 0; nn < tracks2D.length(); ++nn )
1053 {
1054 cout << "2D: " << nn << " radius: " << tracks2D[nn]->radius() << endl;
1055 for ( int mm = 0; mm < tracks2D[nn]->links().length(); ++mm )
1056 cout << "layer: " << tracks2D[nn]->links()[mm]->wire()->layerId()
1057 << " local: " << tracks2D[nn]->links()[mm]->wire()->localId() << endl;
1058 }
1059
1060 cout << "unused axial Seg: " << _allUnused[0][0].length() << ", "
1061 << _allUnused[0][1].length() << ", " << _allUnused[0][2].length() << ", "
1062 << _allUnused[0][3].length() << ", " << _allUnused[0][4].length() << ", "
1063 << _allUnused[0][5].length() //
1064 << " unused stereo Seg: " << _allUnused[1][0].length() << ", "
1065 << _allUnused[1][1].length() << ", " << _allUnused[1][2].length() << ", "
1066 << _allUnused[1][3].length() << ", " << _allUnused[1][4].length() << ", "
1067 << _allUnused[1][5].length() << endl;
1068
1069 for ( int i = 0; i < 2; ++i )
1070 {
1071 if ( i == 0 ) cout << "unused axial hits: " << endl;
1072 else cout << "unused stereo hits: " << endl;
1073 for ( int k = 0; k < _allHits[i].length(); ++k )
1074 {
1075 if ( _allHits[i][k]->hit()->state() & WireHitUsed ) continue;
1076 else
1077 cout << " layerId: " << _allHits[i][k]->hit()->wire()->layerId()
1078 << " localId: " << _allHits[i][k]->hit()->wire()->localId() << endl;
1079 }
1080 if ( i == 0 ) cout << "unused axial link in segs: " << endl;
1081 else cout << "unused stereo link in segs: " << endl;
1082 for ( int j = 0; j < 6; ++j )
1083 {
1084 for ( int k = 0; k < _allUnused[i][j].length(); ++k )
1085 {
1086 cout << "sl: " << i << " " << j << " length of seg " << k << ": "
1087 << _allUnused[i][j][k]->links().length() << endl;
1088 for ( int kk = 0; kk < _allUnused[i][j][k]->links().length(); ++kk )
1089 cout << " layerId: "
1090 << _allUnused[i][j][k]->links()[kk]->hit()->wire()->layerId()
1091 << " localId: "
1092 << _allUnused[i][j][k]->links()[kk]->hit()->wire()->localId() << endl;
1093 }
1094 }
1095 }
1096// }
1097#endif
1098
1099 //...Termination...
1100 /* tracks = _3DTracks;
1101 tracks2D = _2DTracks;
1102 ++_s->_nEvents;
1103 unsigned n3 = _3DTracks.length();
1104 for (unsigned i = 0; i < n3; i++)
1105 if (_3DTracks[i]->finder() & TrackFastFinder)
1106 ++_s->_nTracksFast3D;
1107 else if (_3DTracks[i]->finder() & TrackSlowFinder)
1108 ++_s->_nTracksSlow3D;
1109 unsigned n2 = _2DTracks.length();
1110 for (unsigned i = 0; i < n2; i++)
1111 if (_2DTracks[i]->finder() & TrackFastFinder)
1112 ++_s->_nTracksFast2D;
1113 else if (_2DTracks[i]->finder() & TrackSlowFinder)
1114 ++_s->_nTracksSlow2D;
1115
1116 if (debugLevel()) {
1117 std::cout << name() << " ... # 3D tracks = " << _3DTracks.length()
1118 << ", # 2D tracks = " << _2DTracks.length() << std::endl;
1119 }
1120
1121 #ifdef TRKRECO_DEBUG
1122 _stage = ConformalOutside;
1123 #endif
1124 */
1125 return 0;
1126}
1127
1128void TConformalFinder::fastFinding3D( unsigned level ) {
1129
1130#ifdef TRKRECO_DEBUG_DETAIL
1131 std::cout << "... fast finding (3D) : level = " << level << std::endl;
1132#endif
1133#ifdef TRKRECO_DEBUG
1134 if ( _stage == ConformalSlow2D ) { _stage = ConformalSlow3D; }
1135 else
1136 {
1137 _stage = ConformalFast3DLevel0;
1138 if ( level == 1 ) _stage = ConformalFast3DLevel1;
1139 }
1140#endif
1141
1142 AList<TTrack> tracks3D;
1143 AList<TTrack> touched;
1144 AList<TSegment> bads;
1145 unsigned n = _2DTracks.length();
1146 for ( unsigned i = 0; i < n; i++ )
1147 {
1148
1149 const TTrack& t = *_2DTracks[i];
1150
1151#ifdef TRKRECO_DEBUG
1152 cout << "links in 2Dtracks: " << t.links().length() << endl;
1153 for ( int ii = 0; ii < t.links().length(); ++ii )
1154 {
1155 cout << "layerId: " << t.links()[ii]->wire()->layerId()
1156 << " localId: " << t.links()[ii]->wire()->localId() << endl;
1157 }
1158 cout << "center: " << t.center() << " radius = " << t.radius() << endl;
1159#endif
1160
1161#ifdef TRKRECO_DEBUG_DETAIL
1162 std::cout << "==> fast 3D building : " << t.name() << std::endl;
1163 t.dump( "hits sort flag", " 2D track hits=" );
1164#endif
1165 AList<TSegment> segments = stereoSegments( t );
1166 // jialk
1167 unsigned NS = segments.length();
1168 if ( NS >= 30 ) continue;
1169
1170 // yuany
1171 // cout<<"stereo segments:"<<segments.length()<<endl;
1172 // unsigned n = segments.length();
1173 // for (unsigned i = 0; i < n; i++) {
1174 // segments[i]->dump("hits");
1175 // }
1176
1177 AList<TSegment> badSegments;
1178 if ( _stereoMode == 2 ) badSegments = stereoSegmentsFromBadHits( t );
1179 // yuany
1180 // cout<<"bad stereo segments:"<<endl;
1181 // n = badSegments.length();
1182 // for (unsigned i = 0; i < n; i++) {
1183 // badSegments[i]->dump("hits");
1184 // }
1185
1186#ifdef TRKRECO_WINDOW
1187 displayStatus( "Conf::fast3D ... seed" );
1188 _rphiWindow.append( segments, leda_blue );
1189 _rphiWindow.append( badSegments, leda_red );
1190 _rphiWindow.oneShot( t, leda_green );
1191#endif
1192
1193 // cout<<"stereo mode: "<<_stereoMode<<endl;
1194
1195 //...Save a 2D track...
1196 TTrack* s = NULL;
1197 if ( _stereoMode ) s = _builder.buildStereoNew( t, segments, badSegments );
1198 else s = _builder.buildStereo( t, segments );
1199 HepAListDeleteAll( badSegments );
1200 // cout<<"after 3D build..."<<endl;
1201 if ( !s )
1202 {
1203#ifdef TRKRECO_DEBUG_DETAIL
1204 std::cout << "... 3D failure" << std::endl;
1205#endif
1206#ifdef TRKRECO_WINDOW
1207 displayStatus( "Conf::fastd3D ... 3D failed" );
1208 _rphiWindow.append( segments, leda_blue );
1209 _rphiWindow.oneShot( t, leda_red );
1210#endif
1211 continue;
1212 }
1213 //...Quality check...
1214 if ( !TTrackManager::goodTrack( *s ) )
1215 {
1216#ifdef TRKRECO_DEBUG_DETAIL
1217 std::cout << "... 3D failure (bad quality)" << std::endl;
1218#endif
1219#ifdef TRKRECO_WINDOW
1220 displayStatus( "Conf::fastd3D ... 3D failed (bad quality)" );
1221 _rphiWindow.append( segments, leda_blue );
1222 _rphiWindow.oneShot( *s, leda_red );
1223#endif
1224 // Remove following sentences because _s is NULL now
1225 // and it's wrong to use the pointer for some noise events... 05/10/15 zangsl
1226 //
1227 // if (s->finder() & TrackFastFinder)
1228 // ++_s->_nTracksFast2DBadQuality;
1229 // else if (s->finder() & TrackSlowFinder)
1230 // ++_s->_nTracksSlow2DBadQuality;
1231
1232 deleteTrack( *s );
1233 continue;
1234 }
1235
1236 //...New name...
1237 s->name( t.name() + "-3D" );
1238
1239#ifdef TRKRECO_WINDOW
1240 displayStatus( "Conf::fastd3D ... 3D ok" );
1241 _rphiWindow.append( segments, leda_blue );
1242 _rphiWindow.oneShot( *s, leda_green );
1243#endif
1244
1245 //...Salvage by segments...
1246 salvage( *s, 3, bads );
1247 // cout<<"3D finder done!"<<endl;
1248 tracks3D.append( s );
1249 touched.append( _2DTracks[i] );
1250
1251 s->assign( WireHitConformalFinder );
1252 s->quality( 0 );
1253
1254 //...Segment...
1255 static AList<TTrack> tmp;
1256 tmp.removeAll();
1257 tmp.append( s );
1258 removeUsedSegments( tmp );
1259 // liucy :add constraint of number of tracks
1260 if ( tracks3D.length() > 20 ) break;
1261#ifdef TRKRECO_DEBUG_DETAIL
1262 std::cout << "... 3D finished : " << s->name() << std::endl;
1263 s->dump( "detail", " " );
1264#endif
1265#ifdef TRKRECO_WINDOW
1266 displayStatus( "Conf::fastd3D ... finished" );
1267 _rphiWindow.oneShot( *s, leda_green );
1268#endif
1269 }
1270
1271 // resolveSegments(tracks3D);
1272 _3DTracks.append( tracks3D );
1273 _2DTracks.remove( tracks3D );
1274 _2DTracks.remove( touched );
1275 for ( unsigned i = 0; i < touched.length(); i++ )
1276 {
1277 deleteTrack( *touched[i] );
1278 // saved[i]->fit();
1279 }
1280}
1281
1282#ifdef TRKRECO_WINDOW
1283void TConformalFinder::displayStatus( const std::string& m ) const {
1284 _rphiWindow.clear();
1285 _rphiWindow.text( m );
1286 _rphiWindow.append( _allHits[2], leda_pink );
1287 _rphiWindow.append( _hits[2], leda_cyan );
1288 _rphiWindow.append( _unused[2] );
1289 displayAppendSegments( _allSegments, leda_grey1 );
1290 displayAppendSegments( _allUnused, leda_orange );
1291}
1292
1293void TConformalFinder::displayAppendSegments( const AList<TSegment> a[2][6],
1294 leda_color c ) const {
1295 for ( unsigned i = 0; i < 2; i++ )
1296 {
1297 for ( unsigned j = 0; j < 6; j++ )
1298 {
1299 const AList<TSegment>& segments = a[i][j];
1300 unsigned n = segments.length();
1301 for ( unsigned k = 0; k < n; k++ ) { _rphiWindow.append( *segments[k], c ); }
1302 }
1303 }
1304}
1305
1306void TConformalFinder::displayTracks( const AList<TTrack>& l,
1307 const AList<TSegment> segments[2][6],
1308 const std::string& c ) const {
1309 displayStatus( "Conf::display ... " + c );
1310 for ( unsigned i = 0; i < l.length(); i++ ) _rphiWindow.append( *l[i], leda_green );
1311 _rphiWindow.wait();
1312}
1313#endif
1314
1315bool TConformalFinder::quality2D( TTrack& t, unsigned level ) const {
1316#ifdef TRKRECO_WINDOW
1317 std::string s = "Conf::quality2D ... level " + std::to_string( level );
1318#endif
1319 // jialk caution origin is 15.
1320 //...Check # radius...Liuqg
1321 if ( fabs( t.radius() ) < 15. ) return false; // corresponding to pt = 300*1T*0.50/2(m).
1322
1323 //...Check # of segments(superlayers)...
1324 // unsigned nSuperLayers = NSuperLayers(t.links(), 2);
1325 unsigned nSuperLayers = NSuperLayers( t.links() );
1326 if ( nSuperLayers < _minNSegments )
1327 {
1328#ifdef TRKRECO_DEBUG
1329 std::cout << "... quality check : level=" << level << " : bad" << std::endl;
1330 std::cout << " reason : # segments(superlayer) =" << nSuperLayers;
1331 std::cout << " < " << _minNSegments << std::endl;
1332#endif
1333#ifdef TRKRECO_WINDOW
1334 s += " rejected because of few segments(superlayers)";
1335 displayStatus( s );
1336 _rphiWindow.oneShot( t, leda_red );
1337#endif
1338 return false;
1339 }
1340 if ( level == 0 )
1341 {
1342#ifdef TRKRECO_WINDOW
1343 s += " ok : # of used segments(superlayers) = ";
1344 s += std::to_string( nSuperLayers );
1345 s += " > " + std::to_string( _minNSegments );
1346 displayStatus( s );
1347 _rphiWindow.oneShot( t, leda_green );
1348#endif
1349
1350 return true;
1351 }
1352
1353 //...Check superlayer usage...
1354 unsigned n3 = NSuperLayers( t.links(), 3 );
1355
1356 //...Check super layer usage...
1357 if ( n3 != nSuperLayers )
1358 {
1359 unsigned sl = SuperLayer( t.links(), 2 );
1360 // unsigned sl = SuperLayer(t.links(), 3);
1361 if ( sl == 0 )
1362 {
1363#ifdef TRKRECO_DEBUG
1364 std::cout << "... quality check : level = " << level << " : bad";
1365 std::cout << std::endl;
1366 std::cout << " reason : super layer pattern(n2) = 0 " << std::endl;
1367#endif
1368#ifdef TRKRECO_WINDOW
1369 s += " rejected because of bad super-layer pattern(n2=0)";
1370 displayStatus( s );
1371 _rphiWindow.oneShot( t, leda_red );
1372#endif
1373 return false;
1374 }
1375 // unsigned fl = 0; //belle, liuqg
1376 // while ((sl & (1 << (fl * 2))) == 0) ++fl;
1377 // bool empty = false;
1378
1379 /*unsigned fl[5] = {2, 3, 4, 9, 10}; //tmp....liuqg
1380 unsigned nfl = 0;
1381 for (unsigned i = 0; i < 5; i++) {
1382 if ((sl & (1 << fl[i])) == 1) {
1383 nfl = i;
1384 break;
1385 }
1386 }
1387 bool empty = false;
1388 for (unsigned i = nfl + 1; i < 5; i++) {
1389 bool thisLayer = (sl & (1 << fl[i]));
1390 if (thisLayer && empty) {
1391
1392//#ifdef TRKRECO_DEBUG
1393 std::cout << "... quality check : level = " << level;
1394 std::cout << " : bad" << std::endl;
1395 std::cout << " reason : super layer pattern = ";
1396// for (unsigned j = 0; j < 6; j++) std::cout << (sl >> (j * 2)) % 2;
1397 std::cout << std::endl;
1398//#endif
1399#ifdef TRKRECO_WINDOW
1400 s += " rejected because of bad super-layer pattern";
1401 displayStatus(s);
1402 _rphiWindow.oneShot(t, leda_red);
1403#endif
1404 return false;
1405 }
1406 if (! thisLayer) empty = true;
1407 }*/
1408 }
1409
1410#ifdef TRKRECO_DEBUG
1411 std::cout << "... quality check : level = " << level;
1412 std::cout << " : ok, super layer pattern = " << std::endl;
1413 std::string ptn;
1414 unsigned sl = SuperLayer( t.links(), 2 );
1415 for ( unsigned j = 0; j < 6; j++ )
1416 {
1417 unsigned k = ( sl >> ( j * 2 ) ) % 2;
1418 std::cout << k;
1419 if ( k ) ptn += "1";
1420 else ptn += "0";
1421 }
1422 std::cout << std::endl;
1423#endif
1424#ifdef TRKRECO_WINDOW
1425 s += " ok : super layer ptn = " + ptn;
1426 displayStatus( s );
1427 _rphiWindow.oneShot( t, leda_green );
1428#endif
1429
1430 return true;
1431}
1432
1433void TConformalFinder::fastFinding2D( unsigned level ) {
1434
1435#ifdef TRKRECO_DEBUG_DETAIL
1436 std::cout << "... fast finding (2D) : level = " << level << std::endl;
1437#endif
1438#ifdef TRKRECO_DEBUG
1439 _stage = ConformalFast2DLevel0;
1440 if ( level == 1 ) _stage = ConformalFast2DLevel1;
1441#endif
1442
1443 AList<TSegment>* segments = &_allUnused[0][0];
1444
1445 unsigned idBase = _2DTracks.length() + _3DTracks.length();
1446 unsigned nTrial = 0;
1447 unsigned seedLayer = 5;
1448 // yuany
1449 /* cout<<"before loop "<<endl;
1450 for (unsigned i = 0; i < 5; i++) {
1451 for(unsigned j=0;j<_allUnused[0][i].length();j++){
1452 (_allUnused[0][i])[j]->dump("hits");
1453 (_allUnused[0][i])[j]->dump("link");
1454 }
1455 }*/
1456
1457 // while ((seedLayer--) > 2) { 2006/04/27
1458 while ( ( seedLayer-- ) > 1 )
1459 {
1460
1461 //...Seed loop...
1462 AList<TTrack> trackCandidates;
1463 unsigned n = segments[seedLayer].length();
1464
1465 for ( unsigned i = 0; i < n; i++ )
1466 {
1467 TSegment& seed = *segments[seedLayer][i];
1468 std::string name = "f" + std::to_string( nTrial + idBase );
1469 // yuany
1470 // seed.dump("hits");
1471 // seed.dump("link");
1472#ifdef TRKRECO_DEBUG
1473 std::cout << ">>> fast 2D : super layer " << seedLayer << ", ";
1474 std::cout << i << " : ";
1475 seed.dump( "link" );
1476#endif
1477
1478 //...Check uniqueness...
1479 AList<TSegment> seeds;
1480 // cout<<"NUiqueLinks:"<<NUniqueLinks(seed)<<"; NMajorLinks:"<<NMajorLinks(seed)<<endl;
1481 // cout<<"innerLinks size:"<<seed.innerLinks().length()<<endl;
1482 if ( NUniqueLinks( seed ) > 0 ) { seeds = UniqueLinks( seed ); }
1483 else if ( NMajorLinks( seed ) > 0 ) { seeds = MajorLinks( seed ); }
1484 else { continue; }
1485 seeds.append( seed );
1486
1487#ifdef TRKRECO_DEBUG
1488 cout << "seeds in fastFinding2D: " << seeds.length() << endl;
1489 for ( int kk = 0; kk < seeds.length(); ++kk )
1490 cout << "LayerId: " << seeds[kk]->links()[0]->wire()->layerId()
1491 << " LocalId: " << seeds[kk]->links()[0]->wire()->localId() << endl;
1492#endif
1493
1494 //...Refine...
1495 refine:
1496
1497 // solve LR of seeds;
1498 for ( int k = 0; k < seeds.length(); ++k ) // tsf
1499 seeds[k]->solveLR();
1500
1501#ifdef TRKRECO_WINDOW
1502 displayStatus( "Conf::fast2D ... seed segments" );
1503 _rphiWindow.oneShot( seeds, leda_green );
1504#endif
1505
1506 //...Try to build a track...
1507#ifdef TRKRECO_DEBUG
1508 std::cout << "==> fast building 2D : seed layer = " << seedLayer;
1509 std::cout << ", " << name << std::endl;
1510#endif
1511
1512 TTrack* t = _builder.buildRphi( seeds );
1513 ++nTrial;
1514 // cout<<"buildRphi done."<<endl;
1515
1516 //...Track check...
1517 if ( !t ) continue;
1518 t->name( name );
1519 bool ok = quality2D( *t, 0 );
1520 // cout<<"track quality " <<ok<<endl;
1521 if ( !ok )
1522 {
1523 deleteTrack( *t );
1524 continue;
1525 }
1526 // cout<<"length of seg in 2d build = "<<t->segments().length()<<" cores in 2d =
1527 // "<<t->nCores()<<endl;
1528
1529 //...Bad segment rejection...
1530 AList<TSegment> bads = removeBadSegments( *t );
1531 // cout<<"test point no0; bad segment length: "<<bads.length()<<endl;
1532
1533 // This was taken out because the goto loop continues forever for some noise events.
1534 // 2005/10/14
1535 if ( bads.length() )
1536 {
1537 ok = quality2D( *t, 1 );
1538 if ( !ok )
1539 {
1540 seeds = refineSegments( *t );
1541 if ( seeds.length() >= _minNSegments )
1542 {
1543 deleteTrack( *t );
1544 goto refine;
1545 }
1546 deleteTrack( *t );
1547 continue;
1548 }
1549 }
1550 //...Salvage by segments...
1551 salvage( *t, 1, bads );
1552 // cout <<"test point no1"<<endl;
1553 // refineLinks(* t, 3); //change the MinN from 3 to 2, zangshilei 20060307
1554 refineLinks( *t, 2 );
1555 // cout<<"test point no1.5"<<endl;
1556
1557 // change the level from 2 to 0, 20060428; because the program
1558 // stops(MCv5.1.0/run10237.dat) release by Liuqg
1559 ok = quality2D( *t, 2 );
1560 if ( !ok )
1561 {
1562 deleteTrack( *t );
1563 continue;
1564 }
1565 // cout<<"test point no2"<<endl;
1566
1567 //...Append segments...
1568 if ( NSuperLayers( t->links() ) < 5 ) { t = expand( *t ); }
1569 // cout<<"test point no3"<<endl;
1570
1571 // t->dump("detail", " ");
1572#ifdef TRKRECO_DEBUG
1573 std::cout << "... 2D finished : " << t->name() << std::endl;
1574 t->dump( "hits sort flag pull", " " );
1575#endif
1576#ifdef TRKRECO_WINDOW
1577 displayStatus( "Conf::fast2D ... finished" );
1578 _rphiWindow.oneShot( *t, leda_green );
1579#endif
1580 t->finder( TrackFastFinder );
1581 t->quality( TrackQuality2D );
1582 t->fitting( TrackFitGlobal );
1583 trackCandidates.append( t );
1584 }
1585
1586 //...Resolve multi-track candidates...
1587 resolveSegments( trackCandidates );
1588
1589 //...Remove used segments...
1590 // yuany
1591 /* cout<<"before remove "<<endl;
1592 for (unsigned i = 0; i < 5; i++) {
1593 for(unsigned j=0;j<_allUnused[0][i].length();j++){
1594 (_allUnused[0][i])[j]->dump("hits");
1595 (_allUnused[0][i])[j]->dump("link");
1596 }
1597 }
1598 */
1599 removeUsedSegments( trackCandidates );
1600 // yuany
1601 // cout<<"after remove "<<endl;
1602 /* for (unsigned i = 0; i < 5; i++) {
1603 for(unsigned j=0;j<_allUnused[0][i].length();j++){
1604 (_allUnused[0][i])[j]->dump("hits");
1605 (_allUnused[0][i])[j]->dump("link");
1606 }
1607 }
1608 */
1609 _2DTracks.append( trackCandidates );
1610 }
1611
1612 resolveHits( _2DTracks );
1613}
1614
1616 static const TMDC& cdc = *TMDC::getTMDC();
1617
1618 std::cout << "p = " << p << std::endl;
1619 float r = sqrt( 4. / p.mag2() );
1620 float phi = p.phi();
1621 return cdc.wire( r, phi );
1622}
1623
1625TConformalFinder::pickUpSegmentsInConformal( float phi[12], float loadWidth,
1626 unsigned axialStereoSwitch ) const {
1627 AList<TSegment> outList;
1628 HepPoint3D center( 1., 1., 0. );
1629 center.setPhi( phi[0] );
1630
1631 //...Search for segments...
1632 for ( unsigned sl = 0; sl < 2; sl++ )
1633 {
1634 if ( sl == 0 )
1635 {
1636 if ( !( axialStereoSwitch & 1 ) ) continue;
1637 }
1638 else
1639 {
1640 if ( !( axialStereoSwitch & 2 ) ) continue;
1641 }
1642 for ( unsigned i = 0; i < 6; i++ )
1643 {
1644 const AList<TSegment>& list = _allUnused[sl][i];
1645 unsigned n = list.length();
1646 for ( unsigned j = 0; j < n; j++ )
1647 {
1648 TSegment& s = *list[j];
1649
1650 const HepPoint3D& p = s.position();
1651 if ( center.dot( p ) < 0. ) continue;
1652
1653 bool found = false;
1654 const AList<TMLink>& inners = s.inners();
1655 unsigned m = inners.length();
1656 for ( unsigned k = 0; k < m; k++ )
1657 {
1658 float dPhi = phi[i * 2 + sl] - inners[k]->position().phi();
1659 dPhi = fabs( fmod( dPhi, PI2 ) );
1660 if ( dPhi > ( PI2 - dPhi ) ) dPhi = PI2 - dPhi;
1661 if ( dPhi < WIDTH[i * 2 + sl] * loadWidth )
1662 {
1663 outList.append( s );
1664 found = true;
1665 break;
1666 }
1667 }
1668
1669 if ( found ) continue;
1670 const AList<TMLink>& outers = s.outers();
1671 m = outers.length();
1672 for ( unsigned k = 0; k < m; k++ )
1673 {
1674 float dPhi = phi[i * 2 + sl + 1] - outers[k]->position().phi();
1675 dPhi = fabs( fmod( dPhi, PI2 ) );
1676 if ( dPhi > ( PI2 - dPhi ) ) dPhi = PI2 - dPhi;
1677 if ( dPhi < WIDTH[i * 2 + sl] * loadWidth )
1678 {
1679 outList.append( s );
1680 break;
1681 }
1682 }
1683 }
1684 }
1685 }
1686
1687 return outList;
1688}
1689
1690AList<TMLink> TConformalFinder::pickUpLinksInConformal( float phi[12], float loadWidth,
1691 unsigned axialStereoSwitch ) const {
1692 HepPoint3D center( 1., 1., 0. );
1693 center.setPhi( phi[0] );
1694
1695 AList<TMLink> outList;
1696 unsigned nBad = _unused[2].length();
1697 for ( unsigned i = 0; i < nBad; i++ )
1698 {
1699 unsigned sl = _unused[2][i]->wire()->superLayerId();
1700 unsigned as = sl % 2;
1701 if ( as == 0 )
1702 {
1703 if ( !( axialStereoSwitch & 1 ) ) continue;
1704 }
1705 else
1706 {
1707 if ( !( axialStereoSwitch & 2 ) ) continue;
1708 }
1709
1710 const HepPoint3D& p = _unused[2][i]->position();
1711 if ( center.dot( p ) < 0. ) continue;
1712
1713 float dPhi = phi[sl] - _unused[2][i]->position().phi();
1714 dPhi = fabs( fmod( dPhi, PI2 ) );
1715 if ( dPhi > ( PI2 - dPhi ) ) dPhi = PI2 - dPhi;
1716 if ( dPhi < WIDTH[sl] * loadWidth )
1717 {
1718 outList.append( _unused[2][i] );
1719 continue;
1720 }
1721 dPhi = phi[sl + 1] - _unused[2][i]->position().phi();
1722 dPhi = fabs( fmod( dPhi, PI2 ) );
1723 if ( dPhi > ( PI2 - dPhi ) ) dPhi = PI2 - dPhi;
1724 if ( dPhi < WIDTH[sl] * loadWidth ) outList.append( _unused[2][i] );
1725 }
1726 return outList;
1727}
1728
1729int TConformalFinder::crossPointsInConformal( const AList<TSegment>& inList,
1730 HepPoint3D points[12] ) const {
1731 //...Parameters...
1732 static const float confRadius2[] = {
1733 4. / ( 8.3 * 8.3 ), 4. / ( 16.9 * 16.9 ), 4. / ( 21.7 * 21.7 ), 4. / ( 31.3 * 31.3 ),
1734 4. / ( 36.1 * 36.1 ), 4. / ( 44.1 * 44.1 ), 4. / ( 50.5 * 50.5 ), 4. / ( 58.5 * 58.5 ),
1735 4. / ( 64.9 * 64.9 ), 4. / ( 72.9 * 72.9 ), 4. / ( 79.3 * 79.3 ), 4. / ( 87.4 * 87.4 ) };
1736
1737 //...Get conformal points from segments as seeds...
1738 AList<TMLink> forLine;
1739 HepPoint3D center;
1740 unsigned n = inList.length();
1741 for ( unsigned i = 0; i < n; i++ )
1742 {
1743 const HepPoint3D& p = inList[i]->position();
1744 forLine.append( new TMLink( NULL, NULL, p ) );
1745 center += p;
1746 }
1747 center *= 1. / float( n );
1748
1749 //...Make a line in the conformal plane...
1750 TMLine line( forLine );
1751 int err = line.fit();
1752 if ( err )
1753 {
1754#ifdef TRKRECO_DEBUG
1755 std::cout << "crossPoints ... failed due to line fit failure" << std::endl;
1756#endif
1757 HepAListDeleteAll( forLine );
1758 return -1;
1759 }
1760
1761 //...Calculate points...
1762 for ( unsigned i = 0; i < 12; i++ )
1763 {
1764 HepPoint3D p[2];
1765 float c = -line.a() * line.b();
1766 float d = 1. + line.a() * line.a();
1767 float e = sqrt( confRadius2[i] * d - line.b() * line.b() );
1768 p[0].setX( ( c + e ) / d );
1769 p[0].setY( line.a() * p[0].x() + line.b() );
1770 p[1].setX( ( c - e ) / d );
1771 p[1].setY( line.a() * p[1].x() + line.b() );
1772
1773 float mag0 = ( center - p[0] ).mag();
1774 float mag1 = ( center - p[1] ).mag();
1775
1776 if ( mag0 < mag1 ) points[i] = p[0];
1777 else points[i] = p[1];
1778#ifdef TRKRECO_DEBUG_DETAIL
1779 std::cout << "0,1 = " << p[0] << ", " << p[1] << std::endl;
1780#endif
1781 }
1782
1783#ifdef TRKRECO_DEBUG_DETAIL
1784 std::cout << "... center is : " << center << std::endl;
1785 std::cout << "... cross points are : " << std::endl;
1786 for ( unsigned i = 0; i < 12; i++ )
1787 { std::cout << " " << i << " : " << points[i] << std::endl; }
1788#endif
1789#ifdef TRKRECO_WINDOW
1790 displayStatus( "Conf::crossPoints ... line to salvage for conf plane" );
1791 _rphiWindow.append( inList, leda_green );
1792 _rphiWindow.oneShot( line, leda_blue );
1793#endif
1794
1795 HepAListDeleteAll( forLine );
1796 return 0;
1797}
1798
1799AList<TSegment> TConformalFinder::stereoSegments( const TTrack& t ) const {
1800#ifdef TRKRECO_DEBUG
1801 std::cout << "... finding stereo segments" << std::endl;
1802#endif
1803
1804 const AList<TSegment>& bases = (const AList<TSegment>&)t.segments();
1805 AList<TSegment> seeds;
1806 unsigned n = bases.length();
1807 if ( n == 0 ) return seeds;
1808
1809 //...Calculate cross points in the conformal plane...
1810 TPoint2D points[12];
1811 int err = crossPoints( t, points );
1812 // yuany
1813 // for(unsigned i=0;i<12;i++)
1814 // cout<<points[i]<<endl;
1815 if ( err )
1816 {
1817#ifdef TRKRECO_DEBUG
1818 std::cout << "... stereo segment finding failed" << std::endl;
1819#endif
1820 return seeds;
1821 }
1822
1823 //...Pick up segments...
1824 // return pickUpSegments(points, float(_stereoLoadWidth), 2);
1825 AList<TSegment> list = pickUpSegments( points, float( _stereoLoadWidth ), 2 );
1826 // yuany
1827 // cout<<"list length "<<list.length()<<endl;
1828
1829 //...Save direction of a segment of axial layers...
1830 TPoint2D dir[5];
1831 for ( unsigned i = 0; i < n; i++ )
1832 {
1833 const TSegment& s = *bases[i];
1834 AList<TMLink> ll = s.links();
1835 unsigned sl = ll[0]->wire()->axialStereoLayerId() / 4;
1836 dir[sl] = TPoint2D( s.direction() );
1837 // cout<<"in sl = "<<sl<<" dir = "<<dir[sl]<<endl;
1838 }
1839
1840 //...Cal. direction if empty...
1841 for ( unsigned i = 0; i < 5; i++ )
1842 {
1843 if ( dir[i].mag() < .5 )
1844 {
1845 unsigned j = i;
1846 while ( ( j < 5 ) && ( dir[j].mag() < .5 ) ) ++j;
1847 if ( j > 4 ) j = 4;
1848 if ( dir[j].mag() < .5 )
1849 {
1850 j = i;
1851 while ( ( j > 0 ) && ( dir[j].mag() < .5 ) ) --j;
1852 }
1853 dir[i] = dir[j];
1854 }
1855 }
1856 //...Remove bad segments...
1857#ifdef TRKRECO_DEBUG_DETAIL
1858 std::cout << " ... direction :" << std::endl;
1859 for ( unsigned i = 0; i < 6; i++ )
1860 std::cout << " " << i << " : " << dir[i] << std::endl;
1861 std::cout << " ... direction cos :" << std::endl;
1862#endif
1863 AList<TSegment> badList;
1864 AList<TSegment> toBeChecked[6];
1865 unsigned nL = list.length();
1866 for ( unsigned i = 0; i < 6; ++i ) toBeChecked[i].removeAll();
1867
1868 for ( unsigned j = 0; j < nL; ++j )
1869 {
1870 TSegment& s = *list[j];
1871 AList<TMLink> ll = s.links();
1872 unsigned sl = ll[0]->wire()->axialStereoLayerId() / 4;
1873 toBeChecked[sl].append( s );
1874 }
1875
1876 for ( unsigned i = 0; i < 6; ++i )
1877 {
1878 unsigned nToBeChecked = toBeChecked[i].length();
1879 if ( nToBeChecked < 4 ) continue;
1880 unsigned nBadList = badList.length();
1881 for ( unsigned j = 0; j < nToBeChecked; ++j )
1882 {
1883 if ( ( badList.length() - nBadList ) >= nToBeChecked - 4 ) break;
1884 TSegment& s = *toBeChecked[i][j];
1885 TPoint2D sDir = s.direction();
1886 unsigned sl = i;
1887 unsigned aSl;
1888
1889 if ( sl < 2 ) aSl = 0;
1890 else if ( sl < 4 ) aSl = 2;
1891 else aSl = 3;
1892 if ( dir[aSl].dot( sDir ) < 0.7 ) badList.append( s );
1893 if ( sl == 2 || sl == 3 || sl == 4 )
1894 {
1895 if ( dir[aSl - 1].dot( sDir ) < 0.6 ) badList.append( s );
1896 }
1897 else
1898 {
1899 if ( dir[aSl + 1].dot( sDir ) < 0.6 ) badList.append( s );
1900 }
1901 }
1902 toBeChecked[i].remove( badList );
1903 if ( toBeChecked[i].length() > 4 )
1904 {
1905 AList<TSegment> tmp; // with >= 4 links
1906 unsigned nSegs = toBeChecked[i].length();
1907 for ( unsigned j = 0; j < nSegs; ++j )
1908 {
1909 TSegment& s = *toBeChecked[i][j];
1910 if ( s.links().length() > 3 ) tmp.append( s );
1911 }
1912 toBeChecked[i].remove( tmp );
1913 for ( unsigned j = 0; j < tmp.length(); ++j )
1914 {
1915 AList<TMLink> tmpLinks = tmp[j]->links();
1916 for ( unsigned k = 0; k < toBeChecked[i].length(); ++k )
1917 {
1918 TSegment& ss = *toBeChecked[i][k];
1919 AList<TMLink> threeLinks = ss.links();
1920 for ( unsigned kk = 0; kk < threeLinks.length(); ++kk )
1921 {
1922 TMLink& ll = *threeLinks[kk];
1923 if ( tmpLinks.hasMember( ll ) )
1924 {
1925 badList.append( ss );
1926 break;
1927 }
1928 }
1929 }
1930 } // j
1931 }
1932 // jialk
1933 toBeChecked[i].remove( badList );
1934 if ( toBeChecked[i].length() > 4 )
1935 { // still with > 4 segs after above filter
1936 AList<TSegment> temp;
1937 unsigned nSegs = toBeChecked[i].length();
1938 for ( unsigned k = 0; k < nSegs; ++k )
1939 {
1940 TSegment& s = *toBeChecked[i][k];
1941 temp.append( s );
1942 }
1943 // use bubble to get a sequence
1944 for ( unsigned y = 0; y < nSegs; y++ )
1945 {
1946 for ( unsigned x = 1; x < nSegs - y; x++ )
1947 {
1948 TSegment& s1 = *temp[x];
1949 TSegment& s2 = *temp[x - 1];
1950 if ( s1.links().length() < s2.links().length() )
1951 {
1952 TSegment& s0 = *temp[x - 1];
1953 *temp[x - 1] = *temp[x];
1954 *temp[x] = s0;
1955 }
1956 }
1957 }
1958 for ( unsigned j = 4; j < nSegs; ++j )
1959 {
1960 TSegment& s4 = *temp[j];
1961 badList.append( s4 );
1962 }
1963 }
1964
1965 toBeChecked[i].remove( badList );
1966
1967 // cout<<"**********the num of stereo segs after filter***********
1968 // "<<toBeChecked[i].length()<<endl;
1969 for ( unsigned j = 0; j < toBeChecked[i].length(); ++j )
1970 {
1971 TSegment& s5 = *toBeChecked[i][j];
1972 // cout<<"num of hits"<<s5.links().length()<<endl;
1973 }
1974 }
1975
1976 /* for (unsigned i = 0; i < nL; i++) {
1977 TSegment & s = * list[i];
1978 AList<TMLink> ll = s.links();
1979 unsigned sl = ll[0]->wire()->axialStereoLayerId()/4;
1980 TPoint2D sDir = s.direction();
1981 unsigned aSl;
1982
1983 if (sl < 2) aSl = 0;
1984 else if (sl < 4) aSl = 2;
1985 else aSl = 3;
1986 if (dir[aSl].dot(sDir) < 0.7) badList.append(s);
1987 if (sl == 2 || sl == 3 || sl == 4) {
1988 if (dir[aSl - 1].dot(sDir) < 0.6) badList.append(s);
1989 }
1990 else {
1991 if (dir[aSl + 1].dot(sDir) < 0.6) badList.append(s);
1992 }
1993 #ifdef TRKRECO_DEBUG_DETAIL
1994 std::cout << " " << dir[sl].dot(sDir) << ", ";
1995 std::cout << dir[sl + 1].dot(sDir) << " : ";
1996 s.dump("hits sort");
1997 #endif
1998 }
1999 */
2000 //...Width cut...
2001 // for (unsigned i = 0; i < nL; i++) {
2002 // TSegment & s = * list[i];
2003 // unsigned width = s.width();
2004 // if (width > 2) badList.append(s);
2005 // }
2006
2007 // cout<<"stereoSegment: "<<list.length()<<" badList: "<<badList.length()<<endl;
2008 list.remove( badList );
2009 // cout<<"after remove bads: "<<list.length()<<endl;
2010
2011#ifdef TRKRECO_DEBUG
2012 std::cout << " ... bad segments :" << std::endl;
2013 for ( unsigned i = 0; i < badList.length(); i++ )
2014 badList[i]->dump( "hits sort", " " );
2015#endif
2016
2017 return list;
2018}
2019
2020HepVector3D TConformalFinder::direction( const TSegment& segment ) const {
2021 AList<TMLink> forLine;
2022 const TSegment* s = &segment;
2023 while ( 1 )
2024 {
2025 if ( s->outerLinks().length() != 1 ) break;
2026 const TSegment* o = s->outerLinks()[0];
2027 const HepPoint3D& p = o->position();
2028 forLine.append( new TMLink( NULL, NULL, p ) );
2029 s = o;
2030 }
2031
2032 if ( forLine.length() == 0 ) return segment.direction();
2033 else if ( forLine.length() < 2 )
2034 {
2035 HepAListDeleteAll( forLine );
2036 return segment.direction();
2037 }
2038
2039 //...Make a line in the conformal plane...
2040 TMLine line( forLine );
2041 int err = line.fit();
2042 if ( err )
2043 {
2044#ifdef TRKRECO_DEBUG
2045 std::cout << "direction ... failed due to line fit failure" << std::endl;
2046#endif
2047 HepAListDeleteAll( forLine );
2048 return segment.direction();
2049 }
2050
2051 HepAListDeleteAll( forLine );
2052 Vector3 tmp( -1., -( line.a() + line.b() ) );
2053 tmp.unit();
2054 return HepVector3D( tmp );
2055}
2056
2057void TConformalFinder::salvage( TTrack& track, unsigned asSwitch,
2058 const AList<TSegment>& bads ) const {
2059#ifdef TRKRECO_DEBUG_DETAIL
2060 std::cout << "... salvaging in real plane" << std::endl;
2061#endif
2062
2063 //...Calculate cross points...
2064 TPoint2D points[12];
2065 int err = crossPoints( track, points );
2066 if ( err )
2067 {
2068#ifdef TRKRECO_DEBUG_DETAIL
2069 std::cout << "... salvaging failed in calculation of intersection" << std::endl;
2070#endif
2071 return;
2072 }
2073
2074 //...Pick up segments...
2075 AList<TSegment> toBeChecked = pickUpSegments( points, float( _salvageLoadWidth ), asSwitch );
2076 toBeChecked.remove( bads );
2077 toBeChecked.remove( track.segments() );
2078 toBeChecked = trackSide( track, toBeChecked );
2079
2080 //...Pick up links...
2081 AList<TMLink> links;
2082 unsigned nB = toBeChecked.length();
2083 for ( unsigned i = 0; i < nB; i++ )
2084 {
2085 const AList<TMLink>& tmp = toBeChecked[i]->links();
2086 unsigned nL = tmp.length();
2087 for ( unsigned j = 0; j < nL; j++ )
2088 {
2089 if ( tmp[j]->hit()->track() ) continue;
2090 links.append( tmp[j] );
2091 }
2092 }
2093
2094 //...Search in bad hits...
2095 AList<TMLink> all = pickUpLinks( points, float( _salvageLoadWidth ), asSwitch );
2096#ifdef TRKRECO_DEBUG
2097 std::cout << " pickUpLinks length = " << all.length() << std::endl;
2098#endif
2099
2100 all = trackSide( track, all );
2101 all.remove( track.links() );
2102#ifdef TRKRECO_DEBUG
2103 std::cout << " after reomove pickUpLinks length = " << all.length() << std::endl;
2104#endif
2105 links.append( all );
2106
2107#ifdef TRKRECO_WINDOW
2108 AList<TMLink> tmp = links;
2109#endif
2110
2111 //...Ask builder...
2112 _builder.salvage( track, links );
2113
2114 //...Check used segments...
2115 const AList<TMLink>& usedLinks = track.links();
2116 for ( unsigned i = 0; i < nB; i++ )
2117 {
2118 TSegment& segment = *toBeChecked[i];
2119 AList<TMLink> used = Links( segment, track );
2120 if ( used.length() == 0 ) continue;
2121
2122 track.segments().append( segment );
2123 segment.tracks().append( track );
2124 }
2125
2126#ifdef TRKRECO_WINDOW
2127 displayStatus( "Conf::salvage ... results" );
2128 TTrackBase y( tmp );
2129 _rphiWindow.append( y, leda_red );
2130 _rphiWindow.append( toBeChecked, leda_red );
2131 _rphiWindow.oneShot( track, leda_green );
2132#endif
2133
2134 //...Termination...
2135 return;
2136}
2137
2138int TConformalFinder::crossPoints( const TTrack& track, TPoint2D points[12] ) const {
2139
2140#ifdef TRKRECO_DEBUG_DETAIL
2141 std::cout << " cross points are :" << std::endl;
2142#endif
2143
2144 /*
2145 //...Parameters...
2146 static const float R[] = { 8.3,
2147 16.9,
2148 21.7,
2149 31.3,
2150 36.1,
2151 44.1,
2152 50.5,
2153 58.5,
2154 64.9,
2155 72.9,
2156 79.3,
2157 87.4};
2158 static const float R2[] = { 8.3 * 8.3,
2159 16.9 * 16.9,
2160 21.7 * 21.7,
2161 31.3 * 31.3,
2162 36.1 * 36.1,
2163 44.1 * 44.1,
2164 50.5 * 50.5,
2165 58.5 * 58.5,
2166 64.9 * 64.9,
2167 72.9 * 72.9,
2168 79.3 * 79.3,
2169 87.4 * 87.4};
2170 */
2171 static const float R[] = { 7.3, 12.21, 18.9, 25.375, 31.86, 39.16,
2172 45.685, 52.215, 58.665, 65.91, 72.37, 80. };
2173 static const float R2[] = { R[0] * R[0], R[1] * R[1], R[2] * R[2], R[3] * R[3],
2174 R[4] * R[4], R[5] * R[5], R[6] * R[6], R[7] * R[7],
2175 R[8] * R[8], R[9] * R[9], R[10] * R[10], R[11] * R[11] };
2176
2177 static const TPoint2D o( 0., 0. );
2178 TPoint2D c = track.center();
2179 TPoint2D co = -c;
2180 double r = fabs( track.radius() );
2181 double r2 = r * r;
2182 double d2 = c.mag2();
2183 double d = sqrt( d2 );
2184 double sl = -c.x() / c.y();
2185 //...Calculate points...
2186 unsigned nOk = 0;
2187 for ( unsigned i = 0; i < 12; i++ )
2188 {
2189 double minR = r < R[i] ? r : R[i];
2190 double maxR = r < R[i] ? R[i] : r;
2191
2192#ifdef TRKRECO_DEBUG_DETAIL
2193 std::cout << " r,R ... " << minR << ", " << maxR << ", " << d << std::endl;
2194#endif
2195
2196 if ( ( r + R[i] < d ) || ( minR + d < maxR ) )
2197 { // no intersection of two circles
2198 points[i] = o;
2199 continue;
2200 }
2201 ++nOk;
2202 double a = R2[i] + d2 - r2;
2203 double s = sqrt( 4. * R2[i] * d2 - a * a );
2204 double q = 0.5 * a / c.y();
2205 points[i].x( 0.5 * ( c.x() * a + c.y() * s ) / d2 );
2206 points[i].y( q + sl * points[i].x() );
2207 const double Bz = -1000 * ( getPmgnIMF()->getReferField() );
2208 if ( co.cross( points[i] - c ) * track.charge() * Bz > 0. )
2209 {
2210 points[i].x( 0.5 * ( c.x() * a - c.y() * s ) / d2 );
2211 points[i].y( q + sl * points[i].x() );
2212 }
2213#ifdef TRKRECO_DEBUG_DETAIL
2214 std::cout << " " << i << " : " << points[i] << std::endl;
2215 std::cout << " chg=" << track.charge() << std::endl;
2216 std::cout << ", c=" << c << ", co=" << std::endl;
2217 std::cout << ", " << co.cross( points[i] - c ) * track.charge() << std::endl;
2218 std::cout << " " << 0.5 * ( c.x() * a + c.y() * s ) / d2;
2219 std::cout << ", " << q + sl * ( 0.5 * ( c.x() * a + c.y() * s ) / d2 );
2220 std::cout << " " << 0.5 * ( c.x() * a - c.y() * s ) / d2;
2221 std::cout << ", " << q + sl * ( 0.5 * ( c.x() * a - c.y() * s ) / d2 );
2222 std::cout << std::endl;
2223#endif
2224 }
2225 if ( nOk ) return 0;
2226 else return -1;
2227}
2228
2229AList<TSegment> TConformalFinder::pickUpSegments( const TPoint2D x[12], float loadWidth,
2230 unsigned axialStereoSwitch ) const {
2231 static const TPoint2D O( 0., 0. );
2232 AList<TSegment> outList;
2233
2234 // yuany
2235 //...Search for segments...
2236 for ( unsigned sl = 0; sl < 2; sl++ )
2237 {
2238 unsigned nMax = 5;
2239 if ( sl == 0 )
2240 {
2241 if ( !( axialStereoSwitch & 1 ) ) continue;
2242 }
2243 else
2244 {
2245 nMax = 6;
2246 if ( !( axialStereoSwitch & 2 ) ) continue;
2247 }
2248 for ( unsigned i = 0; i < nMax; i++ )
2249 {
2250
2251 unsigned layerId;
2252 switch ( sl )
2253 {
2254 case 0:
2255 switch ( i )
2256 {
2257 case 0: layerId = 2; break;
2258 case 1: layerId = 3; break;
2259 case 2: layerId = 4; break;
2260 case 3: layerId = 9; break;
2261 case 4: layerId = 10; break;
2262 }
2263 case 1:
2264 switch ( i )
2265 {
2266 case 0: layerId = 0; break;
2267 case 1: layerId = 1; break;
2268 case 2: layerId = 5; break;
2269 case 3: layerId = 6; break;
2270 case 4: layerId = 7; break;
2271 case 5: layerId = 8; break;
2272 }
2273 }
2274 // cout<<"sl "<<sl<<" i "<<i<<" layerId "<<layerId<<endl;
2275
2276 if ( x[layerId] == O ) continue;
2277 float a = WIDTH[layerId] * loadWidth;
2278 float phi0 = x[layerId].phi();
2279 float phi1 = x[layerId + 1].phi(); // Liuqg
2280 float phiC = ( phi0 + phi1 ) / 2.;
2281 float phiD = fabs( phi0 - phiC );
2282 if ( phiD > M_PI_2 )
2283 {
2284 phiC += M_PI;
2285 phiD = M_PI - phiD;
2286 }
2287 phiD += a;
2288
2289 const AList<TSegment>& list = _allUnused[sl][i];
2290 unsigned n = list.length();
2291#ifdef TRKRECO_DEBUG_DETAIL
2292 std::cout << " pickUpSegments ... phi0,1,C,D=" << phi0 << ",";
2293 std::cout << phi1 << "," << phiC << "," << phiD << " nhits " << n << std::endl;
2294#endif
2295 for ( unsigned j = 0; j < n; j++ )
2296 {
2297 TSegment& s = *list[j];
2298
2299#ifdef TRKRECO_DEBUG_DETAIL
2300 s.dump( "hits sort", " " );
2301#endif
2302
2303 bool found = false;
2304 const AList<TMLink>& inners = s.inners();
2305 unsigned m = inners.length();
2306 for ( unsigned k = 0; k < m; k++ )
2307 {
2308 float phi = inners[k]->position().phi();
2309 if ( phi < 0. ) phi += PI2;
2310 float dPhi = fabs( phi - phiC );
2311 if ( dPhi > M_PI ) dPhi = PI2 - dPhi;
2312#ifdef TRKRECO_DEBUG_DETAIL
2313 std::cout << " " << inners[k]->wire()->name();
2314 std::cout << ", phi,dPhi=" << phi << "," << dPhi << std::endl;
2315#endif
2316 if ( dPhi < phiD )
2317 {
2318 outList.append( s );
2319 found = true;
2320 break;
2321 }
2322 }
2323
2324 if ( found ) continue;
2325 const AList<TMLink>& outers = s.outers();
2326 m = outers.length();
2327 for ( unsigned k = 0; k < m; k++ )
2328 {
2329 float phi = outers[k]->position().phi();
2330 if ( phi < 0. ) phi += PI2;
2331 float dPhi = fabs( phi - phiC );
2332 if ( dPhi > M_PI ) dPhi = PI2 - dPhi;
2333#ifdef TRKRECO_DEBUG_DETAIL
2334 std::cout << " " << outers[k]->wire()->name();
2335 std::cout << ", phi,dPhi=" << phi << "," << dPhi << std::endl;
2336#endif
2337 if ( dPhi < phiD )
2338 {
2339 outList.append( s );
2340 found = true;
2341 break;
2342 }
2343 }
2344 }
2345 }
2346 }
2347 return outList;
2348}
2349
2350AList<TMLink> TConformalFinder::pickUpLinks( const TPoint2D x[12], float loadWidth,
2351 unsigned axialStereoSwitch ) const {
2352
2353 static const TPoint2D O( 0., 0. );
2354 AList<TMLink> outList;
2355
2356 unsigned nBad = _unused[2].length();
2357 for ( unsigned i = 0; i < nBad; i++ )
2358 {
2359 unsigned sl = _unused[2][i]->wire()->superLayerId();
2360 unsigned as = 1;
2361 if ( _unused[2][i]->wire()->axial() ) as = 0;
2362 if ( as == 0 )
2363 {
2364 if ( !( axialStereoSwitch & 1 ) ) continue;
2365 }
2366 else
2367 {
2368 if ( !( axialStereoSwitch & 2 ) ) continue;
2369 }
2370
2371 float a = WIDTH[sl] * loadWidth;
2372 float phi0 = x[sl].phi();
2373 float phi1 = x[sl + 1].phi();
2374 float phi = _unused[2][i]->position().phi();
2375
2376 if ( phi < 0. ) phi += PI2;
2377 if ( phi1 < phi0 )
2378 {
2379 phi1 = phi0;
2380 phi0 = x[sl + 1].phi();
2381 }
2382 float dPhi = phi1 - phi0;
2383 if ( dPhi < M_PI )
2384 {
2385 phi0 -= a;
2386 phi1 += a;
2387 if ( phi > phi0 && phi < phi1 ) outList.append( _unused[2][i] );
2388 }
2389 else
2390 {
2391 phi0 += a;
2392 phi1 -= a;
2393 if ( phi < phi0 || phi > phi1 ) outList.append( _unused[2][i] );
2394 }
2395#ifdef TRKRECO_DEBUG_DETAIL
2396 std::cout << "TConformalFinder:: pickUpLinks " << std::endl;
2397 std::cout << "a " << a << " phi0 " << phi0 << " phi1 " << phi1 << " phi " << phi
2398 << " dPhi " << dPhi << std::endl;
2399#endif
2400 }
2401 return outList;
2402}
2403
2404void TConformalFinder::slowFinding2D( unsigned level ) {
2405
2406#ifdef TRKRECO_DEBUG_DETAIL
2407 std::cout << "... slow finding (2D) : level = " << level << std::endl;
2408#endif
2409#ifdef TRKRECO_DEBUG
2410 _stage = ConformalSlow2D;
2411#endif
2412
2413 AList<TSegment>* segments = &_allUnused[0][0];
2414
2415 unsigned id = _2DTracks.length() + _3DTracks.length();
2416 unsigned seedLayer = 5;
2417 while ( seedLayer-- )
2418 {
2419
2420 //...Seed loop...
2421 AList<TSegment> tmp = segments[seedLayer];
2422 unsigned n = tmp.length();
2423 for ( unsigned i = 0; i < n; i++ )
2424 {
2425 AList<TTrack> trackCandidates;
2426 TSegment& current = *tmp[i];
2427 if ( current.links().length() < 3 ) continue;
2428 if ( current.innerLinks().length() != 1 ) continue;
2429 if ( current.innerLinks()[0]->links().length() < 3 ) continue;
2430 AList<TSegment> seeds;
2431 seeds.append( current );
2432 seeds.append( current.innerLinks()[0] );
2433
2434 std::string name = "s" + std::to_string( id );
2435
2436#ifdef TRKRECO_DEBUG
2437 std::cout << "==> slow building : " << name << std::endl;
2438#endif
2439
2440 //...Try to build a track...
2441 for ( int k = 0; k < seeds.length(); ++k ) // tsf
2442 seeds[k]->solveLR();
2443
2444 TTrack* t = expand( seeds );
2445 if ( t )
2446 {
2447 AList<TSegment> bads;
2448 t->name( name );
2449 salvage( *t, 1, bads );
2450 if ( !trackQuality( *t ) )
2451 {
2452 deleteTrack( *t );
2453 continue;
2454 }
2455 t->finder( TrackSlowFinder );
2456 t->quality( TrackQuality2D );
2457 t->fitting( TrackFitGlobal );
2458 trackCandidates.append( t );
2459
2460#ifdef TRKRECO_DEBUG
2461 std::cout << "... 2D finished : " << t->name() << std::endl;
2462 t->dump( "hits sort flag pull", " " );
2463#endif
2464#ifdef TRKRECO_WINDOW
2465 displayStatus( "Conf::expand ... finished" );
2466 _rphiWindow.oneShot( *t, leda_green );
2467#endif
2468 removeUsedSegments( trackCandidates );
2469 _2DTracks.append( trackCandidates );
2470 id = _2DTracks.length() + _3DTracks.length();
2471 }
2472 }
2473
2474 //...Resolve multi-track candidates...
2475 // resolveSegments(trackCandidates);
2476
2477 //...Remove used segments...
2478 }
2479}
2480
2481TTrack* TConformalFinder::expand( AList<TSegment>& seeds ) const {
2482#ifdef TRKRECO_WINDOW
2483 displayStatus( "Conf::expand ... seeds" );
2484 _rphiWindow.oneShot( seeds, leda_green );
2485#endif
2486#ifdef TRKRECO_DEBUG
2487 std::cout << "... expand : # of seeds = " << seeds.length() << std::endl;
2488#endif
2489 TTrack* t = NULL;
2490 if ( seeds.length() > 2 )
2491 {
2492 TTrack* t = _builder.buildRphi( seeds );
2493 if ( t )
2494 {
2495 if ( !trackQuality( *t ) )
2496 {
2497 deleteTrack( *t );
2498 t = NULL;
2499 }
2500 }
2501 }
2502 if ( t == NULL )
2503 {
2504 AList<TMLink> links = Links( seeds );
2505 TCircle c( links );
2506 c.fit();
2507 t = new TTrack( c );
2508 t->fit();
2509 t->segments().append( seeds );
2510 }
2511 return expand( *t );
2512}
2513
2514TTrack* TConformalFinder::expand( TTrack& ti ) const {
2515#ifdef TRKRECO_WINDOW
2516 displayStatus( "Conf::expand ... seed track" );
2517 _rphiWindow.oneShot( ti, leda_green );
2518#endif
2519#ifdef TRKRECO_DEBUG
2520 std::cout << "... expand : by a track" << std::endl;
2521#endif
2522
2523 TTrack* t = &ti;
2524 AList<TSegment> seeds = t->segments();
2525 unsigned nSegments = seeds.length();
2526 unsigned nCores = t->nCores();
2527 unsigned nTrial = 0;
2528 while ( 1 )
2529 {
2530
2531 //...Target superlayer...
2532 unsigned sl = SuperLayer( t->cores() );
2533 unsigned inner;
2534 unsigned outer;
2535 targetSuperLayer( sl, inner, outer );
2536 // cout<<"sl: "<<sl<<" inner: "<<inner<<" outer: "<<outer<<endl;
2537 unsigned target = inner;
2538 if ( target == 11 ) target = outer;
2539 if ( target == 11 ) break;
2540
2541 //...Get target segments...
2542 AList<TSegment> segments = targetSegments( *t, target );
2543 if ( segments.length() == 0 )
2544 {
2545 unsigned fl[5] = { 2, 3, 4, 9, 10 };
2546 unsigned inner2 = 0;
2547 unsigned outer2 = 5;
2548 for ( int i = 0; i < 5; i++ )
2549 {
2550 if ( fl[i] == inner ) inner2 = i;
2551 if ( fl[i] == outer ) outer2 = i;
2552 }
2553 if ( inner > 2 && inner2 > 0 ) target = fl[inner2 - 1];
2554 if ( target == 9 ) { target = fl[outer2 + 1]; }
2555 if ( target == 13 ) break;
2556 segments = targetSegments( *t, target );
2557 }
2558#ifdef TRKRECO_DEBUG
2559 std::cout << "... expand : segments to be checked = ";
2560 std::cout << segments.length() << std::endl;
2561#endif
2562#ifdef TRKRECO_WINDOW
2563 displayStatus( "Conf::expand ... candidate segments" );
2564 _rphiWindow.append( segments, leda_blue );
2565 _rphiWindow.oneShot( *t, leda_green );
2566#endif
2567
2568 //...Create candidate tracks...
2569 unsigned n = segments.length();
2570 AList<TTrack> tracks;
2571 for ( unsigned i = 0; i < n; i++ )
2572 {
2573 segments[i]->solveLR();
2574 AList<TSegment> seed0 = seeds;
2575 seed0.append( segments[i] );
2576 TTrack* t0 = _builder.buildRphi( seed0 );
2577 if ( !t0 ) continue;
2578 if ( ( t0->segments().length() <= nSegments ) || ( t0->nCores() <= nCores ) ||
2579 ( SuperLayer( t0->cores() ) <= sl ) )
2580 {
2581 deleteTrack( *t0 );
2582 continue;
2583#ifdef TRKRECO_DEBUG
2584 std::cout << "... expand : candidate deleted" << std::endl;
2585#endif
2586 }
2587 tracks.append( t0 );
2588 }
2589
2590#ifdef TRKRECO_DEBUG
2591 std::cout << "... expand : target superlayer = " << target;
2592 std::cout << ", # of track candidates = " << tracks.length() << std::endl;
2593#endif
2594
2595 //...Expand by links...
2596 if ( tracks.length() == 0 )
2597 {
2598 AList<TMLink> links = targetLinks( *t, target );
2599 _builder.salvage( *t, links );
2600 unsigned newSl = SuperLayer( t->cores() );
2601 if ( newSl & ( 1 << ( target ) ) )
2602 {
2603#ifdef TRKRECO_DEBUG
2604 std::cout << "... expand : links to be appended = ";
2605 std::cout << links.length() << std::endl;
2606#endif
2607#ifdef TRKRECO_WINDOW
2608 displayStatus( "Conf::expand ... candidate links" );
2609 _rphiWindow.append( links, leda_blue );
2610 _rphiWindow.oneShot( *t, leda_green );
2611#endif
2612 TTrack* t0 = new TTrack( *t );
2613 if ( !t0 ) break;
2614 if ( ( t0->nCores() <= nCores ) || ( SuperLayer( t0->cores() ) <= sl ) )
2615 {
2616 deleteTrack( *t0 );
2617 break;
2618#ifdef TRKRECO_DEBUG
2619 std::cout << "... expand : candidate deleted" << std::endl;
2620#endif
2621 }
2622 tracks.append( t0 );
2623 }
2624 else break;
2625 }
2626
2627#ifdef TRKRECO_DEBUG
2628 std::cout << "... expand : # of track candidates = " << tracks.length() << std::endl;
2629#endif
2630
2631 //...Select best...
2632 unsigned nTracks = tracks.length();
2633 if ( nTracks == 0 ) break;
2634 TTrack* tNew = tracks[0];
2635 unsigned nBestCores = tNew->nCores();
2636 for ( unsigned i = 1; i < nTracks; i++ )
2637 {
2638 if ( tracks[i]->nCores() > nBestCores )
2639 {
2640 deleteTrack( *tNew );
2641 tNew = tracks[i];
2642 nBestCores = tNew->nCores();
2643 }
2644 else { deleteTrack( *tracks[i] ); }
2645 }
2646 nSegments = tNew->segments().length();
2647 nCores = nBestCores;
2648 seeds = tNew->segments();
2649
2650 //...Quality check...
2651 if ( !trackQuality( *tNew ) )
2652 {
2653 deleteTrack( *tNew );
2654 break;
2655 }
2656 deleteTrack( *t );
2657 t = tNew;
2658 }
2659
2660#ifdef TRKRECO_DEBUG
2661 if ( t == &ti ) std::cout << "... expand : failed" << std::endl;
2662 else std::cout << "... expand : track expanded" << std::endl;
2663#endif
2664#ifdef TRKRECO_WINDOW
2665 displayStatus( "Conf::expand ... finished" );
2666 _rphiWindow.oneShot( *t, leda_green );
2667#endif
2668
2669 return t;
2670}
2671
2672void TConformalFinder::targetSuperLayer( unsigned sl, unsigned& inner,
2673 unsigned& outer ) const {
2674 inner = 11;
2675 outer = 11;
2676 bool innerFound = false;
2677 bool outerFound = false;
2678 for ( unsigned i = 0; i < 5; i++ )
2679 { // changed to BESIII,Liuqg
2680 unsigned fl[5] = { 2, 3, 4, 9, 10 };
2681 if ( !innerFound )
2682 {
2683 if ( sl & ( 1 << ( fl[i] ) ) ) innerFound = true;
2684 else inner = fl[i];
2685 }
2686 if ( !outerFound )
2687 {
2688 if ( sl & ( 1 << ( fl[4 - i] ) ) ) outerFound = true;
2689 else outer = fl[4 - i];
2690 }
2691 }
2692}
2693
2694AList<TSegment> TConformalFinder::targetSegments( const TTrack& t, unsigned sl ) const {
2695 AList<TSegment> targets;
2696
2697 //...Calculate cross points...
2698 TPoint2D points[12];
2699 int err = crossPoints( t, points );
2700 if ( err )
2701 {
2702#ifdef TRKRECO_DEBUG
2703 std::cout << " ... no target found" << std::endl;
2704#endif
2705 return targets;
2706 }
2707
2708 //...Pick up segments...
2709 AList<TSegment> toBeChecked = pickUpSegments( points, 3, 1 );
2710 unsigned n = toBeChecked.length();
2711 for ( unsigned i = 0; i < n; i++ )
2712 {
2713 if ( toBeChecked[i]->superLayerId() == sl ) targets.append( toBeChecked[i] );
2714 }
2715
2716 return targets;
2717}
2718
2719AList<TMLink> TConformalFinder::targetLinks( const TTrack& t, unsigned sl ) const {
2720 AList<TMLink> targets;
2721
2722 //...Calculate cross points...
2723 TPoint2D points[12];
2724 int err = crossPoints( t, points );
2725 if ( err )
2726 {
2727#ifdef TRKRECO_DEBUG
2728 std::cout << " ... no target found" << std::endl;
2729#endif
2730 return targets;
2731 }
2732
2733 //...Pick up segments...
2734 AList<TMLink> toBeChecked = pickUpLinks( points, 3, 1 );
2735 unsigned n = toBeChecked.length();
2736 for ( unsigned i = 0; i < n; i++ )
2737 {
2738 if ( toBeChecked[i]->wire()->superLayerId() == sl ) targets.append( toBeChecked[i] );
2739 }
2740
2741 return targets;
2742}
2743
2744AList<TSegment> TConformalFinder::refineSegments( const TTrack& t ) const {
2745 const AList<TSegment>& original = t.segments();
2746 AList<TSegment> outList;
2747 unsigned n = original.length();
2748 for ( unsigned i = 0; i < n; i++ )
2749 {
2750 AList<TMLink> tmp = Links( *original[i], t );
2751 if ( tmp.length() >= _minNLinksForSegmentInRefine ) outList.append( original[i] );
2752 }
2753 unsigned sl = SuperLayer( outList );
2754 unsigned nCMax = 0;
2755 unsigned nStart = 0;
2756 unsigned nC = 0;
2757 unsigned nS = 0;
2758 unsigned fl[5] = { 2, 3, 4, 9, 10 };
2759 for ( unsigned i = 0; i < 5; i++ )
2760 {
2761 if ( sl & ( 1 << fl[i] ) )
2762 {
2763 ++nC;
2764 if ( nC == 1 ) nS = i;
2765 if ( nC > nCMax )
2766 {
2767 nCMax = nC;
2768 nStart = nS;
2769 }
2770 }
2771 else { nC = 0; }
2772 }
2773 // nStart *= 2;
2774 // nCMax *= 2;
2775
2776 outList.removeAll();
2777 if ( nCMax >= _minNSegments )
2778 {
2779 for ( unsigned i = 0; i < n; i++ )
2780 {
2781 unsigned id = original[i]->superLayerId();
2782 if ( ( id >= fl[nStart] ) && ( id < fl[nStart + nCMax] ) ) outList.append( original[i] );
2783 }
2784 }
2785
2786#ifdef TRKRECO_DEBUG
2787 std::cout << "... refine segments : orignal sl = ";
2788 bitDisplay( sl, 11, 0 );
2789 std::cout << ", output sl = ";
2790 bitDisplay( SuperLayer( outList ), 11, 0 );
2791 std::cout << std::endl;
2792#endif
2793
2794 return outList;
2795}
2796
2797bool TConformalFinder::trackQuality( const TTrack& t ) const {
2798 unsigned n1 = NSuperLayers( t.links() );
2799 unsigned n3 = NSuperLayers( t.links(), 2 );
2800
2801 //...check # radius...Liuqg
2802 if ( fabs( t.radius() ) < 15. ) return false;
2803
2804#ifdef TRKRECO_WINDOW
2805 std::cout << "... trackQuality : n1,n3,nMissing=" << n1 << "," << n3;
2806 std::cout << "," << NMissingAxialSuperLayers( t.links() ) << std::endl;
2807#endif
2808#ifdef TRKRECO_WINDOW
2809 displayStatus( "trackQuality" );
2810 if ( ( n3 < 2 ) || ( NMissingAxialSuperLayers( t.links() ) > 1 ) )
2811 _rphiWindow.oneShot( t, leda_red );
2812 else _rphiWindow.oneShot( t, leda_green );
2813#endif
2814 if ( n3 < 2 ) return false;
2815 // if (NMissingAxialSuperLayers(t.links()) > 1) return false;
2816
2817 return true;
2818}
2819
2820void TConformalFinder::refineLinks( TTrack& t, unsigned minN ) const {
2821 const AList<TMLink>& links = t.links();
2822 AList<TMLink> sl[11];
2823 unsigned n = links.length();
2824 for ( unsigned i = 0; i < n; i++ ) sl[links[i]->wire()->superLayerId()].append( links[i] );
2825 AList<TMLink> toBeRemoved;
2826 for ( unsigned i = 0; i < 11; i++ )
2827 if ( sl[i].length() < minN ) toBeRemoved.append( sl[i] );
2828 t.remove( toBeRemoved );
2829#ifdef TRKRECO_DEBUG
2830 std::cout << "... refining links : removed links = " << toBeRemoved.length();
2831 std::cout << std::endl;
2832#endif
2833}
2834
2835AList<TMLink> TConformalFinder::trackSide( const TTrack& t, const AList<TMLink>& a ) const {
2836 static const TPoint2D o( 0., 0. );
2837 TPoint2D c = t.center();
2838 TPoint2D co = -c;
2839
2840 AList<TMLink> tmp;
2841 unsigned n = a.length();
2842 for ( unsigned i = 0; i < n; i++ )
2843 {
2844 TPoint2D x = a[i]->wire()->xyPosition();
2845 const double Bz = -1000 * ( getPmgnIMF()->getReferField() );
2846 if ( co.cross( x - c ) * t.charge() * Bz < 0. ) tmp.append( a[i] );
2847 }
2848 return tmp;
2849}
2850
2851AList<TSegment> TConformalFinder::trackSide( const TTrack& t,
2852 const AList<TSegment>& a ) const {
2853 static const TPoint2D o( 0., 0. );
2854 TPoint2D c = t.center();
2855 TPoint2D co = -c;
2856
2857 AList<TSegment> tmp;
2858 unsigned n = a.length();
2859 for ( unsigned i = 0; i < n; i++ )
2860 {
2861 const AList<TMLink>& b = a[i]->links();
2862 bool bad = false;
2863 unsigned nB = b.length();
2864 for ( unsigned j = 0; j < nB; j++ )
2865 {
2866 TPoint2D x = b[j]->wire()->xyPosition();
2867 // yzhang 2012-05-03
2868 const double Bz = -1000 * ( getPmgnIMF()->getReferField() );
2869 if ( co.cross( x - c ) * t.charge() * Bz > 0. )
2870 {
2871 bad = true;
2872 break;
2873 }
2874 }
2875 if ( bad ) continue;
2876 tmp.append( a[i] );
2877 }
2878 return tmp;
2879}
2880
2881void TConformalFinder::resolveHits( AList<TTrack>& tracks ) const {
2882 unsigned nTracks = tracks.length();
2883 if ( nTracks < 2 ) return;
2884
2885 for ( unsigned i = 0; i < nTracks - 1; i++ )
2886 {
2887 TTrack& t0 = *tracks[i];
2888 const AList<TMLink>& links0 = t0.links();
2889 unsigned n0 = links0.length();
2890 AList<TMLink> remove0;
2891 for ( unsigned j = i + 1; j < nTracks; j++ )
2892 {
2893 TTrack& t1 = *tracks[j];
2894 const AList<TMLink>& links1 = t1.links();
2895 unsigned n1 = links1.length();
2896 AList<TMLink> remove1;
2897
2898 //...Check overlap...
2899 for ( unsigned k = 0; k < n0; k++ )
2900 {
2901 TMLink& l = *links0[k];
2902
2903 //...Decide which is better...
2904 if ( links1.hasMember( l ) )
2905 {
2906 TMLink l0( NULL, l.hit() );
2907 TMLink l1( NULL, l.hit() );
2908 t0.approach( l0 );
2909 t1.approach( l1 );
2910 if ( l0.pull() > l1.pull() ) remove0.append( l );
2911 else remove1.append( l );
2912 }
2913 }
2914
2915 if ( remove1.length() )
2916 {
2917 t1.remove( remove1 );
2918 t1.fit();
2919 }
2920 }
2921
2922 if ( remove0.length() )
2923 {
2924 t0.remove( remove0 );
2925 t0.fit();
2926 }
2927 }
2928}
2929
2930AList<TSegment> TConformalFinder::stereoSegmentsFromBadHits( const TTrack& t ) const {
2931
2932 AList<TSegment> output;
2933 for ( unsigned i = 0; i < 6; i++ ) output.append( new TSegment() );
2934
2935 //...Calculate cross points...
2936 TPoint2D points[12];
2937 int err = crossPoints( t, points );
2938 if ( err )
2939 {
2940#ifdef TRKRECO_DEBUG_DETAIL
2941 std::cout << "... conf::stereoSegBadHits : "
2942 << "error in calculation of intersection" << std::endl;
2943#endif
2944 return output;
2945 }
2946
2947 static const TPoint2D O( 0., 0. );
2948 unsigned nBad = _unused[2].length();
2949 for ( unsigned i = 0; i < nBad; i++ )
2950 {
2951 unsigned sl = _unused[2][i]->wire()->superLayerId();
2952 unsigned asl = _unused[2][i]->wire()->axialStereoLayerId() / 4;
2953 unsigned as;
2954 if ( _unused[2][i]->wire()->axial() ) as = 0;
2955 else as = 1;
2956 // unsigned as = sl % 2;
2957 if ( as == 0 ) continue;
2958
2959 float a = WIDTH[sl] * _salvageLoadWidth;
2960 float phi0 = points[sl].phi();
2961 float phi1 = points[sl + 1].phi();
2962 float phi = _unused[2][i]->position().phi();
2963 if ( phi < 0. ) phi += PI2;
2964 if ( phi1 < phi0 )
2965 {
2966 phi1 = phi0;
2967 phi0 = points[sl + 1].phi();
2968 }
2969 float dPhi = phi1 - phi0;
2970 if ( dPhi < M_PI )
2971 {
2972 phi0 -= a;
2973 phi1 += a;
2974 if ( phi > phi0 && phi < phi1 )
2975 // output[sl / 2]->append(* _unused[2][i]);
2976 output[asl / 4]->append( *_unused[2][i] );
2977 }
2978 else
2979 {
2980 phi0 += a;
2981 phi1 -= a;
2982 if ( phi < phi0 || phi > phi1 ) output[asl / 4]->append( *_unused[2][i] );
2983 }
2984 }
2985
2986 return output;
2987}
2988
2989void TConformalFinder::findSegmentsPerfect( void ) {
2990
2991 //...Create lists of links for each super layer...
2992 AList<TMLink> links[11];
2993 unsigned nHits = _hits[2].length();
2994 for ( unsigned i = 0; i < nHits; i++ )
2995 {
2996 TMLink& l = *_hits[2][i];
2997 links[l.wire()->superLayerId()].append( l );
2998 }
2999
3000 //...MC tracks...
3001 const unsigned nHep = TTrackHEP::list().length();
3002
3003 //...Loop over each super layer...
3004 for ( unsigned i = 0; i < 11; i++ )
3005 {
3006 unsigned superLayerId = i / 2;
3007 unsigned id = i % 2;
3008
3009 //...Counters...
3010 AList<TMLink>** seeds = (AList<TMLink>**)malloc( nHep * sizeof( AList<TMLink>* ) );
3011 for ( unsigned j = 0; j < nHep; j++ ) seeds[j] = NULL;
3012
3013 //...Hit loop...
3014 unsigned n = links[i].length();
3015 for ( unsigned j = 0; j < n; j++ )
3016 {
3017 TMLink& l = *links[i][j];
3018 const TMDCWireHitMC* mc = l.hit()->mc();
3019 if ( !l.hit()->mc() )
3020 {
3021 std::cout << "TConformalFinder::findSegmentsPerfect !!! "
3022 << "no MC info. found ... aborted" << std::endl;
3023 return;
3024 }
3025 const unsigned id = mc->hep()->id();
3026
3027 if ( !seeds[id] ) seeds[id] = new AList<TMLink>();
3028 seeds[id]->append( l );
3029 }
3030
3031 //...Create segments...
3032 AList<TSegment> segments;
3033 for ( unsigned j = 0; j < nHep; j++ )
3034 {
3035 if ( !seeds[j] ) continue;
3036
3037 const unsigned length = seeds[j]->length();
3038 if ( length < _minNLinksForSegment ) continue;
3039 if ( length > _maxNLinksForSegment ) continue;
3040 if ( Width( *seeds[j] ) > _maxWidthForSegment ) continue;
3041
3042 TSegment& s = *new TSegment();
3043 s.append( *seeds[j] );
3044 segments.append( s );
3045 }
3046 _allSegments[id][superLayerId].append( segments );
3047 _allUnused[id][superLayerId] = _allSegments[id][superLayerId];
3048
3049 //...Clear...
3050 for ( unsigned j = 0; j < nHep; j++ )
3051 {
3052 if ( seeds[j] ) delete seeds[j];
3053 }
3054 free( seeds );
3055 }
3056
3057#ifdef TRKRECO_DEBUG_DETAIL
3058 std::cout << "... segment finding(perfect) finished" << std::endl;
3059#endif
3060}
3061
3062void TConformalFinder::findSegmentsTsf( void ) {
3063 //...Create lists of links for each super layer...
3064 AList<TMLink> links[11];
3065 unsigned n = _hits[2].length();
3066 for ( unsigned i = 0; i < n; i++ )
3067 {
3068 TMLink& l = *_hits[2][i];
3069 links[l.wire()->superLayerId()].append( l );
3070 }
3071
3072 // find Segments by tsf
3073 TMDCTsf* tsf[11];
3074
3075 // initial
3076 for ( unsigned i = 0; i < 11; ++i ) tsf[i] = new TMDCTsf( i );
3077
3078 for ( unsigned i = 0; i < 11; i++ )
3079 {
3080 unsigned superLayerId;
3081 unsigned id;
3082 switch ( i )
3083 {
3084 case 0:
3085 superLayerId = 0;
3086 id = 1;
3087 break;
3088 case 1:
3089 superLayerId = 1;
3090 id = 1;
3091 break;
3092 case 2:
3093 superLayerId = 0;
3094 id = 0;
3095 break;
3096 case 3:
3097 superLayerId = 1;
3098 id = 0;
3099 break;
3100 case 4:
3101 superLayerId = 2;
3102 id = 0;
3103 break;
3104 case 5:
3105 superLayerId = 2;
3106 id = 1;
3107 break;
3108 case 6:
3109 superLayerId = 3;
3110 id = 1;
3111 break;
3112 case 7:
3113 superLayerId = 4;
3114 id = 1;
3115 break;
3116 case 8:
3117 superLayerId = 5;
3118 id = 1;
3119 break;
3120 case 9:
3121 superLayerId = 3;
3122 id = 0;
3123 break;
3124 case 10:
3125 superLayerId = 4;
3126 id = 0;
3127 break;
3128 default: break;
3129 }
3130 // find segments
3131 AList<TSegment> tmp = tsf[i]->segments( links[i] );
3132
3133 //...Store them...
3134 _allSegments[id][superLayerId].append( tmp );
3135 _allUnused[id][superLayerId] = _allSegments[id][superLayerId];
3136 delete tsf[i];
3137
3138 //...remove used in seg...
3139 // for (int j = 0; j < _allUnused[id][superLayerId].length(); ++j){
3140 // AList<TMLink> used = _allUnused[id][superLayerId][j]->links();
3141 // _unused[id].remove(used);
3142 // _unused[2].remove(used);
3143 // }
3144 }
3145}
3146
3147IBesMagFieldSvc* TConformalFinder::getPmgnIMF() const {
3148 if ( !m_pmgnIMF )
3149 {
3150 StatusCode scmgn = Gaudi::svcLocator()->service( "MagneticFieldSvc", m_pmgnIMF );
3151 if ( scmgn != StatusCode::SUCCESS )
3152 { std::cout << "Unable to open Magnetic field service" << std::endl; }
3153 }
3154 return m_pmgnIMF;
3155}
HepGeom::Vector3D< double > HepVector3D
HepGeom::Point3D< double > HepPoint3D
const Int_t n
Double_t x[10]
Double_t phi1
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per saves r n generator level $ !Flag for chat level in output
Definition FoamA.h:89
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per saves r n generator level $ !Flag for chat level in !Latex Output unit
Definition FoamA.h:90
XmlRpcServer s
const HepPoint3D ORIGIN
Constants.
Definition TMDCUtil.cxx:47
void bitDisplay(unsigned)
Definition TMDCUtil.cxx:82
unsigned NMajorLinks(const TSegment &a)
returns # of links in the major link.
AList< TMLink > Links(const TSegment &, const TTrack &)
returns AList of TMLink used for a track.
unsigned NUniqueLinks(const TSegment &a)
checks property of segments.
TSegment * OuterMostUniqueLink(const TSegment &a)
returns a segment to the outer-most unique segment.
AList< TSegment > UniqueLinks(const TSegment &a)
returns a list of unique segments in links.
AList< TSegment > MajorLinks(const TSegment &a)
returns a list of segments in major links.
****INTEGER imax DOUBLE PRECISION m_pi *DOUBLE PRECISION m_amfin DOUBLE PRECISION m_Chfin DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_sinw2 DOUBLE PRECISION m_GFermi DOUBLE PRECISION m_MfinMin DOUBLE PRECISION m_ta2 INTEGER m_out INTEGER m_KeyFSR INTEGER m_KeyQCD *COMMON c_Semalib $ !copy of input $ !CMS energy $ !beam mass $ !final mass $ !beam charge $ !final charge $ !smallest final mass $ !Z mass $ !Z width $ !EW mixing angle $ !Gmu Fermi $ alphaQED at q
Definition KKsem.h:33
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition KarLud.h:35
int n1
Definition SD0Tag.cxx:58
#define M_PI
Definition TConstant.h:4
static void conformalTransformationDriftCircle(const HepPoint3D &center, const AList< TMDCWireHit > &hits, AList< TMLink > &links)
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
void clear(void)
clear internal information.
int doit(const AList< TMDCWireHit > &axialHits, const AList< TMDCWireHit > &stereoHits, AList< TTrack > &tracks, AList< TTrack > &tracks2D)
finds tracks.
std::string version(void) const
returns version.
static const TMDCWire * conformal2Wire(const HepPoint3D &conformalPoint)
virtual ~TConformalFinder()
Destructor.
TConformalFinder(unsigned fastFinder, unsigned slowFinder, unsigned perfectSegmentFinding, float maxSigma, float maxSigmaStereo, float salvageLevel, unsigned minNLinksForSegment, unsigned minNCoreLinks, unsigned minNSegments, unsigned salvageLoadWidth, unsigned stereoMode, unsigned stereoLoadWidth, float szSegmentDistance, float szLinkDistance, unsigned fittingFlag)
Constructor.
virtual int debugLevel(void) const
returns debug level.
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
AList< TSegment > segments(void) const
returns an AList<TSegment0> using clusters() function.
void fillPhi(const AList< TMLink > &links)
fills with hits.
AList< TSegment > segments(const AList< TMLink > &links)
finds segments.
Definition TMDCTsf.cxx:190
const TTrackHEP *const hep(void) const
returns a pointer to a GEN_HEPEVT.
float drift(unsigned) const
returns drift distance.
const TMDCWireHitMC *const mc(void) const
returns a pointer to TMDCWireHitMC.
unsigned superLayerId(void) const
returns super layer id.
std::string name(void) const
returns name.
const TMDCWire *const wire(unsigned wireId) const
returns a pointer to a wire. 0 will be returned if 'wireId' is invalid.
static TMDC * getTMDC(void)
Definition TMDC.cxx:84
A class to relate TMDCWireHit and TTrack objects.
const HepVector3D & direction(void) const
returns direction.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition TSegment.cxx:113
const HepPoint3D & position(void) const
returns position.
double distance(const TSegment &) const
calculates distance between two clusters. Smaller value indicates closer.
Definition TSegment.cxx:245
virtual int fit(void)
fits itself by a default fitter. Error was happened if return value is not zero.
const AList< TMLink > & links(unsigned mask=0) const
unsigned nCores(unsigned mask=0) const
returns # of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
const AList< TMLink > & cores(unsigned mask=0) const
returns a list of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
unsigned id(void) const
returns an id started from 0.
static const AList< TTrackHEP > & list(void)
returns a list of TTrackHEP's.
Definition TTrackHEP.cxx:70
static void maskBadHits(const AList< TTrack > &, float maxSigma2)
masks hits with large chisq as associated hits. Pull in TMLink is used.
static bool goodTrack(const TTrack &, bool track2D=false)
checks goodness of a track.
A class to represent a track in tracking.
AList< TSegment > & segments(void)
returns AList<TSegment>.
const std::string & name(void) const
returns/sets name.
TPoint2D center(void) const
returns position of helix center.
double radius(void) const
returns signed radius.
int approach(TMLink &) const
Definition TTrack.cxx:265
double charge(void) const
returns charge.
complex_t R(double Q2, double M2, double G, double Mp2, double Mm2)
Definition TUtil.h:22
int t()
Definition t.c:1
#define NS(x)
Definition xmltok.c:1354