| 4 |
*/ |
*/ |
| 5 |
#include <TrkLevel2.h> |
#include <TrkLevel2.h> |
| 6 |
#include <iostream> |
#include <iostream> |
| 7 |
|
#include <math.h> |
| 8 |
using namespace std; |
using namespace std; |
| 9 |
//...................................... |
//...................................... |
| 10 |
// F77 routines |
// F77 routines |
| 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 |
int readb_(const char*); |
void mini2_(int*,int*,int*); |
| 16 |
void mini2_(int*,int*,int*); |
void guess_(); |
| 17 |
|
void gufld_(float*, float*); |
| 18 |
} |
} |
| 19 |
|
|
| 20 |
//-------------------------------------- |
//-------------------------------------- |
| 21 |
// |
// |
| 22 |
// |
// |
| 23 |
//-------------------------------------- |
//-------------------------------------- |
| 24 |
TrkTrack::TrkTrack(){ |
TrkTrack::TrkTrack(){ |
| 25 |
|
// cout << "TrkTrack::TrkTrack()" << endl; |
| 26 |
seqno = -1; |
seqno = -1; |
| 27 |
image = -1; |
image = -1; |
| 28 |
chi2 = 0; |
chi2 = 0; |
| 29 |
nstep = 0; |
nstep = 0; |
| 30 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
| 31 |
al[it1] = 0; |
al[it1] = 0; |
| 32 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
| 33 |
}; |
}; |
| 34 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
| 35 |
xgood[ip] = 0; |
xgood[ip] = 0; |
| 36 |
ygood[ip] = 0; |
ygood[ip] = 0; |
| 37 |
xm[ip] = 0; |
xm[ip] = 0; |
| 38 |
ym[ip] = 0; |
ym[ip] = 0; |
| 39 |
zm[ip] = 0; |
zm[ip] = 0; |
| 40 |
resx[ip] = 0; |
resx[ip] = 0; |
| 41 |
resy[ip] = 0; |
resy[ip] = 0; |
| 42 |
xv[ip] = 0; |
tailx[ip] = 0; |
| 43 |
yv[ip] = 0; |
taily[ip] = 0; |
| 44 |
zv[ip] = 0; |
xv[ip] = 0; |
| 45 |
axv[ip] = 0; |
yv[ip] = 0; |
| 46 |
ayv[ip] = 0; |
zv[ip] = 0; |
| 47 |
dedx_x[ip] = 0; |
axv[ip] = 0; |
| 48 |
dedx_y[ip] = 0; |
ayv[ip] = 0; |
| 49 |
// clx[ip] = 0; |
dedx_x[ip] = 0; |
| 50 |
// cly[ip] = 0; |
dedx_y[ip] = 0; |
| 51 |
}; |
}; |
| 52 |
clx = new TRefArray(6,0); |
// clx = 0; |
| 53 |
cly = new TRefArray(6,0); |
// cly = 0; |
| 54 |
|
// clx = new TRefArray(6,0); //forse causa memory leak??? |
| 55 |
|
// cly = new TRefArray(6,0); //forse causa memory leak??? |
| 56 |
|
// clx = TRefArray(6,0); |
| 57 |
|
// cly = TRefArray(6,0); |
| 58 |
|
|
| 59 |
}; |
}; |
| 60 |
//-------------------------------------- |
//-------------------------------------- |
| 61 |
// |
// |
| 65 |
seqno = t.seqno; |
seqno = t.seqno; |
| 66 |
image = t.image; |
image = t.image; |
| 67 |
chi2 = t.chi2; |
chi2 = t.chi2; |
| 68 |
nstep = t.nstep; |
nstep = t.nstep; |
| 69 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
| 70 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
| 71 |
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]; |
| 72 |
}; |
}; |
| 73 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
| 74 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
| 75 |
ygood[ip] = t.ygood[ip]; |
ygood[ip] = t.ygood[ip]; |
| 76 |
xm[ip] = t.xm[ip]; |
xm[ip] = t.xm[ip]; |
| 77 |
ym[ip] = t.ym[ip]; |
ym[ip] = t.ym[ip]; |
| 78 |
zm[ip] = t.zm[ip]; |
zm[ip] = t.zm[ip]; |
| 79 |
resx[ip] = t.resx[ip]; |
resx[ip] = t.resx[ip]; |
| 80 |
resy[ip] = t.resy[ip]; |
resy[ip] = t.resy[ip]; |
| 81 |
xv[ip] = t.xv[ip]; |
tailx[ip] = t.tailx[ip]; |
| 82 |
yv[ip] = t.yv[ip]; |
taily[ip] = t.taily[ip]; |
| 83 |
zv[ip] = t.zv[ip]; |
xv[ip] = t.xv[ip]; |
| 84 |
axv[ip] = t.axv[ip]; |
yv[ip] = t.yv[ip]; |
| 85 |
ayv[ip] = t.ayv[ip]; |
zv[ip] = t.zv[ip]; |
| 86 |
dedx_x[ip] = t.dedx_x[ip]; |
axv[ip] = t.axv[ip]; |
| 87 |
dedx_y[ip] = t.dedx_y[ip]; |
ayv[ip] = t.ayv[ip]; |
| 88 |
// clx[ip] = 0;//<<<<pointer |
dedx_x[ip] = t.dedx_x[ip]; |
| 89 |
// cly[ip] = 0;//<<<<pointer |
dedx_y[ip] = t.dedx_y[ip]; |
| 90 |
}; |
}; |
| 91 |
clx = new TRefArray(*(t.clx)); |
// clx = 0; |
| 92 |
cly = new TRefArray(*(t.cly)); |
// cly = 0; |
| 93 |
|
// if(t.clx)clx = new TRefArray(*(t.clx)); |
| 94 |
|
// if(t.cly)cly = new TRefArray(*(t.cly)); |
| 95 |
|
// clx = TRefArray(t.clx); |
| 96 |
|
// cly = TRefArray(t.cly); |
| 97 |
|
|
| 98 |
|
}; |
| 99 |
|
//-------------------------------------- |
| 100 |
|
// |
| 101 |
|
// |
| 102 |
|
//-------------------------------------- |
| 103 |
|
void TrkTrack::Copy(TrkTrack& t){ |
| 104 |
|
|
| 105 |
|
t.seqno = seqno; |
| 106 |
|
t.image = image; |
| 107 |
|
t.chi2 = chi2; |
| 108 |
|
t.nstep = nstep; |
| 109 |
|
for(int it1=0;it1<5;it1++){ |
| 110 |
|
t.al[it1] = al[it1]; |
| 111 |
|
for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2]; |
| 112 |
|
}; |
| 113 |
|
for(int ip=0;ip<6;ip++){ |
| 114 |
|
t.xgood[ip] = xgood[ip]; |
| 115 |
|
t.ygood[ip] = ygood[ip]; |
| 116 |
|
t.xm[ip] = xm[ip]; |
| 117 |
|
t.ym[ip] = ym[ip]; |
| 118 |
|
t.zm[ip] = zm[ip]; |
| 119 |
|
t.resx[ip] = resx[ip]; |
| 120 |
|
t.resy[ip] = resy[ip]; |
| 121 |
|
t.tailx[ip] = tailx[ip]; |
| 122 |
|
t.taily[ip] = taily[ip]; |
| 123 |
|
t.xv[ip] = xv[ip]; |
| 124 |
|
t.yv[ip] = yv[ip]; |
| 125 |
|
t.zv[ip] = zv[ip]; |
| 126 |
|
t.axv[ip] = axv[ip]; |
| 127 |
|
t.ayv[ip] = ayv[ip]; |
| 128 |
|
t.dedx_x[ip] = dedx_x[ip]; |
| 129 |
|
t.dedx_y[ip] = dedx_y[ip]; |
| 130 |
|
|
| 131 |
|
}; |
| 132 |
|
|
| 133 |
|
// t.clx = TRefArray(clx); |
| 134 |
|
// t.cly = TRefArray(cly); |
| 135 |
|
|
| 136 |
}; |
}; |
| 137 |
//-------------------------------------- |
//-------------------------------------- |
| 138 |
// |
// |
| 157 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
| 158 |
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]; |
| 159 |
|
|
| 160 |
|
TrkParams::Load(1); |
| 161 |
|
if( !TrkParams::IsLoaded(1) ){ |
| 162 |
|
cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
| 163 |
|
return 0; |
| 164 |
|
} |
| 165 |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
| 166 |
|
|
| 167 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
| 201 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
| 202 |
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]; |
| 203 |
|
|
| 204 |
|
TrkParams::Load(1); |
| 205 |
|
if( !TrkParams::IsLoaded(1) ){ |
| 206 |
|
cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
| 207 |
|
return 0; |
| 208 |
|
} |
| 209 |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
| 210 |
|
|
| 211 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
| 245 |
return def; |
return def; |
| 246 |
}; |
}; |
| 247 |
// |
// |
| 248 |
Float_t TrkTrack::GetDEDX(){ |
/** |
| 249 |
Float_t dedx=0; |
* Method to retrieve the dE/dx measured on a tracker view. |
| 250 |
for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i]; |
* @param ip plane (0-5) |
| 251 |
dedx = dedx/(this->GetNX()+this->GetNY()); |
* @param iv view (0=x 1=y) |
| 252 |
return dedx; |
*/ |
| 253 |
|
Float_t TrkTrack::GetDEDX(int ip, int iv){ |
| 254 |
|
if(iv==0 && ip>=0 && ip<6)return fabs(dedx_x[ip]); |
| 255 |
|
else if(iv==1 && ip>=0 && ip<6)return fabs(dedx_y[ip]); |
| 256 |
|
else { |
| 257 |
|
cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
| 258 |
|
return 0.; |
| 259 |
|
} |
| 260 |
|
} |
| 261 |
|
/** |
| 262 |
|
* Method to evaluate the dE/dx measured on a tracker plane. |
| 263 |
|
* The two measurements on x- and y-view are averaged. |
| 264 |
|
* @param ip plane (0-5) |
| 265 |
|
*/ |
| 266 |
|
Float_t TrkTrack::GetDEDX(int ip){ |
| 267 |
|
if( (Int_t)XGood(ip)+(Int_t)YGood(ip) == 0 ) return 0; |
| 268 |
|
return (GetDEDX(ip,0)+GetDEDX(ip,1))/((Int_t)XGood(ip)+(Int_t)YGood(ip)); |
| 269 |
}; |
}; |
| 270 |
|
|
| 271 |
|
/** |
| 272 |
|
* Method to evaluate the dE/dx averaged over all planes. |
| 273 |
|
*/ |
| 274 |
|
Float_t TrkTrack::GetDEDX(){ |
| 275 |
|
Float_t dedx=0; |
| 276 |
|
for(Int_t ip=0; ip<6; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip); |
| 277 |
|
dedx = dedx/(GetNX()+GetNY()); |
| 278 |
|
return dedx; |
| 279 |
|
}; |
| 280 |
|
/** |
| 281 |
|
* Returns 1 if the cluster on a tracker view includes bad strips. |
| 282 |
|
* @param ip plane (0-5) |
| 283 |
|
* @param iv view (0=x 1=y) |
| 284 |
|
*/ |
| 285 |
|
Bool_t TrkTrack::IsBad(int ip,int iv){ |
| 286 |
|
if(iv==0 && ip>=0 && ip<6)return (xgood[ip]<0) ; |
| 287 |
|
else if(iv==1 && ip>=0 && ip<6)return (ygood[ip]<0) ; |
| 288 |
|
else { |
| 289 |
|
cout << "TrkTrack::IsBad(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
| 290 |
|
return 0.; |
| 291 |
|
} |
| 292 |
|
}; |
| 293 |
|
/** |
| 294 |
|
* Returns 1 if the signal on a tracker view is saturated. |
| 295 |
|
* @param ip plane (0-5) |
| 296 |
|
* @param iv view (0=x 1=y) |
| 297 |
|
*/ |
| 298 |
|
Bool_t TrkTrack::IsSaturated(int ip,int iv){ |
| 299 |
|
if(iv==0 && ip>=0 && ip<6)return (dedx_x[ip]<0) ; |
| 300 |
|
else if(iv==1 && ip>=0 && ip<6)return (dedx_y[ip]<0) ; |
| 301 |
|
else { |
| 302 |
|
cout << "TrkTrack::IsSaturated(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
| 303 |
|
return 0.; |
| 304 |
|
} |
| 305 |
|
}; |
| 306 |
|
/** |
| 307 |
|
* Returns 1 if either the x or the y signal on a tracker plane is saturated. |
| 308 |
|
* @param ip plane (0-5) |
| 309 |
|
*/ |
| 310 |
|
Bool_t TrkTrack::IsSaturated(int ip){ |
| 311 |
|
return (IsSaturated(ip,0)||IsSaturated(ip,1)); |
| 312 |
|
}; |
| 313 |
|
/** |
| 314 |
|
* Returns 1 if there is at least a saturated signal along the track. |
| 315 |
|
*/ |
| 316 |
|
Bool_t TrkTrack::IsSaturated(){ |
| 317 |
|
for(int ip=0; ip<6; ip++)for(int iv=0; iv<2; iv++)if(IsSaturated(ip,iv))return true; |
| 318 |
|
return false; |
| 319 |
|
} |
| 320 |
|
/** |
| 321 |
|
* Returns the track "lever-arm" on the x view, defined as the distance (in planes) between |
| 322 |
|
* the upper and lower x measurements (the maximum value of lever-arm is 6). |
| 323 |
|
*/ |
| 324 |
|
Int_t TrkTrack::GetLeverArmX(){ |
| 325 |
|
int first_plane = -1; |
| 326 |
|
int last_plane = -1; |
| 327 |
|
for(Int_t ip=0; ip<6; ip++){ |
| 328 |
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
| 329 |
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
| 330 |
|
} |
| 331 |
|
if( first_plane == -1 || last_plane == -1){ |
| 332 |
|
cout<< "Int_t TrkTrack::GetLeverArmX() -- XGood(ip) always false ??? "<<endl; |
| 333 |
|
return 0; |
| 334 |
|
} |
| 335 |
|
return (last_plane-first_plane+1); |
| 336 |
|
} |
| 337 |
|
/** |
| 338 |
|
* Returns the track "lever-arm" on the y view, defined as the distance (in planes) between |
| 339 |
|
* the upper and lower y measurements (the maximum value of lever-arm is 6). |
| 340 |
|
*/ |
| 341 |
|
Int_t TrkTrack::GetLeverArmY(){ |
| 342 |
|
int first_plane = -1; |
| 343 |
|
int last_plane = -1; |
| 344 |
|
for(Int_t ip=0; ip<6; ip++){ |
| 345 |
|
if( YGood(ip) && first_plane == -1 )first_plane = ip; |
| 346 |
|
if( YGood(ip) && first_plane != -1 )last_plane = ip; |
| 347 |
|
} |
| 348 |
|
if( first_plane == -1 || last_plane == -1){ |
| 349 |
|
cout<< "Int_t TrkTrack::GetLeverArmY() -- YGood(ip) always false ??? "<<endl; |
| 350 |
|
return 0; |
| 351 |
|
} |
| 352 |
|
return (last_plane-first_plane+1); |
| 353 |
|
} |
| 354 |
//-------------------------------------- |
//-------------------------------------- |
| 355 |
// |
// |
| 356 |
// |
// |
| 362 |
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] << " "; |
| 363 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
| 364 |
cout << endl << "n.step : "<< nstep; |
cout << endl << "n.step : "<< nstep; |
| 365 |
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) ; |
| 366 |
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) ; |
| 367 |
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] << " "; |
| 368 |
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] << " "; |
| 369 |
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] << " "; |
| 379 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
| 380 |
cout << endl << "dedx_x : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " "; |
cout << endl << "dedx_x : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " "; |
| 381 |
cout << endl << "dedx_y : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " "; |
cout << endl << "dedx_y : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " "; |
| 382 |
|
cout << endl; |
| 383 |
} |
} |
| 384 |
/** |
/** |
| 385 |
* Set the TrkTrack position measurements |
* Set the TrkTrack position measurements |
| 400 |
* Set the TrkTrack good measurement |
* Set the TrkTrack good measurement |
| 401 |
*/ |
*/ |
| 402 |
void TrkTrack::SetGood(int *xg, int *yg){ |
void TrkTrack::SetGood(int *xg, int *yg){ |
| 403 |
|
// NB! si perdera` l'informazione sul numero del cluster |
| 404 |
for(int i=0; i<6; i++) xgood[i]=*xg++; |
for(int i=0; i<6; i++) xgood[i]=*xg++; |
| 405 |
for(int i=0; i<6; i++) ygood[i]=*yg++; |
for(int i=0; i<6; i++) ygood[i]=*yg++; |
| 406 |
} |
} |
| 408 |
/** |
/** |
| 409 |
* Load the magnetic field |
* Load the magnetic field |
| 410 |
*/ |
*/ |
| 411 |
void TrkTrack::LoadField(TString s){ |
void TrkTrack::LoadField(TString path){ |
| 412 |
readb_(s.Data()); |
|
| 413 |
|
// strcpy(path_.path,path.Data()); |
| 414 |
|
// path_.pathlen = path.Length(); |
| 415 |
|
// path_.error = 0; |
| 416 |
|
// readb_(); |
| 417 |
|
|
| 418 |
|
TrkParams::Set(path,1); |
| 419 |
|
TrkParams::Load(1); |
| 420 |
|
|
| 421 |
}; |
}; |
| 422 |
|
|
| 423 |
|
|
| 424 |
|
/** |
| 425 |
|
* Method to fill minimization-routine common |
| 426 |
|
*/ |
| 427 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
| 428 |
|
|
| 429 |
|
for(int i=0; i<6; i++){ |
| 430 |
|
|
| 431 |
|
// track.xgood[i]=xgood[i]; |
| 432 |
|
// track.ygood[i]=ygood[i]; |
| 433 |
|
track.xgood[i]=XGood(i); |
| 434 |
|
track.ygood[i]=YGood(i); |
| 435 |
|
|
| 436 |
|
track.xm[i]=xm[i]; |
| 437 |
|
track.ym[i]=ym[i]; |
| 438 |
|
track.zm[i]=zm[i]; |
| 439 |
|
|
| 440 |
|
// --- temporaneo ---------------------------- |
| 441 |
|
// andrebbe inserita la dimensione del sensore |
| 442 |
|
float segment = 100.; |
| 443 |
|
track.xm_a[i]=xm[i]; |
| 444 |
|
track.xm_b[i]=xm[i]; |
| 445 |
|
track.ym_a[i]=ym[i]; |
| 446 |
|
track.ym_b[i]=ym[i]; |
| 447 |
|
if( XGood(i) && !YGood(i) ){ |
| 448 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
| 449 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
| 450 |
|
}else if( !XGood(i) && YGood(i)){ |
| 451 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
| 452 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
| 453 |
|
} |
| 454 |
|
// --- temporaneo ---------------------------- |
| 455 |
|
|
| 456 |
|
track.resx[i]=resx[i]; |
| 457 |
|
track.resy[i]=resy[i]; |
| 458 |
|
} |
| 459 |
|
|
| 460 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
| 461 |
|
track.zini = 23.5; |
| 462 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
| 463 |
|
|
| 464 |
|
} |
| 465 |
|
/** |
| 466 |
|
* Method to set values from minimization-routine common |
| 467 |
|
*/ |
| 468 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
| 469 |
|
|
| 470 |
|
for(int i=0; i<5; i++) { |
| 471 |
|
al[i]=track->al[i]; |
| 472 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
| 473 |
|
} |
| 474 |
|
chi2 = track->chi2; |
| 475 |
|
nstep = track->nstep; |
| 476 |
|
for(int i=0; i<6; i++){ |
| 477 |
|
xv[i] = track->xv[i]; |
| 478 |
|
yv[i] = track->yv[i]; |
| 479 |
|
zv[i] = track->zv[i]; |
| 480 |
|
xm[i] = track->xm[i]; |
| 481 |
|
ym[i] = track->ym[i]; |
| 482 |
|
zm[i] = track->zm[i]; |
| 483 |
|
axv[i] = track->axv[i]; |
| 484 |
|
ayv[i] = track->ayv[i]; |
| 485 |
|
} |
| 486 |
|
|
| 487 |
|
} |
| 488 |
/** |
/** |
| 489 |
* Tracking method. It calls F77 mini routine. |
* Tracking method. It calls F77 mini routine. |
| 490 |
*/ |
*/ |
| 491 |
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
| 492 |
|
|
| 493 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
| 494 |
|
|
| 495 |
extern cMini2track track_; |
extern cMini2track track_; |
| 496 |
fail = 0; |
fail = 0; |
| 497 |
// extern cMini2fitinfo fit_info_; |
FillMiniStruct(track_); |
| 498 |
// extern void mini_2_(int*,int*); |
|
| 499 |
// track_.xm[0]=1.0; |
// if fit variables have been reset, evaluate the initial guess |
| 500 |
for(int i=0; i<6; i++) track_.xm[i]=xm[i]; |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
| 501 |
for(int i=0; i<6; i++) track_.ym[i]=ym[i]; |
|
| 502 |
for(int i=0; i<6; i++) track_.zm[i]=zm[i]; |
// --------------------- free momentum |
| 503 |
for(int i=0; i<6; i++) track_.resx[i]=resx[i]; |
if(pfixed==0.) { |
| 504 |
for(int i=0; i<6; i++) track_.resy[i]=resy[i]; |
track_.pfixed=0.; |
|
for(int i=0; i<6; i++) track_.xgood[i]=xgood[i]; |
|
|
for(int i=0; i<6; i++) track_.ygood[i]=ygood[i]; |
|
|
// initial guess of "al" with linear fit |
|
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){ |
|
|
double szz=0., szx=0., szy=0., ssx=0., ssy=0., sz=0., s1=0.; |
|
|
double det, ax, ay, bx, by; |
|
|
for(int i=0; i<NPLANE; i++) { |
|
|
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.; |
|
| 505 |
} |
} |
| 506 |
// end guess |
// --------------------- fixed momentum |
|
for(int i=0; i<5; i++) track_.al[i]=al[i]; |
|
| 507 |
if(pfixed!=0.) { |
if(pfixed!=0.) { |
| 508 |
al[4]=1./pfixed; // to fix the momentum |
al[4]=1./pfixed; |
| 509 |
track_.pfixed=pfixed; // " |
track_.pfixed=pfixed; |
| 510 |
|
} |
| 511 |
|
|
| 512 |
|
// store temporarily the initial guess |
| 513 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
| 514 |
|
|
| 515 |
|
// ------------------------------------------ |
| 516 |
|
// call mini routine |
| 517 |
|
TrkParams::Load(1); |
| 518 |
|
if( !TrkParams::IsLoaded(1) ){ |
| 519 |
|
cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
| 520 |
|
return; |
| 521 |
} |
} |
| 522 |
int istep=0; |
int istep=0; |
| 523 |
int ifail=0; |
int ifail=0; |
| 524 |
mini2_(&istep,&ifail, &iprint); |
mini2_(&istep,&ifail, &iprint); |
| 525 |
if(ifail!=0) { |
if(ifail!=0) { |
| 526 |
if(iprint==1)cout << "ERROR: ifail= " << ifail << endl; |
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
| 527 |
fail = 1; |
fail = 1; |
|
// return; |
|
| 528 |
} |
} |
| 529 |
|
// ------------------------------------------ |
| 530 |
|
|
| 531 |
|
SetFromMiniStruct(&track_); |
| 532 |
// cout << endl << "eta ===> " << track_.al[4] << endl; |
// cout << endl << "eta ===> " << track_.al[4] << endl; |
| 533 |
|
|
| 534 |
for(int i=0; i<5; i++) al[i]=track_.al[i]; |
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
| 535 |
chi2=track_.chi2; |
// chi2=track_.chi2; |
| 536 |
nstep=track_.nstep; |
// nstep=track_.nstep; |
| 537 |
for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
// for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
| 538 |
for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
// for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
| 539 |
for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
// for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
| 540 |
for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
// for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
| 541 |
for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
| 542 |
for(int i=0; i<5; i++) { |
// for(int i=0; i<5; i++) { |
| 543 |
for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
| 544 |
|
// } |
| 545 |
|
|
| 546 |
|
if(fail){ |
| 547 |
|
if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
| 548 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
| 549 |
} |
} |
| 550 |
|
|
| 551 |
}; |
}; |
| 552 |
/* |
/* |
| 553 |
* Reset the parameters fit |
* Reset the fit parameters |
| 554 |
*/ |
*/ |
| 555 |
void TrkTrack::FitReset(){ |
void TrkTrack::FitReset(){ |
| 556 |
for(int i=0; i<5; i++) al[i]=-9999.; |
for(int i=0; i<5; i++) al[i]=-9999.; |
| 565 |
for(int j=0; j<5; j++) coval[i][j]=0.; |
for(int j=0; j<5; j++) coval[i][j]=0.; |
| 566 |
} |
} |
| 567 |
} |
} |
| 568 |
|
/* |
| 569 |
|
* Set the tracking mode |
| 570 |
|
*/ |
| 571 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
| 572 |
|
extern cMini2track track_; |
| 573 |
|
track_.trackmode = trackmode; |
| 574 |
|
} |
| 575 |
|
/* |
| 576 |
|
* Set the factor scale for tracking precision |
| 577 |
|
*/ |
| 578 |
|
void TrkTrack::SetPrecisionFactor(double fact){ |
| 579 |
|
extern cMini2track track_; |
| 580 |
|
track_.fact = fact; |
| 581 |
|
} |
| 582 |
|
/* |
| 583 |
|
* Set the factor scale for tracking precision |
| 584 |
|
*/ |
| 585 |
|
void TrkTrack::SetStepMin(int istepmin){ |
| 586 |
|
extern cMini2track track_; |
| 587 |
|
track_.istepmin = istepmin; |
| 588 |
|
} |
| 589 |
|
|
| 590 |
|
|
| 591 |
|
/* |
| 592 |
|
* Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. |
| 593 |
|
* If no cluster is associated, ID=-1. |
| 594 |
|
* @param ip Tracker plane (0-5) |
| 595 |
|
*/ |
| 596 |
|
Int_t TrkTrack::GetClusterX_ID(int ip){ |
| 597 |
|
return ((Int_t)fabs(xgood[ip]))%10000000-1; |
| 598 |
|
}; |
| 599 |
|
/* |
| 600 |
|
* Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. |
| 601 |
|
* If no cluster is associated, ID=-1. |
| 602 |
|
* @param ip Tracker plane (0-5) |
| 603 |
|
*/ |
| 604 |
|
Int_t TrkTrack::GetClusterY_ID(int ip){ |
| 605 |
|
return ((Int_t)fabs(ygood[ip]))%10000000-1; |
| 606 |
|
}; |
| 607 |
|
/* |
| 608 |
|
* Method to retrieve the ladder (0-4, increasing x) traversed by the track on this plane. |
| 609 |
|
* If no ladder is traversed (dead area) the metod retuns -1. |
| 610 |
|
* @param ip Tracker plane (0-5) |
| 611 |
|
*/ |
| 612 |
|
Int_t TrkTrack::GetLadder(int ip){ |
| 613 |
|
if(XGood(ip))return (Int_t)fabs(xgood[ip]/100000000)-1; |
| 614 |
|
if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1; |
| 615 |
|
return -1; |
| 616 |
|
}; |
| 617 |
|
/* |
| 618 |
|
* Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane. |
| 619 |
|
* If no sensor is traversed (dead area) the metod retuns -1. |
| 620 |
|
* @param ip Tracker plane (0-5) |
| 621 |
|
*/ |
| 622 |
|
Int_t TrkTrack::GetSensor(int ip){ |
| 623 |
|
if(XGood(ip))return (Int_t)((Int_t)fabs(xgood[ip]/10000000)%10)-1; |
| 624 |
|
if(YGood(ip))return (Int_t)((Int_t)fabs(ygood[ip]/10000000)%10)-1; |
| 625 |
|
return -1; |
| 626 |
|
}; |
| 627 |
|
|
| 628 |
|
|
| 629 |
//-------------------------------------- |
//-------------------------------------- |
| 630 |
// |
// |
| 631 |
// |
// |
| 632 |
//-------------------------------------- |
//-------------------------------------- |
| 633 |
void TrkTrack::Clear(){ |
void TrkTrack::Clear(){ |
| 634 |
seqno = -1; |
// cout << "TrkTrack::Clear()"<<endl; |
| 635 |
image = -1; |
seqno = -1; |
| 636 |
chi2 = 0; |
image = -1; |
| 637 |
nstep = 0; |
chi2 = 0; |
| 638 |
for(int it1=0;it1<5;it1++){ |
nstep = 0; |
| 639 |
al[it1] = 0; |
for(int it1=0;it1<5;it1++){ |
| 640 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
al[it1] = 0; |
| 641 |
}; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
| 642 |
for(int ip=0;ip<6;ip++){ |
}; |
| 643 |
xgood[ip] = 0; |
for(int ip=0;ip<6;ip++){ |
| 644 |
ygood[ip] = 0; |
xgood[ip] = 0; |
| 645 |
xm[ip] = 0; |
ygood[ip] = 0; |
| 646 |
ym[ip] = 0; |
xm[ip] = 0; |
| 647 |
zm[ip] = 0; |
ym[ip] = 0; |
| 648 |
resx[ip] = 0; |
zm[ip] = 0; |
| 649 |
resy[ip] = 0; |
resx[ip] = 0; |
| 650 |
xv[ip] = 0; |
resy[ip] = 0; |
| 651 |
yv[ip] = 0; |
tailx[ip] = 0; |
| 652 |
zv[ip] = 0; |
taily[ip] = 0; |
| 653 |
axv[ip] = 0; |
xv[ip] = 0; |
| 654 |
ayv[ip] = 0; |
yv[ip] = 0; |
| 655 |
dedx_x[ip] = 0; |
zv[ip] = 0; |
| 656 |
dedx_y[ip] = 0; |
axv[ip] = 0; |
| 657 |
// clx[ip] = 0; |
ayv[ip] = 0; |
| 658 |
// cly[ip] = 0; |
dedx_x[ip] = 0; |
| 659 |
}; |
dedx_y[ip] = 0; |
| 660 |
clx->Clear(); |
|
| 661 |
cly->Clear(); |
}; |
| 662 |
|
// if(clx)clx->Clear(); |
| 663 |
|
// if(cly)cly->Clear(); |
| 664 |
|
// clx.Clear(); |
| 665 |
|
// cly.Clear(); |
| 666 |
}; |
}; |
| 667 |
//-------------------------------------- |
//-------------------------------------- |
| 668 |
// |
// |
| 669 |
// |
// |
| 670 |
//-------------------------------------- |
//-------------------------------------- |
| 671 |
void TrkTrack::Delete(){ |
void TrkTrack::Delete(){ |
| 672 |
Clear(); |
// cout << "TrkTrack::Delete()"<<endl; |
| 673 |
clx->Delete(); |
Clear(); |
| 674 |
cly->Delete(); |
// if(clx)delete clx; |
| 675 |
|
// if(cly)delete cly; |
| 676 |
}; |
}; |
| 677 |
//-------------------------------------- |
//-------------------------------------- |
| 678 |
// |
// |
| 679 |
// |
// |
| 680 |
//-------------------------------------- |
//-------------------------------------- |
| 684 |
// |
// |
| 685 |
//-------------------------------------- |
//-------------------------------------- |
| 686 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
| 687 |
|
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
| 688 |
plane = 0; |
plane = 0; |
| 689 |
coord[0] = 0; |
coord[0] = 0; |
| 690 |
coord[1] = 0; |
coord[1] = 0; |
| 691 |
sgnl = 0; |
sgnl = 0; |
| 692 |
cls = 0; |
// cls = 0; |
| 693 |
}; |
}; |
| 694 |
//-------------------------------------- |
//-------------------------------------- |
| 695 |
// |
// |
| 696 |
// |
// |
| 697 |
//-------------------------------------- |
//-------------------------------------- |
| 698 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
| 699 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
| 700 |
plane = s.plane; |
plane = s.plane; |
| 701 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
| 702 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
| 703 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
| 704 |
// cls = 0;//<<<<pointer |
// cls = 0;//<<<<pointer |
| 705 |
cls = TRef(s.cls); |
// cls = TRef(s.cls); |
| 706 |
}; |
}; |
| 707 |
//-------------------------------------- |
//-------------------------------------- |
| 708 |
// |
// |
| 719 |
// |
// |
| 720 |
// |
// |
| 721 |
//-------------------------------------- |
//-------------------------------------- |
| 722 |
|
void TrkSinglet::Clear(){ |
| 723 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
| 724 |
|
// cls=0; |
| 725 |
|
plane=-1; |
| 726 |
|
coord[0]=-999; |
| 727 |
|
coord[1]=-999; |
| 728 |
|
sgnl=0; |
| 729 |
|
|
| 730 |
|
} |
| 731 |
|
//-------------------------------------- |
| 732 |
|
// |
| 733 |
|
// |
| 734 |
|
//-------------------------------------- |
| 735 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
| 736 |
// good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
| 737 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
| 738 |
// crc[i] = -1; |
good[i] = -1; |
| 739 |
good[i] = -1; |
VKmask[i] = 0; |
| 740 |
}; |
VKflag[i] = 0; |
| 741 |
Track = new TClonesArray("TrkTrack"); |
}; |
| 742 |
SingletX = new TClonesArray("TrkSinglet"); |
Track = 0; |
| 743 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletX = 0; |
| 744 |
|
SingletY = 0; |
| 745 |
|
|
| 746 |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
} |
| 747 |
//sostituire con TRefArray... appena ho capito come si usa |
//-------------------------------------- |
| 748 |
|
// |
| 749 |
|
// |
| 750 |
|
//-------------------------------------- |
| 751 |
|
void TrkLevel2::Set(){ |
| 752 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
| 753 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
| 754 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
| 755 |
} |
} |
| 756 |
//-------------------------------------- |
//-------------------------------------- |
| 757 |
// |
// |
| 759 |
//-------------------------------------- |
//-------------------------------------- |
| 760 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
| 761 |
|
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &sx = *SingletX; |
|
|
TClonesArray &sy = *SingletY; |
|
| 762 |
// |
// |
| 763 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
| 764 |
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]<<" "; |
| 765 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
| 766 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
| 767 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
| 768 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
if(Track){ |
| 769 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
TClonesArray &t = *Track; |
| 770 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
| 771 |
|
} |
| 772 |
|
if(SingletX){ |
| 773 |
|
TClonesArray &sx = *SingletX; |
| 774 |
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
| 775 |
|
} |
| 776 |
|
if(SingletY){ |
| 777 |
|
TClonesArray &sy = *SingletY; |
| 778 |
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
| 779 |
|
} |
| 780 |
} |
} |
| 781 |
//-------------------------------------- |
//-------------------------------------- |
| 782 |
// |
// |
| 783 |
// |
// |
| 784 |
//-------------------------------------- |
//-------------------------------------- |
| 785 |
/** |
/** |
| 786 |
* 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 |
| 787 |
|
* either apriori ,on the basis of the mask read from the DB, |
| 788 |
|
* or run-by-run, on the basis of the calibration parameters) |
| 789 |
|
* @param iv Tracker view (0-11) |
| 790 |
|
* @param ivk Viking-chip number (0-23) |
| 791 |
|
*/ |
| 792 |
|
Bool_t TrkLevel2::GetVKMask(int iv, int ivk){ |
| 793 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
| 794 |
|
return (whichbit&VKmask[iv])!=0; |
| 795 |
|
} |
| 796 |
|
/** |
| 797 |
|
* The method returns false if the viking-chip was masked |
| 798 |
|
* for this event due to common-noise computation failure. |
| 799 |
|
* @param iv Tracker view (0-11) |
| 800 |
|
* @param ivk Viking-chip number (0-23) |
| 801 |
|
*/ |
| 802 |
|
Bool_t TrkLevel2::GetVKFlag(int iv, int ivk){ |
| 803 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
| 804 |
|
return (whichbit&VKflag[iv])!=0; |
| 805 |
|
} |
| 806 |
|
/** |
| 807 |
|
* The method returns true if the viking-chip was masked, either |
| 808 |
|
* forced (see TrkLevel2::GetVKMask(int,int)) or |
| 809 |
|
* for this event only (TrkLevel2::GetVKFlag(int,int)). |
| 810 |
|
* @param iv Tracker view (0-11) |
| 811 |
|
* @param ivk Viking-chip number (0-23) |
| 812 |
|
*/ |
| 813 |
|
Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){ |
| 814 |
|
return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) ); |
| 815 |
|
}; |
| 816 |
|
|
| 817 |
|
//-------------------------------------- |
| 818 |
|
// |
| 819 |
|
// |
| 820 |
|
//-------------------------------------- |
| 821 |
|
/** |
| 822 |
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
| 823 |
|
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
| 824 |
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
| 825 |
*/ |
*/ |
| 826 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
| 827 |
|
|
| 828 |
|
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
| 829 |
|
Clear(); |
| 830 |
|
|
| 831 |
// temporary objects: |
// temporary objects: |
| 832 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
| 833 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
| 834 |
|
|
| 835 |
// **** general variables **** |
// ----------------- |
| 836 |
// good2 = l2->good2; |
// general variables |
| 837 |
|
// ----------------- |
| 838 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
| 839 |
// crc[i] = l2->crc[i]; |
good[i] = l2->good[i]; |
| 840 |
good[i] = l2->good[i]; |
VKmask[i]=0; |
| 841 |
|
VKflag[i]=0; |
| 842 |
|
for(Int_t ii=0; ii<24 ; ii++){ |
| 843 |
|
Int_t setbit = (Int_t)pow(2,ii); |
| 844 |
|
if( l2->vkflag[ii][i]!=-1 )VKmask[i]=VKmask[i]|setbit; |
| 845 |
|
if( l2->vkflag[ii][i]!=0 )VKflag[i]=VKflag[i]|setbit; |
| 846 |
}; |
}; |
| 847 |
// *** TRACKS *** |
}; |
| 848 |
|
// -------------- |
| 849 |
|
// *** TRACKS *** |
| 850 |
|
// -------------- |
| 851 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
| 852 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
| 853 |
|
|
| 854 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
| 855 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
| 856 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
| 857 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
t_track->chi2 = l2->chi2_nt[i]; |
| 858 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->nstep = l2->nstep_nt[i]; |
| 859 |
t_track->nstep = l2->nstep_nt[i]; |
for(int it1=0;it1<5;it1++){ |
| 860 |
for(int it1=0;it1<5;it1++){ |
t_track->al[it1] = l2->al_nt[i][it1]; |
| 861 |
t_track->al[it1] = l2->al_nt[i][it1]; |
for(int it2=0;it2<5;it2++) |
| 862 |
for(int it2=0;it2<5;it2++) |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
| 863 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
}; |
| 864 |
}; |
for(int ip=0;ip<6;ip++){ |
| 865 |
for(int ip=0;ip<6;ip++){ |
// --------------------------------- |
| 866 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
// new implementation of xgood/ygood |
| 867 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
// --------------------------------- |
| 868 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
t_track->xgood[ip] = l2->cltrx[i][ip]; //cluster ID |
| 869 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->ygood[ip] = l2->cltry[i][ip]; //cluster ID |
| 870 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->xgood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
| 871 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
t_track->ygood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
| 872 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
if(l2->xbad[i][ip]>0)t_track->xgood[ip]=-t_track->xgood[ip]; |
| 873 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
if(l2->ybad[i][ip]>0)t_track->ygood[ip]=-t_track->ygood[ip]; |
| 874 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
// if(l2->xbad[i][ip]>0 || l2->ybad[i][ip]>0){ |
| 875 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
// if(l2->dedx_x[i][ip]<0 || l2->dedx_y[i][ip]<0){ |
| 876 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
// cout << ip << " - "<< l2->cltrx[i][ip] << " "<<l2->cltry[i][ip]<<" "<<l2->ls[i][ip]<<endl; |
| 877 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
// cout << ip << " - "<<t_track->xgood[ip]<<" "<<t_track->ygood[ip]<<endl; |
| 878 |
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; |
| 879 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
// cout << ip << " - "<<t_track->BadClusterX(ip)<<" "<<t_track->BadClusterY(ip)<<endl; |
| 880 |
// t_track->clx[ip] = 0; |
// cout << ip << " - "<<t_track->SaturatedClusterX(ip)<<" "<<t_track->SaturatedClusterY(ip)<<endl; |
| 881 |
// t_track->cly[ip] = 0; |
// } |
| 882 |
}; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
| 883 |
new(t[i]) TrkTrack(*t_track); |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
| 884 |
t_track->Clear(); |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
| 885 |
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
| 886 |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
| 887 |
|
t_track->tailx[ip] = l2->tailx[i][ip]; |
| 888 |
|
t_track->taily[ip] = l2->taily[i][ip]; |
| 889 |
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
| 890 |
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
| 891 |
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
| 892 |
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
| 893 |
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
| 894 |
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
| 895 |
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
| 896 |
|
//----------------------------------------------------- |
| 897 |
|
//----------------------------------------------------- |
| 898 |
|
//----------------------------------------------------- |
| 899 |
|
//----------------------------------------------------- |
| 900 |
|
}; |
| 901 |
|
// if(t_track->IsSaturated())t_track->Dump(); |
| 902 |
|
new(t[i]) TrkTrack(*t_track); |
| 903 |
|
t_track->Clear(); |
| 904 |
}; |
}; |
| 905 |
|
|
| 906 |
|
// ---------------- |
| 907 |
// *** SINGLETS *** |
// *** SINGLETS *** |
| 908 |
|
// ---------------- |
| 909 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
| 910 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
| 911 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
| 912 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
| 913 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
| 914 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
| 915 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
| 916 |
// t_singlet->cls = 0; |
//----------------------------------------------------- |
| 917 |
new(sx[i]) TrkSinglet(*t_singlet); |
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
| 918 |
t_singlet->Clear(); |
//----------------------------------------------------- |
| 919 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
| 920 |
|
t_singlet->Clear(); |
| 921 |
} |
} |
| 922 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
| 923 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
| 924 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
| 925 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
| 926 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
| 927 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
| 928 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
| 929 |
// t_singlet->cls = 0; |
//----------------------------------------------------- |
| 930 |
new(sy[i]) TrkSinglet(*t_singlet); |
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
| 931 |
t_singlet->Clear(); |
//----------------------------------------------------- |
| 932 |
}; |
new(sy[i]) TrkSinglet(*t_singlet); |
| 933 |
|
t_singlet->Clear(); |
| 934 |
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(); |
|
|
}; |
|
| 935 |
|
|
| 936 |
delete t_track; |
delete t_track; |
| 937 |
delete t_singlet; |
delete t_singlet; |
| 938 |
} |
} |
| 939 |
/** |
/** |
| 940 |
* 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). |
| 950 |
}; |
}; |
| 951 |
// *** TRACKS *** |
// *** TRACKS *** |
| 952 |
|
|
| 953 |
l2->ntrk = Track->GetEntries(); |
if(Track){ |
| 954 |
for(Int_t i=0;i<l2->ntrk;i++){ |
l2->ntrk = Track->GetEntries(); |
| 955 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
for(Int_t i=0;i<l2->ntrk;i++){ |
| 956 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
| 957 |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
| 958 |
for(int it1=0;it1<5;it1++){ |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
| 959 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
for(int it1=0;it1<5;it1++){ |
| 960 |
for(int it2=0;it2<5;it2++) |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
| 961 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
for(int it2=0;it2<5;it2++) |
| 962 |
}; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
| 963 |
for(int ip=0;ip<6;ip++){ |
}; |
| 964 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
for(int ip=0;ip<6;ip++){ |
| 965 |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip); |
| 966 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip); |
| 967 |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
| 968 |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
| 969 |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
| 970 |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
| 971 |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
| 972 |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
l2->tailx[i][ip] = ((TrkTrack *)Track->At(i))->tailx[ip]; |
| 973 |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
l2->taily[i][ip] = ((TrkTrack *)Track->At(i))->taily[ip]; |
| 974 |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
| 975 |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
| 976 |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
| 977 |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
| 978 |
}; |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
| 979 |
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
| 980 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
| 981 |
|
}; |
| 982 |
|
} |
| 983 |
} |
} |
|
|
|
| 984 |
// *** SINGLETS *** |
// *** SINGLETS *** |
| 985 |
l2->nclsx = SingletX->GetEntries(); |
if(SingletX){ |
| 986 |
for(Int_t i=0;i<l2->nclsx;i++){ |
l2->nclsx = SingletX->GetEntries(); |
| 987 |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
for(Int_t i=0;i<l2->nclsx;i++){ |
| 988 |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
| 989 |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
| 990 |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
| 991 |
} |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
| 992 |
l2->nclsy = SingletY->GetEntries(); |
} |
| 993 |
for(Int_t i=0;i<l2->nclsy;i++){ |
} |
| 994 |
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
|
| 995 |
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
if(SingletY){ |
| 996 |
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
l2->nclsy = SingletY->GetEntries(); |
| 997 |
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
for(Int_t i=0;i<l2->nclsy;i++){ |
| 998 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
| 999 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
| 1000 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
| 1001 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
| 1002 |
|
} |
| 1003 |
} |
} |
| 1004 |
} |
} |
| 1005 |
//-------------------------------------- |
//-------------------------------------- |
| 1007 |
// |
// |
| 1008 |
//-------------------------------------- |
//-------------------------------------- |
| 1009 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
// good2 = -1; |
|
| 1010 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
| 1011 |
// crc[i] = -1; |
good[i] = -1; |
| 1012 |
good[i] = -1; |
VKflag[i] = 0; |
| 1013 |
}; |
VKmask[i] = 0; |
| 1014 |
/* Track->RemoveAll(); |
}; |
| 1015 |
SingletX->RemoveAll(); |
// if(Track)Track->Clear("C"); |
| 1016 |
SingletY->RemoveAll();*/ |
// if(SingletX)SingletX->Clear("C"); |
| 1017 |
// modify to avoid memory leakage |
// if(SingletY)SingletY->Clear("C"); |
| 1018 |
Track->Clear(); |
if(Track)Track->Delete(); |
| 1019 |
SingletX->Clear(); |
if(SingletX)SingletX->Delete(); |
| 1020 |
SingletY->Clear(); |
if(SingletY)SingletY->Delete(); |
| 1021 |
} |
} |
| 1022 |
//-------------------------------------- |
// //-------------------------------------- |
| 1023 |
// |
// // |
| 1024 |
// |
// // |
| 1025 |
//-------------------------------------- |
// //-------------------------------------- |
| 1026 |
void TrkLevel2::Delete(){ |
void TrkLevel2::Delete(){ |
| 1027 |
|
|
| 1028 |
Clear(); |
// cout << "void TrkLevel2::Delete()"<<endl; |
| 1029 |
Track->Delete(); |
Clear(); |
| 1030 |
SingletX->Delete(); |
if(Track)delete Track; |
| 1031 |
SingletY->Delete(); |
if(SingletX)delete SingletX; |
| 1032 |
|
if(SingletY)delete SingletY; |
| 1033 |
|
|
| 1034 |
} |
} |
| 1035 |
//-------------------------------------- |
//-------------------------------------- |
| 1036 |
// |
// |
| 1042 |
*/ |
*/ |
| 1043 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
| 1044 |
|
|
| 1045 |
TRefArray *sorted = new TRefArray(); |
if(!Track)return 0; |
| 1046 |
|
|
| 1047 |
|
TRefArray *sorted = new TRefArray(); |
| 1048 |
|
|
| 1049 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
| 1050 |
// TClonesArray &ts = *PhysicalTrack; |
// TClonesArray &ts = *PhysicalTrack; |
| 1051 |
int N = ntrk(); |
int N = ntrk(); |
| 1052 |
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; |
| 1053 |
// 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; |
| 1054 |
|
|
| 1055 |
int indo=0; |
int indo=0; |
| 1056 |
int indi=0; |
int indi=0; |
| 1057 |
while(N != 0){ |
while(N > 0){ |
| 1058 |
int nfit =0; |
// while(N != 0){ |
| 1059 |
float chi2ref = numeric_limits<float>::max(); |
int nfit =0; |
| 1060 |
|
float chi2ref = numeric_limits<float>::max(); |
| 1061 |
|
|
| 1062 |
// first loop to search maximum num. of fit points |
// first loop to search maximum num. of fit points |
| 1063 |
for(int i=0; i < ntrk(); i++){ |
for(int i=0; i < ntrk(); i++){ |
| 1064 |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
| 1065 |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
| 1066 |
} |
} |
| 1067 |
} |
} |
| 1068 |
//second loop to search minimum chi2 among selected |
//second loop to search minimum chi2 among selected |
| 1069 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i<ntrk(); i++){ |
| 1070 |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
| 1071 |
if(chi2 < 0) chi2 = chi2*1000; |
if(chi2 < 0) chi2 = -chi2*1000; |
| 1072 |
if( chi2 < chi2ref |
if( chi2 < chi2ref |
| 1073 |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
| 1074 |
&& m[i]==1){ |
&& m[i]==1){ |
| 1075 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
chi2ref = ((TrkTrack *)t[i])->chi2; |
| 1076 |
indi = i; |
indi = i; |
| 1077 |
}; |
}; |
| 1078 |
}; |
}; |
| 1079 |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
| 1080 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
| 1081 |
N--; |
N--; |
| 1082 |
|
|
| 1083 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
| 1084 |
}; |
}; |
| 1085 |
sorted->Add( (TrkTrack*)t[indi] ); |
sorted->Add( (TrkTrack*)t[indi] ); |
| 1086 |
|
|
| 1087 |
m[indi] = 0; |
m[indi] = 0; |
| 1088 |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
| 1089 |
N--; |
N--; |
| 1090 |
indo++; |
indo++; |
| 1091 |
} |
} |
| 1092 |
m.clear(); |
m.clear(); |
| 1093 |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
| 1094 |
|
|
| 1095 |
return sorted; |
return sorted; |
| 1096 |
// return PhysicalTrack; |
// return PhysicalTrack; |
| 1097 |
} |
} |
| 1098 |
//-------------------------------------- |
//-------------------------------------- |
| 1111 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
| 1112 |
return 0; |
return 0; |
| 1113 |
} |
} |
| 1114 |
|
if(!Track){ |
| 1115 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
| 1116 |
|
}; |
| 1117 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
| 1118 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
| 1119 |
return track; |
return track; |
| 1133 |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
| 1134 |
return 0; |
return 0; |
| 1135 |
} |
} |
| 1136 |
|
if(!SingletX)return 0; |
| 1137 |
TClonesArray &t = *(SingletX); |
TClonesArray &t = *(SingletX); |
| 1138 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
| 1139 |
return singlet; |
return singlet; |
| 1153 |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
| 1154 |
return 0; |
return 0; |
| 1155 |
} |
} |
| 1156 |
|
if(!SingletY)return 0; |
| 1157 |
TClonesArray &t = *(SingletY); |
TClonesArray &t = *(SingletY); |
| 1158 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
| 1159 |
return singlet; |
return singlet; |
| 1176 |
} |
} |
| 1177 |
|
|
| 1178 |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
| 1179 |
|
if(!sorted)return 0; |
| 1180 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
| 1181 |
sorted->Delete(); |
sorted->Clear(); |
| 1182 |
|
delete sorted; |
| 1183 |
return track; |
return track; |
| 1184 |
} |
} |
| 1185 |
/** |
/** |
| 1188 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
| 1189 |
|
|
| 1190 |
Float_t ntot=0; |
Float_t ntot=0; |
| 1191 |
|
if(!Track)return 0; |
| 1192 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
| 1193 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
| 1194 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
| 1207 |
*/ |
*/ |
| 1208 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
| 1209 |
|
|
| 1210 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
| 1211 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
| 1212 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
| 1213 |
return 0; |
return 0; |
| 1214 |
} |
} |
| 1215 |
|
|
| 1216 |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
| 1217 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
if(!sorted)return 0; |
| 1218 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
| 1219 |
|
|
| 1220 |
if(!track->HasImage()){ |
if(!track->HasImage()){ |
| 1221 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
| 1222 |
return 0; |
return 0; |
| 1223 |
} |
} |
| 1224 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
if(!Track)return 0; |
| 1225 |
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
| 1226 |
|
|
| 1227 |
sorted->Delete(); |
sorted->Delete(); |
| 1228 |
|
delete sorted; |
| 1229 |
return image; |
|
| 1230 |
|
return image; |
| 1231 |
|
|
| 1232 |
} |
} |
| 1233 |
//-------------------------------------- |
//-------------------------------------- |
| 1238 |
* Loads the magnetic field. |
* Loads the magnetic field. |
| 1239 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
| 1240 |
*/ |
*/ |
| 1241 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
| 1242 |
readb_(s.Data()); |
// |
| 1243 |
|
// strcpy(path_.path,path.Data()); |
| 1244 |
|
// path_.pathlen = path.Length(); |
| 1245 |
|
// path_.error = 0; |
| 1246 |
|
// readb_(); |
| 1247 |
|
|
| 1248 |
|
TrkParams::Set(path,1); |
| 1249 |
|
TrkParams::Load(1); |
| 1250 |
|
|
| 1251 |
|
// |
| 1252 |
}; |
}; |
| 1253 |
|
/** |
| 1254 |
|
* Get BY (kGauss) |
| 1255 |
|
* @param v (x,y,z) coordinates in cm |
| 1256 |
|
*/ |
| 1257 |
|
float TrkLevel2::GetBX(float* v){ |
| 1258 |
|
float b[3]; |
| 1259 |
|
gufld_(v,b); |
| 1260 |
|
return b[0]/10.; |
| 1261 |
|
} |
| 1262 |
|
/** |
| 1263 |
|
* Get BY (kGauss) |
| 1264 |
|
* @param v (x,y,z) coordinates in cm |
| 1265 |
|
*/ |
| 1266 |
|
float TrkLevel2::GetBY(float* v){ |
| 1267 |
|
float b[3]; |
| 1268 |
|
gufld_(v,b); |
| 1269 |
|
return b[1]/10.; |
| 1270 |
|
} |
| 1271 |
|
/** |
| 1272 |
|
* Get BY (kGauss) |
| 1273 |
|
* @param v (x,y,z) coordinates in cm |
| 1274 |
|
*/ |
| 1275 |
|
float TrkLevel2::GetBZ(float* v){ |
| 1276 |
|
float b[3]; |
| 1277 |
|
gufld_(v,b); |
| 1278 |
|
return b[2]/10.; |
| 1279 |
|
} |
| 1280 |
//-------------------------------------- |
//-------------------------------------- |
| 1281 |
// |
// |
| 1282 |
// |
// |
| 1373 |
tl = new float[npoint]; |
tl = new float[npoint]; |
| 1374 |
int i=0; |
int i=0; |
| 1375 |
do{ |
do{ |
| 1376 |
x[i] = 0; |
x[i] = 0; |
| 1377 |
y[i] = 0; |
y[i] = 0; |
| 1378 |
z[i] = zin[i]; |
z[i] = zin[i]; |
| 1379 |
thx[i] = 0; |
thx[i] = 0; |
| 1380 |
thy[i] = 0; |
thy[i] = 0; |
| 1381 |
tl[i] = 0; |
tl[i] = 0; |
| 1382 |
i++; |
i++; |
| 1383 |
}while(zin[i-1] > zin[i] && i < npoint); |
}while(zin[i-1] > zin[i] && i < npoint); |
| 1384 |
npoint=i; |
npoint=i; |
| 1385 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
| 1386 |
} |
} |
| 1387 |
|
void Trajectory::Delete(){ |
| 1388 |
|
|
| 1389 |
|
if(x) delete [] x; |
| 1390 |
|
if(y) delete [] y; |
| 1391 |
|
if(z) delete [] z; |
| 1392 |
|
if(thx) delete [] thx; |
| 1393 |
|
if(thy) delete [] thy; |
| 1394 |
|
if(tl) delete [] tl; |
| 1395 |
|
|
| 1396 |
|
} |
| 1397 |
//-------------------------------------- |
//-------------------------------------- |
| 1398 |
// |
// |
| 1399 |
// |
// |
| 1432 |
|
|
| 1433 |
} |
} |
| 1434 |
|
|
| 1435 |
|
/** |
| 1436 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
| 1437 |
|
* 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. |
| 1438 |
|
* @param t pointer to an object of the class Trajectory, |
| 1439 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
| 1440 |
|
* @return error flag. |
| 1441 |
|
*/ |
| 1442 |
|
int Trajectory::DoTrack2(float* al){ |
| 1443 |
|
|
| 1444 |
|
double *dxout = new double[npoint]; |
| 1445 |
|
double *dyout = new double[npoint]; |
| 1446 |
|
double *dthxout = new double[npoint]; |
| 1447 |
|
double *dthyout = new double[npoint]; |
| 1448 |
|
double *dtlout = new double[npoint]; |
| 1449 |
|
double *dzin = new double[npoint]; |
| 1450 |
|
double dal[5]; |
| 1451 |
|
|
| 1452 |
|
int ifail = 0; |
| 1453 |
|
|
| 1454 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
| 1455 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
| 1456 |
|
|
| 1457 |
|
TrkParams::Load(1); |
| 1458 |
|
if( !TrkParams::IsLoaded(1) ){ |
| 1459 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
| 1460 |
|
return 0; |
| 1461 |
|
} |
| 1462 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
| 1463 |
|
|
| 1464 |
|
for (int i=0; i<npoint; i++){ |
| 1465 |
|
x[i] = (float)*dxout++; |
| 1466 |
|
y[i] = (float)*dyout++; |
| 1467 |
|
thx[i] = (float)*dthxout++; |
| 1468 |
|
thy[i] = (float)*dthyout++; |
| 1469 |
|
tl[i] = (float)*dtlout++; |
| 1470 |
|
} |
| 1471 |
|
|
| 1472 |
|
return ifail; |
| 1473 |
|
}; |
| 1474 |
|
|
| 1475 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
| 1476 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |