BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkReco.cxx
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TrkReco.cxx,v 1.100 2012/05/28 05:16:29 maoh Exp $
3//-----------------------------------------------------------------------------
4// Filename : TrkReco.cc
5// Section : Tracking
6// Owner : Yoshi Iwasaki
7// Email : [email protected]
8//-----------------------------------------------------------------------------
9// Description : A tracking module.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11// http://belle.kek.jp/~yiwasaki/tracking/
12//-----------------------------------------------------------------------------
13
14#include <math.h>
15#include "CLHEP/String/Strings.h"
16
18#include "MdcTables/MdcTables.h"
19
20#include "TrkReco/TrkReco.h"
21#include "TrkReco/TMDC.h"
22#include "TrkReco/TMDCWire.h"
23#include "TrkReco/TMDCWireHit.h"
27#include "TrkReco/TCurlFinder.h"
28#include "TrkReco/TFastFinder.h"
29#include "TrkReco/TTrack.h"
30#include "TrkReco/TTrackMC.h"
31#include "TrkReco/TTrackHEP.h"
32#include "TrkReco/TMLink.h"
33#include "TrkReco/TTrackBase.h"
34
38
39#include "GaudiKernel/MsgStream.h"
40#include "GaudiKernel/AlgFactory.h"
41#include "GaudiKernel/ISvcLocator.h"
42#include "GaudiKernel/IDataManagerSvc.h"
43#include "GaudiKernel/SmartDataPtr.h"
44#include "GaudiKernel/IDataProviderSvc.h"
45#include "GaudiKernel/PropertyMgr.h"
46#include "GaudiKernel/IMessageSvc.h"
47#include "GaudiKernel/IDataProviderSvc.h"
48#include "GaudiKernel/IJobOptionsSvc.h"
49#include "GaudiKernel/Bootstrap.h"
50#include "GaudiKernel/StatusCode.h"
51
53#include "Identifier/MdcID.h"
56#include "MdcRawEvent/MdcDigi.h"
57#include "McTruth/McParticle.h"
58#include "McTruth/MdcMcHit.h"
61
62#include "RawDataProviderSvc/MdcRawDataProvider.h"//jialk 20090624
63
64
65#include <vector>
66#include <iostream>
67#include <fstream>
68
72
73
74using namespace std;
75using namespace Event;
76
79
80TrkReco::TrkReco(const std::string& name, ISvcLocator* pSvcLocator) :
81 Algorithm(name, pSvcLocator),
82 _cdc(0),
83 _perfectFinder(0),
84 _rkfitter("range fitter",
85 false,
86 0,
87 true),
88 _confFinder(0),
89 _curlFinder(0),
90 _nEvents(0) {
91
92 /// Initiate Parameters for TrkReco
93 initPara();
94
96}
97
98//************************************************************************Initialize
100 MsgStream log(msgSvc(), name());
101 log << MSG::INFO << "in initialize()" << endreq;
102
103 StatusCode sc;
104
105 /// Get RawDataProviderSvc
106 IRawDataProviderSvc* irawDataProviderSvc;
107 sc = service ("RawDataProviderSvc", irawDataProviderSvc);
108 _rawDataProviderSvc = dynamic_cast<RawDataProviderSvc*> (irawDataProviderSvc);
109 if ( sc.isFailure() ){
110 log << MSG::FATAL << "Could not load RawDataProviderSvc!" << endreq;
111 return StatusCode::FAILURE;
112 }
113
114 /// Get MdcGeomSvc
115 // IMdcGeomSvc* imdcGeomSvc;
116 // sc = service("MdcGeomSvc", imdcGeomSvc);
117 // _mdcGeomSvc = dynamic_cast<MdcGeomSvc*> (imdcGeomSvc);
118 // if (sc.isFailure()) {
119 // return( StatusCode::FAILURE);
120 // }
121
122 /// Get MdcCalibFunSvc
123 IMdcCalibFunSvc* imdcCalibSvc;
124 sc = service ("MdcCalibFunSvc",imdcCalibSvc);
125 _mdcCalibFunSvc = dynamic_cast<MdcCalibFunSvc*> (imdcCalibSvc);
126 if ( sc.isFailure() ){
127 log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endreq;
128 }
129
130 /// Initialize NTuple
131 if (b_tuple) InitTuple();
132
133#ifdef TRKRECO_DEBUG
134 b_debugLevel = 2;
135#endif
136
137 //...Create TMDC...
138// _cdc = cdcInit();
139
140 //...TrkReco...
142
143 //...Create rphi finder...
144/* _perfectFinder = new TPerfectFinder(b_perfectFitting,
145 b_conformalMaxSigma,
146 b_conformalStereoMaxSigma,
147 b_conformalFittingCorrections);
148*/
149 if ((! _confFinder) && (b_conformalFinder == 0)) {
150 _confFinder = new TConformalFinder0(b_conformalMaxSigma,
160 }
161 else if (! _confFinder) {
177 }
178 _confFinder->debugLevel(b_debugLevel);
180
181 //...Salvage flag is ignored in new conf. finder...
182 if (b_doSalvage == 2) _confFinder->doSalvage(true);
183
184 //...Create curl finder...
185 if (! _curlFinder)
186 _curlFinder = new TCurlFinder((unsigned)min_segment,
187 (unsigned)min_salvage,
190 (unsigned)min_sequence,
191 (unsigned)min_fullwire,
200 (unsigned)determine_one_track,
205 (unsigned)stereo_2dfind,
206 (unsigned)merge_exe,
217 z_cut,
219 (unsigned)svd_reconstruction,
221 (unsigned)on_correction,
222 (unsigned)output_2dtracks,
223 (unsigned)curl_version,
224 //jialk
231 _curlFinder->debugLevel(b_debugLevel);
232
233 //...Track manager setup...
234 _trackManager.maxMomentum(b_momentumCut);
235 _trackManager.debugLevel(b_debugLevel);
236 _trackManager.fittingFlag(b_fittingFlag);
237
238 //...Initialize...
239//zsl TUpdater::initialize();
240
241 //...For debug...
242// dump("parameter");
243
245
246 if (b_timeTest && b_tuple) {
247 StatusCode sc = service( "BesTimerSvc", m_timersvc);
248 if( sc.isFailure() ) {
249 log << MSG::WARNING << " Unable to locate BesTimerSvc" << endreq;
250 return StatusCode::FAILURE;
251 }
252 m_timer[1] = m_timersvc->addItem("Execution");
253 m_timer[1]->propName("nExecution");
254 }
255
256 return StatusCode::SUCCESS;
257}
258//************************************************************************MDCInit
259TMDC *
260TrkReco::cdcInit(void) {
261 _cdcVersion = dtostring(b_cdcVersion);
262 if (! _cdc) _cdc = TMDC::getTMDC(_cdcVersion);
264
265 //...Obtain fudge factor...
266 float fudgeFactor = b_fudgeFactor;
267
268/* if (fudgeFactor == 0.) {
269 const calcdc_const4 & c = * (calcdc_const4 *) BsGetEnt(CALMDC_CONST4,
270 1,
271 BBS_No_Index);
272 if (!(& c)) fudgeFactor = 1.;
273 else fudgeFactor = c.m_fudge;
274 }*/
275
276 //...Turn off fudge factor before checking performance...
277 fudgeFactor = 1.0;
278
279 _cdc->fudgeFactor(fudgeFactor);
280 return _cdc;
281}
282
283//************************************************************************Finalize
284StatusCode TrkReco::finalize() {
285
286 if (b_timeTest && b_tuple) m_timersvc->print();
287
288 //...Clear TrkReco objects...
289 if (_cdc) _cdc->fastClear();
290 if (b_doConformalFinder && _confFinder) _confFinder->clear();
291 if (b_doCurlFinder && _curlFinder) _curlFinder->clear();
292
293 //...Summary...
294// dump("summary");
295
296 //...Delete TrkReco objects...
297 if (_confFinder) delete _confFinder;
298 if (_curlFinder) delete _curlFinder;
299
300 return StatusCode::SUCCESS;
301}
302StatusCode TrkReco::beginRun(){
303 /// Get MdcGeomSvc
304 IMdcGeomSvc* imdcGeomSvc;
305 StatusCode sc1 =Gaudi::svcLocator()->service("MdcGeomSvc", imdcGeomSvc);
306 _mdcGeomSvc = dynamic_cast<MdcGeomSvc*> (imdcGeomSvc);
307 if (sc1.isFailure()) {
308 return( StatusCode::FAILURE);
309 }
310 _cdc = cdcInit();
311
312 return StatusCode::SUCCESS;
313}
314void
315TrkReco::disp_stat(const char * m) {
316 std::string msg = m;
317// dump(msg);
318}
319
320//************************************************************************Execute
321StatusCode TrkReco::execute() {
322 MsgStream log(msgSvc(), name());
323 log << MSG::INFO << "in execute()" << endreq;
324 StatusCode sc;
325 if (b_timeTest && b_tuple) m_timer[1]->start();
326
327 // Initiate state of all sense wire
328 if (b_goodTrk && b_tuple)
329 for (int ii=0;ii<43;ii++){
330 for (int jj=0;jj<288;jj++){
331 havedigi[ii][jj]= -99;//no hit/noise
332 }
333 }
334
335 //------------------------------------
336 // Initialize track collection in TDS
337 //------------------------------------
338 //yzhang add 2010-04-30
339 //Clear TDS tracks and hits
341 IDataManagerSvc *dataManSvc;
342 DataObject *aTrackCol;
343 DataObject *aRecHitCol;
345 dataManSvc = dynamic_cast<IDataManagerSvc*> (eventSvc().get());
346 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
347 if(aTrackCol != NULL) {
348 dataManSvc->clearSubTree("/Event/Recon/RecMdcTrackCol");
349 eventSvc()->unregisterObject("/Event/Recon/RecMdcTrackCol");
350 }
351 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aRecHitCol);
352 if(aRecHitCol != NULL) {
353 dataManSvc->clearSubTree("/Event/Recon/RecMdcHitCol");
354 eventSvc()->unregisterObject("/Event/Recon/RecMdcHitCol");
355 }
356 }
357 DataObject *aReconEvent;
358 eventSvc()->findObject("/Event/Recon",aReconEvent);
359 if(!aReconEvent) {
360 ReconEvent* recevt = new ReconEvent;
361 StatusCode sc = eventSvc()->registerObject("/Event/Recon",recevt );
362 if(sc!=StatusCode::SUCCESS) {
363 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
364 return( StatusCode::FAILURE);
365 }
366 }
367 RecMdcTrackCol* trkcol;
368 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
369 if (aTrackCol) {
370 trkcol = dynamic_cast<RecMdcTrackCol*> (aTrackCol);
371 }else{
372 trkcol= new RecMdcTrackCol;
373 sc = eventSvc()->registerObject(EventModel::Recon::RecMdcTrackCol, trkcol);
374 if(!sc.isSuccess()) {
375 log << MSG::FATAL << " Could not register RecMdcTrack collection" <<endreq;
376 return StatusCode::FAILURE;
377 }
378 }
379 RecMdcHitCol* hitcol;
380 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aRecHitCol);
381 if (aRecHitCol) {
382 hitcol = dynamic_cast<RecMdcHitCol*> (aRecHitCol);
383 }else{
384 hitcol= new RecMdcHitCol;
385 sc = eventSvc()->registerObject(EventModel::Recon::RecMdcHitCol, hitcol);
386 if(!sc.isSuccess()) {
387 log << MSG::FATAL << " Could not register RecMdcHit collection" <<endreq;
388 return StatusCode::FAILURE;
389 }
390 }
391 // Part 1: Get Tev
392 t0_bes = 0.;
393 t0Sta = -1;
394 if (useESTime) {
395 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
396//bugcheck jialk
397 if (aevtimeCol && aevtimeCol->size() ) {
398 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
399 t0_bes = (*iter_evt)->getTest();
400 t0Sta = (*iter_evt)->getStat();
401 }else{
402 log << MSG::WARNING << "Could not find EsTimeCol" << endreq;
403 return StatusCode::SUCCESS;
404 }
405 }
406
407 // Part 2: Get the event header
408 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
409 if (!eventHeader) {
410 log << MSG::FATAL << "Could not find Event Header" << endreq;
411 return( StatusCode::FAILURE);
412 }
413 _nEvents = eventHeader->eventNumber();
414 if (b_tuple) std::cout << "TrkReco ... processing ev# " << _nEvents << std::endl;
415
416 // Part 3: Retrieve MDC digi
417 int digiId;
418 uint32_t getDigiFlag = 0;
422 MdcDigiVec mdcDigiVec = _rawDataProviderSvc->getMdcDigiVec(getDigiFlag);
423 if (0 == mdcDigiVec.size()){
424 log << MSG::WARNING << " No hits in MdcDigiVec" << endreq;
425 return StatusCode::SUCCESS;
426 }
427/* //jialk in order to reject events with exceeding # of total hits 2009/03/31
428if (mdcDigiVec.size() > 2000){
429 log << MSG::WARNING << " Too many hits in MdcDigiVec" << endreq;
430 return StatusCode::SUCCESS;
431 }*/
432 MdcDigiVec::iterator iter1 = mdcDigiVec.begin();
433 MC_DIGI_SIZE = mdcDigiVec.size();
434
435 digiId = 0;
436 Identifier mdcId;
437 int layerId;
438 int wireId;
439
440 //Clear the old MdcRec_wirhit tables and create the hits' info for the new event.
441 unsigned nt = MdcRecWirhitCol::getMdcRecWirhitCol()->size();
442 //cout<<"Col size of last Event's WirHit = "<<nt<<endl;
444
445 for (;iter1 != mdcDigiVec.end(); iter1++, digiId++) {
446 //log << MSG::INFO << "MDC digit No: " << digiId << endreq;
447 mdcId = (*iter1)->identify();
448 layerId = MdcID::layer(mdcId);
449 wireId = MdcID::wire(mdcId);
450 /*log << MSG::INFO
451 << " time_channel = " << (*iter1)->getTimeChannel()
452 <<" time = "<<(*iter1)->getTimeChannel()* 40./10000/1000000
453 << " charge_channel = " << (*iter1)->getChargeChannel()
454 << " layerId = " << layerId
455 << " wireId = " << wireId
456 << endreq;*/
457
458 if (b_goodTrk && b_tuple) havedigi[layerId][wireId] = (*iter1)->getTrackIndex(); //-1:noise 0-n:tracks
459
460 MdcRec_wirhit mhit;
461
462 mhit.id = digiId;
463 mhit.geo = _mdcGeomSvc->Wire(layerId,wireId);
464 //Apply crude TOF, Belle: tof=1.074*radius/c, here we use 1.28 instead of 1.074.
465 double tof;
466 tof = 1.28 * mhit.geo->Lyr()->Radius()/299.8; //unit of Radius is mm.
467 mhit.tdc = RawDataUtil::MdcTime((*iter1)->getTimeChannel());
468
469 //cout<<" .. mhit.tdc = "<<mhit.tdc<<" t0_bes = "<<t0_bes<<endl;
470 mhit.tdc -= t0_bes;
471
472 //jialk
473 _trackManager.sett0bes(t0_bes);
474 //mhit.adc = RawDataUtil::MdcCharge((*iter1)->getChargeChannel());
475 //mhit.tdc = (*iter1)->getTimeChannel();
476 mhit.adc = (*iter1)->getChargeChannel();
477 //cout<<"raw tdc(ns): "<<mhit.tdc<<"; tof(ns): "<<tof<<endl;
478// double dist2 = _mdcCalibFunSvc->rawTimeNoTOFToDist(mhit.tdc-tof, layerId, wireId, 2, 0.0);
479 // mhit.erddl = _mdcCalibFunSvc->getSigma(layerId, 2, dist2, 0.0);
480 double timewalk=_mdcCalibFunSvc->getTimeWalk(layerId,mhit.adc);
481 double T0 = _mdcCalibFunSvc->getT0(layerId,wireId);
482 double drifttime = mhit.tdc-tof-timewalk-T0;
483 double dist2 = _mdcCalibFunSvc->driftTimeToDist(drifttime,layerId, wireId, 2, 0);//by liucy 2010/05/12
484 mhit.erddl = _mdcCalibFunSvc->getSigma(layerId, 2 , dist2, 0.0,0.0,0.0,mhit.adc);
485//cout<<"getSigma: "<<mhit.erddl<<endl;
486 mhit.ddl = dist2/10.; //mm->cm
487 mhit.ddr = mhit.ddl;
488 mhit.erddl = mhit.erddl/10.; //mm->cm
489 mhit.erddr = mhit.erddl;
490
491 mhit.lr = 2;
492 mhit.stat = 0;
493 mhit.stat = mhit.stat |= 1048576; //bit20 WireHitTimeValid
494 mhit.stat = mhit.stat |= 2097152; //bit21 WireHitChargeValid
495 mhit.stat = mhit.stat |= 4194304; //bit22 WireHitFindingValid
496 mhit.stat = mhit.stat |= 1073741824; //bit30
497 //cout<<"layerNo = "<<mhit.geo->Layer()<<"; "<<mdigi.digi[i].layerNo<<endl;
498 //cout<<"cellNo = "<<mhit.geo->Cell()<<"; "<<mdigi.digi[i].cellNo<<endl;
499 //cout<<"NCell of this layer = "<<mhit.geo->Lyr()->NCell()<<endl;
500 //cout<<"NCell of this layer = "<<mhit.geo->Lyr()->NCell()<<endl;
501 MdcRecWirhitCol::getMdcRecWirhitCol()->push_back(mhit);
502
503 if (b_tuple) {
504 t10_tdc = mhit.tdc;
505 t10_adc = mhit.adc;
506 t10_drift = mhit.ddl;
507 t10_dDrift = mhit.erddl;
508 t10_lyrId = layerId;
509 t10_localId = wireId;
510 m_tuple10->write();
511 }
512 }
513
514 unsigned nT0Reset = 0;
515
516 //...Starting point...
517TrkReco_start:
518
519 //...Clear myself...
520 clear();
521
522 //jialk in order to reject events with exceeding # of total hits 2009/03/31
523 if (mdcDigiVec.size() > 2000){
524 log << MSG::WARNING << " Too many hits in MdcDigiVec" << endreq;
525 return StatusCode::SUCCESS;
526 }
527
528 //...Update TMDC...
529 _cdc->update(b_doMCAnalysis);
530
531 //...Get lists of hits...
532 unsigned mask = 0;
533 if (! b_useAllHits) mask = WireHitFindingValid;
534 const AList<TMDCWireHit> & axialHits = _cdc->axialHits(mask);
535 const AList<TMDCWireHit> & stereoHits = _cdc->stereoHits(mask);
536 const AList<TMDCWireHit> & allHits = _cdc->hits(mask);
537 //cout<<"axial: "<<axialHits.length()<<" stereo: "<<stereoHits.length()<<endl;
538
539 //...Storage for tracks...
541 AList<TTrack> tracks2D;
542
543 //...Perfect finder...
544 if (b_doPerfectFinder) {
545 _perfectFinder->doit(axialHits, stereoHits, tracks, tracks2D);
546 _trackManager.append(tracks);
547 }
548
549 else {
550 //...Conformal finder...
552
553 //...T0 reset option...
554 if (b_doT0Reset) {
555 if (b_nT0ResetMax > nT0Reset)
556 ((TConformalFinder *) _confFinder)->doT0Reset(true);
557 else
558 ((TConformalFinder *) _confFinder)->doT0Reset(false);
559 }
560
561 _confFinder->doit(axialHits, stereoHits, tracks, tracks2D);
562
563 //...T0 reset...
564 if (b_doT0Reset) {
565 ++nT0Reset;
566 if (((TConformalFinder *) _confFinder)->T0ResetDone())
567 goto TrkReco_start;
568 }
569
570 //cout<<"tracks: "<<tracks.length()<<endl;
571
572 //...Stores tracks...
573 _trackManager.append(tracks);
574 _trackManager.append2D(tracks2D);
575 if (b_conformalFinder == 0) {
576 if (b_doSalvage == 1) _trackManager.salvage(allHits);
577 if (b_doSalvage) _trackManager.mask();
578 }
579 }
580
581 //...Curl finder...
582 if (b_doCurlFinder) {
583 if ((! b_doSalvage) && (b_conformalFinder == 0))
584 _trackManager.maskCurlHits(axialHits,
585 stereoHits,
586 _trackManager.tracks());
587 AList<TTrack> confTracks = _trackManager.tracks();
588 tracks.append(confTracks);
589 _curlFinder->doit(axialHits, stereoHits, tracks, tracks2D);
590 tracks.remove(confTracks);
591 //_trackManager.append(tracks);
592 }
593
594 //...Finishes tracks...
595// if ((b_doSalvage) && (b_conformalFinder == 0)) _trackManager.refit();
596
597 //...Appends tracks which are reconstructed by CurlFinder...
598 if (b_doCurlFinder) {
599 _trackManager.append(tracks);
600 _trackManager.append2D(tracks2D);
601 }
602
603 //...Merge & Mask ...
604 //if ((b_doMerge) && (b_conformalFinder == 0)) _trackManager.merge();
605 _trackManager.merge(); //Liuqg
606 //if (b_conformalFinder != 0) _trackManager.setCurlerFlags();
607
608 //...Salvage for dE/dx...
609 //if (b_doAssociation)
610 // _trackManager.salvageAssociateHits(allHits, b_associateSigma);
611 }
612
613 //...Move a pivot... //move to the innermost hit, remove this step now 2005/10/17 zang shilei
614 //_trackManager.movePivot();
615
616 //...Save Panther tables...
617 // _trackManager.checkNumberOfHits();
618 //if (b_sortMode == 0) _trackManager.sortTracksByQuality();
619 //else _trackManager.sortTracksByPt();
620 /*if (b_doMCAnalysis) {
621 if (mcEvent()) {
622 mcInformation();
623 _trackManager.saveMCTables();
624 }
625 }*/
626
627 if (b_tuple) FillTuple();
628
629 //write Tds
630 int t_tkStat = 2;
631 if (!b_doConformalFinder && b_doCurlFinder) t_tkStat = 3;//FIXME
632 StatusCode scTds = _trackManager.makeTds(trkcol, hitcol, t_tkStat,b_RungeKuttaCorrection,m_CalibFlag);
633 if (scTds != StatusCode::SUCCESS) return( StatusCode::FAILURE);
634
635 //...T0 correction...
638 if (b_tuple) t3_t0Rec = _trackManager.paraT0();
639 }
640 }
641 else if(b_RungeKuttaCorrection==1){
642 if (useESTime) {
643 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
644 if (aevtimeCol && aevtimeCol->size() ) {
645 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
646 t0_bes = (*iter_evt)->getTest();
647 t0Sta = (*iter_evt)->getStat();
648 }else{
649 log << MSG::WARNING << "Could not find EsTimeCol" << endreq;
650 return StatusCode::SUCCESS;
651 }
652 }
653
654 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
655 if (!eventHeader) {
656 log << MSG::FATAL << "Could not find Event Header" << endreq;
657 return( StatusCode::FAILURE);
658 }
659 _nEvents = eventHeader->eventNumber();
660 if (b_tuple) std::cout << "TrkReco ... processing ev# " << _nEvents << std::endl;
661 AList<TTrack> rktracks;
662 int digiId;
663 uint32_t getDigiFlag = 0;
667 MdcDigiVec mdcDigiVec = _rawDataProviderSvc->getMdcDigiVec(getDigiFlag);
668 if (0 == mdcDigiVec.size()){
669 log << MSG::WARNING << " No hits in MdcDigiVec" << endreq;
670 return StatusCode::SUCCESS;
671 }
672 MdcDigiVec::iterator iter1 = mdcDigiVec.begin();
673 MC_DIGI_SIZE = mdcDigiVec.size();
674
675 digiId = 0;
676 Identifier mdcId;
677 int layerId;
678 int wireId;
679
680 unsigned nt = MdcRecWirhitCol::getMdcRecWirhitCol()->size();
682
683 for (;iter1 != mdcDigiVec.end(); iter1++, digiId++) {
684 mdcId = (*iter1)->identify();
685 layerId = MdcID::layer(mdcId);
686 wireId = MdcID::wire(mdcId);
687 if (b_goodTrk && b_tuple) havedigi[layerId][wireId] = (*iter1)->getTrackIndex();
688
689 MdcRec_wirhit mhit;
690
691 mhit.id = digiId;
692 mhit.geo = _mdcGeomSvc->Wire(layerId,wireId);
693 double tof;
694 tof = 1.28 * mhit.geo->Lyr()->Radius()/299.8;
695 mhit.tdc = RawDataUtil::MdcTime((*iter1)->getTimeChannel());
696 mhit.timechannel=(*iter1)->getTimeChannel();
697 mhit.tdc -= t0_bes;
698
699 _trackManager.sett0bes(t0_bes);
700 mhit.adc = (*iter1)->getChargeChannel();
701 double timewalk=_mdcCalibFunSvc->getTimeWalk(layerId,mhit.adc);
702 double T0 = _mdcCalibFunSvc->getT0(layerId,wireId);
703 double drifttime = mhit.tdc-tof-timewalk-T0;
704 double dist2 = _mdcCalibFunSvc->driftTimeToDist(drifttime,layerId, wireId, 2, 0);
705 mhit.erddl = _mdcCalibFunSvc->getSigma(layerId, 2 , dist2, 0.0,0.0,0.0,mhit.adc);
706 mhit.ddl = dist2/10.;
707 mhit.ddr = mhit.ddl;
708 mhit.erddl = mhit.erddl/10.;
709 mhit.erddr = mhit.erddl;
710
711 mhit.lr = 2;
712 mhit.stat = 0;
713 mhit.stat = mhit.stat |= 1048576;
714 mhit.stat = mhit.stat |= 2097152;
715 mhit.stat = mhit.stat |= 4194304;
716 mhit.stat = mhit.stat |= 1073741824;
717 MdcRecWirhitCol::getMdcRecWirhitCol()->push_back(mhit);
718
719 if (b_tuple) {
720 t10_tdc = mhit.tdc;
721 t10_adc = mhit.adc;
722 t10_drift = mhit.ddl;
723 t10_dDrift = mhit.erddl;
724 t10_lyrId = layerId;
725 t10_localId = wireId;
726 m_tuple10->write();
727 }
728 }
729
730 unsigned nT0Reset = 0;
731
732 clear();
733 if (mdcDigiVec.size() > 2000){
734 log << MSG::WARNING << " Too many hits in MdcDigiVec" << endreq;
735 return StatusCode::SUCCESS;
736 }
737 int counter=0;
738 _cdc->update(b_doMCAnalysis);
739
740 unsigned mask = 0;
741 if (! b_useAllHits) mask = WireHitFindingValid;
742 const AList<TMDCWireHit> & axialHits = _cdc->axialHits(mask);
743 const AList<TMDCWireHit> & stereoHits = _cdc->stereoHits(mask);
744 const AList<TMDCWireHit> & allHits = _cdc->hits(mask);
745 AList<TMLink> _allHits[3];
748 _allHits[2].append(_allHits[0]);
749 _allHits[2].append(_allHits[1]);
750
751
752 SmartDataPtr<RecMdcTrackCol> mdcTracks(eventSvc(),EventModel::Recon::RecMdcTrackCol);
753 if( ! mdcTracks )
754 {
755 log << MSG::ERROR << "Unable to retrieve RecMdcTrackCol" << endreq;
756 return StatusCode::FAILURE;
757 } else {
758 log << MSG::DEBUG << "RecMdcTrackCol retrieved of size "<< mdcTracks->size() << endreq;
759 int ntrk=0;
760 for(RecMdcTrackCol::iterator it=mdcTracks->begin(); it!=mdcTracks->end(); it++)
761 {ntrk++;
762 TRunge *r = new TRunge(**it);
763 TTrack *t1 = new TTrack(*r);
764 HitRefVec gothits = (*it)->getVecHits();
765 HitRefVec::iterator it_gothit = gothits.begin();
766 unsigned stat=(*it)->stat();
767 int nhit=0;
768 for( ; it_gothit != gothits.end(); it_gothit++){
769 for(int i=0;i<_allHits[2].length();i++){
770 int lyrraw=_allHits[2][i]->wire()->layerId();
771 int wireraw=_allHits[2][i]->wire()->localId();
772 int g_layer = MdcID::layer((*it_gothit)->getMdcId());
773 int g_wire = MdcID::wire((*it_gothit)->getMdcId());
774 if(lyrraw==g_layer&&g_wire==wireraw){
775 nhit++;
776 t1->append(*_allHits[2][i]);
777 }
778 }
779 }
780 TRunge *rr = new TRunge(*t1);
781 TRunge *tt = new TRunge(*t1);
782 int err=_rkfitter.fit(*rr);
783 int nhits=rr->links().length();
784 int ndrop=0;
785 int nmax=0;
786 if(nhits<=10)nmax=0;
787 if(nhits>10)nmax=(int)nhit*0.3;
788 for(int ii=0;ii<nmax;ii++){
789
790 ndrop=rr->DropWorst();
791 if(ndrop)err=_rkfitter.fit(*rr);
792 if(err)break;
793 }
794 if(err==-2) counter++;
795 if(m_CalibFlag==1) {//This is for Calibration
796 tt->removeLinks();
797 tt->append(rr->links());
798 for(int i=0;i<43;i++){
799 err= _rkfitter.fit(*tt,0,i);
800 }
801 rr->removeLinks();
802 rr->append(tt->links());
803 TTrack *t =new TTrack(*rr);
804 if(err==0){
805 rktracks.append(*t);
806 t->setFinderType(100+stat);
807 }
808 }
809 if(m_CalibFlag==0){
810 TTrack *t =new TTrack(*rr);
811 if(err==0){
812
813 t->setFinderType(100+stat);
814 rktracks.append(*t);
815 }
816 }
817 delete r ;
818 delete t1;
819 delete rr;
820 delete tt;
821 }
822 }
823
824 _trackManager.append(rktracks);
825 IDataManagerSvc *dataManSvc;
826 DataObject *aTrackCol;
827 DataObject *aRecHitCol;
829 dataManSvc = dynamic_cast<IDataManagerSvc*> (eventSvc().get());
830 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
831 if(aTrackCol != NULL) {
832 dataManSvc->clearSubTree("/Event/Recon/RecMdcTrackCol");
833 eventSvc()->unregisterObject("/Event/Recon/RecMdcTrackCol");
834 }
835 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aRecHitCol);
836 if(aRecHitCol != NULL) {
837 dataManSvc->clearSubTree("/Event/Recon/RecMdcHitCol");
838 eventSvc()->unregisterObject("/Event/Recon/RecMdcHitCol");
839 }
840 }
841 DataObject *aReconEvent;
842 eventSvc()->findObject("/Event/Recon",aReconEvent);
843 if(!aReconEvent) {
844 ReconEvent* recevt = new ReconEvent;
845 StatusCode sc = eventSvc()->registerObject("/Event/Recon",recevt );
846 if(sc!=StatusCode::SUCCESS) {
847 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
848 return( StatusCode::FAILURE);
849 }
850 }
851 RecMdcTrackCol* trkcol;
852 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
853 if (aTrackCol) {
854 trkcol = dynamic_cast<RecMdcTrackCol*> (aTrackCol);
855 }else{
856 trkcol= new RecMdcTrackCol;
857 sc = eventSvc()->registerObject(EventModel::Recon::RecMdcTrackCol, trkcol);
858 if(!sc.isSuccess()) {
859 log << MSG::FATAL << " Could not register RecMdcTrack collection" <<endreq;
860 return StatusCode::FAILURE;
861 }
862 }
863 RecMdcHitCol* hitcol;
864 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aRecHitCol);
865 if (aRecHitCol) {
866 hitcol = dynamic_cast<RecMdcHitCol*> (aRecHitCol);
867 }else{
868 hitcol= new RecMdcHitCol;
869 sc = eventSvc()->registerObject(EventModel::Recon::RecMdcHitCol, hitcol);
870 if(!sc.isSuccess()) {
871 log << MSG::FATAL << " Could not register RecMdcHit collection" <<endreq;
872 return StatusCode::FAILURE;
873 }
874 }
875 if (b_tuple) FillTuple();
876
877 int t_tkStat = 2;
878 if (!b_doConformalFinder && b_doCurlFinder) t_tkStat = 3;//FIXME
879 StatusCode scTds = _trackManager.makeTds(trkcol, hitcol, t_tkStat,b_RungeKuttaCorrection,m_CalibFlag);
882 if (b_tuple) t3_t0Rec = _trackManager.paraT0();
883 }
884 for (unsigned i = 0; i < 3; i++) {
885 if (i == 2)
886 HepAListDeleteAll(_allHits[i]);
887 else
888 _allHits[i].removeAll();
889 }
890
891 rktracks.removeAll();
892 }
893 //...For debug...
894 /*if (b_debugLevel) {
895 std::cout << "TrkReco ... ev# " << _nEvents << " processed,"
896 << " #tracks found=" << _trackManager.allTracks().length()
897 << ", #good tracks=" << _trackManager.tracks().length()
898 << ", #2D tracks=" << _trackManager.tracks2D().length()
899 << std::endl;
900 if (b_debugLevel > 1) _trackManager.dump("eventSummary hits");
901 else _trackManager.dump("eventSummary");
902 }*/
903
904 //TUpdater::update();
905 return StatusCode::SUCCESS;
906}
907
908void
909TrkReco::mcInformation(void) {
910
911 //...Preparation...
912 // const AList<TTrack> & allTracks = _trackManager.allTracks();
913 const AList<TTrack> & allTracks = _trackManager.tracksFinal();
914
915 unsigned nHep = TTrackHEP::list().length();
916 unsigned nTrk = allTracks.length();
917 unsigned * N = (unsigned *) malloc(nHep * sizeof(unsigned));
918 for (unsigned i = 0; i < nHep; i++) N[i] = 0;
919
920 //...Loop over all tracks...
921 for (unsigned i = 0; i < nTrk; i++) {
922 TTrackMC * mc = allTracks[i]->_mc;
923 if (! mc) {
924 mc = new TTrackMC(* allTracks[i]);
925 _mcTracks.append(mc);
926 allTracks[i]->_mc = mc;
927 }
928
929 mc->update();
930 if (mc->hepId() != -1)
931 if (mc->charge())
932 ++N[mc->hepId()];
933 }
934
935 //...Check uniqueness...
936 for (unsigned i = 0; i < nHep; i++) {
937 if (N[i] < 2) {
938 for (unsigned j = 0; j < nTrk; j++)
939 if (allTracks[j]->_mc->hepId() == i)
940 allTracks[j]->_mc->_quality += TTrackUnique;
941 }
942 }
943
944 //...Good tracks...
945 for (unsigned i = 0; i < nTrk; i++) {
946 unsigned & quality = allTracks[i]->_mc->_quality;
947 if ((quality & TTrackGhost) && (quality & TTrackUnique))
948 quality += TTrackGood;
949 }
950
951 //...Termination...
952 free(N);
953}
954
955void
957
958 //...Clear track candidates of the last event...
959 HepAListDeleteAll(_mcTracks);
960
961 //...Clear finders...
962 if (b_doPerfectFinder) _perfectFinder->clear();
963 if (b_doConformalFinder) _confFinder->clear();
964 if (b_doCurlFinder) _curlFinder->clear();
965 _trackManager.clear();
966 _trackManager.clearTables();
967}
968
969void
971 clear();
972}
973
974bool
975TrkReco::mcEvent(void) const {
976 // struct belle_event * ev =
977 // (struct belle_event *) BsGetEnt(BELLE_EVENT, 1, BBS_No_Index);
978
979 //...No BELLE_EVENT ???...
980 // if (! ev) return false;
981 // if (ev->m_ExpMC == 2) return true;
982 // return false;
983 return true;
984}
985
986//std::string
987//TrkReco::version(void) const {
988// return "TrkReco-00-00-04";
989//}
990
991void
992TrkReco::initPara(void){
993 _rkfitter.setBesFromGdml();
994 declareProperty("mcPar", b_mcPar = 0);
995 declareProperty("mcHit", b_mcHit = 0);
996 declareProperty("tuple", b_tuple = 0);
997 declareProperty("goodTrk", b_goodTrk = 0);
998 declareProperty("timeTest", b_timeTest = 0);
999
1000 declareProperty("cdcVersion", b_cdcVersion = 1.0);
1001 declareProperty("fudgeFactor", b_fudgeFactor = 1.0);
1002
1003 declareProperty("useESTime", useESTime = 1.0);
1004
1005 declareProperty("debugLevel", b_debugLevel = 0);
1006 declareProperty("useAllHits", b_useAllHits = 0);
1007 declareProperty("doT0Reset", b_doT0Reset = 0);
1008 declareProperty("nT0ResetMax", b_nT0ResetMax = 1);
1009 declareProperty("doMCAnalysis", b_doMCAnalysis = 1);
1010 declareProperty("helixFitterChisqMax", b_helixFitterChisqMax = 0.);
1011
1012 declareProperty("RungeKuttaCorrection", b_RungeKuttaCorrection = 0);
1013 declareProperty("doPerfectFinder", b_doPerfectFinder = 0);
1014 declareProperty("perfectFitting", b_perfectFitting = 0);
1015
1016 declareProperty("conformalFinder", b_conformalFinder = 1);
1017 declareProperty("doConformalFinder", b_doConformalFinder = 0);
1018 declareProperty("doConformalFastFinder", b_doConformalFastFinder = 1);
1019 declareProperty("doConformalSlowFinder", b_doConformalSlowFinder = 1);
1020 declareProperty("conformalPerfectSegmentFinding", b_conformalPerfectSegmentFinding = 0);
1021 declareProperty("conformalFittingFlag", b_conformalFittingFlag = 4); //1: sag 2: propagation 4: tof 8: freeT0
1022 declareProperty("conformalMaxSigma", b_conformalMaxSigma = 30.);
1023 declareProperty("conformalMinNLinksForSegment", b_conformalMinNLinksForSegment = 2);
1024 declareProperty("conformalMinNCores", b_conformalMinNCores = 2); //min core for a seg
1025 declareProperty("conformalMinNSegments", b_conformalMinNSegments = 2); //min seg for trk, default: 3
1026 declareProperty("salvageLevel", b_salvageLevel = 30.);
1027 declareProperty("conformalSalvageLoadWidth", b_conformalSalvageLoadWidth = 1);
1028 declareProperty("conformalStereoMode", b_conformalStereoMode = 1);
1029 declareProperty("conformalStereoLoadWidth", b_conformalStereoLoadWidth = 5);
1030 declareProperty("conformalStereoMaxSigma", b_conformalStereoMaxSigma = 30.);
1031 declareProperty("conformalStereoSzSegmentDistance", b_conformalStereoSzSegmentDistance = 10.);
1032 declareProperty("conformalStereoSzLinkDistance", b_conformalStereoSzLinkDistance = 15.);
1033
1034 declareProperty("doConformalFinderStereo", b_doConformalFinderStereo = 1); //cosmic, use stereo
1035 declareProperty("doConformalFinderCosmic", b_doConformalFinderCosmic = 0);
1036 declareProperty("conformalFraction", b_conformalFraction = 0.7); //cores fraction in trk
1037 declareProperty("conformalStereoZ3", b_conformalStereoZ3 = 20.);
1038 declareProperty("conformalStereoZ4", b_conformalStereoZ4 = 20.);
1039 declareProperty("conformalStereoChisq3", b_conformalStereoChisq3 = 30.);
1040 declareProperty("conformalStereoChisq4", b_conformalStereoChisq4 = 30.);
1041 declareProperty("conformalFittingCorrections", b_conformalFittingCorrections = 0);
1042
1043 declareProperty("doCurlFinder", b_doCurlFinder = 1); //CurlFinder on: 1 off: 0
1044 declareProperty("doSalvage", b_doSalvage = 2);
1045 declareProperty("doMerge", b_doMerge = 0);
1046 declareProperty("momentumCut", b_momentumCut = 0.0);
1047 declareProperty("doT0Determination", b_doT0Determination = 7);
1048 declareProperty("nTracksForT0", b_nTracksForT0 = 2);
1049 declareProperty("sortMode", b_sortMode = 0);
1050 declareProperty("test", b_test = 0);
1051 declareProperty("fittingFlag", b_fittingFlag = 0);
1052 declareProperty("doAssociation", b_doAssociation = 1);
1053 declareProperty("associateSigma", b_associateSigma = 60);
1054
1055 declareProperty("dropHot", m_dropHot= 0);//jialk 20090624
1056 declareProperty("combineTracking",m_combineTracking=0);
1057 declareProperty("keepBadTdc",m_keepBadTdc=0);
1058 declareProperty("keepUnmatch",m_keepUnmatch=0);
1059
1060 declareProperty("CalibFlag",m_CalibFlag=0);
1061 // For Curl Finder -->
1062 declareProperty("min_segment", min_segment = 5); //min links for a segment
1063 declareProperty("min_salvage", min_salvage = 10); //salvage while trk.links < min
1064 declareProperty("bad_distance_for_salvage", bad_distance_for_salvage = 1.0);
1065 declareProperty("good_distance_for_salvage", good_distance_for_salvage = 0.2);
1066 declareProperty("min_sequence", min_sequence = 6);
1067 declareProperty("min_fullwire", min_fullwire = 5); //Belle: 7
1068 declareProperty("range_for_axial_search", range_for_axial_search = 1.5);
1069 declareProperty("range_for_stereo_search", range_for_stereo_search = 2.5);
1070 declareProperty("superlayer_for_stereo_search", superlayer_for_stereo_search = 3);
1071 declareProperty("range_for_axial_last2d_search", range_for_axial_last2d_search = 1.5);
1072 declareProperty("range_for_stereo_last2d_search", range_for_stereo_last2d_search = 2.0);
1073 declareProperty("trace2d_distance", trace2d_distance = 35.0);
1074 declareProperty("trace2d_first_distance", trace2d_first_distance = 0.5);
1075 declareProperty("trace3d_distance", trace3d_distance = 30.0);
1076 declareProperty("determine_one_track", determine_one_track = 0);
1077 declareProperty("selector_max_impact", selector_max_impact = 4.0);
1078 declareProperty("selector_max_sigma", selector_max_sigma = 36.0);
1079 declareProperty("selector_strange_pz", selector_strange_pz = 10.0);
1080 declareProperty("selector_replace_dz", selector_replace_dz = 15.0);
1081 declareProperty("stereo_2dfind", stereo_2dfind = 0);
1082 declareProperty("merge_exe", merge_exe = 1);
1083 declareProperty("merge_ratio", merge_ratio = 0.1);
1084 declareProperty("merge_z_diff", merge_z_diff = 10.0);
1085 declareProperty("mask_distance", mask_distance = 0.5);
1086 declareProperty("ratio_used_wire", ratio_used_wire = 0.3);
1087 declareProperty("range_for_stereo1", range_for_stereo1 = 2.4);
1088 declareProperty("range_for_stereo2", range_for_stereo2 = 2.7);
1089 declareProperty("range_for_stereo3", range_for_stereo3 = 2.9);
1090 declareProperty("range_for_stereo4", range_for_stereo4 = 3.4);
1091 declareProperty("range_for_stereo5", range_for_stereo5 = 4.1);
1092 declareProperty("range_for_stereo6", range_for_stereo6 = 5.0); //Liuqg
1093 declareProperty("z_cut", z_cut = 50.0);
1094 declareProperty("z_diff_for_last_attend", z_diff_for_last_attend = 1.5);
1095 declareProperty("on_correction", on_correction = 4); //1 sag, 2 propagation, 4 tof. definition changed in BES
1096 declareProperty("output_2dtracks", output_2dtracks = 1); //fill 2D track
1097 declareProperty("curl_version", curl_version = 0);
1098 //jialk
1099 declareProperty("minimum_seedLength", minimum_seedLength = 5);
1100 declareProperty("minimum_2DTrackLength", minimum_2DTrackLength = 7);
1101 declareProperty("minimum_3DTrackLength", minimum_3DTrackLength = 10);
1102 declareProperty("minimum_closeHitsLength", minimum_closeHitsLength = 5);
1103 declareProperty("MIN_RADIUS_OF_STRANGE_TRACK",MIN_RADIUS_OF_STRANGE_TRACK = 50);
1104 declareProperty("ULTIMATE_MIN_RADIUS_OF_STRANGE_TRACK",ULTIMATE_MIN_RADIUS_OF_STRANGE_TRACK = 5);
1105 // <-- For Curl Finder
1106}
1107
1108void
1109TrkReco::InitTuple(void){
1110 m_tuple=ntupleSvc()->book("FILE101/rec3D",CLID_ColumnWiseTuple,"MdcRecEvent");
1111 m_tuple->addItem ("mc_phi", t_mcphi);
1112 m_tuple->addItem ("mc_theta", t_mctheta);
1113 m_tuple->addItem ("mc_ptot", t_mcptot);
1114 m_tuple->addItem ("mc_pt", t_mcpt);
1115 m_tuple->addItem ("mc_pz", t_mcpz);
1116 m_tuple->addItem ("mc_t0", t_mct0);
1117 m_tuple->addItem ("nDigi", t_nDigi);
1118
1119 m_tuple->addItem ("dr", t_dr);
1120 m_tuple->addItem ("dz", t_dz);
1121 m_tuple->addItem ("pt", t_pt);
1122 m_tuple->addItem ("ptot", t_ptot);
1123 m_tuple->addItem ("tanlmd",t_tanlmd);
1124 m_tuple->addItem ("phi", t_phi);
1125 m_tuple->addItem ("radius",t_radius);
1126 m_tuple->addItem ("chi2", t_chi2);
1127 m_tuple->addItem ("nHits", t_nHits);
1128 m_tuple->addItem ("nCores",t_nCores);
1129 m_tuple->addItem ("nSegs", t_nSegs);
1130 m_tuple->addItem ("ndf", t_ndf);
1131
1132 m_tuple->addItem ("dpt", t_dpt);
1133 m_tuple->addItem ("dptot", t_dptot);
1134 m_tuple->addItem ("dlmd", t_dlmd);
1135 m_tuple->addItem ("dphi", t_dphi);
1136
1137 m_tuple->addItem ("t0", t_t0);
1138 m_tuple->addItem ("t0_sta",t0_sta); //mdc, tof
1139
1140 m_tuple->addItem ("evtNo", t_evtNo);
1141 m_tuple->addItem ("length", t_length);
1142 m_tuple->addItem ("length2", t_length2);
1143
1144 m_tuple->addItem ("gd_theta", t_good_theta);
1145 m_tuple->addItem ("gd_nLayers", t_gdNLayers);
1146 m_tuple->addItem ("mc_nLayers", t_mcNLayers);
1147 m_tuple->addItem ("best_nLayers",t_bestNLayers);
1148 m_tuple->addItem ("best_mc_nLayers",t_bestMcNLayers);
1149
1150 m_tuple3=ntupleSvc()->book("FILE101/raw",CLID_ColumnWiseTuple,"Raw Data");
1151 m_tuple3->addItem ("mc_t0", t3_mct0);
1152 m_tuple3->addItem ("mc_theta", t3_mctheta);
1153 m_tuple3->addItem ("mc_phi", t3_mcphi);
1154 m_tuple3->addItem ("mc_ptot", t3_mcptot);
1155 m_tuple3->addItem ("mc_pt", t3_mcpt);
1156 m_tuple3->addItem ("mc_pid", t3_mcpid);
1157 m_tuple3->addItem ("evtNo", t3_evtNo);
1158
1159 m_tuple31=ntupleSvc()->book("FILE101/rawEvt",CLID_ColumnWiseTuple,"Raw Data");
1160 m_tuple31->addItem ("nDigi", t3_nDigi);
1161 m_tuple31->addItem ("goodLength", t3_goodLength);
1162 m_tuple31->addItem ("length", t3_length);
1163 m_tuple31->addItem ("t0_rec", t3_t0Rec);
1164 m_tuple31->addItem ("t0", t3_t0);
1165 m_tuple31->addItem ("t0_sta", t3_t0Sta);
1166 m_tuple31->addItem ("finalLength", t3_finalLength);
1167
1168 m_tuple31->addItem ("mc_theta", t3_mctheta);
1169 m_tuple31->addItem ("mc_ptot", t3_mcptot);
1170 m_tuple31->addItem ("mc_pt", t3_mcpt);
1171 m_tuple31->addItem ("evtNo", t3_evtNo);
1172
1173 m_tuple2=ntupleSvc()->book("FILE101/rec2D",CLID_ColumnWiseTuple,"MdcRecEvent 2D");
1174 m_tuple2->addItem ("mc_theta", t2_mctheta);
1175 m_tuple2->addItem ("mc_pt", t2_mcpt);
1176 m_tuple2->addItem ("nDigi", t2_nDigi);
1177 m_tuple2->addItem ("nHits", t2_nHits);
1178 m_tuple2->addItem ("nSegs", t2_nSegs);
1179 m_tuple2->addItem ("chi2", t2_chi2);
1180 m_tuple2->addItem ("evtNo", t2_evtNo);
1181 m_tuple2->addItem ("ndf", t2_ndf);
1182 m_tuple2->addItem ("length", t2_length);
1183 m_tuple2->addItem ("length2", t2_length2);
1184 m_tuple2->addItem ("radius", t2_radius);
1185
1186 m_tuple4=ntupleSvc()->book("FILE101/hit",CLID_ColumnWiseTuple,"MdcRecEvent Hits");
1187 m_tuple4->addItem ("d_cal", t4_Dist);
1188 m_tuple4->addItem ("d_meas", t4_drift); //d_cal-d_meas
1189 m_tuple4->addItem ("e_meas", t4_dDrift); //error measure
1190 m_tuple4->addItem ("mc_drift", t4_mcDrift);
1191 m_tuple4->addItem ("mcLR", t4_mcLR);
1192 m_tuple4->addItem ("pull", t4_pull);
1193 m_tuple4->addItem ("lyrId", t4_lyrId);
1194 m_tuple4->addItem ("localId", t4_localId);
1195 m_tuple4->addItem ("LR", t4_LR);
1196 m_tuple4->addItem ("tdc", t4_tdc);
1197 m_tuple4->addItem ("z", t4_z);
1198 m_tuple4->addItem ("bz", t4_bz); //backward
1199 m_tuple4->addItem ("fz", t4_fz); //forward
1200 m_tuple4->addItem ("fy", t4_fy); //forward
1201 m_tuple4->addItem ("phi", t4_phi);
1202 m_tuple4->addItem ("nHits", t4_nHits);
1203
1204 m_tuple5=ntupleSvc()->book("FILE101/char",CLID_ColumnWiseTuple,"MdcRecEvent Charge");
1205 m_tuple5->addItem ("ptotPos", t5_ptotPos);
1206 m_tuple5->addItem ("ptotNeg", t5_ptotNeg);
1207 m_tuple5->addItem ("drPos", t5_drPos);
1208 m_tuple5->addItem ("drNeg", t5_drNeg);
1209 m_tuple5->addItem ("dzPos", t5_dzPos);
1210 m_tuple5->addItem ("dzNeg", t5_dzNeg);
1211
1212 m_tuple6=ntupleSvc()->book("FILE101/urec",CLID_ColumnWiseTuple,"MdcRecEvent urec");
1213 m_tuple6->addItem ("length2", u_length2);
1214 m_tuple6->addItem ("mc_ptot", u_mcptot);
1215 m_tuple6->addItem ("mc_pt", u_mcpt);
1216 m_tuple6->addItem ("mc_theta", u_mctheta);
1217 m_tuple6->addItem ("nDigi", u_nDigi);
1218 m_tuple6->addItem ("evtNo", u_evtNo);
1219 m_tuple6->addItem ("mc_t0", u_mct0);
1220 m_tuple6->addItem ("t0", ut_t0);
1221 m_tuple6->addItem ("t0_sta", ut0_sta);
1222
1223 if (b_timeTest && b_tuple) {
1224 m_tuple7=ntupleSvc()->book("FILE101/time",CLID_ColumnWiseTuple,"MdcRecEvent time");
1225 m_tuple7->addItem ("time", ti_eventTime); //total time in a event.
1226 m_tuple7->addItem ("recNum", ti_recTrkNum); //total raw-tracks, include decayed tracks!
1227 m_tuple7->addItem ("evtNo", ti_evtNo);
1228 m_tuple7->addItem ("nHits", ti_nHits); //total hits of rec-tracks
1229 m_tuple7->addItem ("nDigi", ti_nDigi); //total hits in rawdata
1230 }
1231
1232 m_tuple9=ntupleSvc()->book("FILE101/seg",CLID_ColumnWiseTuple,"MdcRecEvent segments");
1233 m_tuple9->addItem ("times", t9_times);
1234 m_tuple9->addItem ("nLinks", t9_nLinks);
1235 m_tuple9->addItem ("nUsed", t9_nUsed);
1236 m_tuple9->addItem ("nSL", t9_nSL);
1237 m_tuple9->addItem ("mctheta", t9_mctheta);
1238
1239 m_tuple10=ntupleSvc()->book("FILE101/rawHit",CLID_ColumnWiseTuple,"MdcRecEvent mchitCOL");
1240 m_tuple10->addItem ("tdc", t10_tdc);
1241 m_tuple10->addItem ("adc", t10_adc);
1242 m_tuple10->addItem ("Drift", t10_drift);
1243 m_tuple10->addItem ("dDrift", t10_dDrift);
1244 m_tuple10->addItem ("lyrId", t10_lyrId);
1245 m_tuple10->addItem ("localId", t10_localId);
1246}
1247
1248void
1249TrkReco::FillTuple(void) {
1250 MsgStream log(msgSvc(), name());
1251 log << MSG::INFO << "fill Tuple()" << endreq;
1252
1253 /// Get Tracks
1255 AList<TTrack> tracks2D;
1256 tracks = _trackManager.tracks();
1257 tracks2D = _trackManager.tracks2D();
1258 //if(t3_t0Rec!=999. && fabs(t3_t0Rec + t0_bes - MC_EVENT_TIME) > 4)
1259 //cout<<"3Dtrack in manager: "<<tracks.length()<<endl;
1260 if(tracks.length()==0) cout<<"zslength: 3D length=0, and the 2D length is"<<tracks2D.length()<<endl;
1261
1262 /// Run Time Calculation
1263 if (b_timeTest && b_tuple) {
1264 m_timer[1]->stop();
1265 ti_eventTime = m_timer[1]->elapsed();
1266 ti_nDigi = MC_DIGI_SIZE;
1267 ti_recTrkNum = tracks.length();
1268 ti_evtNo = _nEvents;
1269 for (unsigned i = 0; i < ti_recTrkNum; ++i)
1270 ti_nHits += tracks[i]->nLinks();
1271 m_tuple7->write();
1272 }
1273
1274 /// Retrieve MC
1275 CLHEP::Hep3Vector MC_TRACK_VEC;
1276 CLHEP::HepLorentzVector MC_TRACK_LRZVEC;
1277 float MC_TRACK_NUM;
1278 double MC_EVENT_TIME;
1279
1280 int digiId;
1281 int num_par = 0;
1282 MC_EVENT_TIME = -1;
1283 if (b_mcPar) {
1284 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
1285 if (mcParticleCol) {
1286 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
1287 digiId = 0;
1288 for (;iter_mc != mcParticleCol->end(); iter_mc++, digiId++) {
1289 if((*iter_mc)->statusFlags()==8320||(*iter_mc)->statusFlags()==128) {
1290 MC_EVENT_TIME = (*iter_mc)->initialFourMomentum().t();
1291 break;
1292 }
1293 }
1294 //jialk bugcheck
1295 iter_mc = mcParticleCol->begin();
1296 MC_TRACK_LRZVEC = (*iter_mc)->initialFourMomentum(); //particularly for 1 track events.
1297 MC_TRACK_VEC = (*iter_mc)->initialFourMomentum().vect();
1298 MC_TRACK_NUM = mcParticleCol->size();
1299
1300#ifdef TRKRECO_DEBUG
1301 iter_mc = mcParticleCol->begin();
1302 digiId = 0;
1303 for (;iter_mc != mcParticleCol->end(); iter_mc++, digiId++) {
1304 log << MSG::INFO << "MDC digit No: " << digiId << endreq;
1305 log << MSG::INFO
1306 << " particleId = " << (*iter_mc)->particleProperty()
1307 << " theta = " << (*iter_mc)->initialFourMomentum().theta()
1308 <<" phi= "<< (*iter_mc)->initialFourMomentum().phi()
1309 <<" px= "<< (*iter_mc)->initialFourMomentum().px()
1310 <<" py= "<< (*iter_mc)->initialFourMomentum().py()
1311 <<" pz= "<< (*iter_mc)->initialFourMomentum().pz()
1312 << endreq;
1313 }
1314#endif
1315 digiId = 0;
1316 iter_mc = mcParticleCol->begin();
1317 for (;iter_mc != mcParticleCol->end(); iter_mc++, digiId++) {
1318 CLHEP::HepLorentzVector LRZVEC = (*iter_mc)->initialFourMomentum();
1319 CLHEP::Hep3Vector VEC = (*iter_mc)->initialFourMomentum().vect();
1320 //staFlag = (*iter_mc)->statusFlags();
1321
1322 t3_mctheta = LRZVEC.theta();
1323 t3_mcphi = VEC.phi();
1324 t3_mcptot = VEC.mag()/1000.;
1325 t3_mcpt = VEC.perp()/1000.;
1326 t3_mct0 = (*iter_mc)->initialFourMomentum().t();
1327 t3_mcpid = (*iter_mc)->particleProperty();
1328 t3_evtNo = _nEvents;
1329 if((t3_mcpid==211||t3_mcpid==-211||t3_mcpid==321)&&fabs(cos(t3_mctheta))<0.93) ++num_par;
1330 m_tuple3->write();
1331 }
1332 }
1333 }
1334
1335 /// Fill Tuple
1336 if (tracks.length()==0) {
1337 u_length2 = tracks2D.length();
1338 u_mct0 = MC_EVENT_TIME;
1339 u_mcptot = MC_TRACK_VEC.mag()/1000.;
1340 u_mcpt = MC_TRACK_VEC.perp()/1000.;
1341 u_mctheta = MC_TRACK_LRZVEC.theta();
1342 u_nDigi = MC_DIGI_SIZE;
1343 u_evtNo = _nEvents;
1344 ut0_sta = -1;
1345 ut_t0 = t0_bes;
1346 ut0_sta = t0Sta;
1347 m_tuple6->write(); //unrec...tracks
1348 }
1349
1350 //---Pos and Neg
1351 float dDot = 2;
1352 int flagi = -1, flagj = -1;
1353 HepVector3D ppp1, ppp2;
1354 float pppdDot = 2;
1355 for (unsigned i = 0; i < tracks.length(); i++){
1356 if(tracks.length()<2) break;
1357 if(tracks[i]->charge()>0) {
1358 ppp1 = tracks[i]->p().unit();
1359 for (unsigned j = 0; j < tracks.length(); j++){
1360 if (tracks[j]->charge()<0) {
1361 ppp2 = tracks[j]->p().unit();
1362 pppdDot = ppp1.dot(ppp2);
1363 if (pppdDot<dDot) {
1364 flagi = i;
1365 flagj = j;
1366 dDot = pppdDot;
1367 }
1368 }
1369 }
1370 }
1371 }
1372 if (flagi != -1 && flagj != -1 && dDot < 0) {
1373 t5_ptotPos = tracks[flagi]->ptot();
1374 t5_ptotNeg = tracks[flagj]->ptot();
1375 t5_drPos = tracks[flagi]->helix().dr();
1376 t5_drNeg = tracks[flagj]->helix().dr();
1377 t5_dzPos = tracks[flagi]->helix().dz();
1378 t5_dzNeg = tracks[flagj]->helix().dz();
1379 m_tuple5->write();
1380 } //Pos and Neg...back on back
1381
1382 unsigned nGood = 0;
1383 for (unsigned i = 0; i < tracks.length(); i++){
1384 for(unsigned k = 0; k < tracks[i]->links().length(); k++){
1385 t4_Dist = tracks[i]->links()[k]->distance(); //_onTrack - _onWire
1386 t4_drift = tracks[i]->links()[k]->drift(); //drift updated in THelixFitter.
1387 t4_dDrift= tracks[i]->links()[k]->dDrift(); //dDrift updated in THelixFitter.
1388 t4_pull = tracks[i]->links()[k]->pull();
1389 t4_LR = 2; //initial
1390 t4_LR = tracks[i]->links()[k]->leftRight();
1391 if (t4_LR == 0) t4_LR = -1;
1392 t4_lyrId = tracks[i]->links()[k]->wire()->layerId();
1393 t4_localId = tracks[i]->links()[k]->wire()->localId();
1394 t4_tdc = tracks[i]->links()[k]->hit()->reccdc()->tdc;
1395 t4_z = tracks[i]->links()[k]->positionOnTrack().z();
1396 t4_bz = tracks[i]->links()[k]->wire()->backwardPosition().z();
1397 t4_fz = tracks[i]->links()[k]->wire()->forwardPosition().z();
1398 t4_fy = tracks[i]->links()[k]->wire()->forwardPosition().y();
1399 t4_nHits = tracks[i]->links().length();
1400 unsigned lyrID = tracks[i]->links()[k]->wire()->layerId();
1401 float phi0 = _cdc->layer(lyrID)->offset();
1402 int nWir = (int) _cdc->layer(lyrID)->nWires();
1403 t4_phi = phi0 + t4_localId*2*pi/nWir;
1404 if(t4_phi<0) t4_phi+=2*pi;
1405
1406 if (b_mcHit) {
1407 SmartDataPtr<Event::MdcMcHitCol> mcMdcMcHitCol(eventSvc(),"/Event/MC/MdcMcHitCol");
1408 if (mcMdcMcHitCol) {
1409 Event::MdcMcHitCol::iterator iter_mchit1 = mcMdcMcHitCol->begin();
1410 digiId=0;
1411 for (;iter_mchit1 != mcMdcMcHitCol->end(); iter_mchit1++, digiId++) {
1412 const Identifier ident = (*iter_mchit1)->identify();
1413 if(MdcID::layer(ident) != t4_lyrId) continue;
1414 if(MdcID::wire(ident)==t4_localId) {
1415 t4_mcDrift = (*iter_mchit1)->getDriftDistance(); //drift in MC.
1416 t4_mcLR = (*iter_mchit1)->getPositionFlag();
1417 if (t4_mcLR == 0) t4_mcLR = -1;
1418 break;
1419 }
1420 }
1421 }
1422 }
1423 //cout<<" lyrId, localId: "<<t4_lyrId<<" "<<t4_localId<<endl;
1424 //cout<<" tdc: "<<t4_tdc<<" mcDrift: " << t4_mcDrift<<" Drift: "<<t4_drift<<" t4_Dist: "<<t4_Dist<<endl;
1425 m_tuple4->write(); //rec Hits
1426 }
1427
1428 unsigned segSize = tracks[i]->segments().length();
1429 for(unsigned kk = 0; kk < segSize; ++kk) {
1430 unsigned segLength = tracks[i]->segments()[kk]->links().length();
1431 AList<TMLink> ll = tracks[i]->segments()[kk]->links();
1432 int nSmall = 0;
1433 for(unsigned nn = 0; nn < segLength; ++nn) {
1434 double tmpX = ll[nn]->positionD().x();
1435 double tmpY = ll[nn]->positionD().y();
1436 double tmpA = tracks[i]->segments()[kk]->lineTsf().x();
1437 double tmpB = tracks[i]->segments()[kk]->lineTsf().y();
1438 double tmpC = tracks[i]->segments()[kk]->lineTsf().z();
1439 double dis = fabs(tmpA * tmpX + tmpB * tmpY + tmpC) / sqrt(tmpA * tmpA + tmpB * tmpB);
1440 double idealDis = maxdDistance(ll[nn]);
1441 if(fabs(dis-ll[nn]->cDrift())/idealDis<0.001 && nSmall<2) {
1442 ++nSmall;
1443 continue;
1444 }
1445 t9_times += fabs(dis-ll[nn]->cDrift())/idealDis;
1446 }
1447 t9_nSL = ll[0]->wire()->superLayerId();
1448 t9_nLinks = segLength;
1449 t9_mctheta = MC_TRACK_LRZVEC.theta();
1450 t9_times = t9_times / (t9_nLinks - nSmall);
1451 m_tuple9->write(); //seg info
1452 }
1453
1454 t_mcphi = MC_TRACK_VEC.phi();
1455 t_mctheta = MC_TRACK_LRZVEC.theta();
1456 t_mcptot = MC_TRACK_VEC.mag()/1000.;
1457 t_mcpt = MC_TRACK_VEC.perp()/1000.;
1458 t_mcpz = MC_TRACK_LRZVEC.pz()/1000.;
1459 t_mct0 = MC_EVENT_TIME;
1460 t_nDigi = MC_DIGI_SIZE;
1461
1462 t_dr = tracks[i]->helix().dr();
1463 t_dz = tracks[i]->helix().dz();
1464 t_pt = tracks[i]->pt();
1465 t_ptot = tracks[i]->ptot();
1466 t_tanlmd = tracks[i]->helix().tanl();
1467 t_phi = tracks[i]->helix().phi0();
1468 t_chi2 = tracks[i]->chi2();
1469 t_nHits = tracks[i]->nLinks();
1470 t_nCores = tracks[i]->nCores();
1471 t_nSegs = tracks[i]->segments().length();
1472 t_ndf = tracks[i]->ndf();
1473 t_radius = tracks[i]->radius();
1474 t_evtNo = _nEvents;
1475 t_length = tracks.length();
1476 t_length2 = tracks2D.length();
1477
1478 t_dpt = tracks[i]->pt() - t_mcpt;
1479 t_dptot = tracks[i]->ptot() - t_mcptot;
1480 t_dlmd = atan(tracks[i]->helix().tanl()) - (pi/2 - t_mctheta);
1481 t_dphi = tracks[i]->helix().phi0() - t_mcphi;
1482
1483 t_t0 = t0_bes;
1484 t0_sta = t0Sta;
1485
1486 if (b_mcPar) {
1487 if (b_goodTrk && b_tuple) {
1488 unsigned mcTrackSize = MC_TRACK_NUM;
1489 unsigned recTrackSize = tracks.length();
1490 const unsigned matchSize = 20;
1491 // if(recTrackSize>40 || mcTrackSize>40) matchSize = 50;
1492
1493 int mLayers[matchSize];
1494 for (int ii=0; ii<matchSize; ii++)
1495 mLayers[ii] = 0;
1496 for(int jj = 0; jj < 43; ++jj) {
1497 int tmp[matchSize];
1498 for(unsigned kk = 0; kk < matchSize; ++kk)
1499 tmp[kk] = 0;
1500 for(int kk = 0; kk < 288; ++kk) {
1501 if (havedigi[jj][kk]<0) continue;
1502 tmp[havedigi[jj][kk]] = 1;
1503 }
1504 for(int kk = 0; kk < matchSize; ++kk)
1505 if(tmp[kk] == 1) ++mLayers[kk];
1506 }
1507
1508 unsigned trackSize = tracks[i]->nLinks();
1509 int trkIndex[43];
1510 int nLayers[matchSize];
1511 for (int j = 0; j < 43; ++j)
1512 trkIndex[j] = -99;
1513 for (int j = 0; j < matchSize; ++j)
1514 nLayers[j] = 0;
1515
1516 for (int j = 0; j < trackSize; ++j) {
1517 unsigned lId = tracks[i]->links()[j]->wire()->layerId();
1518 unsigned loId = tracks[i]->links()[j]->wire()->localId();
1519 if (havedigi[lId][loId] >= 0) trkIndex[lId] = havedigi[lId][loId];
1520 }
1521 for (int j = 0; j < 43; ++j)
1522 if (trkIndex[j] >= 0) ++nLayers[trkIndex[j]];
1523
1524 for (int j = 0; j < matchSize; ++j) {
1525 //cout<<"nLayers: "<<nLayers[j]<<" mLayers:"<<mLayers[j]<<endl;
1526 if (nLayers[j]==0) continue;
1527 if ((float)nLayers[j]/(float)mLayers[j] > 0.51) {
1528 t_gdNLayers = nLayers[j];
1529 t_mcNLayers = mLayers[j];
1530 t_good_theta = MC_TRACK_LRZVEC.theta();
1531 ++nGood;
1532 break;
1533 }
1534 }
1535 if (t_good_theta == 0.) {
1536 int tmpLayers = 0;
1537 int tmpi = -1;
1538 for (int j = 0; j < matchSize; ++j) {
1539 if (nLayers[j]==0) continue;
1540 if (nLayers[j] > tmpLayers) {
1541 tmpLayers = nLayers[j];
1542 tmpi = j;
1543 }
1544 }
1545 if (tmpi != -1) {
1546 t_bestNLayers = nLayers[tmpi];
1547 t_bestMcNLayers = mLayers[tmpi];
1548 }
1549 else {
1550 t_bestNLayers = -1;
1551 t_bestMcNLayers = -1;
1552 }
1553 }
1554 else {
1555 t_bestNLayers = -2;
1556 t_bestMcNLayers = -2;
1557 }
1558 } //if b_goodTrk
1559 }
1560 m_tuple->write(); //rec track
1561 }
1562
1563 t3_mctheta = MC_TRACK_LRZVEC.theta();
1564 t3_mcptot = MC_TRACK_VEC.mag()/1000.;
1565 t3_mcpt = MC_TRACK_VEC.perp()/1000.;
1566
1567 t3_nDigi = MC_DIGI_SIZE;
1568 t3_t0 = t0_bes;
1569 t3_t0Sta = t0Sta;
1570 t3_goodLength = nGood;
1571 t3_length = tracks.length();
1572 t3_finalLength = num_par;
1573 m_tuple31->write(); //raw...
1574
1575 for (unsigned i = 0; i < tracks2D.length(); i++) {
1576 t2_mctheta = MC_TRACK_LRZVEC.theta();
1577 t2_mcpt = MC_TRACK_VEC.perp()/1000.;
1578
1579 t2_nDigi = MC_DIGI_SIZE;
1580 t2_nHits = tracks2D[i]->nLinks();
1581 t2_nSegs = tracks2D[i]->segments().length();
1582 t2_chi2 = tracks2D[i]->chi2();
1583 t2_ndf = tracks2D[i]->ndf();
1584 t2_radius = tracks2D[i]->radius();
1585 t2_evtNo = _nEvents;
1586 t2_length = tracks.length();
1587 t2_length2 = tracks2D.length();
1588 m_tuple2->write(); //unused 2D tracks
1589 }
1590}
1591
1592double
1593TrkReco::maxdDistance(TMLink *l) const{
1594 unsigned sl = l->wire()->superLayerId();
1595 unsigned lId = l->wire()->layerId();
1596 double _averR[11] = {9.7, 14.5, 22.14, 28.62, 35.1, 42.39, 48.87, 55.35, 61.83, 69.12, 74.79};
1597 double _averR2[43] = { 7.885, 9.07, 10.29, 11.525,
1598 12.72, 13.875, 15.01, 16.16,
1599 19.7, 21.3, 22.955, 24.555,
1600 26.215, 27.82, 29.465, 31.06,
1601 32.69, 34.265, 35.875, 37.455,
1602 39.975, 41.52, 43.12, 44.76,
1603 46.415, 48.02, 49.685, 51.37,
1604 53.035, 54.595, 56.215, 57.855,
1605 59.475, 60.995, 62.565, 64.165,
1606 66.68, 68.285, 69.915, 71.57,
1607 73.21, 74.76, 76.345};
1608 double radius = _averR2[lId];
1609 const double singleSigma = l->dDrift();
1610 return 2 * singleSigma / (radius * radius);
1611}
1612
1613/*void
1614 TrkReco::dump(const std::string & msg, const std::string & pre) const {
1615 bool def = (msg == "") ? true : false;
1616
1617 if (msg.find("summary") != -1 || msg.find("detail") != -1) {
1618 std::cout << "TrkReco Summary (" << version() << ")" << std::endl;
1619 std::cout << " Track Manager Summary" << std::endl;
1620 _trackManager.dump("summary", " ");
1621 if (_confFinder) {
1622 std::cout << " Conformal Finder Summary" << std::endl;
1623 _confFinder->dump("summary", " ");
1624 }
1625 }
1626 if (def || msg.find("parameter") != std::string::npos || msg.find("detail") != std::string::npos) {
1627 std::string t0 = pre;
1628 std::string t1 = pre + " ";
1629 std::string t2 = pre + " ";
1630
1631 std::cout << t0 << name() << "(" << version() << ")";
1632 std::cout << " : debug level = " << b_debugLevel << std::endl;
1633 if (b_doPerfectFinder != 0) {
1634 std::cout << t1 << "Perfect finder is active. ";
1635 std::cout << "Other finders will not called." << std::endl;
1636 }
1637 if (b_conformalFinder == 1) {
1638 std::cout << t1 << "New TrkReco(new conf. finder) is active.";
1639 std::cout << std::endl;
1640 }
1641
1642 std::cout << t1 << _cdc->name() << "(" << _cdc->version() << ")"
1643 << std::endl;
1644 std::cout << t2 << "cdc version : " << _cdc->cdcVersion()
1645 << std::endl;
1646 std::cout << t2 << "fudge factor : " << _cdc->fudgeFactor()
1647 << std::endl;
1648
1649// if (_cdccat)
1650// std::cout << t1 << _cdccat->name() << "("
1651// << _cdccat->version() << ")" << std::endl;
1652
1653std::cout << t1 << "ignore hit quality : " << b_useAllHits
1654<< std::endl;
1655std::cout << t1 << "do T0 reset : " << b_doT0Reset
1656<< std::endl;
1657std::cout << t1 << " max number of reset : " << b_nT0ResetMax
1658<< std::endl;
1659std::cout << t1 << "MC analysis : " << b_doMCAnalysis
1660<< std::endl;
1661std::cout << t1 << "helix fitter chisq max : "
1662<< b_helixFitterChisqMax << std::endl;
1663std::cout << t1 << "test flag : " << b_test << std::endl;
1664
1665
1666std::cout << t1 << _trackManager.name();
1667std::cout << "(" << _trackManager.version() << ") options"
1668<< std::endl;
1669std::cout << t2 << "T0 determination : " << b_doT0Determination
1670<<std::endl;
1671std::cout << t2 << " # of tracks : " << b_nTracksForT0
1672<< std::endl;
1673std::cout << t2 << "bank sort : " << b_sortMode
1674<< std::endl;
1675std::cout << t2 << "max. momentum allowed : " << b_momentumCut
1676<< " GeV/c";
1677std::cout << std::endl;
1678std::cout << t2 << "salvage : " << b_doSalvage
1679<< std::endl;
1680std::cout << t2 << "salvage level : " << b_salvageLevel
1681<< std::endl;
1682
1683std::cout << t1 << _perfectFinder->name();
1684std::cout << "(" << _perfectFinder->version() << ") options";
1685std::cout << std::endl;
1686std::cout << t2 << "do finding : " << b_doPerfectFinder;
1687std::cout << std::endl;
1688std::cout << t2 << "perfect fitting : " << b_perfectFitting;
1689std::cout << std::endl;
1690
1691std::cout << t1 << _confFinder->name();
1692std::cout << "(" << _confFinder->version() << ") options" << std::endl;
1693std::cout << t2 << "do finding : " << b_doConformalFinder;
1694std::cout << std::endl;
1695if (b_conformalFinder == 1) {
1696 std::cout << t2 << "fast finder : ";
1697 std::cout << b_doConformalFastFinder << std::endl;
1698 std::cout << t2 << "slow finder : ";
1699 std::cout << b_doConformalSlowFinder << std::endl;
1700 std::cout << t2 << "perfect segment find : ";
1701 std::cout << b_conformalPerfectSegmentFinding << std::endl;
1702 std::cout << t2 << "max sigma : ";
1703 std::cout << b_conformalMaxSigma << std::endl;
1704 std::cout << t2 << "min # hits for segment: ";
1705 std::cout << b_conformalMinNLinksForSegment << std::endl;
1706 std::cout << t2 << "min # cores in segment: ";
1707 std::cout << b_conformalMinNCores << std::endl;
1708 std::cout << t2 << "min # segments : ";
1709 std::cout << b_conformalMinNSegments << std::endl;
1710 std::cout << t2 << "salvage level : " << b_salvageLevel
1711 << std::endl;
1712 std::cout << t2 << "salvage load width : ";
1713 std::cout << b_conformalSalvageLoadWidth << std::endl;
1714 std::cout << t2 << "stereo mode : "
1715 << b_conformalStereoMode << std::endl;
1716 std::cout << t2 << "stereo load width : ";
1717 std::cout << b_conformalStereoLoadWidth << std::endl;
1718 std::cout << t2 << "stereo max sigma : ";
1719 std::cout << b_conformalStereoMaxSigma << std::endl;
1720 std::cout << t2 << "stereo segment dist. : ";
1721 std::cout << b_conformalStereoSzSegmentDistance << std::endl;
1722 std::cout << t2 << "stereo link distance : ";
1723 std::cout << b_conformalStereoSzLinkDistance << std::endl;
1724}
1725else {
1726 std::cout << t2 << "Old TrkReco(old conf. finder) is active."
1727 << std::endl;
1728 std::cout << t2 << "do stereo finding : ";
1729 std::cout << b_doConformalFinderStereo;
1730 std::cout << std::endl;
1731 std::cout << t2 << "use cosmic builder : ";
1732 std::cout << b_doConformalFinderCosmic;
1733 std::cout << std::endl;
1734 std::cout << t2 << "max sigma : ";
1735 std::cout << b_conformalMaxSigma <<std::endl;
1736 std::cout << t2 << "fraction : ";
1737 std::cout << b_conformalFraction <<std::endl;
1738 std::cout << t2 << "fitting corrections : ";
1739 std::cout << b_conformalFittingCorrections << std::endl;
1740 std::cout << t2 << "stereo max sigma : ";
1741 std::cout << b_conformalStereoMaxSigma;
1742 std::cout << std::endl;
1743 std::cout << t2 << "stereo z3 : ";
1744 std::cout << b_conformalStereoZ3 <<std::endl;
1745 std::cout << t2 << "stereo z4 : ";
1746 std::cout << b_conformalStereoZ4 <<std::endl;
1747 std::cout << t2 << "stereo chisq 3 : ";
1748 std::cout << b_conformalStereoChisq3;
1749 std::cout << std::endl;
1750 std::cout << t2 << "stereo chisq 4 : ";
1751 std::cout << b_conformalStereoChisq4;
1752 std::cout << std::endl;
1753}
1754std::cout << t1 << _curlFinder->name();
1755std::cout << "(" << _curlFinder->version() << ") options" << std::endl;
1756std::cout << t2 << "do finding : " << b_doCurlFinder
1757<< std::endl;
1758
1759if (_clustFinder) {
1760 std::cout << t1 << _clustFinder->name();
1761 std::cout << "(" << _clustFinder->version() << ") options"
1762 << std::endl;
1763 std::cout << t2 << "do finding : " << b_doClustFinder
1764 << std::endl;
1765 std::cout << t2 << "cathode window : " << b_cathodeWindow
1766 << std::endl;
1767 std::cout << t2 << "systematic correction : "
1768 << b_cathodeSystematics<<std::endl;
1769 std::cout << t2 << "cathode cosmic switch : " << b_cathodeCosmic
1770 << std::endl;
1771}
1772
1773std::cout << t1 << "Patten Matching CurlFinder"
1774<< "(0.2beta) options" << std::endl;
1775std::cout << t2 << "do finding : "
1776<< b_doPMCurlFinder << std::endl;
1777std::cout << t2 << "mode(1=rec, 2=map, 3=plot) : "
1778 << b_pmCurlFinder << std::endl;
1779 std::cout << t2 << "min electrons of svd clusters : "
1780 << min_svd_electrons_in_pmc << std::endl;
1781 std::cout << t1 << "SVD Associator" << "(0.2beta) options"
1782 << std::endl;
1783 std::cout << t2 << "doing : " << b_doSvdAssociator << std::endl;
1784
1785 }
1786if (def || msg.find("tracks") != std::string::npos || msg.find("detail") != std::string::npos) {
1787 _trackManager.dump("eventSummary");
1788}
1789
1790if (msg.find("cathode") != std::string::npos || msg.find("detail") != std::string::npos) {
1791 if (b_doClustFinder && _cdccat) {
1792 _cdccat->dump("hit");
1793 _clustFinder->dump("");
1794 }
1795}
1796}*/
double cos(const BesAngle a)
Definition: BesAngle.h:213
std::vector< double > VEC
std::vector< MdcDigi * > MdcDigiVec
ObjectVector< RecMdcHit > RecMdcHitCol
Definition: RecMdcHit.h:99
ObjectVector< RecMdcTrack > RecMdcTrackCol
Definition: RecMdcTrack.h:79
SmartRefVector< RecMdcHit > HitRefVec
Definition: RecMdcTrack.h:22
INTupleSvc * ntupleSvc()
IMessageSvc * msgSvc()
const HepPoint3D ORIGIN
Constants.
Definition: TMDCUtil.cxx:47
#define WireHitFindingValid
Definition: TMDCWireHit.h:28
#define TTrackGhost
Definition: TTrackMC.h:21
#define TTrackUnique
Definition: TTrackMC.h:28
#define TTrackGood
Definition: TTrackMC.h:22
int TrkRecoTest
Definition: TrkReco.cxx:77
float TrkRecoHelixFitterChisqMax
Definition: TrkReco.cxx:78
float TrkRecoHelixFitterChisqMax
Definition: TrkReco.cxx:78
TTree * t
Definition: binning.cxx:23
void propName(std::string name)
Definition: BesTimer.h:34
void start(void)
Definition: BesTimer.cxx:27
float elapsed(void) const
Definition: BesTimer.h:23
void stop(void)
Definition: BesTimer.cxx:39
virtual void print(void)=0
virtual BesTimer * addItem(const std::string &name)=0
double getSigma(int layid, int lr, double dist, double entrance=0.0, double tanlam=0.0, double z=0.0, double Q=1000.0) const
double getT0(int layid, int cellid) const
double driftTimeToDist(double drifttime, int layid, int cellid, int lr, double entrance=0.0) const
double getTimeWalk(int layid, double Q) const
double Radius(void) const
Definition: MdcGeoLayer.h:160
MdcGeoLayer * Lyr(void) const
Definition: MdcGeoWire.h:140
const MdcGeoWire *const Wire(unsigned id)
Definition: MdcGeomSvc.cxx:768
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
Definition: MdcID.cxx:49
static int wire(const Identifier &id)
Definition: MdcID.cxx:54
static vector< MdcRec_wirhit > * getMdcRecWirhitCol(void)
Definition: MdcTables.cxx:169
unsigned timechannel
Definition: MdcTables.h:341
const MdcGeoWire * geo
Definition: MdcTables.h:335
MdcDigiVec & getMdcDigiVec(uint32_t control=0)
static double MdcTime(int timeChannel)
Definition: RawDataUtil.h:8
A class to find tracks with the conformal method.
static void conformalTransformationDriftCircle(const HepPoint3D &center, const AList< TMDCWireHit > &hits, AList< TMLink > &links)
transforms drift circle of hits into a conformal plane. transformed positions( x0,...
A class to find tracks with the conformal method.
int doit(const AList< TMDCWireHit > &axialHits, const AList< TMDCWireHit > &stereoHits, AList< TTrack > &tracks, AList< TTrack > &tracks2D)
main function
void clear(void)
cleans all members of this class
virtual int debugLevel(void) const
returns debug level.
Definition: TFinderBase.h:90
virtual bool doStereo(bool)
sets flag to reconstruct 3D.
Definition: TFinderBase.h:102
virtual bool doSalvage(bool)
sets flag to salvage hits.
Definition: TFinderBase.h:108
virtual void clear(void)=0
clear internal information.
virtual int doit(const AList< TMDCWireHit > &axialHits, const AList< TMDCWireHit > &stereoHits, AList< TTrack > &tracks3D, AList< TTrack > &tracks2D)=0
finds tracks. 'hits' are used to reconstruct. 'tracks' can be used for both inputs and outputs....
float offset(void) const
returns offset.
Definition: TMDCLayer.h:133
unsigned nWires(void) const
returns # of wires.
Definition: TMDCLayer.h:139
unsigned layerId(void) const
returns layer id.
Definition: TMDCWire.h:219
unsigned superLayerId(void) const
returns super layer id.
Definition: TMDCWire.h:225
Definition: TMDC.h:61
void fastClear(void)
clears TMDC information.
Definition: TMDC.cxx:298
void update(bool mcAnalysis=true)
updates TMDC information. clear() is called in this function.
Definition: TMDC.cxx:317
float fudgeFactor(void) const
returns fudge factor for drift time error.
Definition: TMDC.h:292
const AList< TMDCWireHit > & hits(unsigned mask=0) const
returns a list of TMDCWireHit. 'update()' must be called before calling this function.
Definition: TMDC.cxx:534
static TMDC * getTMDC(void)
Definition: TMDC.cxx:95
const AList< TMDCWireHit > & axialHits(unsigned mask=0) const
returns a list of axial hits. 'update()' must be called before calling this function.
Definition: TMDC.cxx:518
const TMDCLayer *const layer(unsigned id) const
returns a pointer to a layer. 0 will be returned if 'id' is invalid.
Definition: TMDC.h:259
const AList< TMDCWireHit > & stereoHits(unsigned mask=0) const
returns a list of stereo hits. 'update()' must be called before calling this function.
Definition: TMDC.cxx:526
int debugLevel(void) const
returns debug level.
Definition: TMDC.h:239
void setBesFromGdml(void)
virtual int fit(TTrackBase &) const
A class to represent a track in tracking.
Definition: TRunge.h:65
virtual void removeLinks(void)
Definition: TTrackBase.cxx:189
virtual int DropWorst()
Definition: TTrackBase.cxx:212
void append(TMLink &)
appends a TMLink.
Definition: TTrackBase.cxx:362
const AList< TMLink > & links(unsigned mask=0) const
returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.
Definition: TTrackBase.cxx:297
static const AList< TTrackHEP > & list(void)
returns a list of TTrackHEP's.
Definition: TTrackHEP.cxx:72
A class to have MC information of TTrack.
Definition: TTrackMC.h:54
int hepId(void) const
returns HEP ID.
Definition: TTrackMC.h:169
void update(void)
updates information.
Definition: TTrackMC.cxx:67
bool charge(void) const
returns charge matching.
Definition: TTrackMC.h:181
void append2D(AList< TTrack > &list)
void clearTables(void) const
clears tables.
void merge(void)
void append(AList< TTrack > &list)
appends (2D) tracks. 'list' will be cleaned up.
float paraT0(void) const
const AList< TTrack > & tracksFinal(void) const
returns a list of tracks writen to MdcRec_trk.
StatusCode makeTds(RecMdcTrackCol *trackList, RecMdcHitCol *hitList, int tkStat=1, int runge=0, int cal=0)
stores track info. into TDS. by Zang Shilei
const AList< TTrack > & tracks2D(void) const
returns a list of 2D tracks.
const AList< TTrack > & tracks(void) const
returns a list of reconstructed tracks.
int debugLevel(void) const
returns/sets debug level.
void mask(void) const
masks hits out which are in tail of curly tracks.
void sett0bes(double t0)
double maxMomentum(double)
sets the max. momentum.
void maskCurlHits(const AList< TMDCWireHit > &axial, const AList< TMDCWireHit > &stereo, const AList< TTrack > &tracks) const
masks hits on found curl tracks.
void fittingFlag(unsigned)
sets fitting flag.
StatusCode determineT0(unsigned level, unsigned nMaxTracks)
determines T0 and refit all tracks.
void salvage(const AList< TMDCWireHit > &) const
salvages remaining hits.
void clear(void)
clears all internal information.
A class to represent a track in tracking.
Definition: TTrack.h:129
int b_conformalSalvageLoadWidth
Definition: TrkReco.h:168
int b_doSalvage
Definition: TrkReco.h:189
float b_conformalStereoZ3
Definition: TrkReco.h:179
double selector_replace_dz
Definition: TrkReco.h:218
int b_doAssociation
Definition: TrkReco.h:194
double range_for_stereo3
Definition: TrkReco.h:227
double good_distance_for_salvage
Definition: TrkReco.h:203
int b_doConformalFastFinder
Definition: TrkReco.h:159
double range_for_stereo_last2d_search
Definition: TrkReco.h:210
int on_correction
Definition: TrkReco.h:235
int b_conformalMinNCores
Definition: TrkReco.h:165
int b_conformalFittingFlag
Definition: TrkReco.h:162
double range_for_stereo4
Definition: TrkReco.h:228
int b_doConformalFinderStereo
Definition: TrkReco.h:176
double MIN_RADIUS_OF_STRANGE_TRACK
Definition: TrkReco.h:244
int b_sortMode
Definition: TrkReco.h:193
int superlayer_for_stereo_search
Definition: TrkReco.h:208
int output_2dtracks
Definition: TrkReco.h:236
int b_perfectFitting
Definition: TrkReco.h:154
double z_diff_for_last_attend
Definition: TrkReco.h:232
int min_salvage
Definition: TrkReco.h:201
double range_for_stereo1
Definition: TrkReco.h:225
int b_useAllHits
Definition: TrkReco.h:146
int stereo_2dfind
Definition: TrkReco.h:219
float b_conformalStereoSzLinkDistance
Definition: TrkReco.h:173
int b_conformalFittingCorrections
Definition: TrkReco.h:183
int b_doT0Reset
Definition: TrkReco.h:147
float b_helixFitterChisqMax
Definition: TrkReco.h:150
double range_for_stereo6
Definition: TrkReco.h:230
int b_doT0Determination
Definition: TrkReco.h:191
bool m_keepUnmatch
Definition: TrkReco.h:134
StatusCode execute()
Definition: TrkReco.cxx:321
bool m_combineTracking
Definition: TrkReco.h:132
int curl_version
Definition: TrkReco.h:237
double bad_distance_for_salvage
Definition: TrkReco.h:202
int b_conformalMinNLinksForSegment
Definition: TrkReco.h:164
std::string _cdcVersion
Definition: TrkReco.h:138
double range_for_stereo_search
Definition: TrkReco.h:207
float b_conformalStereoZ4
Definition: TrkReco.h:180
double trace3d_distance
Definition: TrkReco.h:213
double merge_ratio
Definition: TrkReco.h:221
float b_salvageLevel
Definition: TrkReco.h:167
double range_for_stereo2
Definition: TrkReco.h:226
double selector_max_sigma
Definition: TrkReco.h:216
double minimum_2DTrackLength
Definition: TrkReco.h:241
int useESTime
Definition: TrkReco.h:142
double merge_z_diff
Definition: TrkReco.h:222
float b_conformalMaxSigma
Definition: TrkReco.h:163
StatusCode beginRun()
Definition: TrkReco.cxx:302
int m_CalibFlag
Definition: TrkReco.h:184
double minimum_closeHitsLength
Definition: TrkReco.h:243
float b_conformalStereoChisq3
Definition: TrkReco.h:181
double ULTIMATE_MIN_RADIUS_OF_STRANGE_TRACK
Definition: TrkReco.h:245
double minimum_seedLength
Definition: TrkReco.h:240
int b_doCurlFinder
Definition: TrkReco.h:199
double ratio_used_wire
Definition: TrkReco.h:224
int min_sequence
Definition: TrkReco.h:204
void fastClear(void)
clears TMDC information.
Definition: TrkReco.cxx:970
float b_fudgeFactor
Definition: TrkReco.h:139
int b_conformalFinder
Definition: TrkReco.h:157
int b_conformalStereoMode
Definition: TrkReco.h:169
double selector_strange_pz
Definition: TrkReco.h:217
TrkReco(const std::string &name, ISvcLocator *pSvcLocator)
returns TrkReco.
Definition: TrkReco.cxx:80
int b_tuple
Definition: TrkReco.h:128
bool m_dropHot
Definition: TrkReco.h:131
int b_conformalMinNSegments
Definition: TrkReco.h:166
int min_fullwire
Definition: TrkReco.h:205
const AList< TTrack > & tracks(void) const
returns a list of reconstructed tracks.
Definition: TrkReco.h:332
void clear(void)
clears all TMDC information.
Definition: TrkReco.cxx:956
int b_doMCAnalysis
Definition: TrkReco.h:149
int b_goodTrk
Definition: TrkReco.h:129
double trace2d_first_distance
Definition: TrkReco.h:212
double range_for_stereo5
Definition: TrkReco.h:229
int b_mcHit
Definition: TrkReco.h:127
int b_doConformalFinder
Definition: TrkReco.h:158
float b_cdcVersion
Definition: TrkReco.h:137
int b_test
Definition: TrkReco.h:196
double mask_distance
Definition: TrkReco.h:223
int b_debugLevel
Definition: TrkReco.h:145
int b_doPerfectFinder
Definition: TrkReco.h:153
double min_svd_electrons
Definition: TrkReco.h:234
float b_associateSigma
Definition: TrkReco.h:195
int b_mcPar
Definition: TrkReco.h:126
int b_nTracksForT0
Definition: TrkReco.h:192
int b_conformalStereoLoadWidth
Definition: TrkReco.h:170
float b_conformalStereoSzSegmentDistance
Definition: TrkReco.h:172
int min_segment
Definition: TrkReco.h:200
double minimum_3DTrackLength
Definition: TrkReco.h:242
int b_doConformalSlowFinder
Definition: TrkReco.h:160
bool m_keepBadTdc
Definition: TrkReco.h:133
double trace2d_distance
Definition: TrkReco.h:211
float b_conformalFraction
Definition: TrkReco.h:178
double b_momentumCut
Definition: TrkReco.h:187
int b_nT0ResetMax
Definition: TrkReco.h:148
StatusCode initialize()
Definition: TrkReco.cxx:99
int b_doMerge
Definition: TrkReco.h:190
int b_RungeKuttaCorrection
Definition: TrkReco.h:135
int svd_reconstruction
Definition: TrkReco.h:233
double range_for_axial_last2d_search
Definition: TrkReco.h:209
int b_timeTest
Definition: TrkReco.h:130
float b_conformalStereoMaxSigma
Definition: TrkReco.h:171
int b_conformalPerfectSegmentFinding
Definition: TrkReco.h:161
double range_for_axial_search
Definition: TrkReco.h:206
float b_conformalStereoChisq4
Definition: TrkReco.h:182
int b_fittingFlag
Definition: TrkReco.h:188
StatusCode finalize()
Definition: TrkReco.cxx:284
void disp_stat(const char *)
initializes TrkReco.
Definition: TrkReco.cxx:315
double selector_max_impact
Definition: TrkReco.h:215
int determine_one_track
Definition: TrkReco.h:214
double z_cut
Definition: TrkReco.h:231
int merge_exe
Definition: TrkReco.h:220
int b_doConformalFinderCosmic
Definition: TrkReco.h:177
_EXTERN_ std::string RecMdcTrackCol
Definition: EventModel.h:86
_EXTERN_ std::string RecMdcHitCol
Definition: EventModel.h:85
Definition: Event.h:21
int nhits
float charge
const float pi
Definition: vector3.h:133