--- DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2008/11/25 14:41:37 1.49 +++ DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2009/03/11 14:19:10 1.54 @@ -12,6 +12,7 @@ extern "C" { void dotrack_(int*, double*, double*, double*, double*, int*); void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); + void dotrack3_(int*, double*, double*, double*, double*,double*, double*, double*,double*,int*); void mini2_(int*,int*,int*); void guess_(); void gufld_(float*, float*); @@ -177,60 +178,33 @@ // //-------------------------------------- /** - * Evaluates the trajectory in the apparatus associated to the track. - * It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling TrkLevel2::LoadField() ), otherwise an error message is returned. - * @param t pointer to an object of the class Trajectory, - * which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). - * @return error flag. * - * >>> OBSOLETE !!! use TrkTrack::DoTrack2(Trajectory* t) instead + * >>> OBSOLETE !!! use TrkTrack::DoTrack(Trajectory* t) instead * */ -int TrkTrack::DoTrack(Trajectory* t){ - - cout << " int TrkTrack::DoTrack(Trajectory* t) --->> OBSOLETE !!! "<npoint]; - double *dyout = new double[t->npoint]; - double *dzin = new double[t->npoint]; - double dal[5]; - - int ifail = 0; - - for (int i=0; i<5; i++) dal[i] = (double)al[i]; - for (int i=0; inpoint; i++) dzin[i] = (double)t->z[i]; +int TrkTrack::DoTrack2(Trajectory* t){ - TrkParams::Load(1); - if( !TrkParams::IsLoaded(1) ){ - cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<npoint),dzin,dxout,dyout,dal,&ifail); - - for (int i=0; inpoint; i++){ - t->x[i] = (float)*(dxout+i); - t->y[i] = (float)*(dyout+i); - } + cout << endl; + cout << " int TrkTrack::DoTrack2(Trajectory* t) --->> NB NB !! this method is going to be eliminated !!! "<>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<npoint]; double *dyout = new double[t->npoint]; @@ -247,7 +221,7 @@ TrkParams::Load(1); if( !TrkParams::IsLoaded(1) ){ - cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); @@ -400,6 +374,23 @@ return (last_plane-first_plane+1); } /** + * Returns the track "lever-arm" on the x+y view, defined as the distance (in planes) between + * the upper and lower x,y (couple) measurements (the maximum value of lever-arm is 6). + */ +Int_t TrkTrack::GetLeverArmXY(){ + int first_plane = -1; + int last_plane = -1; + for(Int_t ip=0; ip<6; ip++){ + if( XGood(ip)*YGood(ip) && first_plane == -1 )first_plane = ip; + if( XGood(ip)*YGood(ip) && first_plane != -1 )last_plane = ip; + } + if( first_plane == -1 || last_plane == -1){ + cout<< "Int_t TrkTrack::GetLeverArmXY() -- XGood(ip)*YGood(ip) always false ??? "<10) index=10; @@ -724,17 +715,17 @@ if( XGood(i) && !YGood(i) ){ track.xm_a[i] = xm[i] - omega * segment; track.ym_a[i] = ym[i] + segment; - track.zm_a[i] = zm[i] + beta * segment; +// track.zm_a[i] = zm[i] + beta * segment;//not used yet track.xm_b[i] = xm[i] + omega * segment; track.ym_b[i] = ym[i] - segment; - track.zm_b[i] = zm[i] - beta * segment; +// track.zm_b[i] = zm[i] - beta * segment;//not used yet }else if( !XGood(i) && YGood(i) ){ track.xm_a[i] = xm[i] + segment; track.ym_a[i] = ym[i] + omega * segment; - track.zm_a[i] = zm[i] - gamma * segment; +// track.zm_a[i] = zm[i] - gamma * segment;//not used yet track.xm_b[i] = xm[i] - segment; track.ym_b[i] = ym[i] - omega * segment; - track.zm_b[i] = zm[i] + gamma * segment; +// track.zm_b[i] = zm[i] + gamma * segment;//not used yet } } @@ -801,11 +792,21 @@ // cout << "void TrkTrack::GetClusterositions() "<0 define an inner fiducial volume) */ -Bool_t TrkTrack::IsInsideAcceptance(){ +// Bool_t TrkTrack::IsInsideAcceptance(){ + +// int ngf = TrkParams::nGF; +// for(int i=0; i= TrkParams::xGF_max[i] || +// yGF[i] <= TrkParams::yGF_min[i] || +// yGF[i] >= TrkParams::yGF_max[i] || +// false)return false; +// } +// return true; + +// } +Bool_t TrkTrack::IsInsideAcceptance(float toll){ + int ngf = TrkParams::nGF; for(int i=0; i= TrkParams::xGF_max[i] || - yGF[i] <= TrkParams::yGF_min[i] || - yGF[i] >= TrkParams::yGF_max[i] || - false)return false; + xGF[i] <= TrkParams::xGF_min[i] + toll || + xGF[i] >= TrkParams::xGF_max[i] - toll || + yGF[i] <= TrkParams::yGF_min[i] + toll || + yGF[i] >= TrkParams::yGF_max[i] - toll || + false){ + + return false; + } } return true; +} + +/** + * Returns true if the track is inside one of the surfaces which define the + * geometrical acceptance. + * @param surf tag of the surface (possible values are: S11 S12 S21 S22 T1 + * CUF T2 T3 T4 T5 CLF T6 S31 S32). + * @param toll Tolerance around the nominal surface (toll>0 define an inner + * fiducial surface) +*/ +Bool_t TrkTrack::IsInsideGFSurface(const char* surf, float toll){ + + + int ngf = TrkParams::nGF; + bool SURFOK = false; + for(int i=0; i TrkParams::xGF_min[i] + toll && + xGF[i] < TrkParams::xGF_max[i] - toll && + yGF[i] > TrkParams::yGF_min[i] + toll && + yGF[i] < TrkParams::yGF_max[i] - toll && + true)return true; + } + } + if( !SURFOK )cout << " Bool_t TrkTrack::IsInsideGFSurface(char* surf, float toll) --> suface "<al);//<<<< integrate the trajectory + tgf.DoTrack(t_track->al);//<<<< integrate the trajectory for(int ip=0; ipxGF[ip] = tgf.x[ip]; t_track->yGF[ip] = tgf.y[ip]; @@ -1831,7 +1907,8 @@ if(!Track)return 0; - TRefArray *sorted = new TRefArray(); + // TRefArray *sorted = new TRefArray(); + TRefArray *sorted = NULL; TClonesArray &t = *Track; // TClonesArray &ts = *PhysicalTrack; @@ -1869,6 +1946,7 @@ // cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<Add( (TrkTrack*)t[indi] ); m[indi] = 0; @@ -2229,12 +2307,18 @@ /** * Evaluates the trajectory in the apparatus associated to the track. - * It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling TrkLevel2::LoadField() ), otherwise an error message is returned. - * @param t pointer to an object of the class Trajectory, - * which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). + * It integrates the equations of motion in the magnetic field. + * @param al Track state-vector (X0,Y0,sin(theta),phi,deflection). + * @param zini z-coordinate of the reference plane (Z0). * @return error flag. + * + * This method is needed when you want to integrate the particle trajectory + * starting from a track state-vector relative to an arbitrary reference plane. + * The default reference plane, used by the tracker routines, is at zini=23.5. + * If you give as input the track state-vector from a TrkTrack object, + * you can use Trajectory::DoTrack(float* al) instead. */ -int Trajectory::DoTrack2(float* al){ +int Trajectory::DoTrack(float* al, float zini){ // double *dxout = new double[npoint]; // double *dyout = new double[npoint]; @@ -2243,33 +2327,36 @@ // double *dtlout = new double[npoint]; // double *dzin = new double[npoint]; - double *dxout; - double *dyout; - double *dthxout; - double *dthyout; - double *dtlout; - double *dzin; - - dxout = (double*) malloc(npoint*sizeof(double)); - dyout = (double*) malloc(npoint*sizeof(double)); - dthxout = (double*) malloc(npoint*sizeof(double)); - dthyout = (double*) malloc(npoint*sizeof(double)); - dtlout = (double*) malloc(npoint*sizeof(double)); - dzin = (double*) malloc(npoint*sizeof(double)); + double *dxout; + double *dyout; + double *dthxout; + double *dthyout; + double *dtlout; + double *dzin; + + dxout = (double*) malloc(npoint*sizeof(double)); + dyout = (double*) malloc(npoint*sizeof(double)); + dthxout = (double*) malloc(npoint*sizeof(double)); + dthyout = (double*) malloc(npoint*sizeof(double)); + dtlout = (double*) malloc(npoint*sizeof(double)); + dzin = (double*) malloc(npoint*sizeof(double)); + + double dal[5]; - double dal[5]; + double dzini = (double)zini; int ifail = 0; - + for (int i=0; i<5; i++) dal[i] = (double)al[i]; for (int i=0; i>> OBSOLETE !!! use Trajectory::DoTrack(float* al, float zini) instead + * + */ +int Trajectory::DoTrack2(float* al, float zini){ + + cout << endl; + cout << " int Trajectory::DoTrack2(float* al, float zini) --->> NB NB !! this method is going to be eliminated !!! "<>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<