12 |
extern "C" { |
extern "C" { |
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 |
|
void dotrack3_(int*, double*, double*, double*, double*,double*, double*, double*,double*,int*); |
16 |
void mini2_(int*,int*,int*); |
void mini2_(int*,int*,int*); |
17 |
void guess_(); |
void guess_(); |
18 |
void gufld_(float*, float*); |
void gufld_(float*, float*); |
178 |
// |
// |
179 |
//-------------------------------------- |
//-------------------------------------- |
180 |
/** |
/** |
|
* 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. |
|
181 |
* |
* |
182 |
* >>> OBSOLETE !!! use TrkTrack::DoTrack2(Trajectory* t) instead |
* >>> OBSOLETE !!! use TrkTrack::DoTrack(Trajectory* t) instead |
183 |
* |
* |
184 |
*/ |
*/ |
185 |
int TrkTrack::DoTrack(Trajectory* t){ |
int TrkTrack::DoTrack2(Trajectory* t){ |
|
|
|
|
cout << " int TrkTrack::DoTrack(Trajectory* t) --->> OBSOLETE !!! "<<endl; |
|
|
cout << " use int TrkTrack::DoTrack2(Trajectory* t)"<<endl; |
|
|
|
|
|
double *dxout = new double[t->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; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
|
186 |
|
|
187 |
TrkParams::Load(1); |
cout << endl; |
188 |
if( !TrkParams::IsLoaded(1) ){ |
cout << " int TrkTrack::DoTrack2(Trajectory* t) --->> NB NB !! this method is going to be eliminated !!! "<<endl; |
189 |
cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
cout << " >>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<<endl; |
190 |
return 0; |
cout << " (Sorry Wolfgang!! Don't be totally confused!! By Elena)"<<endl; |
191 |
} |
cout << endl; |
|
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
|
|
|
|
|
for (int i=0; i<t->npoint; i++){ |
|
|
t->x[i] = (float)*(dxout+i); |
|
|
t->y[i] = (float)*(dyout+i); |
|
|
} |
|
192 |
|
|
193 |
delete [] dxout; |
return DoTrack(t); |
|
delete [] dyout; |
|
|
delete [] dzin; |
|
194 |
|
|
|
return ifail; |
|
195 |
}; |
}; |
196 |
//-------------------------------------- |
//-------------------------------------- |
197 |
// |
// |
198 |
// |
// |
199 |
//-------------------------------------- |
//-------------------------------------- |
200 |
/** |
/** |
201 |
* Evaluates the trajectory in the apparatus associated to the track. |
* Evaluates the trajectory in the apparatus associated to the track state-vector. |
202 |
* 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. |
* It integrates the equations of motion in the magnetic field. |
203 |
* @param t pointer to an object of the class Trajectory, |
* @param t pointer to an object of the class Trajectory, |
204 |
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
* which z coordinates should be previously assigned. |
205 |
* @return error flag. |
* @return error flag. |
206 |
*/ |
*/ |
207 |
int TrkTrack::DoTrack2(Trajectory* t){ |
int TrkTrack::DoTrack(Trajectory* t){ |
208 |
|
|
209 |
double *dxout = new double[t->npoint]; |
double *dxout = new double[t->npoint]; |
210 |
double *dyout = new double[t->npoint]; |
double *dyout = new double[t->npoint]; |
221 |
|
|
222 |
TrkParams::Load(1); |
TrkParams::Load(1); |
223 |
if( !TrkParams::IsLoaded(1) ){ |
if( !TrkParams::IsLoaded(1) ){ |
224 |
cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
225 |
return 0; |
return 0; |
226 |
} |
} |
227 |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
374 |
return (last_plane-first_plane+1); |
return (last_plane-first_plane+1); |
375 |
} |
} |
376 |
/** |
/** |
377 |
|
* Returns the track "lever-arm" on the x+y view, defined as the distance (in planes) between |
378 |
|
* the upper and lower x,y (couple) measurements (the maximum value of lever-arm is 6). |
379 |
|
*/ |
380 |
|
Int_t TrkTrack::GetLeverArmXY(){ |
381 |
|
int first_plane = -1; |
382 |
|
int last_plane = -1; |
383 |
|
for(Int_t ip=0; ip<6; ip++){ |
384 |
|
if( XGood(ip)*YGood(ip) && first_plane == -1 )first_plane = ip; |
385 |
|
if( XGood(ip)*YGood(ip) && first_plane != -1 )last_plane = ip; |
386 |
|
} |
387 |
|
if( first_plane == -1 || last_plane == -1){ |
388 |
|
cout<< "Int_t TrkTrack::GetLeverArmXY() -- XGood(ip)*YGood(ip) always false ??? "<<endl; |
389 |
|
return 0; |
390 |
|
} |
391 |
|
return (last_plane-first_plane+1); |
392 |
|
} |
393 |
|
/** |
394 |
* Returns the reduced chi-square of track x-projection |
* Returns the reduced chi-square of track x-projection |
395 |
*/ |
*/ |
396 |
Float_t TrkTrack::GetChi2X(){ |
Float_t TrkTrack::GetChi2X(){ |
601 |
4.52043, |
4.52043, |
602 |
4.29926}; |
4.29926}; |
603 |
int index; |
int index; |
604 |
float fact; |
float fact=0.; |
605 |
for(int i=0; i<6; i++) { |
for(int i=0; i<6; i++) { |
606 |
index = int((fabs(axv[i])+1.)/2.); |
index = int((fabs(axv[i])+1.)/2.); |
607 |
if(index>10) index=10; |
if(index>10) index=10; |
715 |
if( XGood(i) && !YGood(i) ){ |
if( XGood(i) && !YGood(i) ){ |
716 |
track.xm_a[i] = xm[i] - omega * segment; |
track.xm_a[i] = xm[i] - omega * segment; |
717 |
track.ym_a[i] = ym[i] + segment; |
track.ym_a[i] = ym[i] + segment; |
718 |
track.zm_a[i] = zm[i] + beta * segment; |
// track.zm_a[i] = zm[i] + beta * segment;//not used yet |
719 |
track.xm_b[i] = xm[i] + omega * segment; |
track.xm_b[i] = xm[i] + omega * segment; |
720 |
track.ym_b[i] = ym[i] - segment; |
track.ym_b[i] = ym[i] - segment; |
721 |
track.zm_b[i] = zm[i] - beta * segment; |
// track.zm_b[i] = zm[i] - beta * segment;//not used yet |
722 |
}else if( !XGood(i) && YGood(i) ){ |
}else if( !XGood(i) && YGood(i) ){ |
723 |
track.xm_a[i] = xm[i] + segment; |
track.xm_a[i] = xm[i] + segment; |
724 |
track.ym_a[i] = ym[i] + omega * segment; |
track.ym_a[i] = ym[i] + omega * segment; |
725 |
track.zm_a[i] = zm[i] - gamma * segment; |
// track.zm_a[i] = zm[i] - gamma * segment;//not used yet |
726 |
track.xm_b[i] = xm[i] - segment; |
track.xm_b[i] = xm[i] - segment; |
727 |
track.ym_b[i] = ym[i] - omega * segment; |
track.ym_b[i] = ym[i] - omega * segment; |
728 |
track.zm_b[i] = zm[i] + gamma * segment; |
// track.zm_b[i] = zm[i] + gamma * segment;//not used yet |
729 |
} |
} |
730 |
} |
} |
731 |
|
|
792 |
|
|
793 |
// cout << "void TrkTrack::GetClusterositions() "<<endl; |
// cout << "void TrkTrack::GetClusterositions() "<<endl; |
794 |
|
|
795 |
bool OK=true; |
TrkParams::Load(1); |
796 |
TrkParams::Load(1); if( !TrkParams::IsLoaded(1) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- m.field not loaded "<<endl; |
if( !TrkParams::IsLoaded(1) ){ |
797 |
TrkParams::Load(4); if( !TrkParams::IsLoaded(4) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- p.f.a. par. not loaded "<<endl; |
cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- m.field not loaded "<<endl; |
798 |
TrkParams::Load(5); if( !TrkParams::IsLoaded(5) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- alignment par. not loaded "<<endl; |
return false; |
799 |
if(!OK)return false; |
} |
800 |
|
TrkParams::Load(4); |
801 |
|
if( !TrkParams::IsLoaded(4) ){ |
802 |
|
cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- p.f.a. par. not loaded "<<endl; |
803 |
|
return false; |
804 |
|
} |
805 |
|
TrkParams::Load(5); |
806 |
|
if( !TrkParams::IsLoaded(5) ){ |
807 |
|
cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- alignment par. not loaded "<<endl; |
808 |
|
return false; |
809 |
|
} |
810 |
|
|
811 |
for(int ip=0; ip<6; ip++){ |
for(int ip=0; ip<6; ip++){ |
812 |
// cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;; |
// cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;; |
859 |
*/ |
*/ |
860 |
void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){ |
void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){ |
861 |
|
|
862 |
bool OK=true; |
TrkParams::Load(1); |
863 |
TrkParams::Load(1); if( !TrkParams::IsLoaded(1) )cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- m.field not loaded "<<endl; |
if( !TrkParams::IsLoaded(1) ){ |
864 |
if(!OK)return; |
cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- m.field not loaded "<<endl; |
865 |
|
return; |
866 |
|
} |
867 |
|
TrkParams::Load(5); |
868 |
|
if( !TrkParams::IsLoaded(5) ){ |
869 |
|
cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- align.param. not loaded "<<endl; |
870 |
|
return; |
871 |
|
} |
872 |
|
|
873 |
float al_ini[] = {0.,0.,0.,0.,0.}; |
float al_ini[] = {0.,0.,0.,0.,0.}; |
874 |
|
|
1267 |
|
|
1268 |
}; |
}; |
1269 |
/** |
/** |
1270 |
* \brief Give the average spatial residual |
* \brief Give the anerage spatial residual |
1271 |
*/ |
*/ |
1272 |
Float_t TrkTrack::GetResidual_av(int ip, int iv){ |
Float_t TrkTrack::GetResidual_av(int ip, int iv){ |
1273 |
// |
// |
1681 |
int ngf = TrkParams::nGF; |
int ngf = TrkParams::nGF; |
1682 |
float *zgf = TrkParams::zGF; |
float *zgf = TrkParams::zGF; |
1683 |
Trajectory tgf = Trajectory(ngf,zgf); |
Trajectory tgf = Trajectory(ngf,zgf); |
1684 |
tgf.DoTrack2(t_track->al);//<<<< integrate the trajectory |
tgf.DoTrack(t_track->al);//<<<< integrate the trajectory |
1685 |
for(int ip=0; ip<ngf; ip++){ |
for(int ip=0; ip<ngf; ip++){ |
1686 |
t_track->xGF[ip] = tgf.x[ip]; |
t_track->xGF[ip] = tgf.x[ip]; |
1687 |
t_track->yGF[ip] = tgf.y[ip]; |
t_track->yGF[ip] = tgf.y[ip]; |
1839 |
|
|
1840 |
if(!Track)return 0; |
if(!Track)return 0; |
1841 |
|
|
1842 |
TRefArray *sorted = new TRefArray(); |
// TRefArray *sorted = new TRefArray(); |
1843 |
|
TRefArray *sorted = NULL; |
1844 |
|
|
1845 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1846 |
// TClonesArray &ts = *PhysicalTrack; |
// TClonesArray &ts = *PhysicalTrack; |
1878 |
|
|
1879 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
1880 |
}; |
}; |
1881 |
|
if(!sorted)sorted = new TRefArray( TProcessID::GetProcessWithUID(t[indi])); |
1882 |
sorted->Add( (TrkTrack*)t[indi] ); |
sorted->Add( (TrkTrack*)t[indi] ); |
1883 |
|
|
1884 |
m[indi] = 0; |
m[indi] = 0; |
2239 |
|
|
2240 |
/** |
/** |
2241 |
* Evaluates the trajectory in the apparatus associated to the track. |
* Evaluates the trajectory in the apparatus associated to the track. |
2242 |
* 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. |
* It integrates the equations of motion in the magnetic field. |
2243 |
* @param t pointer to an object of the class Trajectory, |
* @param al Track state-vector (X0,Y0,sin(theta),phi,deflection). |
2244 |
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
* @param zini z-coordinate of the reference plane (Z0). |
2245 |
* @return error flag. |
* @return error flag. |
2246 |
|
* |
2247 |
|
* This method is needed when you want to integrate the particle trajectory |
2248 |
|
* starting from a track state-vector relative to an arbitrary reference plane. |
2249 |
|
* The default reference plane, used by the tracker routines, is at zini=23.5. |
2250 |
|
* If you give as input the track state-vector from a TrkTrack object, |
2251 |
|
* you can use Trajectory::DoTrack(float* al) instead. |
2252 |
*/ |
*/ |
2253 |
int Trajectory::DoTrack2(float* al){ |
int Trajectory::DoTrack(float* al, float zini){ |
2254 |
|
|
2255 |
// double *dxout = new double[npoint]; |
// double *dxout = new double[npoint]; |
2256 |
// double *dyout = new double[npoint]; |
// double *dyout = new double[npoint]; |
2259 |
// double *dtlout = new double[npoint]; |
// double *dtlout = new double[npoint]; |
2260 |
// double *dzin = new double[npoint]; |
// double *dzin = new double[npoint]; |
2261 |
|
|
2262 |
double *dxout; |
double *dxout; |
2263 |
double *dyout; |
double *dyout; |
2264 |
double *dthxout; |
double *dthxout; |
2265 |
double *dthyout; |
double *dthyout; |
2266 |
double *dtlout; |
double *dtlout; |
2267 |
double *dzin; |
double *dzin; |
2268 |
|
|
2269 |
dxout = (double*) malloc(npoint*sizeof(double)); |
dxout = (double*) malloc(npoint*sizeof(double)); |
2270 |
dyout = (double*) malloc(npoint*sizeof(double)); |
dyout = (double*) malloc(npoint*sizeof(double)); |
2271 |
dthxout = (double*) malloc(npoint*sizeof(double)); |
dthxout = (double*) malloc(npoint*sizeof(double)); |
2272 |
dthyout = (double*) malloc(npoint*sizeof(double)); |
dthyout = (double*) malloc(npoint*sizeof(double)); |
2273 |
dtlout = (double*) malloc(npoint*sizeof(double)); |
dtlout = (double*) malloc(npoint*sizeof(double)); |
2274 |
dzin = (double*) malloc(npoint*sizeof(double)); |
dzin = (double*) malloc(npoint*sizeof(double)); |
2275 |
|
|
2276 |
|
double dal[5]; |
2277 |
|
|
2278 |
double dal[5]; |
double dzini = (double)zini; |
2279 |
|
|
2280 |
int ifail = 0; |
int ifail = 0; |
2281 |
|
|
2282 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
2283 |
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
2284 |
|
|
2285 |
TrkParams::Load(1); |
TrkParams::Load(1); |
2286 |
if( !TrkParams::IsLoaded(1) ){ |
if( !TrkParams::IsLoaded(1) ){ |
2287 |
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
cout << "int Trajectory::DoTrack(float* al) --- ERROR --- m.field not loaded"<<endl; |
2288 |
return 0; |
return 0; |
2289 |
} |
} |
2290 |
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
// dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
2291 |
|
dotrack3_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&dzini,&ifail); |
2292 |
|
|
2293 |
for (int i=0; i<npoint; i++){ |
for (int i=0; i<npoint; i++){ |
2294 |
x[i] = (float)*(dxout+i); |
x[i] = (float)*(dxout+i); |
2316 |
return ifail; |
return ifail; |
2317 |
}; |
}; |
2318 |
|
|
2319 |
|
/** |
2320 |
|
* |
2321 |
|
* >>> OBSOLETE !!! use Trajectory::DoTrack(float* al, float zini) instead |
2322 |
|
* |
2323 |
|
*/ |
2324 |
|
int Trajectory::DoTrack2(float* al, float zini){ |
2325 |
|
|
2326 |
|
cout << endl; |
2327 |
|
cout << " int Trajectory::DoTrack2(float* al, float zini) --->> NB NB !! this method is going to be eliminated !!! "<<endl; |
2328 |
|
cout << " >>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<<endl; |
2329 |
|
cout << " (Sorry Wolfgang!! Don't be totally confused!! By Elena)"<<endl; |
2330 |
|
cout << endl; |
2331 |
|
|
2332 |
|
return DoTrack(al,zini); |
2333 |
|
|
2334 |
|
}; |
2335 |
|
|
2336 |
|
|
2337 |
|
|
2338 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
2339 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |
2340 |
ClassImp(TrkTrack); |
ClassImp(TrkTrack); |