BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
HoughValidUpdate Class Reference

#include <HoughValidUpdate.h>

+ Inheritance diagram for HoughValidUpdate:

Classes

struct  Mytrack
 

Public Types

typedef std::map< int, int > M2
 
typedef std::map< int, M2M1
 
typedef std::map< int, int > M2
 
typedef std::map< int, M2M1
 

Public Member Functions

 HoughValidUpdate (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
StatusCode beginRun ()
 
 HoughValidUpdate (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
StatusCode beginRun ()
 

Detailed Description

Member Typedef Documentation

◆ M1 [1/2]

◆ M1 [2/2]

◆ M2 [1/2]

◆ M2 [2/2]

Constructor & Destructor Documentation

◆ HoughValidUpdate() [1/2]

HoughValidUpdate::HoughValidUpdate ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 51 of file HoughValidUpdate.cxx.

51 :
52 Algorithm(name, pSvcLocator)
53{
54 // Declare the properties
55 declareProperty("drawTuple", m_drawTuple=0);
56 declareProperty("useMcInfo", m_useMcInfo=0);
57 declareProperty("method", m_method=0);
58 declareProperty("debug", m_debug = 0);
59 declareProperty("data", m_data= 0);
60 declareProperty("binx", m_binx= 100);
61 declareProperty("biny", m_biny= 200);
62 declareProperty("maxrho", m_maxrho= 0.3);
63 declareProperty("peakCellNumX", m_peakCellNumX);
64 declareProperty("peakCellNumY", m_peakCellNumY);
65 declareProperty("ndev1", m_ndev1= 1);
66 declareProperty("ndev2", m_ndev2= 5);
67 declareProperty("f_hit_pro", m_hit_pro= 0.4);
68 declareProperty("pdtFile", m_pdtFile = "pdt.table");
69 declareProperty("pickHits", m_pickHits = true); // ??
70 declareProperty("pid", m_pid = 0);
71 declareProperty("combineTracking",m_combineTracking = false);
72 declareProperty("getDigiFlag", m_getDigiFlag = 0);
73 declareProperty("maxMdcDigi", m_maxMdcDigi = 0);
74 declareProperty("keepBadTdc", m_keepBadTdc = 0);
75 declareProperty("dropHot", m_dropHot= 0);
76 declareProperty("keepUnmatch", m_keepUnmatch = 0);
77 declareProperty("minMdcDigi", m_minMdcDigi = 0);
78 declareProperty("setnpeak_fit", m_setpeak_fit= -1);
79 declareProperty("Q", m_q= 0);
80 declareProperty("eventcut", m_eventcut= -1);
81 declareProperty("rhocut", m_rhocut= -1.);
82 declareProperty("mcpar", m_mcpar= 0); //if use par truth
83 declareProperty("fillTruth", m_fillTruth= 0);
84 declareProperty("removeBadTrack", m_removeBadTrack= false);
85 declareProperty("dropTrkDrCut", m_dropTrkDrCut= 1.);
86 declareProperty("dropTrkDzCut", m_dropTrkDzCut= 10.);
87 declareProperty("dropTrkPtCut", m_dropTrkPtCut= 99999.);
88 declareProperty("dropTrkChi2Cut", m_dropTrkChi2Cut = 99999.);
89 declareProperty("dropTrkChi2NdfCut", m_dropTrkChi2NdfCut = 99999.);
90 declareProperty("qualityFactor", m_qualityFactor= 3.);
91 declareProperty("dropTrkNhitCut", m_dropTrkNhitCut= 9);
92}

◆ HoughValidUpdate() [2/2]

HoughValidUpdate::HoughValidUpdate ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Member Function Documentation

◆ beginRun() [1/2]

StatusCode HoughValidUpdate::beginRun ( )

Definition at line 94 of file HoughValidUpdate.cxx.

94 {
95
96 //Initailize MdcDetector
97 m_gm = MdcDetector::instance(0);
98 if(NULL == m_gm) return StatusCode::FAILURE;
99
100 return StatusCode::SUCCESS;
101}
static MdcDetector * instance()
Definition: MdcDetector.cxx:21

◆ beginRun() [2/2]

StatusCode HoughValidUpdate::beginRun ( )

◆ execute() [1/2]

StatusCode HoughValidUpdate::execute ( )

Definition at line 317 of file HoughValidUpdate.cxx.

317 {
318
319 cout.precision(6);
320 MsgStream log(msgSvc(), name());
321 log << MSG::INFO << "in execute()" << endreq;
322
323 //event start time
324 SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
325 if (!evTimeCol) {
326 log << MSG::WARNING<< "Could not retrieve RecEsTimeCol , use t0=0" << endreq;
327 m_bunchT0=0.;
328 }else{
329 RecEsTimeCol::iterator iter_evt = evTimeCol->begin();
330 if (iter_evt != evTimeCol->end()){
331 m_bunchT0 = (*iter_evt)->getTest()*1.e-9;//m_bunchT0-s, getTest-ns
332 }
333 }
334
335 // Get the event header, print out event and run number
336 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
337 if (!eventHeader) {
338 log << MSG::FATAL << "Could not find Event Header" << endreq;
339 return( StatusCode::FAILURE);
340 }
341
342 DataObject *aTrackCol;
343 DataObject *aRecHitCol;
344 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
345 if(!m_combineTracking){
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
358 RecMdcTrackCol* trackList;
359 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
360 if (aTrackCol) {
361 trackList = dynamic_cast<RecMdcTrackCol*> (aTrackCol);
362 }else{
363 trackList = new RecMdcTrackCol;
364 StatusCode sc = eventSvc()->registerObject(EventModel::Recon::RecMdcTrackCol, trackList);
365 if(!sc.isSuccess()) {
366 log << MSG::FATAL << " Could not register RecMdcTrack collection" <<endreq;
367 return StatusCode::FAILURE;
368 }
369 }
370
371 RecMdcHitCol* hitList;
372 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aRecHitCol);
373 if (aRecHitCol) {
374 hitList = dynamic_cast<RecMdcHitCol*> (aRecHitCol);
375 }else{
376 hitList = new RecMdcHitCol;
377 StatusCode sc = eventSvc()->registerObject(EventModel::Recon::RecMdcHitCol, hitList);
378 if(!sc.isSuccess()) {
379 log << MSG::FATAL << " Could not register RecMdcHit collection" <<endreq;
380 return StatusCode::FAILURE;
381 }
382 }
383
384 //remove bad quality or low pt track(s)
385 if(m_removeBadTrack) {
386 vector<RecMdcTrack*> vec_trackList;
387 if( m_debug>0 ) cout<<"PATTSF collect "<<trackList->size()<<" track. "<<endl;
388 if(trackList->size()!=0){
389 RecMdcTrackCol::iterator iter_pat = trackList->begin();
390 for(;iter_pat!=trackList->end();iter_pat++){
391 double d0=(*iter_pat)->helix(0);
392 double kap = (*iter_pat)->helix(2);
393 double pt = 0.00001;
394 if(fabs(kap)>0.00001) pt = fabs(1./kap);
395 double dz=(*iter_pat)->helix(4);
396 double chi2=(*iter_pat)->chi2();
397 if( m_debug>0) cout<<"d0: "<<d0<<" z0: "<<dz<<" pt "<<pt<<" chi2 "<<chi2<<endl;
398 if(fabs(d0)>m_dropTrkDrCut || fabs(dz)>m_dropTrkDzCut || chi2>m_dropTrkChi2Cut || pt>m_dropTrkPtCut) {
399 vec_trackList.push_back(*iter_pat);
400 //remove hits on track
401 HitRefVec rechits = (*iter_pat)->getVecHits();
402 HitRefVec::iterator hotIter = rechits.begin();
403 while (hotIter!=rechits.end()) {
404 if(m_debug>0) cout <<"remove hit " << (*hotIter)->getId() <<endl;
405 hitList->remove(*hotIter);
406 hotIter++;
407 }
408 trackList->remove(*iter_pat);
409 iter_pat--;
410 }
411 // if( m_debug>0 ) cout<<"after delete trackcol size : "<<trackList->size()<<endl;
412 }
413 } else {
414 if(m_debug>0) cout<<" PATTSF find 0 track. "<<endl;
415 }
416 }//end of remove bad quality high pt track
417
418 int nTdsTk=trackList->size();
419
420
421 t_eventNum=eventHeader->eventNumber();
422 t_runNum=eventHeader->runNumber();
423 if( m_drawTuple ){
424 m_eventNum=t_eventNum;
425 m_runNum=t_runNum;
426 }
427 if(m_debug>0) cout<<" begin event :"<<t_eventNum<<endl;
428 if(t_eventNum<=m_eventcut) {
429 cout<<" eventNum cut "<<t_eventNum<<endl;
430 return StatusCode::SUCCESS;
431 }
432 log << MSG::INFO << "HoughValidUpdate: retrieved event: " << eventHeader->eventNumber() << " run: " << eventHeader->runNumber() << endreq;
433
434 vector<double> vec_u;
435 vector<double> vec_v;
436 vector<double> vec_p;
437 vector<double> vec_x_east;
438 vector<double> vec_y_east;
439 vector<double> vec_z_east;
440 vector<double> vec_x_west;
441 vector<double> vec_y_west;
442 vector<double> vec_z_west;
443 vector<double> vec_z_Mc;
444 vector<double> vec_x;
445 vector<double> vec_y;
446 vector<double> vec_z;
447 vector<int> vec_layer;
448 vector<int> vec_wire;
449 vector<int> vec_slant;
450 vector<double> vec_zStereo;
451 vector<double> l;
452
453 vector<int> vec_layer_Mc;
454 vector<int> vec_wire_Mc;
455 vector<int> vec_hit_Mc;
456 vector<double> vec_ztruth_Mc;
457 vector<double> vec_flt_truth_mc;
458 vector<double> vec_pos_flag;
459 vector<double> vec_phit_MC;
460
461 // get mc particle digi
462 int mc_particle=GetMcInfo();
463 if(m_debug>2) cout<<"MC particle : "<<mc_particle<<endl;
464
465 // retrieve Mdc truth hits
466 if(m_fillTruth ==1 && m_useMcInfo) {
467 int digiId_Mc=0;
468 int nHitAxial_Mc=0;
469 SmartDataPtr<Event::MdcMcHitCol> mcMdcMcHitCol(eventSvc(),"/Event/MC/MdcMcHitCol");
470 if (!mcMdcMcHitCol) {
471 log << MSG::INFO << "Could not find MdcMcHit" << endreq;
472 }else{
473 Event::MdcMcHitCol::iterator iterMcHit = mcMdcMcHitCol->begin();
474
475 for(; iterMcHit != mcMdcMcHitCol->end(); ++iterMcHit,digiId_Mc++) {
476 Identifier mdcid = (*iterMcHit)->identify();
477 int layerId_Mc = MdcID::layer(mdcid);
478 int wireId_Mc = MdcID::wire(mdcid);
479 double hittemp=layerId_Mc*1000+wireId_Mc;
480 double mc_hit_distance =(*iterMcHit)->getDriftDistance();
481 double z_mc = (*iterMcHit)->getPositionZ()/10.;//mm 2 cm
482 double flt_truth=(z_mc-dz_mc)/tanl_mc;
483 double pos_flag=(*iterMcHit)->getPositionFlag();
484
485 // cout<<"flag: "<<(*iterMcHit)->getPositionFlag()<<endl;
486 if( (*iterMcHit)->getPositionFlag()==-999 ){
487 // cout<<"track Id: "<<(*iterMcHit)->getTrackIndex()<<endl;
488 double px= (*iterMcHit)->getPositionX();
489 double py= (*iterMcHit)->getPositionY();
490 double pz= (*iterMcHit)->getPositionZ();
491 double pxyz = sqrt(px*px+py*py+pz*pz);
492 vec_phit_MC.push_back(pxyz);
493 // cout<<"PX: "<<px<<endl;
494 // cout<<"PY: "<<py<<endl;
495 // cout<<"PT: "<<sqrt(px*px+py*py)<<endl;
496 // cout<<"PZ: "<<pz<<endl;
497 // cout<<"PXYZ: "<<pxyz<<endl;
498 // cout<<endl;
499 }
500
501 // cout<<"( MC: " <<layerId_Mc<<","<<wireId_Mc<<"):"<<endl;
502 vec_layer_Mc.push_back(layerId_Mc);
503 vec_wire_Mc.push_back(wireId_Mc);
504 vec_hit_Mc.push_back(hittemp);
505 vec_ztruth_Mc.push_back(z_mc);
506 vec_flt_truth_mc.push_back(flt_truth);
507 vec_pos_flag.push_back(pos_flag);
508
509 if(m_debug>5) {
510 cout<<"(" <<layerId_Mc<<","<<wireId_Mc<<"):"<<endl;
511 cout<<" hit_distance : "<<mc_hit_distance<<endl;
512 cout<<" position flag : "<<pos_flag<<endl;
513 cout<<" hit_z_mc : "<<z_mc<<endl;
514 cout<<" flt_truth : "<<flt_truth<<endl;
515 }
516
517 if(m_data==0){
518 if ((layerId_Mc>=8&&layerId_Mc<=19)||(layerId_Mc>=36)) {
519 nHitAxial_Mc++;}
520 const MdcGeoWire *geowir =m_mdcGeomSvc->Wire(layerId_Mc,wireId_Mc);
521 HepPoint3D eastP = geowir->Backward()/10.0;//mm 2 cm
522 HepPoint3D westP = geowir->Forward() /10.0;//mm 2 cm
523
524 double x = (*iterMcHit)->getPositionX()/10.;//mm 2 cm
525 double y = (*iterMcHit)->getPositionY()/10.;//mm 2 cm
526 double z = (*iterMcHit)->getPositionZ()/10.;//mm 2 cm
527 double u=CFtrans(x,y);
528 double v=CFtrans(y,x);
529 double p=sqrt(u*u+v*v);
530
531 vec_x_east.push_back(eastP.x());
532 vec_y_east.push_back(eastP.y());
533 vec_z_east.push_back(eastP.z());
534 vec_x_west.push_back(westP.x());
535 vec_y_west.push_back(westP.y());
536 vec_z_west.push_back(westP.z());
537 vec_x.push_back(x);
538 vec_y.push_back(y);
539 vec_z.push_back(z);
540 vec_u.push_back(u);
541 vec_v.push_back(v);
542 vec_p.push_back(p);
543 vec_slant.push_back( SlantId(layerId_Mc) );
544
545 m_x_east[digiId_Mc]=eastP.x();
546 m_y_east[digiId_Mc]=eastP.y();
547 m_z_east[digiId_Mc]=eastP.z();
548 m_x_west[digiId_Mc]=westP.x();
549 m_y_west[digiId_Mc]=westP.y();
550 m_z_west[digiId_Mc]=westP.z();
551 m_layer[digiId_Mc]=layerId_Mc;
552 m_cell[digiId_Mc]=wireId_Mc;
553 m_x[digiId_Mc]=x;
554 m_y[digiId_Mc]=y;
555 m_z[digiId_Mc]=z;
556 m_u[digiId_Mc]=u;
557 m_v[digiId_Mc]=v;
558 m_p[digiId_Mc]=p;
559 m_slant[digiId_Mc]=SlantId(layerId_Mc);
560 }
561 }
562 }
563 m_nHit_Mc=digiId_Mc;
564 m_nHitAxial_Mc=nHitAxial_Mc;
565 if(0==m_data) {m_nHit=digiId_Mc; m_nHitAxial=nHitAxial_Mc;}
566 }
567
568 // retrieve Mdc digi vector form RawDataProviderSvc
569 vector<int> vec_hit;
570 vector<int> vec_track_index;
571 set<int> hit_noise; //1
572 uint32_t getDigiFlag = 0;
573 if(m_dropHot || m_combineTracking)getDigiFlag |= MdcRawDataProvider::b_dropHot;
574 if(m_keepBadTdc) getDigiFlag |= MdcRawDataProvider::b_keepBadTdc;
575 if(m_keepUnmatch) getDigiFlag |= MdcRawDataProvider::b_keepUnmatch;
576
577 MdcDigiVec mdcDigiVec = m_rawDataProviderSvc->getMdcDigiVec(getDigiFlag);
578 if(m_debug>0) cout<<"MdcDigiVec: "<<mdcDigiVec.size()<<endl;
579 MdcDigiVec::iterator iter1 = mdcDigiVec.begin();
580 int digiId = 0;
581 int nHitAxial = 0;
582 for (;iter1 != mdcDigiVec.end(); iter1++, digiId++) {
583 Identifier mdcId= (*iter1)->identify();
584 int layerId = MdcID::layer(mdcId);
585 int wireId = MdcID::wire(mdcId);
586 double hittemp=layerId*1000+wireId;
587 const MdcGeoWire *geowir =m_mdcGeomSvc->Wire(layerId,wireId);
588 HepPoint3D eastP = geowir->Backward()/10.0;// cm
589 HepPoint3D westP = geowir->Forward() /10.0;// cm
590 if ((layerId>=8&&layerId<=19)||(layerId>=36)) nHitAxial++;
591
592 int track_index=(*iter1)->getTrackIndex();
593 if( track_index>=1000 ) track_index-=1000;
594 if( track_index<0 ) hit_noise.insert(hittemp);
595 int tchannal=(*iter1)->getTimeChannel();
596 int qchannal=(*iter1)->getChargeChannel();
597 if( tchannal!=qchannal && m_debug>0 ) cout<<"("<<layerId<<","<<wireId<<")"<< 0<<endl;
598 if( m_debug>3 ) cout<<"track_index in digi: "<<"("<<layerId<<","<<wireId<<" "<< track_index<<endl;
599 if( m_debug>3 ) cout<<"event: "<<t_eventNum<<" "<<"layer: "<<layerId<<" "<<"wireId: "<<wireId<<" "<<"zeast: "<<eastP.z()<<" "<<"zwest: "<<westP.z()<<" "<<endl;
600
601 //conformal trans:
602 double x =(eastP.x()+westP.x())/2.;
603 double y =(eastP.y()+westP.y())/2.;
604 double u=CFtrans(x,y);
605 double v=CFtrans(y,x);
606 if(m_debug>3) cout<<"digiId: "<<digiId<<" layer: "<<layerId<<" "<<"wireId: "<<wireId<<" "<<"x: "<<x<<" "<<"y: "<<y<<" "<< "u: "<<u<<"v: "<<v<<endl;
607
608 vec_track_index.push_back(track_index);
609 vec_layer.push_back(layerId);
610 vec_wire.push_back(wireId);
611 vec_hit.push_back(hittemp);
612 vec_x_east.push_back(eastP.x());
613 vec_y_east.push_back(eastP.y());
614 vec_z_east.push_back(eastP.z());
615 vec_x_west.push_back(westP.x());
616 vec_y_west.push_back(westP.y());
617 vec_z_west.push_back(westP.z());
618 vec_x.push_back(x);
619 vec_y.push_back(y);
620 vec_p.push_back(sqrt(u*u+v*v));
621 vec_u.push_back(u);
622 vec_v.push_back(v);
623 vec_slant.push_back( SlantId(layerId) );
624
625 if(m_drawTuple){
626 m_x_east[digiId]=eastP.x();
627 m_y_east[digiId]=eastP.y();
628 m_z_east[digiId]=eastP.z();
629 m_x_west[digiId]=westP.x();
630 m_y_west[digiId]=westP.y();
631 m_z_west[digiId]=westP.z();
632 m_layer[digiId]=layerId;
633 m_cell[digiId]=wireId;
634 m_x[digiId]=(vec_x_east[digiId]+vec_x_west[digiId])/2;
635 m_y[digiId]=(vec_y_east[digiId]+vec_y_west[digiId])/2;
636 m_u[digiId]=u;
637 m_v[digiId]=v;
638 m_p[digiId]=sqrt(u*u+v*v);
639 m_slant[digiId]=SlantId( layerId );
640 m_layerNhit[layerId]++;
641 }
642 }
643 if(m_drawTuple){
644 m_nHit=digiId;
645 m_nHitAxial=nHitAxial;
646 m_nHitStereo=m_nHit-m_nHitAxial;
647 }
648 if(m_debug>0) cout<<"Hit digi number: "<<digiId<<endl;
649 if(digiId<5||nHitAxial<3) {
650 if(m_drawTuple) m_trackFailure=1;
651 if(m_drawTuple) ntuplehit->write();
652 if(m_debug>0) cout<<"not enough hit "<<endl;
653 return StatusCode::SUCCESS;
654 }
655
656 //correspond mc_fltLenth with digiHit
657 vector<int> vec_digitruth(digiId,0);
658 vector<double> vec_flt_truth(digiId,999.);
659 vector<double> vec_ztruth(digiId,999.);
660 vector<double> vec_posflag_truth(digiId,999.);
661 if(m_useMcInfo){
662 int if_exit_delta_e=0;
663 int nhit_digi=0;
664 for(int iHit=0;iHit<digiId;iHit++){
665 vector<int>::iterator iter_ihit = find( vec_hit_Mc.begin(),vec_hit_Mc.end(),vec_hit[iHit] );
666 if( iter_ihit==vec_hit_Mc.end() ) {
667 vec_digitruth[iHit]=0;
668 if(m_drawTuple) m_digi_truth[iHit]=0;
669 if_exit_delta_e=1;
670 }
671 else {
672 vec_digitruth[iHit]=1;
673 m_digi_truth[iHit]=1;
674 nhit_digi++;
675 }
676 for(int iHit_Mc=0;iHit_Mc<vec_flt_truth_mc.size();iHit_Mc++){
677 if(vec_hit[iHit]==vec_hit_Mc[iHit_Mc]) {
678 vec_flt_truth[iHit]=vec_flt_truth_mc[iHit_Mc];
679 vec_ztruth[iHit]=vec_ztruth_Mc[iHit_Mc];
680 vec_posflag_truth[iHit]=vec_pos_flag[iHit_Mc];
681 if(m_drawTuple){
682 m_ztruth[iHit]=vec_ztruth_Mc[iHit_Mc];
683 m_ltruth[iHit]=vec_flt_truth_mc[iHit_Mc];
684 m_postruth[iHit]=vec_pos_flag[iHit_Mc];
685 }
686 }
687 }
688 if(m_debug>3) cout<<" hitPos: "<<"("<<vec_layer[iHit]<<","<<vec_wire[iHit]<<")"<<" flt_truth: "<<vec_flt_truth[iHit]<<" z_truth: "<<vec_ztruth[iHit]<<" pos_flag: "<<vec_posflag_truth[iHit]<<" digi_truth: "<<vec_digitruth[iHit]<<endl;
689 }
690 if( m_drawTuple ){
691 m_e_delta=if_exit_delta_e;
692 m_nHitDigi=nhit_digi;
693 }
694 }
695
696 // calcu the last layer
697 vector<int>::iterator laymax=max_element( vec_layer.begin(),vec_layer.end() );
698 if(m_drawTuple) m_layer_max=*laymax;
699
700 //------------------------- finish hit -------------------------------
701 int nhit;
702 int nhitaxial;
703 if(m_data==0 && m_useMcInfo && m_fillTruth) {
704 nhit=m_nHit_Mc;
705 nhitaxial=m_nHitAxial_Mc;
706 }
707 else{
708 nhit=digiId;
709 nhitaxial=nHitAxial;
710 }
711
712 binX=m_binx;
713 binY=m_biny;
714 TH2D *h1 = new TH2D("h1","h1",binX,0,M_PI,binY,-m_maxrho,m_maxrho);
715 TH2D *h2 = new TH2D("h2","h2",binX,0,M_PI,binY,-m_maxrho,m_maxrho);
716
717 //method 0
718 /*
719 if(m_method==0){
720 vector<double> vec_rho;
721 vector<double> vec_theta;
722 vector< vector<int> > vec_hitNum(2,vector<int>()); //store 2 hits in a cross point
723 vector<int> xybin;
724 //RhoTheta(nhit,vec_u,vec_v,vec_rho,vec_theta,vec_hitNum,vec_digitruth); //calculate cross point
725 RhoThetaAxial(vec_slant,nhit,vec_u,vec_v,vec_rho,vec_theta,vec_hitNum,vec_digitruth); //calculate cross point
726 FillRhoTheta(h1,vec_theta,vec_rho); //fill histgram method by rhotheta
727 if(m_nCross>125000) return StatusCode::SUCCESS;
728
729 //sum in x
730 int xsum_bin;
731 int xsum=0;
732 TF1 *f =new TF1("f","gaus",0,3.1415926);
733 TH1D *hx=new TH1D("hx","hx",binX,0,3.1415926);
734 TH1D *hx_new=new TH1D("hx_new","hx_new",m_binx,0,3.1415926);
735 for(int ibinx =0;ibinx<binX;ibinx++){
736 int t_xsum=0;
737 for(int ibiny =0;ibiny<binY;ibiny++){
738 t_xsum+=h1->GetBinContent(ibinx+1,ibiny+1);
739 }
740 hx->SetBinContent(ibinx+1,t_xsum);
741 if( xsum <= t_xsum ) {
742 xsum=t_xsum;
743 xsum_bin=ibinx+1;
744 }
745 }
746 for(int ibinx =0;ibinx<binX;ibinx++){
747 int hx_content = hx->GetBinContent(ibinx+1);
748 int binx_new=(ibinx+1)-(xsum_bin-(binX/2+1));
749 if(binx_new<1) { binx_new+=binX; }
750 if(binx_new>binX) { binx_new-=binX; }
751 hx_new->SetBinContent( binx_new , hx_content);
752 }
753 hx_new->Fit("f","QN");
754 double xsigma=f->GetParameter(2);
755 delete hx;
756 delete hx_new;
757
758 //sum in y axial
759 TH1D *hy=new TH1D("hy","hy",binY,-0.3,0.3);
760 or(int ibiny =0;ibiny<binY;ibiny++){
761 int t_ysum=0;
762 for(int ibinx =0;ibinx<binX;ibinx++){
763 t_ysum+=h1->GetBinContent(ibinx+1,ibiny+1);
764 }
765 hy->SetBinContent(ibiny+1,t_ysum);
766 }
767 hy->Fit("f","QN");
768 double ysigma=f->GetParameter(2);
769 delete hy;
770 delete f;
771
772 for(int ibinx=0;ibinx<binX;ibinx++){
773 for(int ibiny=0;ibiny<binY;ibiny++){
774 int binNum=h1->GetBinContent(ibinx+1,ibiny+1);
775 xybin.push_back(binNum);
776 m_xybin[binY*ibinx+ibiny]=binNum;
777 }
778 }
779 m_xybinNum=binX*binY;
780 m_xsigma=xsigma;
781 m_ysigma=ysigma;
782 }
783 */
784
785 //method 1
786 vector< vector< vector<int> > > vec_selectNum(binX,vector< vector<int> >(binY,vector<int>() ) );
787 M2 peak_hit_num;
788 M1 peak_hit_list;
789 int peak_track;
790 if(m_method==1){
791 FillHist(h1,vec_u,vec_v,nhit,vec_selectNum);
792 int max_count=0;
793 int max_binx=0;
794 int max_biny=0;
795 for(int i=0;i<binX;i++){
796 for(int j=0;j<binY;j++){
797 int count=h1->GetBinContent(i+1,j+1);
798 if(max_count<count) {
799 max_count=count;
800 max_binx=i+1;
801 max_biny=j+1;
802 }
803 }
804 }
805
806 if(vec_selectNum[max_binx-1][max_biny-1].size() != max_count ) cout<< "ERROR IN VEC!!! "<<endl;
807 if(m_debug>4) {
808 cout<<"maxBin: ["<<max_binx-1<<","<<max_biny-1<<"]: "<<vec_selectNum[max_binx-1][max_biny-1].size()<<endl;
809 for(int i =0;i<vec_selectNum[max_binx-1][max_biny-1].size();i++) cout<<" maxBin select hit: "<<vec_selectNum[max_binx-1][max_biny-1][i]<<endl;
810 }
811
812 if(m_debug>4) {
813 for(int ibinx=0;ibinx<binX;ibinx++){
814 for(int ibiny=0;ibiny<binY;ibiny++){
815 int bincount=h1->GetBinContent(ibinx+1,ibiny+1);
816 if(vec_selectNum[ibinx][ibiny].size() != bincount ) cout<< "ERROR IN VECTORSELECT filling "<<endl;
817 if(vec_selectNum[ibinx][ibiny].size() == 0 ) continue;
818 cout<<"bin:"<<"["<<ibinx<<","<<ibiny<<"]"<<" select:"<<vec_selectNum[ibinx][ibiny].size()<<endl;
819 for(int i=0;i<vec_selectNum[ibinx][ibiny].size();i++){
820 int ihit=vec_selectNum[ibinx][ibiny][i];
821 cout<<" hit: "<<ihit<<" ("<<vec_layer[ihit]<<","<<vec_wire[ihit]<<")"<<endl;
822 }
823 }
824 }
825 }
826
827 //find peak
828 // set threshold
829 int count_use=0;
830 double sum=0;
831 double sum2=0;
832 for(int i=0;i<binX;i++){
833 for(int j=0;j<binY;j++){
834 int count=h1->GetBinContent(i+1,j+1);
835 if(count!=0){
836 count_use++;
837 sum+=count;
838 sum2+=count*count;
839 }
840 }
841 }
842 double f_n=m_ndev1;
843 double aver=sum/count_use;
844 double dev=sqrt(sum2/count_use-aver*aver);
845 int min_counts=(int)(aver+f_n*dev);
846 if (min_counts<m_ndev2) min_counts=m_ndev2;
847 if(m_debug>2) cout<<"aver: "<<aver<<" "<<"dev: "<<dev<<" min: "<<min_counts<<endl;
848
849 vector< vector <int> > hough_trans_CS(binX,vector <int> (binY,0) );
850 vector< vector <int> > hough_trans_CS_peak(binX,vector <int> (binY,0) );
851 for(int i=0;i<binX;i++){
852 for(int j=0;j<binY;j++){
853 hough_trans_CS[i][j]=h1->GetBinContent(i+1,j+1);
854 }
855 }
856
857 int npeak_1=0;
858 for (int r=0; r<binY; r++) {
859 double binHigh=2*m_maxrho/binY;
860 double rho_peak=r*binHigh-m_maxrho;
861 for (int a=0; a<binX; a++) {
862 long max_around=0;
863 for (int ar=a-1; ar<=a+1; ar++) {
864 for (int rx=r-1; rx<=r+1; rx++) {
865 int ax;
866 if (ar<0) { ax=ar+binX; }
867 else if (ar>=binX) { ax=ar-binX; }
868 else { ax=ar; }
869 if ( (ax!=a || rx!=r) && rx>=0 && rx<binY) {
870 if (hough_trans_CS[ax][rx]>max_around) { max_around=hough_trans_CS[ax][rx]; }
871 }
872 }
873 }
874
875 if (hough_trans_CS[a][r]<=min_counts||fabs(rho_peak)<m_rhocut) { hough_trans_CS_peak[a][r]=0; }
876 else if (hough_trans_CS[a][r]<max_around) { hough_trans_CS_peak[a][r]=0; }
877 else if (hough_trans_CS[a][r]==max_around) { hough_trans_CS_peak[a][r]=1; }
878 else if (hough_trans_CS[a][r]>max_around) { hough_trans_CS_peak[a][r]=2; }
879 if(hough_trans_CS_peak[a][r]!=0) {
880 if(m_debug>2) cout<<" possible peak1:"<<"["<<a<<","<<r<<"]"<<": "<<hough_trans_CS_peak[a][r]<<" "<<hough_trans_CS[a][r]<<endl;
881 npeak_1++;
882 }
883 }
884 }
885
886
887 //find double-point-peaks in parameter space
888 int npeak_2=0;
889 for (int r=0; r<binY; r++) {
890 for (int a=0; a<binX; a++) {
891 if (hough_trans_CS_peak[a][r]==1) {
892 hough_trans_CS_peak[a][r]=2;
893 for (int ar=a-1; ar<=a+1; ar++) {
894 for (int rx=r-1; rx<=r+1; rx++) {
895 int ax;
896 if (ar<0) { ax=ar+binX; }
897 else if (ar>=binX) { ax=ar-binX; }
898 else { ax=ar; }
899 if ( (ax!=a || rx!=r) && rx>=0 && rx<binY) {
900 if (hough_trans_CS_peak[ax][rx]==1) { hough_trans_CS_peak[ax][rx]=0; }
901 }
902 }
903 }
904 }
905 if(hough_trans_CS_peak[a][r]==2) {
906 double binHigh=2*m_maxrho/binY;
907 double rho_peak=r*binHigh-m_maxrho;
908 npeak_2++;
909 if(m_debug>2){
910 cout<<" possible peak2: "<<"["<<a<<","<<r<<"]"<<": "<<hough_trans_CS_peak[a][r]<<" "<<hough_trans_CS[a][r]<<" rhopeak: "<<rho_peak<<endl;
911 for(int i=0;i<hough_trans_CS[a][r];i++){
912 int hitNum=vec_selectNum[a][r][i];
913 if(m_debug>2) cout<<" select hit: "<<hitNum<<"("<<vec_layer[hitNum]<<","<<vec_wire[hitNum]<<")"<<endl;
914 }
915 }
916 }
917 }
918 }
919
920 //fill the histogram again
921 for(int i=0;i<binX;i++){
922 for(int j=0;j<binY;j++){
923 if(hough_trans_CS_peak[i][j]==2){
924 h2->SetBinContent(i+1,j+1,hough_trans_CS[i][j]);
925 }
926 }
927 }
928
929 vector<int> peakList[3];
930 for(int n=0;n<npeak_2;n++){
931 for (int r=0; r<binY; r++) {
932 for (int a=0; a<binX; a++) {
933 if (hough_trans_CS_peak[a][r]==2) {
934 peakList[0].push_back(a);
935 peakList[1].push_back(r);
936 peakList[2].push_back(hough_trans_CS[a][r]);
937 }
938 }
939 }
940 }
941
942 if(m_drawTuple){
943 m_npeak_1=npeak_1;
944 m_npeak_2=npeak_2;
945 }
946 if(m_debug>0) {
947 cout<<"npeak_1: "<<npeak_1<<endl;
948 cout<<"npeak_2: "<<npeak_2<<endl;
949 }
950
951 //sort peaks by height
952 int n_max;
953 for (int na=0; na<npeak_2-1; na++) {
954 n_max=na;
955 for (int nb=na+1; nb<npeak_2; nb++) {
956 if (peakList[2][n_max]<peakList[2][nb]) { n_max=nb; }
957 }
958 if (n_max!=na) { // swap
959 float swap[3];
960 for (int i=0; i<3; i++) {
961 swap[i]=peakList[i][na];
962 peakList[i][na]=peakList[i][n_max];
963 peakList[i][n_max]=swap[i];
964 }
965 }
966 }
967
968 if(npeak_2==0||npeak_2>100){
969 if(m_debug>0) cout<<" FAILURE IN NPEAK2 !!!!!! "<<endl;
970 delete h1;
971 delete h2;
972 if(m_drawTuple){
973 m_trackFailure=2;
974 m_npeak_2=-999;
975 }
976 if(m_drawTuple) ntuplehit->write();
977 return StatusCode::SUCCESS;
978 }
979
980 if(m_debug>2){
981 for(int n=0;n<npeak_2;n++){
982 int bintheta=peakList[0][n];
983 int binrho=peakList[1][n];
984 int count=peakList[2][n];
985 cout<<"possible peakList after SORT: "<<n<<": "<<"["<<bintheta<<","<<binrho<<"]: "<<count<<endl;
986 for(int i=0;i<count;i++){
987 int hitNum=vec_selectNum[bintheta][binrho][i];
988 if(m_debug>2) cout<<" "<<" select hit:"<<":"<<hitNum<<" ------ "<<"("<<vec_layer[hitNum]<<","<<vec_wire[hitNum]<<")"<<endl;
989 }
990 }
991 }
992
993 // combine peak to track
994 peak_track=npeak_2;
995 Combine(h1,m_peakCellNumX,m_peakCellNumY,vec_selectNum,peak_hit_list,peak_hit_num,peak_track,peakList);
996 if(m_drawTuple) m_npeak_after_tracking=peak_track;
997
998 if(m_debug>0) cout<<"event"<<t_eventNum<<": "<<"has found: "<<peak_track<<" track."<<endl;
999 for( int i=0;i<peak_track;i++){
1000 if(m_debug>0) cout<<"peak["<<i<<"] collect "<<peak_hit_num[i]<<" hits "<<endl;
1001 int nhitaxialselect=0; // temp for each peak_track
1002 for(int j =0;j<peak_hit_num[i];j++){
1003 int hit_number=peak_hit_list[i][j];
1004 if(vec_slant[hit_number]==0) nhitaxialselect++ ;
1005 if(m_debug>0) cout<<" "<<" collect hits: ("<<vec_layer[hit_number]<<","<<vec_wire[hit_number]<<")"<<endl;
1006 }
1007 if(m_drawTuple){
1008 m_nHitSelect[i]=peak_hit_num[i];
1009 m_nHitAxialSelect[i]=nhitaxialselect;
1010 m_nHitStereoSelect[i]=peak_hit_num[i]-nhitaxialselect;
1011 m_axiallose[i]=m_nHitAxial-m_nHitAxialSelect[i];
1012 m_stereolose[i]=m_nHit-m_nHitSelect[i]-m_axiallose[i];
1013 }
1014 }
1015 }
1016
1017 vector<int> vec_hitbeforefit;
1018 vector<bool> vec_truthHit(nhit,false);
1019 int peak_fit=peak_track;
1020 if(m_setpeak_fit!=-1) {
1021 peak_fit=m_setpeak_fit;
1022 }
1023 if(m_drawTuple) m_trackNum=peak_fit;
1024
1025 vector<int> vec_hit_use;
1026 // vector<int> vec_hit_use_in2d;
1027 // vector<int> vec_hit_use_intrack1;
1028 // vector<int> vec_Qchoise;
1029 vector<TrkRecoTrk*> vec_newTrack;
1030 vector<TrkRecoTrk*> vec_track_in_tds;
1031 vector<int> vec_hitOnTrack;
1032 vector<MdcHit*> vec_for_clean;
1033 vector<TrkRecoTrk*> vec_trk_for_clean;
1034 vector<Mytrack> vec_myTrack;
1035 int track_fit_success=0;
1036
1037 for(track_fit=0;track_fit<peak_fit;track_fit++){
1038 double d0_before_least=-999.;
1039 double phi0_before_least=-999.;
1040 double omega_before_least=-999.;
1041 map<int,double> hit_to_circle1;
1042 map<int,double> hit_to_circle2;
1043 map<int,double> hit_to_circle3;
1044 if(m_debug>0) cout<<"Do fitting track: "<<track_fit<<endl;
1045
1046 for(int i=0;i<nhit;i++) vec_truthHit[i]=false;
1047
1048 // confirm every track has which hits
1049 if(m_debug>1) cout<<"candi track["<<track_fit<<"] collect "<<peak_hit_num[track_fit]<<" hits "<<endl;
1050
1051 for(int i=0;i<peak_hit_num[track_fit];i++){
1052 int hitNum=peak_hit_list[track_fit][i];
1053 int hittemp=vec_layer[hitNum]*1000+vec_wire[hitNum];
1054 vector<int>::iterator iter_ihit = find( vec_hit_use.begin(),vec_hit_use.end(),hittemp );
1055 if( iter_ihit==vec_hit_use.end() ) vec_truthHit[hitNum]=true;
1056 if( m_debug >1 && vec_truthHit[hitNum]==true) cout<<" "<<"collect hit :"<<"("<<vec_layer[hitNum]<<","<<vec_wire[hitNum]<<")"<<" "<<endl;;
1057 }
1058 if( m_debug >1){
1059 for(int i=0;i<nhit;i++){
1060 if(vec_truthHit[i]==false){
1061 cout<<"candi track "<<"uncollect hit: "<<endl;
1062 cout<<" "<<"uncollect hit :"<<"("<<vec_layer[i]<<","<<vec_wire[i]<<")"<<" " <<endl;
1063 }
1064 }
1065 }
1066 // begin chisq fit
1067 int t_nHitAxialSelect=0;
1068 for(int i=0;i<nhit;i++){
1069 if(vec_truthHit[i]==true){
1070 if(vec_slant[i]==0) t_nHitAxialSelect++;
1071 }
1072 }
1073 if(m_debug>1) cout<<"track "<<track_fit<<" with axial select: "<<t_nHitAxialSelect<<endl;
1074 if(t_nHitAxialSelect<3 && m_drawTuple){
1075 m_x_circle[track_fit]=-999.;
1076 m_y_circle[track_fit]=-999.;
1077 m_r[track_fit]=-999.;
1078 m_chis_pt[track_fit] = -999.;
1079 m_pt[track_fit]=-999.;
1080 continue;
1081 }
1082 double circle_x=0;
1083 double circle_y=0;
1084 double circle_r=0;
1085 int leastSquare=LeastSquare(nhit,vec_x,vec_y,vec_slant,vec_layer,vec_truthHit,d0_before_least,phi0_before_least,omega_before_least,circle_x,circle_y,circle_r);
1086 //hitdis to circle1
1087 for(int i=0;i<nhit;i++){
1088 int hittemp=vec_layer[i]*1000+vec_wire[i];
1089 double dist_temp=sqrt(pow( (vec_y[i]-circle_y),2)+pow( (vec_x[i]-circle_x),2))-circle_r;
1090 if(dist_temp>10.) vec_truthHit[i]=false;
1091 if(m_debug>1&&vec_truthHit[i]==true) cout<<"IN LEAST1: "<<"("<<vec_layer[i]<<","<<vec_wire[i]<<"):"<<dist_temp<<endl;
1092 }
1093
1094 t_nHitAxialSelect=0;
1095 for(int i=0;i<nhit;i++){
1096 if(vec_truthHit[i]==true){
1097 if(vec_slant[i]==0) t_nHitAxialSelect++;
1098 }
1099 }
1100 if(m_debug>1) cout<<"track "<<track_fit<<"with axial2 select: "<<t_nHitAxialSelect<<endl;
1101 if(t_nHitAxialSelect<3) continue;
1102
1103 int leastSquare2=LeastSquare(nhit,vec_x,vec_y,vec_slant,vec_layer,vec_truthHit,d0_before_least,phi0_before_least,omega_before_least,circle_x,circle_y,circle_r);
1104 for(int i=0;i<nhit;i++){
1105 int hittemp=vec_layer[i]*1000+vec_wire[i];
1106 double dist_temp=sqrt(pow( (vec_y[i]-circle_y),2)+pow( (vec_x[i]-circle_x),2))-circle_r;
1107 hit_to_circle1[hittemp]=dist_temp;
1108 if(m_debug>1&&vec_truthHit[i]==true) cout<<" IN LEAST2: "<<"("<<vec_layer[i]<<","<<vec_wire[i]<<"):"<<dist_temp<<endl;
1109 }
1110
1111 if(m_drawTuple){
1112 m_x_circle[track_fit]=circle_x;
1113 m_y_circle[track_fit]=circle_y;
1114 m_r[track_fit]=circle_r;
1115 m_chis_pt[track_fit]=circle_r/333.567;
1116 }
1117
1118 // q select
1119 TrkHitList* qhits[2];
1120 const TrkFit* newFit[2];
1121 TrkHitList* qhits2[2];
1122 const TrkFit* newFit2[2];
1123 TrkRecoTrk* newTrack2[2];
1124
1125 int Q_iq[]={-1,1};
1126 double Q_Chis_2d[]={9999,9999};
1127 double Q_Chis_3d[]={9999,9999};
1128 double Q_z[]={999,999};
1129 double Q_pt2[]={999,999};
1130 double Q_tanl[]={999,999};
1131 int Q_ok[2][2]={0};
1132
1133 int q_start=0;
1134 int q_end=1;
1135 if(m_q==-1) {q_start=0;q_end=0;}
1136 if(m_q==1) {q_start=1;q_end=1;}
1137 for(int i_q=q_start;i_q<=q_end;i_q++){
1138 double d0=d0_before_least;
1139 double phi0=phi0_before_least;
1140 double omega=omega_before_least;
1141 double z0=0;
1142 double tanl=0;
1143 if(m_debug>0 ){
1144 cout<<"BY LEASTSQUARE: "<<endl;
1145 cout<<" d0: "<<d0<<" d0_mc "<<d0_mc<<endl;
1146 cout<<" phi0: "<<phi0<<" phi0_mc "<<phi0_mc<<endl;
1147 cout<<" omega0: "<<omega<<" omega_mc "<<omega_mc<<endl;
1148 }
1149
1150 vector<double> vec_flt_least; //use circle info
1151 for(int i=0;i<nhit;i++){
1152 double theta_temp;
1153 if(circle_x==0||vec_x[i]-circle_x==0){
1154 theta_temp=0;
1155 }
1156 else{
1157 theta_temp=M_PI-atan2(vec_y[i]-circle_y,vec_x[i]-circle_x)+atan2(circle_y,circle_x);
1158 if(theta_temp>2*M_PI){
1159 theta_temp=theta_temp-2*M_PI;
1160 }
1161 if(theta_temp<0){
1162 theta_temp=theta_temp+2*M_PI;
1163 }
1164 }
1165 if(Q_iq[i_q]==-1) {
1166 double l_temp=circle_r*theta_temp;
1167 vec_flt_least.push_back(l_temp);
1168 }
1169 if(Q_iq[i_q]==1) {
1170 theta_temp=2*M_PI-theta_temp;
1171 double l_temp=circle_r*(theta_temp);
1172 vec_flt_least.push_back(l_temp);
1173 }
1174 }
1175 if(m_debug>2) {
1176 for(int i=0;i<nhit;i++){
1177 cout<<"By least 2d: "<< "("<<vec_layer[i]<<","<<vec_wire[i]<<"):"<<vec_flt_least[i]<<endl;
1178 }
1179 }
1180
1181 //exchange par to 2d
1182 if(Q_iq[i_q]==-1){
1183 d0=-d0;
1184 omega=-1./circle_r;
1185 }
1186 if(Q_iq[i_q]==1){
1187 d0=d0;
1188 omega=1./circle_r;
1189 phi0=phi0-M_PI;
1190 }
1191
1192 // 2d global fit
1193 double x_cirtemp;
1194 double y_cirtemp;
1195 double r_temp;
1196 TrkExchangePar tt(d0,phi0,omega,z0,tanl);
1197 TrkCircleMaker circlefactory;
1198 float chisum =0.;
1199 TrkRecoTrk* newTrack = circlefactory.makeTrack(tt, chisum, *m_context, m_bunchT0);
1200 //vec_trk_for_clean.push_back(newTrack);
1201 bool permitFlips = true;
1202 bool lPickHits = m_pickHits;
1203 circlefactory.setFlipAndDrop(*newTrack, permitFlips, lPickHits);
1204 int nDigi = digiToHots(mdcDigiVec,newTrack,vec_truthHit,getDigiFlag,vec_flt_least,hit_to_circle1,vec_for_clean);
1205 if(m_debug>2){
1206 newTrack->printAll(std::cout);
1207 }
1208 //fit
1209 // TrkHitList* qhits = newTrack->hits();
1210 qhits[i_q] = newTrack->hits();
1211 TrkErrCode err=qhits[i_q]->fit();
1212 newFit[i_q] = newTrack->fitResult();
1213
1214 //test fit result
1215 if (!newFit[i_q] || (newFit[i_q]->nActive()<3) || err.failure()!=0) {
1216 if(m_debug>0){
1217 cout << "evt "<<t_eventNum<<" global 2d fit failed ";
1218 if(newFit[i_q]) cout <<" nAct "<<newFit[i_q]->nActive();
1219 cout<<"ERR1 failure ="<<err.failure()<<endl;
1220 }
1221 // m_2dFit[track_fit]=0;
1222 Q_ok[i_q][0]=0;
1223 Q_ok[i_q][1]=0;
1224 Q_Chis_2d[i_q]=-999.;
1225 delete newTrack;
1226 continue;
1227 }else{
1228 Q_ok[i_q][0]=1;
1229 Q_ok[i_q][1]=0;
1230 if(m_debug>0) cout <<"evt "<<t_eventNum<< " global 2d fit success"<<endl;
1231 if(m_debug>2) {
1232 newTrack->print(std::cout);
1233 }
1234 Q_Chis_2d[i_q]=newFit[i_q]->chisq();
1235
1236 TrkExchangePar par = newFit[i_q]->helix(0.);
1237 d0=par.d0();
1238 phi0=par.phi0();
1239 omega=par.omega();
1240 r_temp=Q_iq[i_q]/par.omega();
1241 x_cirtemp = sin(par.phi0()) *(par.d0()+1/par.omega()) * -1.; //z axis verse,x_babar = -x_belle
1242 y_cirtemp = -1.*cos(par.phi0()) *(par.d0()+1/par.omega()) * -1;//???
1243
1244 if(m_debug>1) cout<<" circle after globle 2d: "<<"("<<x_cirtemp<<","<<y_cirtemp<<","<<r_temp<<")"<<endl;
1245 if(m_debug>0) cout<<"pt_rec: "<<-1*Q_iq[i_q]/omega/333.567<<endl;
1246
1247 if(m_drawTuple){
1248 m_x_circle[track_fit]=x_cirtemp;
1249 m_y_circle[track_fit]=y_cirtemp;
1250 m_r[track_fit]=r_temp;
1251 m_chis_pt[track_fit] = newFit[i_q]->chisq();
1252 m_pt[track_fit]=r_temp/333.567;
1253 }
1254 }
1255
1256 int nfit2d=0;
1257 if(m_debug>1) cout<<" hot list:"<<endl;
1258 TrkHotList::hot_iterator hotIter= qhits[i_q]->hotList().begin();
1259 int lay=((MdcHit*)(hotIter->hit()))->layernumber();
1260 int wir=((MdcHit*)(hotIter->hit()))->wirenumber();
1261 int hittemp=lay*1000+wir;
1262 while (hotIter!=qhits[i_q]->hotList().end()) {
1263 if(m_debug>1){ cout <<"(" <<((MdcHit*)(hotIter->hit()))->layernumber()
1264 <<","<<((MdcHit*)(hotIter->hit()))->wirenumber()
1265 <<":"<<hotIter->isActive()<<") ";
1266 }
1267 if (hotIter->isActive()==1) nfit2d++;
1268 hotIter++;
1269 }
1270 if(m_debug>0) cout<<"charge "<<i_q<<" In 2Dfit Num Of Active Hits: "<<nfit2d<<endl;
1271
1272 //caculate z position
1273 if(m_debug>0 && m_drawTuple){
1274 cout<<" By global 2d charge "<<i_q<<endl;
1275 cout<<" d0: " <<d0<<" "<<m_drTruth[0]<<endl;
1276 cout<<" phi0: " <<phi0<<" "<<m_phi0Truth[0]<<endl;
1277 cout<<" omega: "<<omega<<" "<<m_omegaTruth[0]<<endl;
1278 cout<<" z0: " <<z0<<" "<<m_dzTruth[0]<<endl;
1279 cout<<" tanl: "<<tanl<<" "<<m_tanl_mc[0]<<endl;
1280 }
1281
1282 if(m_debug>2) {
1283 cout<<"least:( "<<circle_x<<","<<circle_y<<","<<circle_r<<endl;
1284 cout<<"2d:( "<<x_cirtemp<<","<<y_cirtemp<<","<<r_temp<<endl;
1285 }
1286 delete newTrack;
1287
1288 //calcu every hit after 2dfit
1289 vector<double> vec_flt;
1290 vector<double> vec_theta_ontrack;
1291 for(int i=0;i<nhit;i++){
1292 double theta_temp;
1293 if(x_cirtemp==0||vec_x[i]-x_cirtemp==0){
1294 theta_temp=0;
1295 }
1296 else{
1297 theta_temp=M_PI-atan2(vec_y[i]-y_cirtemp,vec_x[i]-x_cirtemp)+atan2(y_cirtemp,x_cirtemp);
1298 if(theta_temp>2*M_PI){
1299 theta_temp=theta_temp-2*M_PI;
1300 }
1301 if(theta_temp<0){
1302 theta_temp=theta_temp+2*M_PI;
1303 }
1304 if(Q_iq[i_q]==-1) {
1305 double l_temp=r_temp*theta_temp;
1306 vec_flt.push_back(l_temp);
1307 vec_theta_ontrack.push_back(theta_temp);
1308 // if(vec_truthHit[i]==true) cout<<"("<<vec_layer[i]<<","<<vec_wire[i]<<"):l:"<<vec_flt[i]<<" theta:"<<vec_theta_ontrack[i]<<endl;
1309 }
1310 if(Q_iq[i_q]==1) {
1311 theta_temp=2*M_PI-theta_temp;
1312 double l_temp=r_temp*(theta_temp);
1313 vec_flt.push_back(l_temp);
1314 vec_theta_ontrack.push_back(theta_temp);
1315 // if(vec_truthHit[i]==true) cout<<"("<<vec_layer[i]<<","<<vec_wire[i]<<"):l:"<<vec_flt[i]<<" theta:"<<vec_theta_ontrack[i]<<endl;
1316 }
1317 }
1318 }
1319
1320 if(m_debug>3){
1321 for(int i=0;i<nhit;i++){
1322 cout<<"i: "<<"theta: "<<vec_theta_ontrack[i]<<" l: "<<vec_flt[i]<<endl;
1323 }
1324 }
1325
1326 for(int i=0;i<nhit;i++){
1327 int hittemp=vec_layer[i]*1000+vec_wire[i];
1328 double dist_temp=sqrt(pow( (vec_y[i]-y_cirtemp),2)+pow( (vec_x[i]-x_cirtemp),2))-r_temp;
1329 hit_to_circle2[hittemp]=dist_temp;
1330 }
1331
1332 vector<double> vec_l_Calcu_Left;
1333 vector<double> vec_l_Calcu_Right;
1334 vector<double> vec_z_Calcu_Left;
1335 vector<double> vec_z_Calcu_Right;
1336 vector<double> vec_z_Calcu;
1337 vector<double> vec_l_Calcu;
1338 vector<double> vec_delta_z;
1339 vector<double> vec_delta_l;
1340
1341 double l_Calcu_Left=-999.;
1342 double l_Calcu_Right=-999.;
1343 double z_Calcu_Left=-999.;
1344 double z_Calcu_Right=-999.;
1345 double z_Calcu=-999.;
1346 double l_Calcu=-999.;
1347 double delta_z=-999.;
1348 double delta_l=-999.;
1349 // z caculate
1350 MdcDigiVec::iterator iter2 = mdcDigiVec.begin();
1351 int zPos;
1352 int digiId = 0;
1353 for (;iter2 != mdcDigiVec.end(); iter2++, digiId++) {
1354 if(vec_truthHit[digiId]==false) continue;
1355 if(vec_slant[digiId]==0) continue;
1356 if(vec_theta_ontrack[digiId]>M_PI) continue;
1357 const MdcDigi* aDigi = *iter2;
1358 MdcHit *hit = new MdcHit(aDigi, m_gm);
1359 hit->setCalibSvc(m_mdcCalibFunSvc);
1360 hit->setCountPropTime(true);
1361 zPos=zPosition(*hit,m_bunchT0,x_cirtemp,y_cirtemp,r_temp,digiId,delta_z,delta_l,l_Calcu_Left,l_Calcu_Right,z_Calcu_Left,z_Calcu_Right,z_Calcu,l_Calcu,Q_iq[i_q]);
1362 if(m_debug>2) cout<<"in ZS calcu hitPos: "<<"("<<vec_layer[digiId]<<","<<vec_wire[digiId]<<")"<<" l_truth: "<<vec_flt_truth[digiId]<<" z_truth: "<<vec_ztruth[digiId]<<" l_Cal: "<<l_Calcu<<" z_Cal: "<<z_Calcu<<endl;
1363 delete hit;
1364 if(zPos==-1||zPos==-2) continue;
1365 vec_l_Calcu_Left.push_back(l_Calcu_Left);
1366 vec_l_Calcu_Right.push_back(l_Calcu_Right);
1367 vec_z_Calcu_Left.push_back(z_Calcu_Left);
1368 vec_z_Calcu_Right.push_back(z_Calcu_Right);
1369 vec_z_Calcu.push_back(z_Calcu);
1370 vec_l_Calcu.push_back(l_Calcu_Right);
1371 vec_delta_z.push_back(delta_z);
1372 vec_delta_l.push_back(delta_l);
1373 }
1374 int nHitUseInZs=vec_delta_z.size();
1375
1376 if(m_drawTuple){
1377 for(int i=0;i<nHitUseInZs;i++){
1378 m_nHitStereo_use=vec_delta_z.size();
1379 m_lCalcuLeft[i]=vec_l_Calcu_Left[i];
1380 m_lCalcuRight[i]=vec_l_Calcu_Right[i];
1381 m_zCalcuLeft[i]=vec_z_Calcu_Left[i];
1382 m_zCalcuRight[i]=vec_z_Calcu_Right[i];
1383 m_lCalcu[i]=vec_l_Calcu[i];
1384 m_zCalcu[i]=vec_z_Calcu[i];
1385 m_delta_z[i]=vec_delta_z[i];
1386 m_delta_l[i]=vec_delta_l[i];
1387 }
1388 }
1389
1390 //ambig choose
1391 vector< vector< vector <double> > > point(2, vector< vector<double> >(2,vector<double>() ));
1392 for(int iHit=0;iHit<nHitUseInZs;iHit++){
1393 point[0][0].push_back(vec_l_Calcu_Left[iHit]);
1394 point[0][1].push_back(vec_z_Calcu_Left[iHit]);
1395 point[1][0].push_back(vec_l_Calcu_Right[iHit]);
1396 point[1][1].push_back(vec_z_Calcu_Right[iHit]);
1397 }
1398 vector<int> ambigList;
1399 if(nHitUseInZs!=0){
1400 AmbigChoose(point,nHitUseInZs,ambigList,tanl,z0);
1401 if(m_drawTuple){
1402 m_tanl_Cal=tanl;
1403 m_z0_Cal=z0;
1404 }
1405
1406 if(m_useMcInfo && m_drawTuple){
1407 int ambig_no_match_num=0;
1408 for(int iHit=0;iHit<nHitUseInZs;iHit++){
1409 if(ambigList[iHit]==0) ambigList[iHit]=1;
1410 else ambigList[iHit]=0;
1411 if(ambigList[iHit]!=m_postruth[iHit]) { m_ambig_no_match=1; ambig_no_match_num++; }
1412 }
1413 m_ambig_no_match_propotion=(double)(ambig_no_match_num)/m_nHitStereo_use;
1414 for (int iHit=0;iHit<ambigList.size();iHit++){
1415 m_amb[iHit]=ambigList[iHit];
1416 }
1417 }
1418 }
1419
1420 if(m_debug>0 && m_drawTuple){
1421 cout<<"By 3d track zs fit:"<<endl;
1422 cout<<"d0: "<<d0<<" mc : "<<m_drTruth[0]<<endl;
1423 cout<<"phi0: "<<phi0<<" mc : "<<m_phi0Truth[0]<<endl;
1424 cout<<"omega: "<<omega<<" mc : "<<m_omegaTruth[0]<<endl;
1425 cout<<"z0: "<<z0<<" mc : "<<m_dzTruth[0]<<endl;
1426 cout<<"tanl: "<<tanl<<" mc : "<<m_tanl_mc[0]<<endl;
1427 }
1428
1429 if(m_mcpar==1){
1430 d0=m_drTruth[0];
1431 phi0=m_phi0Truth[0];
1432 if(Q_iq[i_q]==-1) {phi0=m_phi0Truth[0]-3./2.*M_PI;omega=m_omegaTruth[0];}
1433 else {phi0=m_phi0Truth[0]-1./2.*M_PI;omega=-1*m_omegaTruth[0];}
1434 z0=m_dzTruth[0];
1435 tanl=m_tanl_mc[0];
1436 }
1437
1438 //-------------------------------------------5 parameter fit-----------------------
1439
1440 if(m_debug>0) cout<< "become 3d fit "<<endl;
1441 TrkExchangePar tt2(d0,phi0,omega,z0,tanl);
1442 TrkHelixMaker helixfactory;
1443 chisum =0.;
1444 newTrack2[i_q] = helixfactory.makeTrack(tt2, chisum, *m_context, m_bunchT0);
1445 vec_trk_for_clean.push_back(newTrack2[i_q]);
1446 permitFlips = true;
1447 lPickHits = m_pickHits;
1448 helixfactory.setFlipAndDrop(*newTrack2[i_q], permitFlips, lPickHits);
1449 int nDigi2 = digiToHots2(mdcDigiVec,newTrack2[i_q],vec_truthHit,vec_flt_truth,getDigiFlag,vec_slant,vec_l_Calcu,vec_flt,vec_theta_ontrack,vec_hitbeforefit,hit_to_circle2,vec_for_clean,tanl);
1450 if(m_debug>2){
1451 cout<<__FILE__<<__LINE__<<"AFTER digiToHots 3d ---------BEFORE 3d fit"<<endl;
1452 newTrack2[i_q]->printAll(std::cout);
1453 }
1454 //fit
1455 qhits2[i_q] = newTrack2[i_q]->hits();
1456 TrkErrCode err2=qhits2[i_q]->fit();
1457 newFit2[i_q] = newTrack2[i_q]->fitResult();
1458 int nActiveHit = newTrack2[i_q]->hots()->nActive();
1459 int fitSuccess_3d = 0;
1460 if (!newFit2[i_q] || (newFit2[i_q]->nActive()<5) || err2.failure()!=0) {
1461 fitSuccess_3d=0;
1462 Q_ok[i_q][1]=0;
1463 Q_Chis_3d[i_q]=-999.;
1464 if(m_debug>0){
1465 cout << "evt "<<t_eventNum<<" global 3d fit failed ";
1466 if(!newFit2[i_q]) cout<<" newfit2 point is NULL!!!" <<endl;
1467 if(newFit2[i_q]) cout <<" nAct "<<newFit2[i_q]->nActive();
1468 cout<<"ERR2 failure ="<<err2.failure()<<endl;
1469 }
1470 }else{
1471 //fit success
1472 TrkExchangePar par2 = newFit2[i_q]->helix(0.);
1473 if( abs( 1/(par2.omega()) )>0.001){
1474 fitSuccess_3d=1;
1475 Q_Chis_3d[i_q]=newFit2[i_q]->chisq();
1476 Q_ok[i_q][1]=1;
1477 if(m_debug>0) cout <<"evt "<<t_eventNum<< " global 3d fit success "<<err2.failure()<<endl;
1478 if(m_debug>2){
1479 cout<<__FILE__<<__LINE__<<"AFTER fit 3d "<<endl;
1480 newTrack2[i_q]->print(std::cout);
1481 }
1482 } else {
1483 fitSuccess_3d=0;
1484 Q_ok[i_q][1]=0;
1485 Q_Chis_3d[i_q]=-999.;
1486 if(m_debug>2) cout<<"3dfit failure of omega "<<endl;
1487 }
1488 bool badQuality = false;
1489 //yzhang add 2016-06-15
1490 //test quality of track
1491 if(fabs(Q_Chis_3d[i_q])>m_qualityFactor*m_dropTrkChi2Cut ){
1492 if(m_debug>0){
1493 std::cout<<__FILE__<<" "<<__LINE__<<" drop track by chi2 "<<Q_Chis_3d[i_q]<<" > "<<m_qualityFactor<<" * "<<m_dropTrkChi2Cut <<std::endl;
1494 }
1495 badQuality=1;
1496 }
1497 if( fabs(par2.d0())>m_qualityFactor*m_dropTrkDrCut) {
1498 if(m_debug>0){
1499 std::cout<<__FILE__<<" "<<__LINE__<<" drop track by d0 "<<par2.d0()<<" > "<<m_qualityFactor<<" * "<<m_dropTrkDrCut <<std::endl;
1500 }
1501 badQuality=1;
1502 }
1503 if( fabs(par2.z0())>m_qualityFactor*m_dropTrkDzCut) {
1504 if(m_debug>0){
1505 std::cout<<__FILE__<<" "<<__LINE__<<" drop track by z0 "<<par2.z0()<<" > "<<m_qualityFactor<<" * "<<m_dropTrkDzCut <<std::endl;
1506 }
1507 badQuality=1;
1508 }
1509 if( (fabs(Q_Chis_3d[i_q])/qhits2[i_q]->nHit()) > m_qualityFactor*m_dropTrkChi2NdfCut) {
1510 if(m_debug>0){
1511 std::cout<<__FILE__<<" "<<__LINE__<<" drop track by chi2/ndf"<<(fabs(Q_Chis_3d[i_q])/qhits2[i_q]->nHit()) <<" > "<<m_qualityFactor<<" * "<<m_dropTrkChi2NdfCut<<std::endl;
1512 }
1513 badQuality=1;
1514 }
1515 if( nActiveHit <= m_dropTrkNhitCut) {
1516 if(m_debug>0){
1517 std::cout<<__FILE__<<" "<<__LINE__<<" drop track by nhit"<<nActiveHit <<" <= "<<m_qualityFactor<<" * "<<m_dropTrkNhitCut<<std::endl;
1518 }
1519 badQuality=1;
1520 }
1521 if(badQuality) {
1522 fitSuccess_3d=0;
1523 Q_ok[i_q][1]=0;
1524 Q_Chis_3d[i_q]=-999.;
1525 if(m_debug>2) cout<<"3dfit failure of bad quality"<<endl;
1526 }
1527 //zhangy
1528 }
1529
1530 // -------------try to out put parameters---
1531 if(fitSuccess_3d==1){
1532 TrkExchangePar par2 = newFit2[i_q]->helix(0.);
1533 if(m_debug>0){
1534 cout<<"BY 3d global fit charge "<<i_q<<endl;
1535 cout<<"d0: "<<par2.d0()<<endl;
1536 cout<<"phi0: "<<par2.phi0()<<endl;
1537 cout<<"w: "<<par2.omega()<<endl;
1538 cout<<"z: "<<par2.z0()<<endl;
1539 cout<<"tanl: "<<par2.tanDip()<<endl;
1540 }
1541 r_temp=Q_iq[i_q]/par2.omega();
1542 x_cirtemp = sin(par2.phi0()) *(par2.d0()+1/par2.omega()) * -1.; //z axis verse,x_babar = -x_belle
1543 y_cirtemp = -1.*cos(par2.phi0()) *(par2.d0()+1/par2.omega()) * -1;//???
1544 if(m_debug>0) cout<<" circle after globle 3d: "<<"("<<x_cirtemp<<","<<y_cirtemp<<","<<r_temp<<")"<<endl;
1545 double pxy=-1*r_temp/333.567;
1546 double pz=pxy*par2.tanDip();
1547 double pxyz=sqrt(pxy*pxy+pz*pz);
1548
1549 Q_pt2[i_q]=fabs(pxy);
1550 Q_z[i_q]=par2.z0();
1551 Q_tanl[i_q]=par2.tanDip();
1552 } else{
1553 continue;
1554 }
1555 //------------------------------------clean-------------------------
1556
1557 for(int i=0;i<nhit;i++){
1558 int hittemp=vec_layer[i]*1000+vec_wire[i];
1559 double dist_temp=sqrt(pow( (vec_y[i]-y_cirtemp),2)+pow( (vec_x[i]-x_cirtemp),2))-r_temp;
1560 hit_to_circle3[hittemp]=dist_temp;
1561 }
1562 }
1563
1564 if(m_debug>3){
1565 cout<<"chis 2d: "<<Q_Chis_2d[0]<<" "<<Q_Chis_2d[1]<<endl;
1566 cout<<"chis 3d: "<<Q_Chis_3d[0]<<" "<<Q_Chis_3d[1]<<endl;
1567 cout<<"Z: "<<Q_z[0]<<" "<<Q_z[1]<<endl;
1568 cout<<"chis ok-: "<<Q_ok[0][0]<<" "<<Q_ok[0][1]<<endl;
1569 cout<<"chis ok+: "<<Q_ok[1][0]<<" "<<Q_ok[1][1]<<endl;
1570 }
1571
1572 int Q;
1573 int Q_judge[2]={0};
1574 if(Q_ok[0][1]==1) Q_judge[0]=1;
1575 if(Q_ok[1][1]==1) Q_judge[1]=1;
1576 if(Q_judge[0]==1&&Q_judge[1]==0) Q=-1;
1577 if(Q_judge[0]==0&&Q_judge[1]==1) Q=1;
1578 if(Q_judge[0]==1&&Q_judge[1]==1) {
1579 if(fabs(Q_z[0])>fabs(Q_z[1])) Q=1;
1580 else Q=-1;
1581 }
1582 if(Q_judge[0]==0&&Q_judge[1]==0) {Q=0; continue;}
1583 int q_choose=0;
1584 if(Q==-1) q_choose=0;
1585 if(Q== 1) q_choose=1;
1586 TrkExchangePar par_final = newFit2[q_choose]->helix(0.);
1587 if(m_debug>0){
1588 cout<<"after q choose By 3d global fit: "<<Q<<endl;
1589 cout<<"d0: "<<par_final.d0()<<endl;
1590 cout<<"phi0: "<<par_final.phi0()<<endl;
1591 cout<<"w: "<<par_final.omega()<<endl;
1592 cout<<"z: "<<par_final.z0()<<endl;
1593 cout<<"tanl: "<<par_final.tanDip()<<endl;
1594 }
1595 double pxy=-1*Q_iq[q_choose]/par_final.omega()/333.567;
1596 double pz=pxy*par_final.tanDip();
1597 double pxyz=sqrt(pxy*pxy+pz*pz);
1598
1599 if(m_debug>0) cout<<"pt2_rec: "<<pxy<<endl;
1600 if(m_drawTuple){
1601 m_pt2_rec_final[track_fit_success]=pxy;
1602 m_p_rec_final[track_fit_success]=pxyz;
1603 m_d0_final[track_fit_success]=par_final.d0();
1604 m_phi0_final[track_fit_success]=par_final.phi0();
1605 m_omega_final[track_fit_success]=par_final.omega();
1606 m_z0_final[track_fit_success]=par_final.z0();
1607 m_tanl_final[track_fit_success]=par_final.tanDip();
1608 m_Q[track_fit_success]=Q;
1609 }
1610
1611 int nfit3d=0;
1612 if(m_debug>1) cout<<" hot list:"<<endl;
1613 TrkHotList::hot_iterator hotIter2= qhits2[q_choose]->hotList().begin();
1614 while (hotIter2!=qhits2[q_choose]->hotList().end()) {
1615 int lay=((MdcHit*)(hotIter2->hit()))->layernumber();
1616 int wir=((MdcHit*)(hotIter2->hit()))->wirenumber();
1617 int hittemp=lay*1000+wir;
1618 if(m_debug>1){ cout <<"(" <<((MdcHit*)(hotIter2->hit()))->layernumber()
1619 <<","<<((MdcHit*)(hotIter2->hit()))->wirenumber()
1620 <<":"<<hotIter2->isActive()<<") ";
1621 }
1622 if( hotIter2->isActive()==1) {
1623 nfit3d++;
1624 if(track_fit_success==0) vec_hitOnTrack.push_back(hittemp); //single track
1625 }
1626 hotIter2++;
1627 }
1628 if(m_debug>0) cout<<"In 3D fit Num Of Active Hits: "<<nfit3d<<endl;
1629
1630 track_fit_success++;
1631 int choise_temp,choise_no;
1632 if(Q==-1) choise_temp=0,choise_no=1;
1633 if(Q==1) choise_temp=1,choise_no=0;
1634 vec_newTrack.push_back( newTrack2[choise_temp] );
1635 } //end loop of all track
1636
1637 for(int iTrack=0;iTrack<vec_newTrack.size();iTrack++){
1638 const TrkFit* newFit_combine = vec_newTrack[iTrack]->fitResult();
1639 TrkExchangePar par_combine= newFit_combine->helix(0.);
1640 double cx_combine=(-333.567/par_combine.omega()+par_combine.d0())*cos(par_combine.phi0());
1641 double cy_combine=(-333.567/par_combine.omega()+par_combine.d0())*sin(par_combine.phi0());
1642 double phi_combine=par_combine.phi0()-M_PI/2;
1643 double pxy_combine=1./par_combine.omega()/333.567;
1644 if(pxy_combine<0) phi_combine+=M_PI;
1645 if(phi_combine<0) phi_combine+=2*M_PI;
1646 if(phi_combine>2*M_PI) phi_combine-=2*M_PI;
1647
1648 Mytrack mytrack;
1649 mytrack.pt=pxy_combine;
1650 mytrack.charge=(int)(fabs(pxy_combine)/pxy_combine);
1651 mytrack.phi=phi_combine;
1652 mytrack.r=-333.567/par_combine.omega();
1653 mytrack.x_cir=cx_combine;
1654 mytrack.y_cir=cy_combine;
1655 mytrack.newTrack=vec_newTrack[iTrack];
1656 mytrack.use_in_tds=true;
1657 mytrack.vec_hit_on_trk=vec_hitOnTrack;
1658 // cout<<"size of hitontrk: "<<mytrack.vec_hit_on_trk.size()<<endl;
1659 vec_myTrack.push_back(mytrack);
1660
1661 }
1662
1663 std::sort(vec_myTrack.begin(),vec_myTrack.end(),compare);
1664
1665 for(int i=0;i<vec_newTrack.size();i++){
1666 Mytrack *mytrack_i=&(vec_myTrack[i]);
1667 if(mytrack_i->use_in_tds==false) continue;
1668 for(int j=i+1;j<vec_newTrack.size();j++){
1669 Mytrack *mytrack_j=&(vec_myTrack[j]);
1670 if(mytrack_j->use_in_tds==false) continue;
1671 if( fabs(mytrack_j->phi-mytrack_i->phi)<0.1 ) mytrack_j->use_in_tds=false;
1672 if(fabs(mytrack_j->r)*(1.-0.25) <= fabs(mytrack_i->r) && fabs(mytrack_i->r) <= fabs(mytrack_j->r)*(1.+0.25)){
1673 if(fabs(mytrack_j->x_cir-mytrack_i->x_cir) <= fabs(mytrack_j->r)*(0.25)&& fabs(mytrack_j->y_cir-mytrack_i->y_cir) <= fabs(mytrack_j->r)*(0.25) ){
1674 if(mytrack_j->charge==mytrack_i->charge)
1675 mytrack_j->use_in_tds=false;
1676 }
1677 }
1678 }
1679 }
1680
1681 int nTrack_tds=0;
1682 vector<Mytrack> vec_mytrack_in_tds;
1683 for(int i=0;i<track_fit_success;i++){
1684 Mytrack mytrack=vec_myTrack[i];
1685 if(mytrack.use_in_tds==false) continue;
1686 vec_mytrack_in_tds.push_back(mytrack);
1687 nTrack_tds++;
1688 }
1689
1690 if(m_drawTuple){
1691 m_trackNum_tds=nTrack_tds;
1692 m_trackNum_fit=track_fit_success;
1693 }
1694
1695 // RecMdcTrackCol::iterator iteritrk = trackList->begin();
1696 // for(;iteritrk!=trackList->end();iteritrk++){
1697 // cout<<"IN PATTSF: "<<endl;
1698 // cout<<"parameter: "<<(*iteritrk)->helix(0)<<" "<<(*iteritrk)->helix(1)<<" "<<(*iteritrk)->helix(2)<<" "<<(*iteritrk)->helix(3)<<" "<<(*iteritrk)->helix(4)<<endl;
1699 // cout<<"chi: "<<(*iteritrk)->chi2()<<" ndof: "<<(*iteritrk)->ndof()<<"nster: "<<(*iteritrk)->nster()<<endl;
1700 // }
1701
1702 //print track in pattsf with bad vertex
1703 // RecMdcTrackCol::iterator iteritrk_pattsf = vec_trackList.begin();
1704 // for(;iteritrk_pattsf!=vec_trackList.end();iteritrk_pattsf++){
1705 // cout<<"in PATTSF LOST: "<<(*iteritrk_pattsf)->helix(0)<<" "<<(*iteritrk_pattsf)->helix(1)<<" "<<(*iteritrk_pattsf)->helix(2)<<" "<<(*iteritrk_pattsf)->helix(3)<<" "<<(*iteritrk_pattsf)->helix(4)<<endl;
1706 // }
1707
1708 int outputTrk=0;
1709 int itrack=0;
1710 for(int i=0;i<nTrack_tds;i++){
1711 Mytrack mytrack=vec_mytrack_in_tds[i];
1712 const TrkFit* newFit_tds= mytrack.newTrack->fitResult();
1713 TrkExchangePar par_tds= newFit_tds->helix(0.);
1714 // cout<<"IN HOUGH: "<<endl;
1715 // cout<<" parameter: "<<par_tds.d0()<<" "<<par_tds.phi0()<<" "<<333.567*par_tds.omega()<<" "<<par_tds.z0()<<" "<<par_tds.tanDip()<<endl;
1716 // cout<<" chis: "<<newFit_tds->chisq()<<" ndof: "<<newFit_tds->nDof()<<" nMdc: "<<newFit_tds->nMdc()<<endl;
1717 double cr= 1./ par_tds.omega();
1718 double cx= sin(par_tds.phi0()) *(par_tds.d0()+1/par_tds.omega()) * -1.; //z axis verse,x_babar = -x_belle
1719 double cy= -1.*cos(par_tds.phi0()) *(par_tds.d0()+1/par_tds.omega()) * -1;//???
1720
1721 unsigned bestIndex = 0;
1722 double bestDiff = 1.0e+20;
1723 double cR, cX, cY;
1724 vector<double> a0,a1,a2,a3,a4;
1725 vector<double> zdelta;
1726 RecMdcTrackCol::iterator iteritrk = trackList->begin();
1727 int itrk=0;
1728 for(;iteritrk!=trackList->end();iteritrk++){
1729 double pt=(*iteritrk)->pxy();
1730 a0.push_back( (*iteritrk)->helix(0) );
1731 a1.push_back( (*iteritrk)->helix(1) );
1732 a2.push_back( (*iteritrk)->helix(2) );
1733 a3.push_back( (*iteritrk)->helix(3) );
1734 a4.push_back( (*iteritrk)->helix(4) );
1735 zdelta.push_back( par_tds.z0()-(*iteritrk)->helix(3) );
1736 // cout<<"IN the NEW List: "<<endl;
1737 // cout<<" parameter: "<<a0[itrk]<<" "<<a1[itrk]<<" "<<a2[itrk]<<" "<<a3[itrk]<<" "<<a4[itrk]<<endl;
1738 // cout<<" chi: "<<(*iteritrk)->chi2()<<" ndof: "<<(*iteritrk)->ndof()<<"nster: "<<(*iteritrk)->nster()<<endl;
1739 cR=(-333.567)/a2[itrk];
1740 cX=(cR+a0[itrk])*cos(a1[itrk]);
1741 cY=(cR+a0[itrk])*sin(a1[itrk]);
1742
1743 if(fabs(cr)*(1.-0.25) <= fabs(cR) && fabs(cR) <= fabs(cr)*(1.+0.25)){
1744 if(fabs(cx-cX) <= fabs(cr)*(0.25)&& fabs(cy-cY) <= fabs(cr)*(0.25) ){
1745 double diff = fabs((fabs(cr)-fabs(cR))*(cx-cX)*(cy-cY));
1746 if(diff < bestDiff){
1747 bestDiff = diff;
1748 bestIndex = itrk;
1749 }
1750 }
1751 }
1752 itrk++;
1753 }
1754
1755 if(bestDiff == 1.0e20) { if(m_debug>0) cout<<" no merge "<<endl; }
1756 else continue;
1757
1758 // TrkHitList* hitlist = mytrack.newTrack->hits();
1759 // TrkHitList::hot_iterator hotIter= hitlist->begin();
1760 // while (hotIter!=hitlist->end()) {
1761 // cout <<"(" <<((MdcHit*)(hotIter->hit()))->layernumber()
1762 // <<","<<((MdcHit*)(hotIter->hit()))->wirenumber()
1763 // <<":"<<hotIter->isActive()<<") ";
1764 //
1765 // if (hotIter->isActive()==0) hitlist->remove() ;
1766 // hotIter++;
1767 // }
1768
1769
1770 MdcTrack* mdcTrack;
1771 mdcTrack= new MdcTrack(mytrack.newTrack);
1772 vec_track_in_tds.push_back(mytrack.newTrack);
1773 int tkStat = 4;//track find by Hough set stat=4
1774 int tkId = nTdsTk + itrack;
1775 mdcTrack->storeTrack(tkId, trackList, hitList, tkStat);
1776 if(m_drawTuple) m_hitOnTrk[outputTrk]=mdcTrack->track().hots()->nActive();
1777 outputTrk++;
1778 delete mdcTrack;
1779
1780 double pxy=1/par_tds.omega()/333.567;
1781 double pz=pxy*par_tds.tanDip();
1782 double pxyz=sqrt(pxy*pxy+pz*pz);
1783 if(m_drawTuple){
1784 m_pt2_rec_tds[itrack]=pxy;
1785 m_p_rec_tds[itrack]=pxyz;
1786 m_d0_tds[itrack]=par_tds.d0();
1787 m_phi0_tds[itrack]=par_tds.phi0();
1788 m_omega_tds[itrack]=par_tds.omega();
1789 m_z0_tds[itrack]=par_tds.z0();
1790 m_tanl_tds[itrack]=par_tds.tanDip();
1791 m_Q_tds[itrack]=pxy>0?1:-1;
1792 }
1793 itrack++;
1794 }
1795 if(m_drawTuple) m_outputTrk=outputTrk;
1796 int nTdsTk_temp=trackList->size();
1797 if(m_debug>0) m_mdcPrintSvc->printRecMdcTrackCol();
1798
1799 /*
1800 m_track_use_intrk1=vec_hit_use_intrack1.size();
1801 int nNoise_intrk1=0;
1802 for(int ihit=0;ihit<vec_hit_use_intrack1.size();ihit++){
1803 int noise_yes = hit_noise.count( vec_hit_use_intrack1[ihit] );
1804 if(noise_yes==1) {nNoise_intrk1++; cout<<"noise hit in track1: "<<vec_hit_use_intrack1[ihit]<<endl;}
1805 }
1806 m_noise_intrk1=nNoise_intrk1;
1807 */
1808
1809
1810 // m_nhitdis1=vec_hit_use.size();
1811 // m_nhitdis2=vec_hitbeforefit.size();
1812 // for(int ihit=0;ihit<vec_hit_use.size();ihit++){
1813 // int hittemp=vec_hit_use[ihit];
1814 // m_hit_dis1[ihit]=hit_to_circle2[hittemp];
1815 // m_hit_dis1_3d[ihit]=hit_to_circle3[hittemp];
1816 // }
1817 // for(int ihit=0;ihit<vec_hitbeforefit.size();ihit++){
1818 // int hittemp=vec_hitbeforefit[ihit];
1819 // m_hit_dis2[ihit]=hit_to_circle2[hittemp];
1820 // m_hit_dis2_3d[ihit]=hit_to_circle3[hittemp];
1821 // }
1822
1823 for(int i=0;i<vec_for_clean.size();i++){
1824 delete vec_for_clean[i];
1825 }
1826 for(int i=0;i<vec_trk_for_clean.size();i++){
1827 //cout<<"size "<<vec_trk_for_clean.size()<<endl;
1828 //cout<<"vec_clean: "<<vec_trk_for_clean[i]<<endl;
1829 vector<TrkRecoTrk*>::iterator iterTrk =find(vec_track_in_tds.begin(),vec_track_in_tds.end(),vec_trk_for_clean[i]);
1830 if(iterTrk ==vec_track_in_tds.end() ) delete vec_trk_for_clean[i];
1831 //for(int j=0;j<vec_newTrack.size();j++) cout<<"vec_newTrack: "<<vec_newTrack[j]<<endl;
1832 }
1833 delete h1;
1834 delete h2;
1835
1836 if(m_drawTuple) ntuplehit->write();
1837 if(m_debug>0) cout<<"end event" <<endl;
1838 return StatusCode::SUCCESS;
1839}
const Int_t n
Double_t x[10]
double sin(const BesAngle a)
double cos(const BesAngle a)
ObjectVector< RecMdcHit > RecMdcHitCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
SmartRefVector< RecMdcHit > HitRefVec
**********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
bool compare(const HoughValidUpdate::Mytrack &a, const HoughValidUpdate::Mytrack &b)
#define M_PI
Definition: TConstant.h:4
const MdcGeoWire *const Wire(unsigned id)
Definition: MdcGeomSvc.cxx:768
void setCalibSvc(const MdcCalibFunSvc *calibSvc)
Definition: MdcHit.cxx:136
void setCountPropTime(const bool count)
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
void printRecMdcTrackCol() const
void storeTrack(int trackId, RecMdcTrackCol *trackList, RecMdcHitCol *hitList, int tkStat)
Definition: MdcTrack.cxx:143
virtual double chisq() const =0
virtual int nActive() const =0
virtual TrkExchangePar helix(double fltL) const =0
TrkErrCode fit()
Definition: TrkHitList.cxx:59
const TrkHotList & hotList() const
Definition: TrkHitList.cxx:51
virtual int nActive(TrkEnums::TrkViewInfo view=TrkEnums::bothView) const =0
virtual void print(std::ostream &) const
const TrkFit * fitResult() const
Definition: TrkRecoTrk.cxx:387
virtual void printAll(std::ostream &) const
bool setFlipAndDrop(TrkRecoTrk &, bool allowFlips, bool allowDrops) const
TrkRecoTrk * makeTrack(const TrkExchangePar &helix, const double chi2, const TrkContext &, double trackT0) const
uint32_t count(const node_t &list)
Definition: node.cxx:42

◆ execute() [2/2]

StatusCode HoughValidUpdate::execute ( )

◆ finalize() [1/2]

StatusCode HoughValidUpdate::finalize ( )

Definition at line 1842 of file HoughValidUpdate.cxx.

1842 {
1843 MsgStream log(msgSvc(), name());
1844 delete m_bfield ;
1845 delete m_context ;
1846 log << MSG::INFO << "in finalize()" << endreq;
1847 return StatusCode::SUCCESS;
1848}

◆ finalize() [2/2]

StatusCode HoughValidUpdate::finalize ( )

◆ initialize() [1/2]

StatusCode HoughValidUpdate::initialize ( )

Definition at line 104 of file HoughValidUpdate.cxx.

104 {
105
106 MsgStream log(msgSvc(), name());
107 log << MSG::INFO << "in initialize()" << endreq;
108
109 StatusCode sc;
110 //for(int i=0;i<43;i++) TrkHelixFitter::nSigmaCut[i] = m_helixHitsSigma[i];
111
112 IPartPropSvc* p_PartPropSvc;
113 static const bool CREATEIFNOTTHERE(true);
114 sc = service("PartPropSvc", p_PartPropSvc, CREATEIFNOTTHERE);
115 if (!sc.isSuccess() || 0 == p_PartPropSvc) {
116 log << MSG::ERROR << " Could not initialize PartPropSvc" << endreq;
117 return sc;
118 }
119 m_particleTable = p_PartPropSvc->PDT();
120
121 // RawData
122 IRawDataProviderSvc* irawDataProviderSvc;
123 sc = service ("RawDataProviderSvc", irawDataProviderSvc);
124 m_rawDataProviderSvc = dynamic_cast<RawDataProviderSvc*> (irawDataProviderSvc);
125 if ( sc.isFailure() ){
126 log << MSG::FATAL << name()<<" Could not load RawDataProviderSvc!" << endreq;
127 return StatusCode::FAILURE;
128
129 }
130
131 // Geometry
132 IMdcGeomSvc* imdcGeomSvc;
133 sc = service ("MdcGeomSvc", imdcGeomSvc);
134 m_mdcGeomSvc = dynamic_cast<MdcGeomSvc*> (imdcGeomSvc);
135 if ( sc.isFailure() ){
136 log << MSG::FATAL << "Could not load MdcGeoSvc!" << endreq;
137 return StatusCode::FAILURE;
138 }
139
140 // MdcPrintSvc
141 IMdcPrintSvc* iMdcPrintSvc;
142 sc = service ("MdcPrintSvc", iMdcPrintSvc);
143 m_mdcPrintSvc= dynamic_cast<MdcPrintSvc*> (iMdcPrintSvc);
144 if ( sc.isFailure() ){
145 log << MSG::FATAL << "Could not load MdcPrintSvc!" << endreq;
146 return StatusCode::FAILURE;
147 }
148
149 sc = service ("MagneticFieldSvc",m_pIMF);
150 if(sc!=StatusCode::SUCCESS) {
151 log << MSG::ERROR << "Unable to open Magnetic field service"<<endreq;
152 }
153 m_bfield = new BField(m_pIMF);
154 log << MSG::INFO << "field z = "<<m_bfield->bFieldNominal()<< endreq;
155
156 m_context = new TrkContextEv(m_bfield);
157
158 Pdt::readMCppTable(m_pdtFile);
159
160 //Get MdcCalibFunSvc
161 IMdcCalibFunSvc* imdcCalibSvc;
162 sc = service ("MdcCalibFunSvc", imdcCalibSvc);
163 m_mdcCalibFunSvc = dynamic_cast<MdcCalibFunSvc*>(imdcCalibSvc);
164 if ( sc.isFailure() ){
165 log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endreq;
166 return StatusCode::FAILURE;
167 }
168
169 //initialize ntuplehit
170 if(m_drawTuple){
171 NTuplePtr nt1(ntupleSvc(), "HoughValidUpdate/hit");
172 if ( nt1 ){
173 ntuplehit = nt1;
174 } else {
175 ntuplehit = ntupleSvc()->book("HoughValidUpdate/hit", CLID_ColumnWiseTuple, "hit");
176 if(ntuplehit){
177 ntuplehit->addItem("eventNum", m_eventNum);
178 ntuplehit->addItem("runNum", m_runNum);
179 ntuplehit->addItem("nHitMc", m_nHit_Mc,0, 6796);
180 ntuplehit->addItem("nHitAxialMc", m_nHitAxial_Mc);
181 ntuplehit->addItem("layerMc", m_nHit_Mc, m_layer_Mc);
182 ntuplehit->addItem("cellMc", m_nHit_Mc, m_cell_Mc);
183
184 ntuplehit->addItem("nTrkMC", m_nTrkMC,0,10);
185 ntuplehit->addItem("pidTruth", m_nTrkMC,m_pidTruth);
186 ntuplehit->addItem("costaTruth", m_nTrkMC,m_costaTruth);
187 ntuplehit->addItem("ptTruth", m_nTrkMC,m_ptTruth);
188 ntuplehit->addItem("pzTruth", m_nTrkMC,m_pzTruth);
189 ntuplehit->addItem("pTruth", m_nTrkMC,m_pTruth);
190 ntuplehit->addItem("qTruth", m_nTrkMC,m_qTruth);
191 ntuplehit->addItem("drTruth", m_nTrkMC,m_drTruth);
192 ntuplehit->addItem("phiTruth", m_nTrkMC,m_phi0Truth);
193 ntuplehit->addItem("omegaTruth", m_nTrkMC,m_omegaTruth);
194 ntuplehit->addItem("dzTruth", m_nTrkMC,m_dzTruth);
195 ntuplehit->addItem("tanlTruth", m_nTrkMC,m_tanl_mc);
196
197 ntuplehit->addItem("nHit", m_nHit,0, 6796);
198 ntuplehit->addItem("nHitDigi", m_nHitDigi);
199 ntuplehit->addItem("nHitAxial", m_nHitAxial);
200 ntuplehit->addItem("nHitStereo", m_nHitStereo);
201 ntuplehit->addItem("layer", m_nHit, m_layer);
202 ntuplehit->addItem("cell", m_nHit, m_cell);
203 ntuplehit->addItem("x_east", m_nHit, m_x_east);
204 ntuplehit->addItem("y_east", m_nHit, m_y_east);
205 ntuplehit->addItem("z_east", m_nHit, m_z_east);
206 ntuplehit->addItem("x_west", m_nHit, m_x_west);
207 ntuplehit->addItem("y_west", m_nHit, m_y_west);
208 ntuplehit->addItem("z_west", m_nHit, m_z_west);
209 ntuplehit->addItem("x", m_nHit, m_x);
210 ntuplehit->addItem("y", m_nHit, m_y);
211 ntuplehit->addItem("z", m_nHit, m_z);
212 ntuplehit->addItem("u", m_nHit, m_u);
213 ntuplehit->addItem("v", m_nHit, m_v);
214 ntuplehit->addItem("p", m_nHit, m_p);
215 ntuplehit->addItem("slant", m_nHit, m_slant);
216 ntuplehit->addItem("layerNhit", 43, m_layerNhit);
217 ntuplehit->addItem("layerMax", m_layer_max);
218 ntuplehit->addItem("l_truth", m_nHit, m_ltruth);
219 ntuplehit->addItem("z_truth", m_nHit, m_ztruth);
220 ntuplehit->addItem("z_postruth", m_nHit, m_postruth);
221 ntuplehit->addItem("digi_truth", m_nHit, m_digi_truth);
222 ntuplehit->addItem("e_delta", m_e_delta);
223 //hough map
224 ntuplehit->addItem("nCross", m_nCross, 0, 125000);
225 ntuplehit->addItem("rho", m_nCross, m_rho);
226 ntuplehit->addItem("theta", m_nCross, m_theta);
227 ntuplehit->addItem("xybinNum", m_xybinNum, 0,100000);
228 ntuplehit->addItem("xybin", m_xybinNum, m_xybin);
229 ntuplehit->addItem("xsigma", m_xsigma);
230 ntuplehit->addItem("ysigma", m_ysigma);
231
232 ntuplehit->addItem("npeak_1", m_npeak_1);
233 ntuplehit->addItem("npeak_2", m_npeak_2);
234 ntuplehit->addItem("trackFailure", m_trackFailure);
235 ntuplehit->addItem("npeak_after_tracking", m_npeak_after_tracking, 0,1000);
236 ntuplehit->addItem("nHitSelect", m_npeak_after_tracking, m_nHitSelect);
237 ntuplehit->addItem("nHitAxialSelect", m_npeak_after_tracking, m_nHitAxialSelect);
238 ntuplehit->addItem("nHitStereoSelect", m_npeak_after_tracking, m_nHitStereoSelect);
239 ntuplehit->addItem("naxiallose", m_npeak_after_tracking, m_axiallose);
240 ntuplehit->addItem("nstereolose", m_npeak_after_tracking, m_stereolose);
241
242 ntuplehit->addItem("trackNum_Mc", m_trackNum_Mc, 0,100);
243 ntuplehit->addItem("trackNum", m_trackNum, 0,100);
244 ntuplehit->addItem("trackNum_fit", m_trackNum_fit, 0,100);
245 ntuplehit->addItem("trackNum_tds", m_trackNum_tds, 0,100);
246 ntuplehit->addItem("circleCenterX", m_trackNum, m_x_circle);
247 ntuplehit->addItem("circleCenterY", m_trackNum, m_y_circle);
248 ntuplehit->addItem("circleR", m_trackNum, m_r);
249 ntuplehit->addItem("chis_pt", m_trackNum, m_chis_pt);
250 ntuplehit->addItem("pt_rec", m_trackNum, m_pt);
251
252 ntuplehit->addItem("nHitStereo_use",m_nHitStereo_use,0,1000);
253 ntuplehit->addItem("l_Calcu_Left", m_nHitStereo_use, m_lCalcuLeft);
254 ntuplehit->addItem("l_Calcu_Right", m_nHitStereo_use, m_lCalcuRight);
255 ntuplehit->addItem("z_Calcu_Left", m_nHitStereo_use, m_zCalcuLeft);
256 ntuplehit->addItem("z_Calcu_Right", m_nHitStereo_use, m_zCalcuRight);
257 ntuplehit->addItem("z_Calcu", m_nHitStereo_use, m_zCalcu);
258 ntuplehit->addItem("l_Calcu", m_nHitStereo_use, m_lCalcu);
259 ntuplehit->addItem("z_delta", m_nHitStereo_use, m_delta_z);
260 ntuplehit->addItem("l_delta", m_nHitStereo_use, m_delta_l);
261 ntuplehit->addItem("amb", m_nHitStereo_use, m_amb);
262 ntuplehit->addItem("amb_no_match", m_ambig_no_match);
263 ntuplehit->addItem("amb_no_match_pro", m_ambig_no_match_propotion);
264 ntuplehit->addItem("tanl_Cal", m_tanl_Cal);
265 ntuplehit->addItem("z0_Cal", m_z0_Cal);
266
267 ntuplehit->addItem("pt2_rec_final", m_trackNum_fit, m_pt2_rec_final);
268 ntuplehit->addItem("p_rec_final", m_trackNum_fit, m_p_rec_final);
269 ntuplehit->addItem("d0_final", m_trackNum_fit, m_d0_final);
270 ntuplehit->addItem("phi0_final", m_trackNum_fit, m_phi0_final);
271 ntuplehit->addItem("omega_final", m_trackNum_fit, m_omega_final);
272 ntuplehit->addItem("z0_final", m_trackNum_fit, m_z0_final);
273 ntuplehit->addItem("tanl_final", m_trackNum_fit, m_tanl_final);
274 ntuplehit->addItem("chis_3d_final", m_trackNum_fit, m_chis_3d_final);
275 ntuplehit->addItem("Q_final", m_trackNum_fit, m_Q);
276
277 ntuplehit->addItem("pt2_rec_tds", m_trackNum_tds, m_pt2_rec_tds);
278 ntuplehit->addItem("p_rec_tds", m_trackNum_tds, m_p_rec_tds);
279 ntuplehit->addItem("d0_tds", m_trackNum_tds, m_d0_tds);
280 ntuplehit->addItem("phi0_tds", m_trackNum_tds, m_phi0_tds);
281 ntuplehit->addItem("omega_tds", m_trackNum_tds, m_omega_tds);
282 ntuplehit->addItem("z0_tds", m_trackNum_tds, m_z0_tds);
283 ntuplehit->addItem("tanl_tds", m_trackNum_tds, m_tanl_tds);
284 ntuplehit->addItem("Q_tds", m_trackNum_tds, m_Q_tds);
285
286
287 ntuplehit->addItem("nhitdis0", m_nhitdis0, 0,2000);
288 ntuplehit->addItem("nhitdis1", m_nhitdis1, 0,2000);
289 ntuplehit->addItem("nhitdis2", m_nhitdis2, 0,2000);
290 ntuplehit->addItem("hitdis0", m_nhitdis0, m_hit_dis0);
291 ntuplehit->addItem("hitdis1", m_nhitdis1, m_hit_dis1);
292 ntuplehit->addItem("hitdis2", m_nhitdis2, m_hit_dis2);
293 ntuplehit->addItem("hitdis1_3d", m_nhitdis1, m_hit_dis1_3d);
294 ntuplehit->addItem("hitdis2_3d", m_nhitdis2, m_hit_dis2_3d);
295 ntuplehit->addItem("track_use_intrk1", m_track_use_intrk1);
296 ntuplehit->addItem("noise_intrk1", m_noise_intrk1);
297 ntuplehit->addItem("decay", m_decay);
298 ntuplehit->addItem("outputTrk", m_outputTrk, 0,100);
299 ntuplehit->addItem("hitOnTrk", m_outputTrk, m_hitOnTrk);
300
301
302 } else { log << MSG::ERROR << "Cannot book tuple HoughValidUpdate/hough" << endmsg;
303 return StatusCode::FAILURE;
304 }
305 }
306 }
307
308 if(m_debug>2) TrkHelixFitter::m_debug = true;
309
310 return StatusCode::SUCCESS;
311
312
313}
static void readMCppTable(std::string filenm)

◆ initialize() [2/2]

StatusCode HoughValidUpdate::initialize ( )

The documentation for this class was generated from the following files: