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); |
// clx = new TRefArray(6,0); //forse causa memory leak??? |
55 |
// cly = new TRefArray(6,0); |
// cly = new TRefArray(6,0); //forse causa memory leak??? |
56 |
}; |
}; |
57 |
//-------------------------------------- |
//-------------------------------------- |
58 |
// |
// |
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++){ |
235 |
// |
// |
236 |
Float_t TrkTrack::GetDEDX(){ |
Float_t TrkTrack::GetDEDX(){ |
237 |
Float_t dedx=0; |
Float_t dedx=0; |
238 |
for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i]; |
// for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i]; |
239 |
|
for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*XGood(i)+dedx_y[i]*YGood(i); |
240 |
dedx = dedx/(this->GetNX()+this->GetNY()); |
dedx = dedx/(this->GetNX()+this->GetNY()); |
241 |
return dedx; |
return dedx; |
242 |
}; |
}; |
252 |
cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; |
cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; |
253 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
254 |
cout << endl << "n.step : "<< nstep; |
cout << endl << "n.step : "<< nstep; |
255 |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << XGood(i) ; |
256 |
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << ygood[i] ; |
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << YGood(i) ; |
257 |
cout << endl << "xm : "; for(int i=0; i<6; i++)cout << xm[i] << " "; |
cout << endl << "xm : "; for(int i=0; i<6; i++)cout << xm[i] << " "; |
258 |
cout << endl << "ym : "; for(int i=0; i<6; i++)cout << ym[i] << " "; |
cout << endl << "ym : "; for(int i=0; i<6; i++)cout << ym[i] << " "; |
259 |
cout << endl << "zm : "; for(int i=0; i<6; i++)cout << zm[i] << " "; |
cout << endl << "zm : "; for(int i=0; i<6; i++)cout << zm[i] << " "; |
290 |
* Set the TrkTrack good measurement |
* Set the TrkTrack good measurement |
291 |
*/ |
*/ |
292 |
void TrkTrack::SetGood(int *xg, int *yg){ |
void TrkTrack::SetGood(int *xg, int *yg){ |
293 |
|
// NB! si perdera` l'informazione sul numero del cluster |
294 |
for(int i=0; i<6; i++) xgood[i]=*xg++; |
for(int i=0; i<6; i++) xgood[i]=*xg++; |
295 |
for(int i=0; i<6; i++) ygood[i]=*yg++; |
for(int i=0; i<6; i++) ygood[i]=*yg++; |
296 |
} |
} |
300 |
*/ |
*/ |
301 |
void TrkTrack::LoadField(TString path){ |
void TrkTrack::LoadField(TString path){ |
302 |
|
|
303 |
strcpy(path_.path,path.Data()); |
// strcpy(path_.path,path.Data()); |
304 |
path_.pathlen = path.Length(); |
// path_.pathlen = path.Length(); |
305 |
path_.error = 0; |
// path_.error = 0; |
306 |
readb_(); |
// readb_(); |
307 |
|
|
308 |
|
TrkParams::Set(path,1); |
309 |
|
TrkParams::Load(1); |
310 |
|
|
311 |
}; |
}; |
312 |
|
|
313 |
|
|
314 |
/** |
/** |
315 |
* Method to fill minimization-routine common |
* Method to fill minimization-routine common |
316 |
*/ |
*/ |
318 |
|
|
319 |
for(int i=0; i<6; i++){ |
for(int i=0; i<6; i++){ |
320 |
|
|
321 |
track.xgood[i]=xgood[i]; |
// track.xgood[i]=xgood[i]; |
322 |
track.ygood[i]=ygood[i]; |
// track.ygood[i]=ygood[i]; |
323 |
|
track.xgood[i]=XGood(i); |
324 |
|
track.ygood[i]=YGood(i); |
325 |
|
|
326 |
track.xm[i]=xm[i]; |
track.xm[i]=xm[i]; |
327 |
track.ym[i]=ym[i]; |
track.ym[i]=ym[i]; |
334 |
track.xm_b[i]=xm[i]; |
track.xm_b[i]=xm[i]; |
335 |
track.ym_a[i]=ym[i]; |
track.ym_a[i]=ym[i]; |
336 |
track.ym_b[i]=ym[i]; |
track.ym_b[i]=ym[i]; |
337 |
if( xgood[i] && !ygood[i] ){ |
if( XGood(i) && !YGood(i) ){ |
338 |
track.ym_a[i] = track.ym_a[i]+segment; |
track.ym_a[i] = track.ym_a[i]+segment; |
339 |
track.ym_b[i] = track.ym_b[i]-segment; |
track.ym_b[i] = track.ym_b[i]-segment; |
340 |
}else if( !xgood[i] && ygood[i]){ |
}else if( !XGood(i) && YGood(i)){ |
341 |
track.xm_a[i] = track.xm_a[i]+segment; |
track.xm_a[i] = track.xm_a[i]+segment; |
342 |
track.xm_b[i] = track.xm_b[i]-segment; |
track.xm_b[i] = track.xm_b[i]-segment; |
343 |
} |
} |
373 |
axv[i] = track->axv[i]; |
axv[i] = track->axv[i]; |
374 |
ayv[i] = track->ayv[i]; |
ayv[i] = track->ayv[i]; |
375 |
} |
} |
|
|
|
376 |
|
|
377 |
} |
} |
378 |
/** |
/** |
404 |
|
|
405 |
// ------------------------------------------ |
// ------------------------------------------ |
406 |
// call mini routine |
// call mini routine |
407 |
|
TrkParams::Load(1); |
408 |
|
if( !TrkParams::IsLoaded(1) ){ |
409 |
|
cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
410 |
|
return; |
411 |
|
} |
412 |
int istep=0; |
int istep=0; |
413 |
int ifail=0; |
int ifail=0; |
414 |
mini2_(&istep,&ifail, &iprint); |
mini2_(&istep,&ifail, &iprint); |
455 |
for(int j=0; j<5; j++) coval[i][j]=0.; |
for(int j=0; j<5; j++) coval[i][j]=0.; |
456 |
} |
} |
457 |
} |
} |
458 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
459 |
|
extern cMini2track track_; |
460 |
|
track_.trackmode = trackmode; |
461 |
|
} |
462 |
|
|
463 |
|
|
464 |
|
/* |
465 |
|
* Method to retrieve the X-view clusters associated to the track. |
466 |
|
* @param ip Tracker plane (0-5) |
467 |
|
*/ |
468 |
|
TrkCluster *TrkTrack::GetClusterX(int ip){ |
469 |
|
cout << " TrkCluster *TrkTrack::GetClusterX(int ip) -- momentaneamente fuori servizio --"<< endl; |
470 |
|
if(!clx)return NULL; |
471 |
|
TrkCluster *pt = (TrkCluster*)(clx->At(ip)); |
472 |
|
return pt; |
473 |
|
}; |
474 |
|
/* |
475 |
|
* Method to retrieve the Y-view clusters associated to the track. |
476 |
|
* @param ip Tracker plane (0-5) |
477 |
|
*/ |
478 |
|
TrkCluster *TrkTrack::GetClusterY(int ip){ |
479 |
|
cout << " TrkCluster *TrkTrack::GetClusterY(int ip) -- momentaneamente fuori servizio --"<< endl; |
480 |
|
if(!cly)return NULL; |
481 |
|
TrkCluster *pt = (TrkCluster*)(cly->At(ip)); |
482 |
|
return pt; |
483 |
|
}; |
484 |
|
|
485 |
|
|
486 |
//-------------------------------------- |
//-------------------------------------- |
487 |
// |
// |
586 |
// |
// |
587 |
//-------------------------------------- |
//-------------------------------------- |
588 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
589 |
cout <<"TrkLevel2::TrkLevel2()"<<endl; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
590 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
591 |
good[i] = -1; |
good[i] = -1; |
592 |
}; |
}; |
646 |
/** |
/** |
647 |
* 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). |
648 |
*/ |
*/ |
649 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
// void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
650 |
|
|
651 |
|
// // temporary objects: |
652 |
|
// TrkSinglet* t_singlet = new TrkSinglet(); |
653 |
|
// TrkTrack* t_track = new TrkTrack(); |
654 |
|
|
655 |
|
// // **** general variables **** |
656 |
|
// // good2 = l2->good2; |
657 |
|
// for(Int_t i=0; i<12 ; i++){ |
658 |
|
// // crc[i] = l2->crc[i]; |
659 |
|
// good[i] = l2->good[i]; |
660 |
|
// }; |
661 |
|
// // *** TRACKS *** |
662 |
|
// if(!Track) Track = new TClonesArray("TrkTrack"); |
663 |
|
// TClonesArray &t = *Track; |
664 |
|
// for(int i=0; i<l2->ntrk; i++){ |
665 |
|
// t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
666 |
|
// t_track->image = l2->image[i]-1; |
667 |
|
// // cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
668 |
|
// t_track->chi2 = l2->chi2_nt[i]; |
669 |
|
// t_track->nstep = l2->nstep_nt[i]; |
670 |
|
// for(int it1=0;it1<5;it1++){ |
671 |
|
// t_track->al[it1] = l2->al_nt[i][it1]; |
672 |
|
// for(int it2=0;it2<5;it2++) |
673 |
|
// t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
674 |
|
// }; |
675 |
|
// for(int ip=0;ip<6;ip++){ |
676 |
|
// t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
677 |
|
// t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
678 |
|
// t_track->xm[ip] = l2->xm_nt[i][ip]; |
679 |
|
// t_track->ym[ip] = l2->ym_nt[i][ip]; |
680 |
|
// t_track->zm[ip] = l2->zm_nt[i][ip]; |
681 |
|
// t_track->resx[ip] = l2->resx_nt[i][ip]; |
682 |
|
// t_track->resy[ip] = l2->resy_nt[i][ip]; |
683 |
|
// t_track->xv[ip] = l2->xv_nt[i][ip]; |
684 |
|
// t_track->yv[ip] = l2->yv_nt[i][ip]; |
685 |
|
// t_track->zv[ip] = l2->zv_nt[i][ip]; |
686 |
|
// t_track->axv[ip] = l2->axv_nt[i][ip]; |
687 |
|
// t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
688 |
|
// t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
689 |
|
// t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
690 |
|
// // t_track->clx[ip] = 0; |
691 |
|
// // t_track->cly[ip] = 0; |
692 |
|
// }; |
693 |
|
// new(t[i]) TrkTrack(*t_track); |
694 |
|
// t_track->Clear(); |
695 |
|
// }; |
696 |
|
// // *** SINGLETS *** |
697 |
|
// if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
698 |
|
// TClonesArray &sx = *SingletX; |
699 |
|
// for(int i=0; i<l2->nclsx; i++){ |
700 |
|
// t_singlet->plane = l2->planex[i]; |
701 |
|
// t_singlet->coord[0] = l2->xs[i][0]; |
702 |
|
// t_singlet->coord[1] = l2->xs[i][1]; |
703 |
|
// t_singlet->sgnl = l2->signlxs[i]; |
704 |
|
// // t_singlet->cls = 0; |
705 |
|
// new(sx[i]) TrkSinglet(*t_singlet); |
706 |
|
// t_singlet->Clear(); |
707 |
|
// } |
708 |
|
// if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
709 |
|
// TClonesArray &sy = *SingletY; |
710 |
|
// for(int i=0; i<l2->nclsy; i++){ |
711 |
|
// t_singlet->plane = l2->planey[i]; |
712 |
|
// t_singlet->coord[0] = l2->ys[i][0]; |
713 |
|
// t_singlet->coord[1] = l2->ys[i][1]; |
714 |
|
// t_singlet->sgnl = l2->signlys[i]; |
715 |
|
// // t_singlet->cls = 0; |
716 |
|
// new(sy[i]) TrkSinglet(*t_singlet); |
717 |
|
// t_singlet->Clear(); |
718 |
|
// }; |
719 |
|
|
720 |
|
// delete t_track; |
721 |
|
// delete t_singlet; |
722 |
|
// } |
723 |
|
//-------------------------------------- |
724 |
|
// |
725 |
|
// |
726 |
|
//-------------------------------------- |
727 |
|
/** |
728 |
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
729 |
|
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
730 |
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
731 |
|
*/ |
732 |
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
733 |
|
|
734 |
// temporary objects: |
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
735 |
|
Clear(); |
736 |
|
// temporary objects: |
737 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
738 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
739 |
|
|
740 |
// **** general variables **** |
// ----------------- |
741 |
// good2 = l2->good2; |
// general variables |
742 |
|
// ----------------- |
743 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
744 |
// crc[i] = l2->crc[i]; |
good[i] = l2->good[i]; |
745 |
good[i] = l2->good[i]; |
}; |
746 |
}; |
// -------------- |
747 |
// *** TRACKS *** |
// *** TRACKS *** |
748 |
|
// -------------- |
749 |
if(!Track) Track = new TClonesArray("TrkTrack"); |
if(!Track) Track = new TClonesArray("TrkTrack"); |
750 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
751 |
|
//----------------------------------------------------- |
752 |
|
if( l1 && !t_track->clx )t_track->clx = new TRefArray(6,0); |
753 |
|
if( l1 && !t_track->cly )t_track->cly = new TRefArray(6,0); |
754 |
|
//----------------------------------------------------- |
755 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
756 |
|
// cout <<" TRACK "<<i<<" ------------------ "<<endl; |
757 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
758 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
|
759 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
760 |
t_track->nstep = l2->nstep_nt[i]; |
t_track->nstep = l2->nstep_nt[i]; |
761 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
764 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
765 |
}; |
}; |
766 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
767 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
t_track->xgood[ip] = l2->cltrx[i][ip];//l2->xgood_nt[i][ip]; |
768 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
t_track->ygood[ip] = l2->cltry[i][ip];//l2->ygood_nt[i][ip]; |
769 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
770 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
771 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
778 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
779 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
780 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
781 |
// t_track->clx[ip] = 0; |
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<endl; |
782 |
// t_track->cly[ip] = 0; |
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<endl; |
783 |
|
//----------------------------------------------------- |
784 |
|
//----------------------------------------------------- |
785 |
|
// if(l1 && t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
786 |
|
// if(l1 && t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
787 |
|
if(l2->xgood_nt[i][ip]){ |
788 |
|
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<endl; |
789 |
|
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<" "; |
790 |
|
// if( l1->GetCluster(l2->cltrx[i][ip]-1)->TestBit(l1->GetCluster(l2->cltrx[i][ip]-1)->kIsReferenced) )cout << ">> is referenced "; |
791 |
|
if(l1)t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
792 |
|
// cout << " --- "<<l1->GetCluster(l2->cltrx[i][ip]-1)->GetUniqueID()<<endl; |
793 |
|
// t_track->xgood[ip] = l2->cltrx[i][ip]; // WORK-AROUND ***** |
794 |
|
}else{ |
795 |
|
if(l1)t_track->clx->RemoveAt(ip); |
796 |
|
} |
797 |
|
if(l2->ygood_nt[i][ip]){ |
798 |
|
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<endl; |
799 |
|
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<" "; |
800 |
|
// if( l1->GetCluster(l2->cltry[i][ip]-1)->TestBit(l1->GetCluster(l2->cltry[i][ip]-1)->kIsReferenced) )cout << ">> is referenced "; |
801 |
|
if(l1)t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
802 |
|
// cout << " --- "<<l1->GetCluster(l2->cltry[i][ip]-1)->GetUniqueID()<<endl; |
803 |
|
// t_track->ygood[ip] = l2->cltry[i][ip]; // WORK-AROUND ***** |
804 |
|
}else{ |
805 |
|
if(l1)t_track->cly->RemoveAt(ip); |
806 |
|
} |
807 |
|
//----------------------------------------------------- |
808 |
|
//----------------------------------------------------- |
809 |
}; |
}; |
810 |
new(t[i]) TrkTrack(*t_track); |
new(t[i]) TrkTrack(*t_track); |
811 |
t_track->Clear(); |
t_track->Clear(); |
812 |
}; |
}; |
813 |
|
// ---------------- |
814 |
// *** SINGLETS *** |
// *** SINGLETS *** |
815 |
|
// ---------------- |
816 |
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
817 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
818 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
820 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
821 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
822 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
823 |
// t_singlet->cls = 0; |
//----------------------------------------------------- |
824 |
|
if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
825 |
|
//----------------------------------------------------- |
826 |
new(sx[i]) TrkSinglet(*t_singlet); |
new(sx[i]) TrkSinglet(*t_singlet); |
827 |
t_singlet->Clear(); |
t_singlet->Clear(); |
828 |
} |
} |
833 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
834 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
835 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
836 |
// t_singlet->cls = 0; |
//----------------------------------------------------- |
837 |
|
if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
838 |
|
//----------------------------------------------------- |
839 |
new(sy[i]) TrkSinglet(*t_singlet); |
new(sy[i]) TrkSinglet(*t_singlet); |
840 |
t_singlet->Clear(); |
t_singlet->Clear(); |
841 |
}; |
}; |
843 |
delete t_track; |
delete t_track; |
844 |
delete t_singlet; |
delete t_singlet; |
845 |
} |
} |
|
//-------------------------------------- |
|
|
// |
|
|
// |
|
|
//-------------------------------------- |
|
|
/** |
|
|
* 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; |
|
|
} |
|
846 |
/** |
/** |
847 |
* 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). |
848 |
*/ |
*/ |
869 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
870 |
}; |
}; |
871 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
872 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip); |
873 |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip); |
874 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
875 |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
876 |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
957 |
|
|
958 |
int indo=0; |
int indo=0; |
959 |
int indi=0; |
int indi=0; |
960 |
while(N != 0){ |
while(N > 0){ |
961 |
|
// while(N != 0){ |
962 |
int nfit =0; |
int nfit =0; |
963 |
float chi2ref = numeric_limits<float>::max(); |
float chi2ref = numeric_limits<float>::max(); |
964 |
|
|
969 |
} |
} |
970 |
} |
} |
971 |
//second loop to search minimum chi2 among selected |
//second loop to search minimum chi2 among selected |
972 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i<ntrk(); i++){ |
973 |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
974 |
if(chi2 < 0) chi2 = chi2*1000; |
if(chi2 < 0) chi2 = -chi2*1000; |
975 |
if( chi2 < chi2ref |
if( chi2 < chi2ref |
976 |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
977 |
&& m[i]==1){ |
&& m[i]==1){ |
983 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
984 |
N--; |
N--; |
985 |
|
|
986 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
987 |
}; |
}; |
988 |
sorted->Add( (TrkTrack*)t[indi] ); |
sorted->Add( (TrkTrack*)t[indi] ); |
989 |
|
|
990 |
m[indi] = 0; |
m[indi] = 0; |
991 |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
992 |
N--; |
N--; |
993 |
indo++; |
indo++; |
994 |
} |
} |
995 |
m.clear(); |
m.clear(); |
996 |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
997 |
|
|
998 |
return sorted; |
return sorted; |
999 |
// return PhysicalTrack; |
// return PhysicalTrack; |
1143 |
*/ |
*/ |
1144 |
void TrkLevel2::LoadField(TString path){ |
void TrkLevel2::LoadField(TString path){ |
1145 |
// |
// |
1146 |
strcpy(path_.path,path.Data()); |
// strcpy(path_.path,path.Data()); |
1147 |
path_.pathlen = path.Length(); |
// path_.pathlen = path.Length(); |
1148 |
path_.error = 0; |
// path_.error = 0; |
1149 |
readb_(); |
// readb_(); |
1150 |
|
|
1151 |
|
TrkParams::Set(path,1); |
1152 |
|
TrkParams::Load(1); |
1153 |
|
|
1154 |
// |
// |
1155 |
}; |
}; |
1156 |
|
/** |
1157 |
|
* Get BY (kGauss) |
1158 |
|
* @param v (x,y,z) coordinates in cm |
1159 |
|
*/ |
1160 |
|
float TrkLevel2::GetBX(float* v){ |
1161 |
|
float b[3]; |
1162 |
|
gufld_(v,b); |
1163 |
|
return b[0]/10.; |
1164 |
|
} |
1165 |
|
/** |
1166 |
|
* Get BY (kGauss) |
1167 |
|
* @param v (x,y,z) coordinates in cm |
1168 |
|
*/ |
1169 |
|
float TrkLevel2::GetBY(float* v){ |
1170 |
|
float b[3]; |
1171 |
|
gufld_(v,b); |
1172 |
|
return b[1]/10.; |
1173 |
|
} |
1174 |
|
/** |
1175 |
|
* Get BY (kGauss) |
1176 |
|
* @param v (x,y,z) coordinates in cm |
1177 |
|
*/ |
1178 |
|
float TrkLevel2::GetBZ(float* v){ |
1179 |
|
float b[3]; |
1180 |
|
gufld_(v,b); |
1181 |
|
return b[2]/10.; |
1182 |
|
} |
1183 |
//-------------------------------------- |
//-------------------------------------- |
1184 |
// |
// |
1185 |
// |
// |
1357 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1358 |
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1359 |
|
|
1360 |
|
TrkParams::Load(1); |
1361 |
|
if( !TrkParams::IsLoaded(1) ){ |
1362 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
1363 |
|
return 0; |
1364 |
|
} |
1365 |
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1366 |
|
|
1367 |
for (int i=0; i<npoint; i++){ |
for (int i=0; i<npoint; i++){ |