13 |
void dotrack_(int*, double*, double*, double*, double*, int*); |
void dotrack_(int*, double*, double*, double*, double*, int*); |
14 |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
15 |
// int readb_(const char*); |
// int readb_(const char*); |
16 |
int readb_(); |
// int readb_(); |
17 |
void mini2_(int*,int*,int*); |
void mini2_(int*,int*,int*); |
18 |
void guess_(); |
void guess_(); |
19 |
|
void gufld_(float*, float*); |
20 |
} |
} |
21 |
|
|
22 |
//-------------------------------------- |
//-------------------------------------- |
23 |
// |
// |
24 |
// |
// |
51 |
}; |
}; |
52 |
clx = 0; |
clx = 0; |
53 |
cly = 0; |
cly = 0; |
54 |
|
// clx = new TRefArray(6,0); //forse causa memory leak??? |
55 |
|
// cly = new TRefArray(6,0); //forse causa memory leak??? |
56 |
}; |
}; |
57 |
//-------------------------------------- |
//-------------------------------------- |
58 |
// |
// |
83 |
dedx_x[ip] = t.dedx_x[ip]; |
dedx_x[ip] = t.dedx_x[ip]; |
84 |
dedx_y[ip] = t.dedx_y[ip]; |
dedx_y[ip] = t.dedx_y[ip]; |
85 |
}; |
}; |
86 |
clx = new TRefArray(*(t.clx)); |
clx = 0; |
87 |
cly = new TRefArray(*(t.cly)); |
cly = 0; |
88 |
|
if(t.clx)clx = new TRefArray(*(t.clx)); |
89 |
|
if(t.cly)cly = new TRefArray(*(t.cly)); |
90 |
|
|
91 |
}; |
}; |
92 |
//-------------------------------------- |
//-------------------------------------- |
145 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
146 |
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
147 |
|
|
148 |
|
TrkParams::Load(1); |
149 |
|
if( !TrkParams::IsLoaded(1) ){ |
150 |
|
cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
151 |
|
return 0; |
152 |
|
} |
153 |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
154 |
|
|
155 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
189 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
190 |
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
191 |
|
|
192 |
|
TrkParams::Load(1); |
193 |
|
if( !TrkParams::IsLoaded(1) ){ |
194 |
|
cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
195 |
|
return 0; |
196 |
|
} |
197 |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
198 |
|
|
199 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
298 |
*/ |
*/ |
299 |
void TrkTrack::LoadField(TString path){ |
void TrkTrack::LoadField(TString path){ |
300 |
|
|
301 |
strcpy(path_.path,path.Data()); |
// strcpy(path_.path,path.Data()); |
302 |
path_.pathlen = path.Length(); |
// path_.pathlen = path.Length(); |
303 |
path_.error = 0; |
// path_.error = 0; |
304 |
readb_(); |
// readb_(); |
305 |
|
|
306 |
|
TrkParams::Set(path,1); |
307 |
|
TrkParams::Load(1); |
308 |
|
|
309 |
}; |
}; |
310 |
|
|
311 |
|
|
312 |
/** |
/** |
313 |
* Method to fill minimization-routine common |
* Method to fill minimization-routine common |
314 |
*/ |
*/ |
369 |
axv[i] = track->axv[i]; |
axv[i] = track->axv[i]; |
370 |
ayv[i] = track->ayv[i]; |
ayv[i] = track->ayv[i]; |
371 |
} |
} |
|
|
|
372 |
|
|
373 |
} |
} |
374 |
/** |
/** |
400 |
|
|
401 |
// ------------------------------------------ |
// ------------------------------------------ |
402 |
// call mini routine |
// call mini routine |
403 |
|
TrkParams::Load(1); |
404 |
|
if( !TrkParams::IsLoaded(1) ){ |
405 |
|
cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
406 |
|
return; |
407 |
|
} |
408 |
int istep=0; |
int istep=0; |
409 |
int ifail=0; |
int ifail=0; |
410 |
mini2_(&istep,&ifail, &iprint); |
mini2_(&istep,&ifail, &iprint); |
451 |
for(int j=0; j<5; j++) coval[i][j]=0.; |
for(int j=0; j<5; j++) coval[i][j]=0.; |
452 |
} |
} |
453 |
} |
} |
454 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
455 |
|
extern cMini2track track_; |
456 |
|
track_.trackmode = trackmode; |
457 |
|
} |
458 |
|
|
459 |
|
|
460 |
|
/* |
461 |
|
* Method to retrieve the X-view clusters associated to the track. |
462 |
|
* @param ip Tracker plane (0-5) |
463 |
|
*/ |
464 |
|
TrkCluster *TrkTrack::GetClusterX(int ip){ |
465 |
|
cout << " TrkCluster *TrkTrack::GetClusterX(int ip) -- momentaneamente fuori servizio --"<< endl; |
466 |
|
if(!clx)return NULL; |
467 |
|
TrkCluster *pt = (TrkCluster*)(clx->At(ip)); |
468 |
|
return pt; |
469 |
|
}; |
470 |
|
/* |
471 |
|
* Method to retrieve the Y-view clusters associated to the track. |
472 |
|
* @param ip Tracker plane (0-5) |
473 |
|
*/ |
474 |
|
TrkCluster *TrkTrack::GetClusterY(int ip){ |
475 |
|
cout << " TrkCluster *TrkTrack::GetClusterY(int ip) -- momentaneamente fuori servizio --"<< endl; |
476 |
|
if(!cly)return NULL; |
477 |
|
TrkCluster *pt = (TrkCluster*)(cly->At(ip)); |
478 |
|
return pt; |
479 |
|
}; |
480 |
|
|
481 |
|
|
482 |
//-------------------------------------- |
//-------------------------------------- |
483 |
// |
// |
582 |
// |
// |
583 |
//-------------------------------------- |
//-------------------------------------- |
584 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
585 |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
586 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
587 |
good[i] = -1; |
good[i] = -1; |
588 |
}; |
}; |
589 |
// Track = new TClonesArray("TrkTrack"); |
// okkio!! memory-leak |
590 |
// SingletX = new TClonesArray("TrkSinglet"); |
// Track = new TClonesArray("TrkTrack"); |
591 |
// SingletY = new TClonesArray("TrkSinglet"); |
// SingletX = new TClonesArray("TrkSinglet"); |
592 |
|
// SingletY = new TClonesArray("TrkSinglet"); |
593 |
Track = 0; |
Track = 0; |
594 |
SingletX = 0; |
SingletX = 0; |
595 |
SingletY = 0; |
SingletY = 0; |
599 |
// |
// |
600 |
// |
// |
601 |
//-------------------------------------- |
//-------------------------------------- |
602 |
|
void TrkLevel2::Set(){ |
603 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
604 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
605 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
606 |
|
} |
607 |
|
//-------------------------------------- |
608 |
|
// |
609 |
|
// |
610 |
|
//-------------------------------------- |
611 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
612 |
|
|
613 |
// |
// |
642 |
/** |
/** |
643 |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
644 |
*/ |
*/ |
645 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
// void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
646 |
|
|
647 |
|
// // temporary objects: |
648 |
|
// TrkSinglet* t_singlet = new TrkSinglet(); |
649 |
|
// TrkTrack* t_track = new TrkTrack(); |
650 |
|
|
651 |
|
// // **** general variables **** |
652 |
|
// // good2 = l2->good2; |
653 |
|
// for(Int_t i=0; i<12 ; i++){ |
654 |
|
// // crc[i] = l2->crc[i]; |
655 |
|
// good[i] = l2->good[i]; |
656 |
|
// }; |
657 |
|
// // *** TRACKS *** |
658 |
|
// if(!Track) Track = new TClonesArray("TrkTrack"); |
659 |
|
// TClonesArray &t = *Track; |
660 |
|
// for(int i=0; i<l2->ntrk; i++){ |
661 |
|
// t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
662 |
|
// t_track->image = l2->image[i]-1; |
663 |
|
// // cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
664 |
|
// t_track->chi2 = l2->chi2_nt[i]; |
665 |
|
// t_track->nstep = l2->nstep_nt[i]; |
666 |
|
// for(int it1=0;it1<5;it1++){ |
667 |
|
// t_track->al[it1] = l2->al_nt[i][it1]; |
668 |
|
// for(int it2=0;it2<5;it2++) |
669 |
|
// t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
670 |
|
// }; |
671 |
|
// for(int ip=0;ip<6;ip++){ |
672 |
|
// t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
673 |
|
// t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
674 |
|
// t_track->xm[ip] = l2->xm_nt[i][ip]; |
675 |
|
// t_track->ym[ip] = l2->ym_nt[i][ip]; |
676 |
|
// t_track->zm[ip] = l2->zm_nt[i][ip]; |
677 |
|
// t_track->resx[ip] = l2->resx_nt[i][ip]; |
678 |
|
// t_track->resy[ip] = l2->resy_nt[i][ip]; |
679 |
|
// t_track->xv[ip] = l2->xv_nt[i][ip]; |
680 |
|
// t_track->yv[ip] = l2->yv_nt[i][ip]; |
681 |
|
// t_track->zv[ip] = l2->zv_nt[i][ip]; |
682 |
|
// t_track->axv[ip] = l2->axv_nt[i][ip]; |
683 |
|
// t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
684 |
|
// t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
685 |
|
// t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
686 |
|
// // t_track->clx[ip] = 0; |
687 |
|
// // t_track->cly[ip] = 0; |
688 |
|
// }; |
689 |
|
// new(t[i]) TrkTrack(*t_track); |
690 |
|
// t_track->Clear(); |
691 |
|
// }; |
692 |
|
// // *** SINGLETS *** |
693 |
|
// if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
694 |
|
// TClonesArray &sx = *SingletX; |
695 |
|
// for(int i=0; i<l2->nclsx; i++){ |
696 |
|
// t_singlet->plane = l2->planex[i]; |
697 |
|
// t_singlet->coord[0] = l2->xs[i][0]; |
698 |
|
// t_singlet->coord[1] = l2->xs[i][1]; |
699 |
|
// t_singlet->sgnl = l2->signlxs[i]; |
700 |
|
// // t_singlet->cls = 0; |
701 |
|
// new(sx[i]) TrkSinglet(*t_singlet); |
702 |
|
// t_singlet->Clear(); |
703 |
|
// } |
704 |
|
// if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
705 |
|
// TClonesArray &sy = *SingletY; |
706 |
|
// for(int i=0; i<l2->nclsy; i++){ |
707 |
|
// t_singlet->plane = l2->planey[i]; |
708 |
|
// t_singlet->coord[0] = l2->ys[i][0]; |
709 |
|
// t_singlet->coord[1] = l2->ys[i][1]; |
710 |
|
// t_singlet->sgnl = l2->signlys[i]; |
711 |
|
// // t_singlet->cls = 0; |
712 |
|
// new(sy[i]) TrkSinglet(*t_singlet); |
713 |
|
// t_singlet->Clear(); |
714 |
|
// }; |
715 |
|
|
716 |
|
// delete t_track; |
717 |
|
// delete t_singlet; |
718 |
|
// } |
719 |
|
//-------------------------------------- |
720 |
|
// |
721 |
|
// |
722 |
|
//-------------------------------------- |
723 |
|
/** |
724 |
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
725 |
|
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
726 |
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
727 |
|
*/ |
728 |
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
729 |
|
|
730 |
// temporary objects: |
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
731 |
|
Clear(); |
732 |
|
// temporary objects: |
733 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
734 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
735 |
|
|
736 |
// **** general variables **** |
// ----------------- |
737 |
// good2 = l2->good2; |
// general variables |
738 |
|
// ----------------- |
739 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
740 |
// crc[i] = l2->crc[i]; |
good[i] = l2->good[i]; |
741 |
good[i] = l2->good[i]; |
}; |
742 |
}; |
// -------------- |
743 |
// *** TRACKS *** |
// *** TRACKS *** |
744 |
|
// -------------- |
745 |
if(!Track) Track = new TClonesArray("TrkTrack"); |
if(!Track) Track = new TClonesArray("TrkTrack"); |
746 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
747 |
|
//----------------------------------------------------- |
748 |
|
if( l1 && !t_track->clx )t_track->clx = new TRefArray(6,0); |
749 |
|
if( l1 && !t_track->cly )t_track->cly = new TRefArray(6,0); |
750 |
|
//----------------------------------------------------- |
751 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
752 |
|
// cout <<" TRACK "<<i<<" ------------------ "<<endl; |
753 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
754 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
|
755 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
756 |
t_track->nstep = l2->nstep_nt[i]; |
t_track->nstep = l2->nstep_nt[i]; |
757 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
760 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
761 |
}; |
}; |
762 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
763 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
t_track->xgood[ip] = l2->cltrx[i][ip];//l2->xgood_nt[i][ip]; |
764 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
t_track->ygood[ip] = l2->cltry[i][ip];//l2->ygood_nt[i][ip]; |
765 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
766 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
767 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
774 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
775 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
776 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
777 |
// t_track->clx[ip] = 0; |
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<endl; |
778 |
// t_track->cly[ip] = 0; |
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<endl; |
779 |
|
//----------------------------------------------------- |
780 |
|
//----------------------------------------------------- |
781 |
|
// if(l1 && t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
782 |
|
// if(l1 && t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
783 |
|
if(l2->xgood_nt[i][ip]){ |
784 |
|
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<endl; |
785 |
|
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<" "; |
786 |
|
// if( l1->GetCluster(l2->cltrx[i][ip]-1)->TestBit(l1->GetCluster(l2->cltrx[i][ip]-1)->kIsReferenced) )cout << ">> is referenced "; |
787 |
|
if(l1)t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
788 |
|
// cout << " --- "<<l1->GetCluster(l2->cltrx[i][ip]-1)->GetUniqueID()<<endl; |
789 |
|
// t_track->xgood[ip] = l2->cltrx[i][ip]; // WORK-AROUND ***** |
790 |
|
}else{ |
791 |
|
if(l1)t_track->clx->RemoveAt(ip); |
792 |
|
} |
793 |
|
if(l2->ygood_nt[i][ip]){ |
794 |
|
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<endl; |
795 |
|
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<" "; |
796 |
|
// if( l1->GetCluster(l2->cltry[i][ip]-1)->TestBit(l1->GetCluster(l2->cltry[i][ip]-1)->kIsReferenced) )cout << ">> is referenced "; |
797 |
|
if(l1)t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
798 |
|
// cout << " --- "<<l1->GetCluster(l2->cltry[i][ip]-1)->GetUniqueID()<<endl; |
799 |
|
// t_track->ygood[ip] = l2->cltry[i][ip]; // WORK-AROUND ***** |
800 |
|
}else{ |
801 |
|
if(l1)t_track->cly->RemoveAt(ip); |
802 |
|
} |
803 |
|
//----------------------------------------------------- |
804 |
|
//----------------------------------------------------- |
805 |
}; |
}; |
806 |
new(t[i]) TrkTrack(*t_track); |
new(t[i]) TrkTrack(*t_track); |
807 |
t_track->Clear(); |
t_track->Clear(); |
808 |
}; |
}; |
809 |
|
// ---------------- |
810 |
// *** SINGLETS *** |
// *** SINGLETS *** |
811 |
|
// ---------------- |
812 |
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
813 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
814 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
816 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
817 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
818 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
819 |
// t_singlet->cls = 0; |
//----------------------------------------------------- |
820 |
|
if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
821 |
|
//----------------------------------------------------- |
822 |
new(sx[i]) TrkSinglet(*t_singlet); |
new(sx[i]) TrkSinglet(*t_singlet); |
823 |
t_singlet->Clear(); |
t_singlet->Clear(); |
824 |
} |
} |
829 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
830 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
831 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
832 |
// t_singlet->cls = 0; |
//----------------------------------------------------- |
833 |
|
if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
834 |
|
//----------------------------------------------------- |
835 |
new(sy[i]) TrkSinglet(*t_singlet); |
new(sy[i]) TrkSinglet(*t_singlet); |
836 |
t_singlet->Clear(); |
t_singlet->Clear(); |
837 |
}; |
}; |
839 |
delete t_track; |
delete t_track; |
840 |
delete t_singlet; |
delete t_singlet; |
841 |
} |
} |
|
//-------------------------------------- |
|
|
// |
|
|
// |
|
|
//-------------------------------------- |
|
|
/** |
|
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
|
|
* Ref to Level1 data (clusters) is also set. |
|
|
*/ |
|
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
|
|
|
|
|
// temporary objects: |
|
|
TrkSinglet* t_singlet = new TrkSinglet(); |
|
|
TrkTrack* t_track = new TrkTrack(); |
|
|
// general variables |
|
|
// good2 = l2->good2; |
|
|
for(Int_t i=0; i<12 ; i++){ |
|
|
// crc[i] = l2->crc[i]; |
|
|
good[i] = l2->good[i]; |
|
|
}; |
|
|
// *** TRACKS *** |
|
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
|
|
TClonesArray &t = *Track; |
|
|
if(!t_track->clx)t_track->clx = new TRefArray(6,0); |
|
|
if(!t_track->cly)t_track->cly = new TRefArray(6,0); |
|
|
for(int i=0; i<l2->ntrk; i++){ |
|
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
|
|
t_track->image = l2->image[i]-1; |
|
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
|
|
t_track->chi2 = l2->chi2_nt[i]; |
|
|
t_track->nstep = l2->nstep_nt[i]; |
|
|
for(int it1=0;it1<5;it1++){ |
|
|
t_track->al[it1] = l2->al_nt[i][it1]; |
|
|
for(int it2=0;it2<5;it2++) |
|
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
|
|
}; |
|
|
for(int ip=0;ip<6;ip++){ |
|
|
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
|
|
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
|
|
t_track->xm[ip] = l2->xm_nt[i][ip]; |
|
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
|
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
|
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
|
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
|
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
|
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
|
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
|
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
|
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
|
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
|
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
|
|
// cout << "traccia "<<i<<" -- "<< ip << " "<< l2->cltrx[i][ip] <<" "<< l2->cltry[i][ip] <<" "<< t_track->xgood[ip] << t_track->ygood[ip]<<endl; |
|
|
//----------------------------------------------------- |
|
|
//----------------------------------------------------- |
|
|
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
|
|
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
|
|
// if(t_track->ygood[ip])cout<<" i "<<i<<" ip "<<ip<<" l2->cltry[i][ip] "<<l2->cltry[i][ip]<< " l1->GetCluster(l2->cltry[i][ip]-1) "<<l1->GetCluster(l2->cltry[i][ip]-1)<<endl; |
|
|
// if(t_track->xgood[ip])cout<<" i "<<i<<" ip "<<ip<<" l2->cltrx[i][ip] "<<l2->cltrx[i][ip]<< " l1->GetCluster(l2->cltrx[i][ip]-1) "<<l1->GetCluster(l2->cltrx[i][ip]-1)<<endl; |
|
|
//----------------------------------------------------- |
|
|
//----------------------------------------------------- |
|
|
}; |
|
|
new(t[i]) TrkTrack(*t_track); |
|
|
t_track->Clear(); |
|
|
}; |
|
|
// *** SINGLETS *** |
|
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
|
|
TClonesArray &sx = *SingletX; |
|
|
for(int i=0; i<l2->nclsx; i++){ |
|
|
t_singlet->plane = l2->planex[i]; |
|
|
t_singlet->coord[0] = l2->xs[i][0]; |
|
|
t_singlet->coord[1] = l2->xs[i][1]; |
|
|
t_singlet->sgnl = l2->signlxs[i]; |
|
|
//----------------------------------------------------- |
|
|
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
|
|
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
|
|
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
|
|
//----------------------------------------------------- |
|
|
new(sx[i]) TrkSinglet(*t_singlet); |
|
|
t_singlet->Clear(); |
|
|
} |
|
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
|
|
TClonesArray &sy = *SingletY; |
|
|
for(int i=0; i<l2->nclsy; i++){ |
|
|
t_singlet->plane = l2->planey[i]; |
|
|
t_singlet->coord[0] = l2->ys[i][0]; |
|
|
t_singlet->coord[1] = l2->ys[i][1]; |
|
|
t_singlet->sgnl = l2->signlys[i]; |
|
|
//----------------------------------------------------- |
|
|
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
|
|
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
|
|
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
|
|
//----------------------------------------------------- |
|
|
new(sy[i]) TrkSinglet(*t_singlet); |
|
|
t_singlet->Clear(); |
|
|
}; |
|
|
|
|
|
delete t_track; |
|
|
delete t_singlet; |
|
|
} |
|
842 |
/** |
/** |
843 |
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
844 |
*/ |
*/ |
953 |
|
|
954 |
int indo=0; |
int indo=0; |
955 |
int indi=0; |
int indi=0; |
956 |
while(N != 0){ |
while(N > 0){ |
957 |
|
// while(N != 0){ |
958 |
int nfit =0; |
int nfit =0; |
959 |
float chi2ref = numeric_limits<float>::max(); |
float chi2ref = numeric_limits<float>::max(); |
960 |
|
|
965 |
} |
} |
966 |
} |
} |
967 |
//second loop to search minimum chi2 among selected |
//second loop to search minimum chi2 among selected |
968 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i<ntrk(); i++){ |
969 |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
970 |
if(chi2 < 0) chi2 = chi2*1000; |
if(chi2 < 0) chi2 = -chi2*1000; |
971 |
if( chi2 < chi2ref |
if( chi2 < chi2ref |
972 |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
973 |
&& m[i]==1){ |
&& m[i]==1){ |
979 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
980 |
N--; |
N--; |
981 |
|
|
982 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
983 |
}; |
}; |
984 |
sorted->Add( (TrkTrack*)t[indi] ); |
sorted->Add( (TrkTrack*)t[indi] ); |
985 |
|
|
986 |
m[indi] = 0; |
m[indi] = 0; |
987 |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
988 |
N--; |
N--; |
989 |
indo++; |
indo++; |
990 |
} |
} |
991 |
m.clear(); |
m.clear(); |
992 |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
993 |
|
|
994 |
return sorted; |
return sorted; |
995 |
// return PhysicalTrack; |
// return PhysicalTrack; |
1139 |
*/ |
*/ |
1140 |
void TrkLevel2::LoadField(TString path){ |
void TrkLevel2::LoadField(TString path){ |
1141 |
// |
// |
1142 |
strcpy(path_.path,path.Data()); |
// strcpy(path_.path,path.Data()); |
1143 |
path_.pathlen = path.Length(); |
// path_.pathlen = path.Length(); |
1144 |
path_.error = 0; |
// path_.error = 0; |
1145 |
readb_(); |
// readb_(); |
1146 |
|
|
1147 |
|
TrkParams::Set(path,1); |
1148 |
|
TrkParams::Load(1); |
1149 |
|
|
1150 |
// |
// |
1151 |
}; |
}; |
1152 |
|
/** |
1153 |
|
* Get BY (kGauss) |
1154 |
|
* @param v (x,y,z) coordinates in cm |
1155 |
|
*/ |
1156 |
|
float TrkLevel2::GetBX(float* v){ |
1157 |
|
float b[3]; |
1158 |
|
gufld_(v,b); |
1159 |
|
return b[0]/10.; |
1160 |
|
} |
1161 |
|
/** |
1162 |
|
* Get BY (kGauss) |
1163 |
|
* @param v (x,y,z) coordinates in cm |
1164 |
|
*/ |
1165 |
|
float TrkLevel2::GetBY(float* v){ |
1166 |
|
float b[3]; |
1167 |
|
gufld_(v,b); |
1168 |
|
return b[1]/10.; |
1169 |
|
} |
1170 |
|
/** |
1171 |
|
* Get BY (kGauss) |
1172 |
|
* @param v (x,y,z) coordinates in cm |
1173 |
|
*/ |
1174 |
|
float TrkLevel2::GetBZ(float* v){ |
1175 |
|
float b[3]; |
1176 |
|
gufld_(v,b); |
1177 |
|
return b[2]/10.; |
1178 |
|
} |
1179 |
//-------------------------------------- |
//-------------------------------------- |
1180 |
// |
// |
1181 |
// |
// |
1353 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1354 |
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1355 |
|
|
1356 |
|
TrkParams::Load(1); |
1357 |
|
if( !TrkParams::IsLoaded(1) ){ |
1358 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
1359 |
|
return 0; |
1360 |
|
} |
1361 |
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1362 |
|
|
1363 |
for (int i=0; i<npoint; i++){ |
for (int i=0; i<npoint; i++){ |