| 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*); |
|
// int readb_(const char*); |
|
|
int readb_(); |
|
| 15 |
void mini2_(int*,int*,int*); |
void mini2_(int*,int*,int*); |
| 16 |
void guess_(); |
void guess_(); |
| 17 |
|
void gufld_(float*, float*); |
| 18 |
|
float risxeta2_(float *); |
| 19 |
|
float risxeta3_(float *); |
| 20 |
|
float risxeta4_(float *); |
| 21 |
|
float risyeta2_(float *); |
| 22 |
} |
} |
| 23 |
|
|
| 24 |
//-------------------------------------- |
//-------------------------------------- |
| 25 |
// |
// |
| 26 |
// |
// |
| 27 |
//-------------------------------------- |
//-------------------------------------- |
| 28 |
TrkTrack::TrkTrack(){ |
TrkTrack::TrkTrack(){ |
| 29 |
|
// cout << "TrkTrack::TrkTrack()" << endl; |
| 30 |
seqno = -1; |
seqno = -1; |
| 31 |
image = -1; |
image = -1; |
| 32 |
chi2 = 0; |
chi2 = 0; |
| 36 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
| 37 |
}; |
}; |
| 38 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
| 39 |
xgood[ip] = 0; |
xgood[ip] = 0; |
| 40 |
ygood[ip] = 0; |
ygood[ip] = 0; |
| 41 |
xm[ip] = 0; |
xm[ip] = 0; |
| 42 |
ym[ip] = 0; |
ym[ip] = 0; |
| 43 |
zm[ip] = 0; |
zm[ip] = 0; |
| 44 |
resx[ip] = 0; |
resx[ip] = 0; |
| 45 |
resy[ip] = 0; |
resy[ip] = 0; |
| 46 |
xv[ip] = 0; |
tailx[ip] = 0; |
| 47 |
yv[ip] = 0; |
taily[ip] = 0; |
| 48 |
zv[ip] = 0; |
xv[ip] = 0; |
| 49 |
axv[ip] = 0; |
yv[ip] = 0; |
| 50 |
ayv[ip] = 0; |
zv[ip] = 0; |
| 51 |
dedx_x[ip] = 0; |
axv[ip] = 0; |
| 52 |
dedx_y[ip] = 0; |
ayv[ip] = 0; |
| 53 |
// clx[ip] = 0; |
dedx_x[ip] = 0; |
| 54 |
// cly[ip] = 0; |
dedx_y[ip] = 0; |
| 55 |
}; |
}; |
| 56 |
clx = new TRefArray(6,0); |
// clx = 0; |
| 57 |
cly = new TRefArray(6,0); |
// cly = 0; |
| 58 |
|
// clx = new TRefArray(6,0); //forse causa memory leak??? |
| 59 |
|
// cly = new TRefArray(6,0); //forse causa memory leak??? |
| 60 |
|
// clx = TRefArray(6,0); |
| 61 |
|
// cly = TRefArray(6,0); |
| 62 |
|
|
| 63 |
|
TrkParams::SetTrackingMode(); |
| 64 |
|
TrkParams::SetPrecisionFactor(); |
| 65 |
|
TrkParams::SetStepMin(); |
| 66 |
|
TrkParams::SetPFA(); |
| 67 |
|
|
| 68 |
}; |
}; |
| 69 |
//-------------------------------------- |
//-------------------------------------- |
| 70 |
// |
// |
| 80 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; |
| 81 |
}; |
}; |
| 82 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
| 83 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
| 84 |
ygood[ip] = t.ygood[ip]; |
ygood[ip] = t.ygood[ip]; |
| 85 |
xm[ip] = t.xm[ip]; |
xm[ip] = t.xm[ip]; |
| 86 |
ym[ip] = t.ym[ip]; |
ym[ip] = t.ym[ip]; |
| 87 |
zm[ip] = t.zm[ip]; |
zm[ip] = t.zm[ip]; |
| 88 |
resx[ip] = t.resx[ip]; |
resx[ip] = t.resx[ip]; |
| 89 |
resy[ip] = t.resy[ip]; |
resy[ip] = t.resy[ip]; |
| 90 |
xv[ip] = t.xv[ip]; |
tailx[ip] = t.tailx[ip]; |
| 91 |
yv[ip] = t.yv[ip]; |
taily[ip] = t.taily[ip]; |
| 92 |
zv[ip] = t.zv[ip]; |
xv[ip] = t.xv[ip]; |
| 93 |
axv[ip] = t.axv[ip]; |
yv[ip] = t.yv[ip]; |
| 94 |
ayv[ip] = t.ayv[ip]; |
zv[ip] = t.zv[ip]; |
| 95 |
dedx_x[ip] = t.dedx_x[ip]; |
axv[ip] = t.axv[ip]; |
| 96 |
dedx_y[ip] = t.dedx_y[ip]; |
ayv[ip] = t.ayv[ip]; |
| 97 |
// clx[ip] = 0;//<<<<pointer |
dedx_x[ip] = t.dedx_x[ip]; |
| 98 |
// cly[ip] = 0;//<<<<pointer |
dedx_y[ip] = t.dedx_y[ip]; |
| 99 |
}; |
}; |
| 100 |
clx = new TRefArray(*(t.clx)); |
// clx = 0; |
| 101 |
cly = new TRefArray(*(t.cly)); |
// cly = 0; |
| 102 |
|
// if(t.clx)clx = new TRefArray(*(t.clx)); |
| 103 |
|
// if(t.cly)cly = new TRefArray(*(t.cly)); |
| 104 |
|
// clx = TRefArray(t.clx); |
| 105 |
|
// cly = TRefArray(t.cly); |
| 106 |
|
|
| 107 |
|
TrkParams::SetTrackingMode(); |
| 108 |
|
TrkParams::SetPrecisionFactor(); |
| 109 |
|
TrkParams::SetStepMin(); |
| 110 |
|
TrkParams::SetPFA(); |
| 111 |
|
|
| 112 |
|
}; |
| 113 |
|
//-------------------------------------- |
| 114 |
|
// |
| 115 |
|
// |
| 116 |
|
//-------------------------------------- |
| 117 |
|
void TrkTrack::Copy(TrkTrack& t){ |
| 118 |
|
|
| 119 |
|
t.seqno = seqno; |
| 120 |
|
t.image = image; |
| 121 |
|
t.chi2 = chi2; |
| 122 |
|
t.nstep = nstep; |
| 123 |
|
for(int it1=0;it1<5;it1++){ |
| 124 |
|
t.al[it1] = al[it1]; |
| 125 |
|
for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2]; |
| 126 |
|
}; |
| 127 |
|
for(int ip=0;ip<6;ip++){ |
| 128 |
|
t.xgood[ip] = xgood[ip]; |
| 129 |
|
t.ygood[ip] = ygood[ip]; |
| 130 |
|
t.xm[ip] = xm[ip]; |
| 131 |
|
t.ym[ip] = ym[ip]; |
| 132 |
|
t.zm[ip] = zm[ip]; |
| 133 |
|
t.resx[ip] = resx[ip]; |
| 134 |
|
t.resy[ip] = resy[ip]; |
| 135 |
|
t.tailx[ip] = tailx[ip]; |
| 136 |
|
t.taily[ip] = taily[ip]; |
| 137 |
|
t.xv[ip] = xv[ip]; |
| 138 |
|
t.yv[ip] = yv[ip]; |
| 139 |
|
t.zv[ip] = zv[ip]; |
| 140 |
|
t.axv[ip] = axv[ip]; |
| 141 |
|
t.ayv[ip] = ayv[ip]; |
| 142 |
|
t.dedx_x[ip] = dedx_x[ip]; |
| 143 |
|
t.dedx_y[ip] = dedx_y[ip]; |
| 144 |
|
|
| 145 |
|
}; |
| 146 |
|
|
| 147 |
|
// t.clx = TRefArray(clx); |
| 148 |
|
// t.cly = TRefArray(cly); |
| 149 |
|
|
| 150 |
}; |
}; |
| 151 |
//-------------------------------------- |
//-------------------------------------- |
| 152 |
// |
// |
| 171 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
| 172 |
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]; |
| 173 |
|
|
| 174 |
|
TrkParams::Load(1); |
| 175 |
|
if( !TrkParams::IsLoaded(1) ){ |
| 176 |
|
cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
| 177 |
|
return 0; |
| 178 |
|
} |
| 179 |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
| 180 |
|
|
| 181 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
| 215 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
| 216 |
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]; |
| 217 |
|
|
| 218 |
|
TrkParams::Load(1); |
| 219 |
|
if( !TrkParams::IsLoaded(1) ){ |
| 220 |
|
cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
| 221 |
|
return 0; |
| 222 |
|
} |
| 223 |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
| 224 |
|
|
| 225 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
| 259 |
return def; |
return def; |
| 260 |
}; |
}; |
| 261 |
// |
// |
| 262 |
Float_t TrkTrack::GetDEDX(){ |
/** |
| 263 |
Float_t dedx=0; |
* Method to retrieve the dE/dx measured on a tracker view. |
| 264 |
for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i]; |
* @param ip plane (0-5) |
| 265 |
dedx = dedx/(this->GetNX()+this->GetNY()); |
* @param iv view (0=x 1=y) |
| 266 |
return dedx; |
*/ |
| 267 |
|
Float_t TrkTrack::GetDEDX(int ip, int iv){ |
| 268 |
|
if(iv==0 && ip>=0 && ip<6)return fabs(dedx_x[ip]); |
| 269 |
|
else if(iv==1 && ip>=0 && ip<6)return fabs(dedx_y[ip]); |
| 270 |
|
else { |
| 271 |
|
cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
| 272 |
|
return 0.; |
| 273 |
|
} |
| 274 |
|
} |
| 275 |
|
/** |
| 276 |
|
* Method to evaluate the dE/dx measured on a tracker plane. |
| 277 |
|
* The two measurements on x- and y-view are averaged. |
| 278 |
|
* @param ip plane (0-5) |
| 279 |
|
*/ |
| 280 |
|
Float_t TrkTrack::GetDEDX(int ip){ |
| 281 |
|
if( (Int_t)XGood(ip)+(Int_t)YGood(ip) == 0 ) return 0; |
| 282 |
|
return (GetDEDX(ip,0)+GetDEDX(ip,1))/((Int_t)XGood(ip)+(Int_t)YGood(ip)); |
| 283 |
}; |
}; |
| 284 |
|
|
| 285 |
|
/** |
| 286 |
|
* Method to evaluate the dE/dx averaged over all planes. |
| 287 |
|
*/ |
| 288 |
|
Float_t TrkTrack::GetDEDX(){ |
| 289 |
|
Float_t dedx=0; |
| 290 |
|
for(Int_t ip=0; ip<6; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip); |
| 291 |
|
dedx = dedx/(GetNX()+GetNY()); |
| 292 |
|
return dedx; |
| 293 |
|
}; |
| 294 |
|
/** |
| 295 |
|
* Returns 1 if the cluster on a tracker view includes bad strips. |
| 296 |
|
* @param ip plane (0-5) |
| 297 |
|
* @param iv view (0=x 1=y) |
| 298 |
|
*/ |
| 299 |
|
Bool_t TrkTrack::IsBad(int ip,int iv){ |
| 300 |
|
if(iv==0 && ip>=0 && ip<6)return (xgood[ip]<0) ; |
| 301 |
|
else if(iv==1 && ip>=0 && ip<6)return (ygood[ip]<0) ; |
| 302 |
|
else { |
| 303 |
|
cout << "TrkTrack::IsBad(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
| 304 |
|
return 0.; |
| 305 |
|
} |
| 306 |
|
}; |
| 307 |
|
/** |
| 308 |
|
* Returns 1 if the signal on a tracker view is saturated. |
| 309 |
|
* @param ip plane (0-5) |
| 310 |
|
* @param iv view (0=x 1=y) |
| 311 |
|
*/ |
| 312 |
|
Bool_t TrkTrack::IsSaturated(int ip,int iv){ |
| 313 |
|
if(iv==0 && ip>=0 && ip<6)return (dedx_x[ip]<0) ; |
| 314 |
|
else if(iv==1 && ip>=0 && ip<6)return (dedx_y[ip]<0) ; |
| 315 |
|
else { |
| 316 |
|
cout << "TrkTrack::IsSaturated(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
| 317 |
|
return 0.; |
| 318 |
|
} |
| 319 |
|
}; |
| 320 |
|
/** |
| 321 |
|
* Returns 1 if either the x or the y signal on a tracker plane is saturated. |
| 322 |
|
* @param ip plane (0-5) |
| 323 |
|
*/ |
| 324 |
|
Bool_t TrkTrack::IsSaturated(int ip){ |
| 325 |
|
return (IsSaturated(ip,0)||IsSaturated(ip,1)); |
| 326 |
|
}; |
| 327 |
|
/** |
| 328 |
|
* Returns 1 if there is at least a saturated signal along the track. |
| 329 |
|
*/ |
| 330 |
|
Bool_t TrkTrack::IsSaturated(){ |
| 331 |
|
for(int ip=0; ip<6; ip++)for(int iv=0; iv<2; iv++)if(IsSaturated(ip,iv))return true; |
| 332 |
|
return false; |
| 333 |
|
} |
| 334 |
|
/** |
| 335 |
|
* Returns the track "lever-arm" on the x view, defined as the distance (in planes) between |
| 336 |
|
* the upper and lower x measurements (the maximum value of lever-arm is 6). |
| 337 |
|
*/ |
| 338 |
|
Int_t TrkTrack::GetLeverArmX(){ |
| 339 |
|
int first_plane = -1; |
| 340 |
|
int last_plane = -1; |
| 341 |
|
for(Int_t ip=0; ip<6; ip++){ |
| 342 |
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
| 343 |
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
| 344 |
|
} |
| 345 |
|
if( first_plane == -1 || last_plane == -1){ |
| 346 |
|
cout<< "Int_t TrkTrack::GetLeverArmX() -- XGood(ip) always false ??? "<<endl; |
| 347 |
|
return 0; |
| 348 |
|
} |
| 349 |
|
return (last_plane-first_plane+1); |
| 350 |
|
} |
| 351 |
|
/** |
| 352 |
|
* Returns the track "lever-arm" on the y view, defined as the distance (in planes) between |
| 353 |
|
* the upper and lower y measurements (the maximum value of lever-arm is 6). |
| 354 |
|
*/ |
| 355 |
|
Int_t TrkTrack::GetLeverArmY(){ |
| 356 |
|
int first_plane = -1; |
| 357 |
|
int last_plane = -1; |
| 358 |
|
for(Int_t ip=0; ip<6; ip++){ |
| 359 |
|
if( YGood(ip) && first_plane == -1 )first_plane = ip; |
| 360 |
|
if( YGood(ip) && first_plane != -1 )last_plane = ip; |
| 361 |
|
} |
| 362 |
|
if( first_plane == -1 || last_plane == -1){ |
| 363 |
|
cout<< "Int_t TrkTrack::GetLeverArmY() -- YGood(ip) always false ??? "<<endl; |
| 364 |
|
return 0; |
| 365 |
|
} |
| 366 |
|
return (last_plane-first_plane+1); |
| 367 |
|
} |
| 368 |
|
/** |
| 369 |
|
* Returns the reduced chi-square of track x-projection |
| 370 |
|
*/ |
| 371 |
|
Float_t TrkTrack::GetChi2X(){ |
| 372 |
|
float chiq=0; |
| 373 |
|
for(int ip=0; ip<6; ip++)if(XGood(ip))chiq+= pow((xv[ip]-xm[ip])/resx[ip],2.); |
| 374 |
|
if(GetNX()>3)chiq=chiq/(GetNX()-3); |
| 375 |
|
else chiq=0; |
| 376 |
|
if(chiq==0)cout << " Float_t TrkTrack::GetChi2X() -- WARNING -- value not defined "<<chiq<<endl; |
| 377 |
|
return chiq; |
| 378 |
|
} |
| 379 |
|
/** |
| 380 |
|
* Returns the reduced chi-square of track y-projection |
| 381 |
|
*/ |
| 382 |
|
Float_t TrkTrack::GetChi2Y(){ |
| 383 |
|
float chiq=0; |
| 384 |
|
for(int ip=0; ip<6; ip++)if(YGood(ip))chiq+= pow((yv[ip]-ym[ip])/resy[ip],2.); |
| 385 |
|
if(GetNY()>2)chiq=chiq/(GetNY()-2); |
| 386 |
|
else chiq=0; |
| 387 |
|
if(chiq==0)cout << " Float_t TrkTrack::GetChi2Y() -- WARNING -- value not defined "<<chiq<<endl; |
| 388 |
|
return chiq; |
| 389 |
|
} |
| 390 |
|
/** |
| 391 |
|
* Returns the logarythm of the likeliwood-function of track x-projection |
| 392 |
|
*/ |
| 393 |
|
Float_t TrkTrack::GetLnLX(){ |
| 394 |
|
float lnl=0; |
| 395 |
|
for(int ip=0; ip<6; ip++) |
| 396 |
|
if( XGood(ip) && tailx[ip]!=0 ) |
| 397 |
|
lnl += (tailx[ip]+1.) * log( (tailx[ip]*pow(resx[ip],2.) + pow(xv[ip]-xm[ip],2.)) / (tailx[ip]*pow(resx[ip],2)) ); |
| 398 |
|
if(GetNX()>3)lnl=lnl/(GetNX()-3); |
| 399 |
|
else lnl=0; |
| 400 |
|
if(lnl==0){ |
| 401 |
|
cout << " Float_t TrkTrack::GetLnLX() -- WARNING -- value not defined "<<lnl<<endl; |
| 402 |
|
Dump(); |
| 403 |
|
} |
| 404 |
|
return lnl; |
| 405 |
|
|
| 406 |
|
} |
| 407 |
|
/** |
| 408 |
|
* Returns the logarythm of the likeliwood-function of track y-projection |
| 409 |
|
*/ |
| 410 |
|
Float_t TrkTrack::GetLnLY(){ |
| 411 |
|
float lnl=0; |
| 412 |
|
for(int ip=0; ip<6; ip++) |
| 413 |
|
if( YGood(ip) && taily[ip]!=0 ) |
| 414 |
|
lnl += (taily[ip]+1.) * log( (taily[ip]*pow(resy[ip],2.) + pow(yv[ip]-ym[ip],2.)) / (taily[ip]*pow(resy[ip],2)) ); |
| 415 |
|
if(GetNY()>2)lnl=lnl/(GetNY()-2); |
| 416 |
|
else lnl=0; |
| 417 |
|
if(lnl==0){ |
| 418 |
|
cout << " Float_t TrkTrack::GetLnLY() -- WARNING -- value not defined "<<lnl<<endl; |
| 419 |
|
Dump(); |
| 420 |
|
} |
| 421 |
|
return lnl; |
| 422 |
|
|
| 423 |
|
} |
| 424 |
//-------------------------------------- |
//-------------------------------------- |
| 425 |
// |
// |
| 426 |
// |
// |
| 432 |
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] << " "; |
| 433 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
| 434 |
cout << endl << "n.step : "<< nstep; |
cout << endl << "n.step : "<< nstep; |
| 435 |
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) ; |
| 436 |
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) ; |
| 437 |
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] << " "; |
| 438 |
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] << " "; |
| 439 |
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] << " "; |
| 442 |
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
| 443 |
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
| 444 |
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
| 445 |
|
cout << endl << "tailx : "; for(int i=0; i<6; i++)cout << tailx[i] << " "; |
| 446 |
|
cout << endl << "taily : "; for(int i=0; i<6; i++)cout << taily[i] << " "; |
| 447 |
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
| 448 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
| 449 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
| 469 |
for(int i=0; i<6; i++) resy[i]=*ry++; |
for(int i=0; i<6; i++) resy[i]=*ry++; |
| 470 |
} |
} |
| 471 |
/** |
/** |
| 472 |
|
* Set the TrkTrack tails position resolution |
| 473 |
|
*/ |
| 474 |
|
void TrkTrack::SetTail(double *tx, double *ty, double factor){ |
| 475 |
|
for(int i=0; i<6; i++) tailx[i]=factor*(*tx++); |
| 476 |
|
for(int i=0; i<6; i++) taily[i]=factor*(*ty++); |
| 477 |
|
} |
| 478 |
|
/** |
| 479 |
|
* Set the TrkTrack Student parameter (resx,resy,tailx,taily) |
| 480 |
|
* from previous gausian fit |
| 481 |
|
*@param flag =0 standard, =1 with noise correction |
| 482 |
|
*/ |
| 483 |
|
void TrkTrack::SetStudentParam(int flag){ |
| 484 |
|
float sx[11]={0.000128242, |
| 485 |
|
0.000136942, |
| 486 |
|
0.000162718, |
| 487 |
|
0.000202644, |
| 488 |
|
0.00025597, |
| 489 |
|
0.000317456, |
| 490 |
|
0.000349048, |
| 491 |
|
0.000384638, |
| 492 |
|
0.000457295, |
| 493 |
|
0.000512319, |
| 494 |
|
0.000538573}; |
| 495 |
|
float tx[11]={1.79402, |
| 496 |
|
2.04876, |
| 497 |
|
2.88376, |
| 498 |
|
3.3, |
| 499 |
|
3.14084, |
| 500 |
|
4.07686, |
| 501 |
|
4.44736, |
| 502 |
|
3.5179, |
| 503 |
|
3.38697, |
| 504 |
|
3.45739, |
| 505 |
|
3.18627}; |
| 506 |
|
float sy[11]={0.000483075, |
| 507 |
|
0.000466925, |
| 508 |
|
0.000431658, |
| 509 |
|
0.000428317, |
| 510 |
|
0.000433854, |
| 511 |
|
0.000444044, |
| 512 |
|
0.000482098, |
| 513 |
|
0.000537579, |
| 514 |
|
0.000636279, |
| 515 |
|
0.000741998, |
| 516 |
|
0.000864261}; |
| 517 |
|
float ty[11]={0.997032, |
| 518 |
|
1.11147, |
| 519 |
|
1.18526, |
| 520 |
|
1.61404, |
| 521 |
|
2.21908, |
| 522 |
|
3.08959, |
| 523 |
|
4.48833, |
| 524 |
|
4.42687, |
| 525 |
|
4.65253, |
| 526 |
|
4.52043, |
| 527 |
|
4.29926}; |
| 528 |
|
int index; |
| 529 |
|
float fact; |
| 530 |
|
for(int i=0; i<6; i++) { |
| 531 |
|
index = int((fabs(axv[i])+1.)/2.); |
| 532 |
|
if(index>10) index=10; |
| 533 |
|
tailx[i]=tx[index]; |
| 534 |
|
if(flag==1) { |
| 535 |
|
if(fabs(axv[i])<=10.) fact = resx[i]/risxeta2_(&(axv[i])); |
| 536 |
|
if(fabs(axv[i])>10.&&fabs(axv[i])<=15.) fact = resx[i]/risxeta3_(&(axv[i])); |
| 537 |
|
if(fabs(axv[i])>15.) fact = resx[i]/risxeta4_(&(axv[i])); |
| 538 |
|
} else fact = 1.; |
| 539 |
|
resx[i] = sx[index]*fact; |
| 540 |
|
} |
| 541 |
|
for(int i=0; i<6; i++) { |
| 542 |
|
index = int((fabs(ayv[i])+1.)/2.); |
| 543 |
|
if(index>10) index=10; |
| 544 |
|
taily[i]=ty[index]; |
| 545 |
|
if(flag==1) fact = resy[i]/risyeta2_(&(ayv[i])); |
| 546 |
|
else fact = 1.; |
| 547 |
|
resy[i] = sy[index]*fact; |
| 548 |
|
} |
| 549 |
|
} |
| 550 |
|
/** |
| 551 |
* Set the TrkTrack good measurement |
* Set the TrkTrack good measurement |
| 552 |
*/ |
*/ |
| 553 |
void TrkTrack::SetGood(int *xg, int *yg){ |
void TrkTrack::SetGood(int *xg, int *yg){ |
| 554 |
|
|
| 555 |
for(int i=0; i<6; i++) xgood[i]=*xg++; |
for(int i=0; i<6; i++) xgood[i]=*xg++; |
| 556 |
for(int i=0; i<6; i++) ygood[i]=*yg++; |
for(int i=0; i<6; i++) ygood[i]=*yg++; |
| 557 |
} |
} |
| 561 |
*/ |
*/ |
| 562 |
void TrkTrack::LoadField(TString path){ |
void TrkTrack::LoadField(TString path){ |
| 563 |
|
|
| 564 |
strcpy(path_.path,path.Data()); |
// strcpy(path_.path,path.Data()); |
| 565 |
path_.pathlen = path.Length(); |
// path_.pathlen = path.Length(); |
| 566 |
path_.error = 0; |
// path_.error = 0; |
| 567 |
readb_(); |
// readb_(); |
| 568 |
|
|
| 569 |
|
TrkParams::SetTrackingMode(); |
| 570 |
|
TrkParams::SetPrecisionFactor(); |
| 571 |
|
TrkParams::SetStepMin(); |
| 572 |
|
|
| 573 |
|
TrkParams::Set(path,1); |
| 574 |
|
TrkParams::Load(1); |
| 575 |
|
|
| 576 |
}; |
}; |
| 577 |
|
|
| 578 |
|
|
| 579 |
|
/** |
| 580 |
|
* Method to fill minimization-routine common |
| 581 |
|
*/ |
| 582 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
| 583 |
|
|
| 584 |
|
for(int i=0; i<6; i++){ |
| 585 |
|
|
| 586 |
|
// cout << i<<" - "<<xgood[i]<<" "<<XGood(i)<<endl; |
| 587 |
|
// cout << i<<" - "<<ygood[i]<<" "<<YGood(i)<<endl; |
| 588 |
|
track.xgood[i]=XGood(i); |
| 589 |
|
track.ygood[i]=YGood(i); |
| 590 |
|
|
| 591 |
|
track.xm[i]=xm[i]; |
| 592 |
|
track.ym[i]=ym[i]; |
| 593 |
|
track.zm[i]=zm[i]; |
| 594 |
|
|
| 595 |
|
// --- temporaneo ---------------------------- |
| 596 |
|
// andrebbe inserita la dimensione del sensore |
| 597 |
|
float segment = 100.; |
| 598 |
|
track.xm_a[i]=xm[i]; |
| 599 |
|
track.xm_b[i]=xm[i]; |
| 600 |
|
track.ym_a[i]=ym[i]; |
| 601 |
|
track.ym_b[i]=ym[i]; |
| 602 |
|
if( XGood(i) && !YGood(i) ){ |
| 603 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
| 604 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
| 605 |
|
}else if( !XGood(i) && YGood(i)){ |
| 606 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
| 607 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
| 608 |
|
} |
| 609 |
|
// --- temporaneo ---------------------------- |
| 610 |
|
|
| 611 |
|
track.resx[i]=resx[i]; |
| 612 |
|
track.resy[i]=resy[i]; |
| 613 |
|
track.tailx[i]=tailx[i]; |
| 614 |
|
track.taily[i]=taily[i]; |
| 615 |
|
} |
| 616 |
|
|
| 617 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
| 618 |
|
track.zini = 23.5; |
| 619 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
| 620 |
|
|
| 621 |
|
} |
| 622 |
|
/** |
| 623 |
|
* Method to set values from minimization-routine common |
| 624 |
|
*/ |
| 625 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
| 626 |
|
|
| 627 |
|
for(int i=0; i<5; i++) { |
| 628 |
|
al[i]=track->al[i]; |
| 629 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
| 630 |
|
} |
| 631 |
|
chi2 = track->chi2; |
| 632 |
|
nstep = track->nstep; |
| 633 |
|
for(int i=0; i<6; i++){ |
| 634 |
|
xv[i] = track->xv[i]; |
| 635 |
|
yv[i] = track->yv[i]; |
| 636 |
|
zv[i] = track->zv[i]; |
| 637 |
|
xm[i] = track->xm[i]; |
| 638 |
|
ym[i] = track->ym[i]; |
| 639 |
|
zm[i] = track->zm[i]; |
| 640 |
|
axv[i] = track->axv[i]; |
| 641 |
|
ayv[i] = track->ayv[i]; |
| 642 |
|
} |
| 643 |
|
|
| 644 |
|
} |
| 645 |
/** |
/** |
| 646 |
* Tracking method. It calls F77 mini routine. |
* \brief Method to re-evaluate coordinates of clusters associated with a track. |
| 647 |
|
* |
| 648 |
|
* The method can be applied only after recovering level1 information |
| 649 |
|
* (either by reprocessing single events from level0 or from |
| 650 |
|
* the TrkLevel1 branch, if present); it calls F77 subroutines that |
| 651 |
|
* read the level1 common and fill the minimization-routine common. |
| 652 |
|
* Some clusters can be excluded or added by means of the methods: |
| 653 |
|
* |
| 654 |
|
* TrkTrack::ResetXGood(int ip) |
| 655 |
|
* TrkTrack::ResetYGood(int ip) |
| 656 |
|
* TrkTrack::SetXGood(int ip, int cid, int is) |
| 657 |
|
* TrkTrack::SetYGood(int ip, int cid, int is) |
| 658 |
|
* |
| 659 |
|
* NB! The method TrkTrack::SetGood(int *xg, int *yg) set the plane-mask (0-1) |
| 660 |
|
* for the minimization-routine common. It deletes the cluster information |
| 661 |
|
* (at least for the moment...) thus cannot be applied before |
| 662 |
|
* TrkTrack::EvaluateClusterPositions(). |
| 663 |
|
* |
| 664 |
|
* Different p.f.a. can be applied by calling (once) the method: |
| 665 |
|
* |
| 666 |
|
* TrkParams::SetPFA(0); //Set ETA p.f.a. |
| 667 |
|
* |
| 668 |
|
* @see TrkParams::SetPFA(int) |
| 669 |
*/ |
*/ |
| 670 |
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
Bool_t TrkTrack::EvaluateClusterPositions(){ |
| 671 |
|
|
| 672 |
|
// cout << "void TrkTrack::GetClusterPositions() "<<endl; |
| 673 |
|
|
| 674 |
|
TrkParams::Load( ); |
| 675 |
|
if( !TrkParams::IsLoaded() )return false; |
| 676 |
|
|
| 677 |
|
for(int ip=0; ip<6; ip++){ |
| 678 |
|
// cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;; |
| 679 |
|
int icx = GetClusterX_ID(ip)+1; |
| 680 |
|
int icy = GetClusterY_ID(ip)+1; |
| 681 |
|
int sensor = GetSensor(ip)+1;//<< convenzione "Paolo" |
| 682 |
|
if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena" |
| 683 |
|
int ladder = GetLadder(ip)+1; |
| 684 |
|
float ax = axv[ip]; |
| 685 |
|
float ay = ayv[ip]; |
| 686 |
|
float v[3]; |
| 687 |
|
v[0]=xv[ip]; |
| 688 |
|
v[1]=yv[ip]; |
| 689 |
|
v[2]=zv[ip]; |
| 690 |
|
float bfx = 10*TrkParams::GetBX(v);//Tesla |
| 691 |
|
float bfy = 10*TrkParams::GetBY(v);//Tesla |
| 692 |
|
int ipp=ip+1; |
| 693 |
|
xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy); |
| 694 |
|
if(icx<0 || icy<0)return false; |
| 695 |
|
} |
| 696 |
|
return true; |
| 697 |
|
} |
| 698 |
|
/** |
| 699 |
|
* \brief Tracking method. It calls F77 mini routine. |
| 700 |
|
* |
| 701 |
|
* @param pfixed Particle momentum. If pfixed=0 the momentum |
| 702 |
|
* is left as a free parameter, otherwise it is fixed to the input value. |
| 703 |
|
* @param fail Output flag (!=0 if the fit failed). |
| 704 |
|
* @param iprint Flag to set debug mode ( 0 = no output; 1 = verbose; 2 = debug). |
| 705 |
|
* @param froml1 Flag to re-evaluate positions (see TrkTrack::GetClusterPositions()). |
| 706 |
|
* |
| 707 |
|
* The option to re-evaluate positions can be used only after recovering |
| 708 |
|
* level1 information, eg. by reprocessing the single event. |
| 709 |
|
* |
| 710 |
|
* Example: |
| 711 |
|
* |
| 712 |
|
* if( !event->GetTrkLevel0() )return false; |
| 713 |
|
* event->GetTrkLevel0()->ProcessEvent(); // re-processing level0->level1 |
| 714 |
|
* int fail=0; |
| 715 |
|
* event->GetTrkLevel2()->GetTrack(0)->Fit(0.,fail,0,1); |
| 716 |
|
* |
| 717 |
|
* @see EvaluateClusterPositions() |
| 718 |
|
* |
| 719 |
|
* The fitting procedure can be varied by changing the tracking mode, |
| 720 |
|
* the fit-precision factor and the minimum number of step. |
| 721 |
|
* @see SetTrackingMode(int) |
| 722 |
|
* @see SetPrecisionFactor(double) |
| 723 |
|
* @see SetStepMin(int) |
| 724 |
|
*/ |
| 725 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){ |
| 726 |
|
|
| 727 |
float al_ini[] = {0.,0.,0.,0.,0.}; |
float al_ini[] = {0.,0.,0.,0.,0.}; |
| 728 |
|
|
| 729 |
|
TrkParams::Load( ); |
| 730 |
|
if( !TrkParams::IsLoaded() )return; |
| 731 |
|
|
| 732 |
extern cMini2track track_; |
extern cMini2track track_; |
| 733 |
fail = 0; |
fail = 0; |
| 734 |
|
|
| 735 |
for(int i=0; i<6; i++) track_.xm[i]=xm[i]; |
FillMiniStruct(track_); |
| 736 |
for(int i=0; i<6; i++) track_.ym[i]=ym[i]; |
|
| 737 |
for(int i=0; i<6; i++) track_.zm[i]=zm[i]; |
if(froml1!=0){ |
| 738 |
for(int i=0; i<6; i++) track_.resx[i]=resx[i]; |
if( !EvaluateClusterPositions() ){ |
| 739 |
for(int i=0; i<6; i++) track_.resy[i]=resy[i]; |
cout << "void TrkTrack::Fit("<<pfixed<<","<<fail<<","<<iprint<<","<<froml1<<") --- ERROR evaluating cluster positions "<<endl; |
| 740 |
for(int i=0; i<6; i++) track_.xgood[i]=xgood[i]; |
FillMiniStruct(track_) ; |
| 741 |
for(int i=0; i<6; i++) track_.ygood[i]=ygood[i]; |
fail = 1; |
| 742 |
|
return; |
| 743 |
// initial guess of "al" with linear fit |
} |
| 744 |
// if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){ |
}else{ |
| 745 |
// cout << "initial guess "<<endl; |
FillMiniStruct(track_); |
| 746 |
// double szz=0., szx=0., szy=0., ssx=0., ssy=0., sz=0., s1=0.; |
} |
| 747 |
// double det, ax, ay, bx, by; |
|
| 748 |
// for(int i=0; i<NPLANE; i++) { |
// if fit variables have been reset, evaluate the initial guess |
|
// szz=szz+zm[i]*zm[i]; |
|
|
// szx=szx+zm[i]*xm[i]; |
|
|
// szy=szy+zm[i]*ym[i]; |
|
|
// ssx=ssx+xm[i]; |
|
|
// ssy=ssy+ym[i]; |
|
|
// sz=sz+zm[i]; |
|
|
// s1=s1+1.; |
|
|
// } |
|
|
// det=szz*s1-sz*sz; |
|
|
// ax=(szx*s1-sz*ssx)/det; |
|
|
// bx=(szz*ssx-szx*sz)/det; |
|
|
// ay=(szy*s1-sz*ssy)/det; |
|
|
// by=(szz*ssy-szy*sz)/det; |
|
|
// al[0]=ax*23.5+bx; // ZINI = 23.5 !!! it should be the same parameter in all codes |
|
|
// al[1]=ay*23.5+by; // " |
|
|
// al[2]= sqrt(pow(ax,2)+pow(ay,2))/ sqrt(pow(ax,2)+pow(ay,2)+1.); |
|
|
// al[3]=0.; |
|
|
// if( (ax!=0.)||(ay!=0.) ) { |
|
|
// al[3]= asin(ay/ sqrt(pow(ax,2)+pow(ay,2))); |
|
|
// if(ax<0.) al[3]=acos(-1.)-al[3]; |
|
|
// } |
|
|
// al[4]=0.; |
|
|
// } |
|
|
// end guess |
|
|
|
|
|
for(int i=0; i<5; i++) track_.al[i]=al[i]; |
|
|
track_.zini = 23.5; |
|
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
|
|
|
|
| 749 |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
| 750 |
|
|
| 751 |
// --------------------- free momentum |
// --------------------- free momentum |
| 752 |
if(pfixed==0.) { |
if(pfixed==0.) { |
| 753 |
// al[4]=0.; // free momentum |
track_.pfixed=0.; |
|
track_.pfixed=0.; // " |
|
| 754 |
} |
} |
| 755 |
// --------------------- fixed momentum |
// --------------------- fixed momentum |
| 756 |
if(pfixed!=0.) { |
if(pfixed!=0.) { |
| 757 |
al[4]=1./pfixed; // to fix the momentum |
al[4]=1./pfixed; |
| 758 |
track_.pfixed=pfixed; // " |
track_.pfixed=pfixed; |
| 759 |
} |
} |
| 760 |
|
|
| 761 |
// store temporarily the initial guess |
// store temporarily the initial guess |
| 762 |
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
| 763 |
|
|
| 764 |
|
// ------------------------------------------ |
| 765 |
|
// call mini routine |
| 766 |
|
// TrkParams::Load(1); |
| 767 |
|
// if( !TrkParams::IsLoaded(1) ){ |
| 768 |
|
// cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
| 769 |
|
// return; |
| 770 |
|
// } |
| 771 |
int istep=0; |
int istep=0; |
| 772 |
int ifail=0; |
int ifail=0; |
| 773 |
mini2_(&istep,&ifail, &iprint); |
mini2_(&istep,&ifail, &iprint); |
| 774 |
if(ifail!=0) { |
if(ifail!=0) { |
| 775 |
if(iprint==1)cout << "ERROR: ifail= " << ifail << endl; |
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
| 776 |
fail = 1; |
fail = 1; |
|
// return; |
|
| 777 |
} |
} |
| 778 |
|
// ------------------------------------------ |
| 779 |
|
|
| 780 |
|
SetFromMiniStruct(&track_); |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
|
|
|
|
|
for(int i=0; i<5; i++) al[i]=track_.al[i]; |
|
|
chi2=track_.chi2; |
|
|
nstep=track_.nstep; |
|
|
for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
|
|
for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
|
|
for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
|
|
for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
|
|
for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
|
|
for(int i=0; i<5; i++) { |
|
|
for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
|
|
} |
|
| 781 |
|
|
| 782 |
if(fail){ |
if(fail){ |
| 783 |
cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
if(iprint)cout << " >>>> fit failed "<<endl; |
| 784 |
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
| 785 |
} |
} |
| 786 |
|
|
| 787 |
}; |
}; |
| 788 |
/* |
/** |
| 789 |
* Reset the fit parameters |
* Reset the fit parameters |
| 790 |
*/ |
*/ |
| 791 |
void TrkTrack::FitReset(){ |
void TrkTrack::FitReset(){ |
| 792 |
for(int i=0; i<5; i++) al[i]=-9999.; |
for(int i=0; i<5; i++) al[i]=-9999.; |
| 793 |
chi2=0.; |
chi2=0.; |
| 794 |
nstep=0; |
nstep=0; |
| 795 |
for(int i=0; i<6; i++) xv[i]=0.; |
// for(int i=0; i<6; i++) xv[i]=0.; |
| 796 |
for(int i=0; i<6; i++) yv[i]=0.; |
// for(int i=0; i<6; i++) yv[i]=0.; |
| 797 |
for(int i=0; i<6; i++) zv[i]=0.; |
// for(int i=0; i<6; i++) zv[i]=0.; |
| 798 |
for(int i=0; i<6; i++) axv[i]=0.; |
// for(int i=0; i<6; i++) axv[i]=0.; |
| 799 |
for(int i=0; i<6; i++) ayv[i]=0.; |
// for(int i=0; i<6; i++) ayv[i]=0.; |
| 800 |
for(int i=0; i<5; i++) { |
for(int i=0; i<5; i++) { |
| 801 |
for(int j=0; j<5; j++) coval[i][j]=0.; |
for(int j=0; j<5; j++) coval[i][j]=0.; |
| 802 |
} |
} |
| 803 |
} |
} |
| 804 |
|
/** |
| 805 |
|
* Set the tracking mode |
| 806 |
|
*/ |
| 807 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
| 808 |
|
extern cMini2track track_; |
| 809 |
|
track_.trackmode = trackmode; |
| 810 |
|
} |
| 811 |
|
/** |
| 812 |
|
* Set the factor scale for tracking precision |
| 813 |
|
*/ |
| 814 |
|
void TrkTrack::SetPrecisionFactor(double fact){ |
| 815 |
|
extern cMini2track track_; |
| 816 |
|
track_.fact = fact; |
| 817 |
|
} |
| 818 |
|
/** |
| 819 |
|
* Set the minimum number of steps for tracking precision |
| 820 |
|
*/ |
| 821 |
|
void TrkTrack::SetStepMin(int istepmin){ |
| 822 |
|
extern cMini2track track_; |
| 823 |
|
track_.istepmin = istepmin; |
| 824 |
|
} |
| 825 |
|
/** |
| 826 |
|
* Returns 1 if the track is inside the magnet cavity |
| 827 |
|
* Set the minimum number of steps for tracking precision |
| 828 |
|
*/ |
| 829 |
|
Bool_t TrkTrack::IsInsideCavity(){ |
| 830 |
|
float xmagntop, ymagntop, xmagnbottom, ymagnbottom; |
| 831 |
|
xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*axv[0]/180.); |
| 832 |
|
ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*ayv[0]/180.); |
| 833 |
|
xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*axv[5]/180.); |
| 834 |
|
ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*ayv[5]/180.); |
| 835 |
|
if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH && |
| 836 |
|
ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH && |
| 837 |
|
xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH && |
| 838 |
|
ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true); |
| 839 |
|
else return(false); |
| 840 |
|
} |
| 841 |
|
/** |
| 842 |
|
* Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. |
| 843 |
|
* If no cluster is associated, ID=-1. |
| 844 |
|
* @param ip Tracker plane (0-5) |
| 845 |
|
*/ |
| 846 |
|
Int_t TrkTrack::GetClusterX_ID(int ip){ |
| 847 |
|
return ((Int_t)fabs(xgood[ip]))%10000000-1; |
| 848 |
|
}; |
| 849 |
|
/** |
| 850 |
|
* Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. |
| 851 |
|
* If no cluster is associated, ID=-1. |
| 852 |
|
* @param ip Tracker plane (0-5) |
| 853 |
|
*/ |
| 854 |
|
Int_t TrkTrack::GetClusterY_ID(int ip){ |
| 855 |
|
return ((Int_t)fabs(ygood[ip]))%10000000-1; |
| 856 |
|
}; |
| 857 |
|
/** |
| 858 |
|
* Method to retrieve the ladder (0-4, increasing x) traversed by the track on this plane. |
| 859 |
|
* If no ladder is traversed (dead area) the metod retuns -1. |
| 860 |
|
* @param ip Tracker plane (0-5) |
| 861 |
|
*/ |
| 862 |
|
Int_t TrkTrack::GetLadder(int ip){ |
| 863 |
|
if(XGood(ip))return (Int_t)fabs(xgood[ip]/100000000)-1; |
| 864 |
|
if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1; |
| 865 |
|
return -1; |
| 866 |
|
}; |
| 867 |
|
/** |
| 868 |
|
* Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane. |
| 869 |
|
* If no sensor is traversed (dead area) the metod retuns -1. |
| 870 |
|
* @param ip Tracker plane (0-5) |
| 871 |
|
*/ |
| 872 |
|
Int_t TrkTrack::GetSensor(int ip){ |
| 873 |
|
if(XGood(ip))return (Int_t)((Int_t)fabs(xgood[ip]/10000000)%10)-1; |
| 874 |
|
if(YGood(ip))return (Int_t)((Int_t)fabs(ygood[ip]/10000000)%10)-1; |
| 875 |
|
return -1; |
| 876 |
|
}; |
| 877 |
|
|
| 878 |
|
/** |
| 879 |
|
* \brief Method to include a x-cluster to the track. |
| 880 |
|
* @param ip Tracker plane (0-5) |
| 881 |
|
* @param clid Cluster ID (0,1,...) |
| 882 |
|
* @param is Sensor (0-1, increasing y) |
| 883 |
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
| 884 |
|
*/ |
| 885 |
|
void TrkTrack::SetXGood(int ip, int clid, int is){ |
| 886 |
|
int il=0; //ladder (temporary) |
| 887 |
|
bool bad=false; //ladder (temporary) |
| 888 |
|
xgood[ip]=il*100000000+is*10000000+clid; |
| 889 |
|
if(bad)xgood[ip]=-xgood[ip]; |
| 890 |
|
}; |
| 891 |
|
/** |
| 892 |
|
* \brief Method to include a y-cluster to the track. |
| 893 |
|
* @param ip Tracker plane (0-5) |
| 894 |
|
* @param clid Cluster ID (0,1,...) |
| 895 |
|
* @param is Sensor (0-1) |
| 896 |
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
| 897 |
|
*/ |
| 898 |
|
void TrkTrack::SetYGood(int ip, int clid, int is){ |
| 899 |
|
int il=0; //ladder (temporary) |
| 900 |
|
bool bad=false; //ladder (temporary) |
| 901 |
|
ygood[ip]=il*100000000+is*10000000+clid; |
| 902 |
|
if(bad)ygood[ip]=-ygood[ip]; |
| 903 |
|
}; |
| 904 |
|
|
| 905 |
//-------------------------------------- |
//-------------------------------------- |
| 906 |
// |
// |
| 907 |
// |
// |
| 908 |
//-------------------------------------- |
//-------------------------------------- |
| 909 |
void TrkTrack::Clear(){ |
void TrkTrack::Clear(){ |
| 910 |
seqno = -1; |
// cout << "TrkTrack::Clear()"<<endl; |
| 911 |
image = -1; |
seqno = -1; |
| 912 |
chi2 = 0; |
image = -1; |
| 913 |
nstep = 0; |
chi2 = 0; |
| 914 |
for(int it1=0;it1<5;it1++){ |
nstep = 0; |
| 915 |
al[it1] = 0; |
for(int it1=0;it1<5;it1++){ |
| 916 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
al[it1] = 0; |
| 917 |
}; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
| 918 |
for(int ip=0;ip<6;ip++){ |
}; |
| 919 |
xgood[ip] = 0; |
for(int ip=0;ip<6;ip++){ |
| 920 |
ygood[ip] = 0; |
xgood[ip] = 0; |
| 921 |
xm[ip] = 0; |
ygood[ip] = 0; |
| 922 |
ym[ip] = 0; |
xm[ip] = 0; |
| 923 |
zm[ip] = 0; |
ym[ip] = 0; |
| 924 |
resx[ip] = 0; |
zm[ip] = 0; |
| 925 |
resy[ip] = 0; |
resx[ip] = 0; |
| 926 |
xv[ip] = 0; |
resy[ip] = 0; |
| 927 |
yv[ip] = 0; |
tailx[ip] = 0; |
| 928 |
zv[ip] = 0; |
taily[ip] = 0; |
| 929 |
axv[ip] = 0; |
xv[ip] = 0; |
| 930 |
ayv[ip] = 0; |
yv[ip] = 0; |
| 931 |
dedx_x[ip] = 0; |
zv[ip] = 0; |
| 932 |
dedx_y[ip] = 0; |
axv[ip] = 0; |
| 933 |
// clx[ip] = 0; |
ayv[ip] = 0; |
| 934 |
// cly[ip] = 0; |
dedx_x[ip] = 0; |
| 935 |
}; |
dedx_y[ip] = 0; |
| 936 |
clx->Clear(); |
|
| 937 |
cly->Clear(); |
}; |
| 938 |
|
// if(clx)clx->Clear(); |
| 939 |
|
// if(cly)cly->Clear(); |
| 940 |
|
// clx.Clear(); |
| 941 |
|
// cly.Clear(); |
| 942 |
}; |
}; |
| 943 |
//-------------------------------------- |
//-------------------------------------- |
| 944 |
// |
// |
| 945 |
// |
// |
| 946 |
//-------------------------------------- |
//-------------------------------------- |
| 947 |
void TrkTrack::Delete(){ |
void TrkTrack::Delete(){ |
| 948 |
Clear(); |
// cout << "TrkTrack::Delete()"<<endl; |
| 949 |
clx->Delete(); |
Clear(); |
| 950 |
cly->Delete(); |
// if(clx)delete clx; |
| 951 |
|
// if(cly)delete cly; |
| 952 |
}; |
}; |
| 953 |
//-------------------------------------- |
//-------------------------------------- |
| 954 |
// |
// |
| 955 |
// |
// |
| 956 |
//-------------------------------------- |
//-------------------------------------- |
| 960 |
// |
// |
| 961 |
//-------------------------------------- |
//-------------------------------------- |
| 962 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
| 963 |
|
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
| 964 |
plane = 0; |
plane = 0; |
| 965 |
coord[0] = 0; |
coord[0] = 0; |
| 966 |
coord[1] = 0; |
coord[1] = 0; |
| 967 |
sgnl = 0; |
sgnl = 0; |
| 968 |
cls = 0; |
// cls = 0; |
| 969 |
}; |
}; |
| 970 |
//-------------------------------------- |
//-------------------------------------- |
| 971 |
// |
// |
| 972 |
// |
// |
| 973 |
//-------------------------------------- |
//-------------------------------------- |
| 974 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
| 975 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
| 976 |
plane = s.plane; |
plane = s.plane; |
| 977 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
| 978 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
| 979 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
| 980 |
// cls = 0;//<<<<pointer |
// cls = 0;//<<<<pointer |
| 981 |
cls = TRef(s.cls); |
// cls = TRef(s.cls); |
| 982 |
}; |
}; |
| 983 |
//-------------------------------------- |
//-------------------------------------- |
| 984 |
// |
// |
| 995 |
// |
// |
| 996 |
// |
// |
| 997 |
//-------------------------------------- |
//-------------------------------------- |
| 998 |
|
void TrkSinglet::Clear(){ |
| 999 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
| 1000 |
|
// cls=0; |
| 1001 |
|
plane=-1; |
| 1002 |
|
coord[0]=-999; |
| 1003 |
|
coord[1]=-999; |
| 1004 |
|
sgnl=0; |
| 1005 |
|
|
| 1006 |
|
} |
| 1007 |
|
//-------------------------------------- |
| 1008 |
|
// |
| 1009 |
|
// |
| 1010 |
|
//-------------------------------------- |
| 1011 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
| 1012 |
// good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
| 1013 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
| 1014 |
// crc[i] = -1; |
good[i] = -1; |
| 1015 |
good[i] = -1; |
VKmask[i] = 0; |
| 1016 |
}; |
VKflag[i] = 0; |
| 1017 |
Track = new TClonesArray("TrkTrack"); |
}; |
| 1018 |
SingletX = new TClonesArray("TrkSinglet"); |
Track = 0; |
| 1019 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletX = 0; |
| 1020 |
|
SingletY = 0; |
| 1021 |
|
|
| 1022 |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
} |
| 1023 |
//sostituire con TRefArray... appena ho capito come si usa |
//-------------------------------------- |
| 1024 |
|
// |
| 1025 |
|
// |
| 1026 |
|
//-------------------------------------- |
| 1027 |
|
void TrkLevel2::Set(){ |
| 1028 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
| 1029 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
| 1030 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
| 1031 |
} |
} |
| 1032 |
//-------------------------------------- |
//-------------------------------------- |
| 1033 |
// |
// |
| 1035 |
//-------------------------------------- |
//-------------------------------------- |
| 1036 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
| 1037 |
|
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &sx = *SingletX; |
|
|
TClonesArray &sy = *SingletY; |
|
| 1038 |
// |
// |
| 1039 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
| 1040 |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
| 1041 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
| 1042 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
| 1043 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
| 1044 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
if(Track){ |
| 1045 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
TClonesArray &t = *Track; |
| 1046 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
| 1047 |
|
} |
| 1048 |
|
if(SingletX){ |
| 1049 |
|
TClonesArray &sx = *SingletX; |
| 1050 |
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
| 1051 |
|
} |
| 1052 |
|
if(SingletY){ |
| 1053 |
|
TClonesArray &sy = *SingletY; |
| 1054 |
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
| 1055 |
|
} |
| 1056 |
} |
} |
| 1057 |
|
/** |
| 1058 |
|
* \brief Dump processing status |
| 1059 |
|
*/ |
| 1060 |
|
void TrkLevel2::StatusDump(int view){ |
| 1061 |
|
cout << "DSP n. "<<view+1<<" status: "<<hex<<good[view]<<endl; |
| 1062 |
|
}; |
| 1063 |
|
/** |
| 1064 |
|
* \brief Check event status |
| 1065 |
|
* |
| 1066 |
|
* Check the event status, according to a flag-mask given as input. |
| 1067 |
|
* Return true if the view passes the check. |
| 1068 |
|
* |
| 1069 |
|
* @param view View number (0-11) |
| 1070 |
|
* @param flagmask Mask of flags to check (eg. flagmask=0x111 no missing packet, |
| 1071 |
|
* no crc error, no software alarm) |
| 1072 |
|
* |
| 1073 |
|
* @see TrkLevel2 class definition to know how the status flag is defined |
| 1074 |
|
* |
| 1075 |
|
*/ |
| 1076 |
|
Bool_t TrkLevel2::StatusCheck(int view, int flagmask){ |
| 1077 |
|
|
| 1078 |
|
if( view<0 || view >= 12)return false; |
| 1079 |
|
return !(good[view]&flagmask); |
| 1080 |
|
|
| 1081 |
|
}; |
| 1082 |
|
|
| 1083 |
|
|
| 1084 |
//-------------------------------------- |
//-------------------------------------- |
| 1085 |
// |
// |
| 1086 |
// |
// |
| 1087 |
//-------------------------------------- |
//-------------------------------------- |
| 1088 |
/** |
/** |
| 1089 |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
* The method returns false if the viking-chip was masked |
| 1090 |
|
* either apriori ,on the basis of the mask read from the DB, |
| 1091 |
|
* or run-by-run, on the basis of the calibration parameters) |
| 1092 |
|
* @param iv Tracker view (0-11) |
| 1093 |
|
* @param ivk Viking-chip number (0-23) |
| 1094 |
|
*/ |
| 1095 |
|
Bool_t TrkLevel2::GetVKMask(int iv, int ivk){ |
| 1096 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
| 1097 |
|
return (whichbit&VKmask[iv])!=0; |
| 1098 |
|
} |
| 1099 |
|
/** |
| 1100 |
|
* The method returns false if the viking-chip was masked |
| 1101 |
|
* for this event due to common-noise computation failure. |
| 1102 |
|
* @param iv Tracker view (0-11) |
| 1103 |
|
* @param ivk Viking-chip number (0-23) |
| 1104 |
|
*/ |
| 1105 |
|
Bool_t TrkLevel2::GetVKFlag(int iv, int ivk){ |
| 1106 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
| 1107 |
|
return (whichbit&VKflag[iv])!=0; |
| 1108 |
|
} |
| 1109 |
|
/** |
| 1110 |
|
* The method returns true if the viking-chip was masked, either |
| 1111 |
|
* forced (see TrkLevel2::GetVKMask(int,int)) or |
| 1112 |
|
* for this event only (TrkLevel2::GetVKFlag(int,int)). |
| 1113 |
|
* @param iv Tracker view (0-11) |
| 1114 |
|
* @param ivk Viking-chip number (0-23) |
| 1115 |
*/ |
*/ |
| 1116 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){ |
| 1117 |
|
return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) ); |
| 1118 |
|
}; |
| 1119 |
|
|
| 1120 |
// temporary objects: |
//-------------------------------------- |
| 1121 |
|
// |
| 1122 |
|
// |
| 1123 |
|
//-------------------------------------- |
| 1124 |
|
/** |
| 1125 |
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
| 1126 |
|
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
| 1127 |
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
| 1128 |
|
*/ |
| 1129 |
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
| 1130 |
|
|
| 1131 |
|
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
| 1132 |
|
Clear(); |
| 1133 |
|
|
| 1134 |
|
// temporary objects: |
| 1135 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
| 1136 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
| 1137 |
|
|
| 1138 |
// **** general variables **** |
// ----------------- |
| 1139 |
// good2 = l2->good2; |
// general variables |
| 1140 |
|
// ----------------- |
| 1141 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
| 1142 |
// crc[i] = l2->crc[i]; |
good[i] = l2->good[i]; |
| 1143 |
good[i] = l2->good[i]; |
VKmask[i]=0; |
| 1144 |
|
VKflag[i]=0; |
| 1145 |
|
for(Int_t ii=0; ii<24 ; ii++){ |
| 1146 |
|
Int_t setbit = (Int_t)pow(2,ii); |
| 1147 |
|
if( l2->vkflag[ii][i]!=-1 )VKmask[i]=VKmask[i]|setbit; |
| 1148 |
|
if( l2->vkflag[ii][i]!=0 )VKflag[i]=VKflag[i]|setbit; |
| 1149 |
}; |
}; |
| 1150 |
// *** TRACKS *** |
}; |
| 1151 |
|
// -------------- |
| 1152 |
|
// *** TRACKS *** |
| 1153 |
|
// -------------- |
| 1154 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
| 1155 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
| 1156 |
|
|
| 1157 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
| 1158 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
| 1159 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
| 1160 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
t_track->chi2 = l2->chi2_nt[i]; |
| 1161 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->nstep = l2->nstep_nt[i]; |
| 1162 |
t_track->nstep = l2->nstep_nt[i]; |
for(int it1=0;it1<5;it1++){ |
| 1163 |
for(int it1=0;it1<5;it1++){ |
t_track->al[it1] = l2->al_nt[i][it1]; |
| 1164 |
t_track->al[it1] = l2->al_nt[i][it1]; |
for(int it2=0;it2<5;it2++) |
| 1165 |
for(int it2=0;it2<5;it2++) |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
| 1166 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
}; |
| 1167 |
}; |
for(int ip=0;ip<6;ip++){ |
| 1168 |
for(int ip=0;ip<6;ip++){ |
// --------------------------------- |
| 1169 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
// new implementation of xgood/ygood |
| 1170 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
// --------------------------------- |
| 1171 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
t_track->xgood[ip] = l2->cltrx[i][ip]; //cluster ID |
| 1172 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->ygood[ip] = l2->cltry[i][ip]; //cluster ID |
| 1173 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->xgood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
| 1174 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
t_track->ygood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
| 1175 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
if(l2->xbad[i][ip]>0)t_track->xgood[ip]=-t_track->xgood[ip]; |
| 1176 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
if(l2->ybad[i][ip]>0)t_track->ygood[ip]=-t_track->ygood[ip]; |
| 1177 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
// if(l2->xbad[i][ip]>0 || l2->ybad[i][ip]>0){ |
| 1178 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
// if(l2->dedx_x[i][ip]<0 || l2->dedx_y[i][ip]<0){ |
| 1179 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
// cout << ip << " - "<< l2->cltrx[i][ip] << " "<<l2->cltry[i][ip]<<" "<<l2->ls[i][ip]<<endl; |
| 1180 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
// cout << ip << " - "<<t_track->xgood[ip]<<" "<<t_track->ygood[ip]<<endl; |
| 1181 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
// cout << ip << " - "<<t_track->GetClusterX_ID(ip)<<" "<<t_track->GetClusterY_ID(ip)<<" "<<t_track->GetLadder(ip)<<" "<<t_track->GetSensor(ip)<<endl; |
| 1182 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
// cout << ip << " - "<<t_track->BadClusterX(ip)<<" "<<t_track->BadClusterY(ip)<<endl; |
| 1183 |
// t_track->clx[ip] = 0; |
// cout << ip << " - "<<t_track->SaturatedClusterX(ip)<<" "<<t_track->SaturatedClusterY(ip)<<endl; |
| 1184 |
// t_track->cly[ip] = 0; |
// } |
| 1185 |
}; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
| 1186 |
new(t[i]) TrkTrack(*t_track); |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
| 1187 |
t_track->Clear(); |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
| 1188 |
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
| 1189 |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
| 1190 |
|
t_track->tailx[ip] = l2->tailx[i][ip]; |
| 1191 |
|
t_track->taily[ip] = l2->taily[i][ip]; |
| 1192 |
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
| 1193 |
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
| 1194 |
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
| 1195 |
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
| 1196 |
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
| 1197 |
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
| 1198 |
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
| 1199 |
|
//----------------------------------------------------- |
| 1200 |
|
//----------------------------------------------------- |
| 1201 |
|
//----------------------------------------------------- |
| 1202 |
|
//----------------------------------------------------- |
| 1203 |
|
}; |
| 1204 |
|
// if(t_track->IsSaturated())t_track->Dump(); |
| 1205 |
|
new(t[i]) TrkTrack(*t_track); |
| 1206 |
|
t_track->Clear(); |
| 1207 |
}; |
}; |
| 1208 |
|
|
| 1209 |
|
// ---------------- |
| 1210 |
// *** SINGLETS *** |
// *** SINGLETS *** |
| 1211 |
|
// ---------------- |
| 1212 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
| 1213 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
| 1214 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
| 1215 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
| 1216 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
| 1217 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
| 1218 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
| 1219 |
// t_singlet->cls = 0; |
//----------------------------------------------------- |
| 1220 |
new(sx[i]) TrkSinglet(*t_singlet); |
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
| 1221 |
t_singlet->Clear(); |
//----------------------------------------------------- |
| 1222 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
| 1223 |
|
t_singlet->Clear(); |
| 1224 |
} |
} |
| 1225 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
| 1226 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
| 1227 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
| 1228 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
| 1229 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
| 1230 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
| 1231 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
| 1232 |
// t_singlet->cls = 0; |
//----------------------------------------------------- |
| 1233 |
new(sy[i]) TrkSinglet(*t_singlet); |
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
| 1234 |
t_singlet->Clear(); |
//----------------------------------------------------- |
| 1235 |
}; |
new(sy[i]) TrkSinglet(*t_singlet); |
| 1236 |
|
t_singlet->Clear(); |
| 1237 |
delete t_track; |
}; |
|
delete t_singlet; |
|
|
} |
|
|
//-------------------------------------- |
|
|
// |
|
|
// |
|
|
//-------------------------------------- |
|
|
/** |
|
|
* 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 *** |
|
|
TClonesArray &t = *Track; |
|
|
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; |
|
|
//----------------------------------------------------- |
|
|
// t_track->clx[ip] = l1->GetCluster(l2->cltrx[i][ip]-1); |
|
|
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
|
|
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 *** |
|
|
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(); |
|
|
} |
|
|
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(); |
|
|
}; |
|
| 1238 |
|
|
| 1239 |
delete t_track; |
delete t_track; |
| 1240 |
delete t_singlet; |
delete t_singlet; |
| 1241 |
} |
} |
| 1242 |
/** |
/** |
| 1243 |
* 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). |
| 1253 |
}; |
}; |
| 1254 |
// *** TRACKS *** |
// *** TRACKS *** |
| 1255 |
|
|
| 1256 |
l2->ntrk = Track->GetEntries(); |
if(Track){ |
| 1257 |
for(Int_t i=0;i<l2->ntrk;i++){ |
l2->ntrk = Track->GetEntries(); |
| 1258 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
for(Int_t i=0;i<l2->ntrk;i++){ |
| 1259 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
| 1260 |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
| 1261 |
for(int it1=0;it1<5;it1++){ |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
| 1262 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
for(int it1=0;it1<5;it1++){ |
| 1263 |
for(int it2=0;it2<5;it2++) |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
| 1264 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
for(int it2=0;it2<5;it2++) |
| 1265 |
}; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
| 1266 |
for(int ip=0;ip<6;ip++){ |
}; |
| 1267 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
for(int ip=0;ip<6;ip++){ |
| 1268 |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip); |
| 1269 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip); |
| 1270 |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
| 1271 |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
| 1272 |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
| 1273 |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
| 1274 |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
| 1275 |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
l2->tailx[i][ip] = ((TrkTrack *)Track->At(i))->tailx[ip]; |
| 1276 |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
l2->taily[i][ip] = ((TrkTrack *)Track->At(i))->taily[ip]; |
| 1277 |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
| 1278 |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
| 1279 |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
| 1280 |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
| 1281 |
}; |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
| 1282 |
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
| 1283 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
| 1284 |
|
}; |
| 1285 |
|
} |
| 1286 |
} |
} |
|
|
|
| 1287 |
// *** SINGLETS *** |
// *** SINGLETS *** |
| 1288 |
l2->nclsx = SingletX->GetEntries(); |
if(SingletX){ |
| 1289 |
for(Int_t i=0;i<l2->nclsx;i++){ |
l2->nclsx = SingletX->GetEntries(); |
| 1290 |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
for(Int_t i=0;i<l2->nclsx;i++){ |
| 1291 |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
| 1292 |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
| 1293 |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
| 1294 |
} |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
| 1295 |
l2->nclsy = SingletY->GetEntries(); |
} |
| 1296 |
for(Int_t i=0;i<l2->nclsy;i++){ |
} |
| 1297 |
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
|
| 1298 |
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
if(SingletY){ |
| 1299 |
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
l2->nclsy = SingletY->GetEntries(); |
| 1300 |
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
for(Int_t i=0;i<l2->nclsy;i++){ |
| 1301 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
| 1302 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
| 1303 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
| 1304 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
| 1305 |
|
} |
| 1306 |
} |
} |
| 1307 |
} |
} |
| 1308 |
//-------------------------------------- |
//-------------------------------------- |
| 1310 |
// |
// |
| 1311 |
//-------------------------------------- |
//-------------------------------------- |
| 1312 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
// good2 = -1; |
|
| 1313 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
| 1314 |
// crc[i] = -1; |
good[i] = -1; |
| 1315 |
good[i] = -1; |
VKflag[i] = 0; |
| 1316 |
}; |
VKmask[i] = 0; |
| 1317 |
/* Track->RemoveAll(); |
}; |
| 1318 |
SingletX->RemoveAll(); |
// if(Track)Track->Clear("C"); |
| 1319 |
SingletY->RemoveAll();*/ |
// if(SingletX)SingletX->Clear("C"); |
| 1320 |
// modify to avoid memory leakage |
// if(SingletY)SingletY->Clear("C"); |
| 1321 |
Track->Clear(); |
if(Track)Track->Delete(); |
| 1322 |
SingletX->Clear(); |
if(SingletX)SingletX->Delete(); |
| 1323 |
SingletY->Clear(); |
if(SingletY)SingletY->Delete(); |
| 1324 |
} |
} |
| 1325 |
//-------------------------------------- |
// //-------------------------------------- |
| 1326 |
// |
// // |
| 1327 |
// |
// // |
| 1328 |
//-------------------------------------- |
// //-------------------------------------- |
| 1329 |
void TrkLevel2::Delete(){ |
void TrkLevel2::Delete(){ |
| 1330 |
|
|
| 1331 |
Clear(); |
// cout << "void TrkLevel2::Delete()"<<endl; |
| 1332 |
Track->Delete(); |
Clear(); |
| 1333 |
SingletX->Delete(); |
if(Track)delete Track; |
| 1334 |
SingletY->Delete(); |
if(SingletX)delete SingletX; |
| 1335 |
|
if(SingletY)delete SingletY; |
| 1336 |
|
|
| 1337 |
} |
} |
| 1338 |
//-------------------------------------- |
//-------------------------------------- |
| 1339 |
// |
// |
| 1345 |
*/ |
*/ |
| 1346 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
| 1347 |
|
|
| 1348 |
TRefArray *sorted = new TRefArray(); |
if(!Track)return 0; |
| 1349 |
|
|
| 1350 |
|
TRefArray *sorted = new TRefArray(); |
| 1351 |
|
|
| 1352 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
| 1353 |
// TClonesArray &ts = *PhysicalTrack; |
// TClonesArray &ts = *PhysicalTrack; |
| 1354 |
int N = ntrk(); |
int N = ntrk(); |
| 1355 |
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
| 1356 |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
| 1357 |
|
|
| 1358 |
int indo=0; |
int indo=0; |
| 1359 |
int indi=0; |
int indi=0; |
| 1360 |
while(N != 0){ |
while(N > 0){ |
| 1361 |
int nfit =0; |
// while(N != 0){ |
| 1362 |
float chi2ref = numeric_limits<float>::max(); |
int nfit =0; |
| 1363 |
|
float chi2ref = numeric_limits<float>::max(); |
| 1364 |
|
|
| 1365 |
// first loop to search maximum num. of fit points |
// first loop to search maximum num. of fit points |
| 1366 |
for(int i=0; i < ntrk(); i++){ |
for(int i=0; i < ntrk(); i++){ |
| 1367 |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
| 1368 |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
| 1369 |
} |
} |
| 1370 |
} |
} |
| 1371 |
//second loop to search minimum chi2 among selected |
//second loop to search minimum chi2 among selected |
| 1372 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i<ntrk(); i++){ |
| 1373 |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
| 1374 |
if(chi2 < 0) chi2 = chi2*1000; |
if(chi2 < 0) chi2 = -chi2*1000; |
| 1375 |
if( chi2 < chi2ref |
if( chi2 < chi2ref |
| 1376 |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
| 1377 |
&& m[i]==1){ |
&& m[i]==1){ |
| 1378 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
chi2ref = ((TrkTrack *)t[i])->chi2; |
| 1379 |
indi = i; |
indi = i; |
| 1380 |
}; |
}; |
| 1381 |
}; |
}; |
| 1382 |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
| 1383 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
| 1384 |
N--; |
N--; |
| 1385 |
|
|
| 1386 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
| 1387 |
}; |
}; |
| 1388 |
sorted->Add( (TrkTrack*)t[indi] ); |
sorted->Add( (TrkTrack*)t[indi] ); |
| 1389 |
|
|
| 1390 |
m[indi] = 0; |
m[indi] = 0; |
| 1391 |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
| 1392 |
N--; |
N--; |
| 1393 |
indo++; |
indo++; |
| 1394 |
} |
} |
| 1395 |
m.clear(); |
m.clear(); |
| 1396 |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
| 1397 |
|
|
| 1398 |
return sorted; |
return sorted; |
| 1399 |
// return PhysicalTrack; |
// return PhysicalTrack; |
| 1400 |
} |
} |
| 1401 |
//-------------------------------------- |
//-------------------------------------- |
| 1414 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
| 1415 |
return 0; |
return 0; |
| 1416 |
} |
} |
| 1417 |
|
if(!Track){ |
| 1418 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
| 1419 |
|
}; |
| 1420 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
| 1421 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
| 1422 |
return track; |
return track; |
| 1436 |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
| 1437 |
return 0; |
return 0; |
| 1438 |
} |
} |
| 1439 |
|
if(!SingletX)return 0; |
| 1440 |
TClonesArray &t = *(SingletX); |
TClonesArray &t = *(SingletX); |
| 1441 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
| 1442 |
return singlet; |
return singlet; |
| 1456 |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
| 1457 |
return 0; |
return 0; |
| 1458 |
} |
} |
| 1459 |
|
if(!SingletY)return 0; |
| 1460 |
TClonesArray &t = *(SingletY); |
TClonesArray &t = *(SingletY); |
| 1461 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
| 1462 |
return singlet; |
return singlet; |
| 1479 |
} |
} |
| 1480 |
|
|
| 1481 |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
| 1482 |
|
if(!sorted)return 0; |
| 1483 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
| 1484 |
sorted->Delete(); |
sorted->Clear(); |
| 1485 |
|
delete sorted; |
| 1486 |
return track; |
return track; |
| 1487 |
} |
} |
| 1488 |
/** |
/** |
| 1491 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
| 1492 |
|
|
| 1493 |
Float_t ntot=0; |
Float_t ntot=0; |
| 1494 |
|
if(!Track)return 0; |
| 1495 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
| 1496 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
| 1497 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
| 1510 |
*/ |
*/ |
| 1511 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
| 1512 |
|
|
| 1513 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
| 1514 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
| 1515 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
| 1516 |
return 0; |
return 0; |
| 1517 |
} |
} |
| 1518 |
|
|
| 1519 |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
| 1520 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
if(!sorted)return 0; |
| 1521 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
| 1522 |
|
|
| 1523 |
if(!track->HasImage()){ |
if(!track->HasImage()){ |
| 1524 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
| 1525 |
return 0; |
return 0; |
| 1526 |
} |
} |
| 1527 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
if(!Track)return 0; |
| 1528 |
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
| 1529 |
|
|
| 1530 |
sorted->Delete(); |
sorted->Delete(); |
| 1531 |
|
delete sorted; |
| 1532 |
return image; |
|
| 1533 |
|
return image; |
| 1534 |
|
|
| 1535 |
} |
} |
| 1536 |
//-------------------------------------- |
//-------------------------------------- |
| 1543 |
*/ |
*/ |
| 1544 |
void TrkLevel2::LoadField(TString path){ |
void TrkLevel2::LoadField(TString path){ |
| 1545 |
// |
// |
| 1546 |
strcpy(path_.path,path.Data()); |
// strcpy(path_.path,path.Data()); |
| 1547 |
path_.pathlen = path.Length(); |
// path_.pathlen = path.Length(); |
| 1548 |
path_.error = 0; |
// path_.error = 0; |
| 1549 |
readb_(); |
// readb_(); |
| 1550 |
|
|
| 1551 |
|
TrkParams::SetTrackingMode(); |
| 1552 |
|
TrkParams::SetPrecisionFactor(); |
| 1553 |
|
TrkParams::SetStepMin(); |
| 1554 |
|
|
| 1555 |
|
TrkParams::Set(path,1); |
| 1556 |
|
TrkParams::Load(1); |
| 1557 |
|
|
| 1558 |
// |
// |
| 1559 |
}; |
}; |
| 1560 |
|
// /** |
| 1561 |
|
// * Get BY (kGauss) |
| 1562 |
|
// * @param v (x,y,z) coordinates in cm |
| 1563 |
|
// */ |
| 1564 |
|
// float TrkLevel2::GetBX(float* v){ |
| 1565 |
|
// float b[3]; |
| 1566 |
|
// gufld_(v,b); |
| 1567 |
|
// return b[0]/10.; |
| 1568 |
|
// } |
| 1569 |
|
// /** |
| 1570 |
|
// * Get BY (kGauss) |
| 1571 |
|
// * @param v (x,y,z) coordinates in cm |
| 1572 |
|
// */ |
| 1573 |
|
// float TrkLevel2::GetBY(float* v){ |
| 1574 |
|
// float b[3]; |
| 1575 |
|
// gufld_(v,b); |
| 1576 |
|
// return b[1]/10.; |
| 1577 |
|
// } |
| 1578 |
|
// /** |
| 1579 |
|
// * Get BY (kGauss) |
| 1580 |
|
// * @param v (x,y,z) coordinates in cm |
| 1581 |
|
// */ |
| 1582 |
|
// float TrkLevel2::GetBZ(float* v){ |
| 1583 |
|
// float b[3]; |
| 1584 |
|
// gufld_(v,b); |
| 1585 |
|
// return b[2]/10.; |
| 1586 |
|
// } |
| 1587 |
//-------------------------------------- |
//-------------------------------------- |
| 1588 |
// |
// |
| 1589 |
// |
// |
| 1680 |
tl = new float[npoint]; |
tl = new float[npoint]; |
| 1681 |
int i=0; |
int i=0; |
| 1682 |
do{ |
do{ |
| 1683 |
x[i] = 0; |
x[i] = 0; |
| 1684 |
y[i] = 0; |
y[i] = 0; |
| 1685 |
z[i] = zin[i]; |
z[i] = zin[i]; |
| 1686 |
thx[i] = 0; |
thx[i] = 0; |
| 1687 |
thy[i] = 0; |
thy[i] = 0; |
| 1688 |
tl[i] = 0; |
tl[i] = 0; |
| 1689 |
i++; |
i++; |
| 1690 |
}while(zin[i-1] > zin[i] && i < npoint); |
}while(zin[i-1] > zin[i] && i < npoint); |
| 1691 |
npoint=i; |
npoint=i; |
| 1692 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
| 1693 |
} |
} |
| 1694 |
|
void Trajectory::Delete(){ |
| 1695 |
|
|
| 1696 |
|
if(x) delete [] x; |
| 1697 |
|
if(y) delete [] y; |
| 1698 |
|
if(z) delete [] z; |
| 1699 |
|
if(thx) delete [] thx; |
| 1700 |
|
if(thy) delete [] thy; |
| 1701 |
|
if(tl) delete [] tl; |
| 1702 |
|
|
| 1703 |
|
} |
| 1704 |
//-------------------------------------- |
//-------------------------------------- |
| 1705 |
// |
// |
| 1706 |
// |
// |
| 1739 |
|
|
| 1740 |
} |
} |
| 1741 |
|
|
| 1742 |
|
/** |
| 1743 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
| 1744 |
|
* 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. |
| 1745 |
|
* @param t pointer to an object of the class Trajectory, |
| 1746 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
| 1747 |
|
* @return error flag. |
| 1748 |
|
*/ |
| 1749 |
|
int Trajectory::DoTrack2(float* al){ |
| 1750 |
|
|
| 1751 |
|
double *dxout = new double[npoint]; |
| 1752 |
|
double *dyout = new double[npoint]; |
| 1753 |
|
double *dthxout = new double[npoint]; |
| 1754 |
|
double *dthyout = new double[npoint]; |
| 1755 |
|
double *dtlout = new double[npoint]; |
| 1756 |
|
double *dzin = new double[npoint]; |
| 1757 |
|
double dal[5]; |
| 1758 |
|
|
| 1759 |
|
int ifail = 0; |
| 1760 |
|
|
| 1761 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
| 1762 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
| 1763 |
|
|
| 1764 |
|
TrkParams::Load(1); |
| 1765 |
|
if( !TrkParams::IsLoaded(1) ){ |
| 1766 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
| 1767 |
|
return 0; |
| 1768 |
|
} |
| 1769 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
| 1770 |
|
|
| 1771 |
|
for (int i=0; i<npoint; i++){ |
| 1772 |
|
x[i] = (float)*dxout++; |
| 1773 |
|
y[i] = (float)*dyout++; |
| 1774 |
|
thx[i] = (float)*dthxout++; |
| 1775 |
|
thy[i] = (float)*dthyout++; |
| 1776 |
|
tl[i] = (float)*dtlout++; |
| 1777 |
|
} |
| 1778 |
|
|
| 1779 |
|
return ifail; |
| 1780 |
|
}; |
| 1781 |
|
|
| 1782 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
| 1783 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |