| 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*); |
// int readb_(const char*); |
| 16 |
|
int readb_(); |
| 17 |
|
void mini2_(int*,int*,int*); |
| 18 |
|
void guess_(); |
| 19 |
} |
} |
| 20 |
//-------------------------------------- |
//-------------------------------------- |
| 21 |
// |
// |
| 25 |
seqno = -1; |
seqno = -1; |
| 26 |
image = -1; |
image = -1; |
| 27 |
chi2 = 0; |
chi2 = 0; |
| 28 |
|
nstep = 0; |
| 29 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
| 30 |
al[it1] = 0; |
al[it1] = 0; |
| 31 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
| 32 |
}; |
}; |
| 33 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
| 34 |
xgood[ip] = 0; |
xgood[ip] = 0; |
| 59 |
seqno = t.seqno; |
seqno = t.seqno; |
| 60 |
image = t.image; |
image = t.image; |
| 61 |
chi2 = t.chi2; |
chi2 = t.chi2; |
| 62 |
|
nstep = t.nstep; |
| 63 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
| 64 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
| 65 |
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]; |
| 66 |
}; |
}; |
| 67 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
| 68 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
| 200 |
//-------------------------------------- |
//-------------------------------------- |
| 201 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
| 202 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
| 203 |
|
cout << endl << "seq. n. : "<< seqno; |
| 204 |
|
cout << endl << "image n. : "<< image; |
| 205 |
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] << " "; |
| 206 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
| 207 |
|
cout << endl << "n.step : "<< nstep; |
| 208 |
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] ; |
| 209 |
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] ; |
| 210 |
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] << " "; |
| 211 |
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] << " "; |
| 212 |
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] << " "; |
| 213 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
| 214 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
| 215 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
| 216 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
| 217 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
| 218 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
| 219 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
| 220 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
| 221 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
| 222 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
| 223 |
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] << " "; |
| 224 |
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] << " "; |
| 225 |
|
cout << endl; |
| 226 |
|
} |
| 227 |
|
/** |
| 228 |
|
* Set the TrkTrack position measurements |
| 229 |
|
*/ |
| 230 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
| 231 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
| 232 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
| 233 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
| 234 |
|
} |
| 235 |
|
/** |
| 236 |
|
* Set the TrkTrack position resolution |
| 237 |
|
*/ |
| 238 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
| 239 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
| 240 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
| 241 |
|
} |
| 242 |
|
/** |
| 243 |
|
* Set the TrkTrack good measurement |
| 244 |
|
*/ |
| 245 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
| 246 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
| 247 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
| 248 |
|
} |
| 249 |
|
|
| 250 |
|
/** |
| 251 |
|
* Load the magnetic field |
| 252 |
|
*/ |
| 253 |
|
void TrkTrack::LoadField(TString path){ |
| 254 |
|
|
| 255 |
|
strcpy(path_.path,path.Data()); |
| 256 |
|
path_.pathlen = path.Length(); |
| 257 |
|
path_.error = 0; |
| 258 |
|
readb_(); |
| 259 |
|
|
| 260 |
|
}; |
| 261 |
|
/** |
| 262 |
|
* Tracking method. It calls F77 mini routine. |
| 263 |
|
*/ |
| 264 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
| 265 |
|
|
| 266 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
| 267 |
|
|
| 268 |
|
extern cMini2track track_; |
| 269 |
|
fail = 0; |
| 270 |
|
|
| 271 |
|
for(int i=0; i<6; i++) track_.xm[i]=xm[i]; |
| 272 |
|
for(int i=0; i<6; i++) track_.ym[i]=ym[i]; |
| 273 |
|
for(int i=0; i<6; i++) track_.zm[i]=zm[i]; |
| 274 |
|
for(int i=0; i<6; i++) track_.resx[i]=resx[i]; |
| 275 |
|
for(int i=0; i<6; i++) track_.resy[i]=resy[i]; |
| 276 |
|
for(int i=0; i<6; i++) track_.xgood[i]=xgood[i]; |
| 277 |
|
for(int i=0; i<6; i++) track_.ygood[i]=ygood[i]; |
| 278 |
|
|
| 279 |
|
// initial guess of "al" with linear fit |
| 280 |
|
// if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){ |
| 281 |
|
// cout << "initial guess "<<endl; |
| 282 |
|
// double szz=0., szx=0., szy=0., ssx=0., ssy=0., sz=0., s1=0.; |
| 283 |
|
// double det, ax, ay, bx, by; |
| 284 |
|
// for(int i=0; i<NPLANE; i++) { |
| 285 |
|
// szz=szz+zm[i]*zm[i]; |
| 286 |
|
// szx=szx+zm[i]*xm[i]; |
| 287 |
|
// szy=szy+zm[i]*ym[i]; |
| 288 |
|
// ssx=ssx+xm[i]; |
| 289 |
|
// ssy=ssy+ym[i]; |
| 290 |
|
// sz=sz+zm[i]; |
| 291 |
|
// s1=s1+1.; |
| 292 |
|
// } |
| 293 |
|
// det=szz*s1-sz*sz; |
| 294 |
|
// ax=(szx*s1-sz*ssx)/det; |
| 295 |
|
// bx=(szz*ssx-szx*sz)/det; |
| 296 |
|
// ay=(szy*s1-sz*ssy)/det; |
| 297 |
|
// by=(szz*ssy-szy*sz)/det; |
| 298 |
|
// al[0]=ax*23.5+bx; // ZINI = 23.5 !!! it should be the same parameter in all codes |
| 299 |
|
// al[1]=ay*23.5+by; // " |
| 300 |
|
// al[2]= sqrt(pow(ax,2)+pow(ay,2))/ sqrt(pow(ax,2)+pow(ay,2)+1.); |
| 301 |
|
// al[3]=0.; |
| 302 |
|
// if( (ax!=0.)||(ay!=0.) ) { |
| 303 |
|
// al[3]= asin(ay/ sqrt(pow(ax,2)+pow(ay,2))); |
| 304 |
|
// if(ax<0.) al[3]=acos(-1.)-al[3]; |
| 305 |
|
// } |
| 306 |
|
// al[4]=0.; |
| 307 |
|
// } |
| 308 |
|
// end guess |
| 309 |
|
|
| 310 |
|
for(int i=0; i<5; i++) track_.al[i]=al[i]; |
| 311 |
|
track_.zini = 23.5; |
| 312 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
| 313 |
|
|
| 314 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
| 315 |
|
|
| 316 |
|
// --------------------- free momentum |
| 317 |
|
if(pfixed==0.) { |
| 318 |
|
// al[4]=0.; // free momentum |
| 319 |
|
track_.pfixed=0.; // " |
| 320 |
|
} |
| 321 |
|
// --------------------- fixed momentum |
| 322 |
|
if(pfixed!=0.) { |
| 323 |
|
al[4]=1./pfixed; // to fix the momentum |
| 324 |
|
track_.pfixed=pfixed; // " |
| 325 |
|
} |
| 326 |
|
|
| 327 |
|
// store temporarily the initial guess |
| 328 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
| 329 |
|
|
| 330 |
|
|
| 331 |
|
int istep=0; |
| 332 |
|
int ifail=0; |
| 333 |
|
mini2_(&istep,&ifail, &iprint); |
| 334 |
|
if(ifail!=0) { |
| 335 |
|
if(iprint==1)cout << "ERROR: ifail= " << ifail << endl; |
| 336 |
|
fail = 1; |
| 337 |
|
// return; |
| 338 |
|
} |
| 339 |
|
|
| 340 |
|
|
| 341 |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
| 342 |
|
|
| 343 |
|
for(int i=0; i<5; i++) al[i]=track_.al[i]; |
| 344 |
|
chi2=track_.chi2; |
| 345 |
|
nstep=track_.nstep; |
| 346 |
|
for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
| 347 |
|
for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
| 348 |
|
for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
| 349 |
|
for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
| 350 |
|
for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
| 351 |
|
for(int i=0; i<5; i++) { |
| 352 |
|
for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
| 353 |
|
} |
| 354 |
|
|
| 355 |
|
if(fail){ |
| 356 |
|
cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
| 357 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
| 358 |
|
} |
| 359 |
|
|
| 360 |
|
}; |
| 361 |
|
/* |
| 362 |
|
* Reset the fit parameters |
| 363 |
|
*/ |
| 364 |
|
void TrkTrack::FitReset(){ |
| 365 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
| 366 |
|
chi2=0.; |
| 367 |
|
nstep=0; |
| 368 |
|
for(int i=0; i<6; i++) xv[i]=0.; |
| 369 |
|
for(int i=0; i<6; i++) yv[i]=0.; |
| 370 |
|
for(int i=0; i<6; i++) zv[i]=0.; |
| 371 |
|
for(int i=0; i<6; i++) axv[i]=0.; |
| 372 |
|
for(int i=0; i<6; i++) ayv[i]=0.; |
| 373 |
|
for(int i=0; i<5; i++) { |
| 374 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
| 375 |
|
} |
| 376 |
} |
} |
| 377 |
|
|
| 378 |
|
//-------------------------------------- |
| 379 |
|
// |
| 380 |
|
// |
| 381 |
|
//-------------------------------------- |
| 382 |
|
void TrkTrack::Clear(){ |
| 383 |
|
seqno = -1; |
| 384 |
|
image = -1; |
| 385 |
|
chi2 = 0; |
| 386 |
|
nstep = 0; |
| 387 |
|
for(int it1=0;it1<5;it1++){ |
| 388 |
|
al[it1] = 0; |
| 389 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
| 390 |
|
}; |
| 391 |
|
for(int ip=0;ip<6;ip++){ |
| 392 |
|
xgood[ip] = 0; |
| 393 |
|
ygood[ip] = 0; |
| 394 |
|
xm[ip] = 0; |
| 395 |
|
ym[ip] = 0; |
| 396 |
|
zm[ip] = 0; |
| 397 |
|
resx[ip] = 0; |
| 398 |
|
resy[ip] = 0; |
| 399 |
|
xv[ip] = 0; |
| 400 |
|
yv[ip] = 0; |
| 401 |
|
zv[ip] = 0; |
| 402 |
|
axv[ip] = 0; |
| 403 |
|
ayv[ip] = 0; |
| 404 |
|
dedx_x[ip] = 0; |
| 405 |
|
dedx_y[ip] = 0; |
| 406 |
|
// clx[ip] = 0; |
| 407 |
|
// cly[ip] = 0; |
| 408 |
|
}; |
| 409 |
|
clx->Clear(); |
| 410 |
|
cly->Clear(); |
| 411 |
|
}; |
| 412 |
|
//-------------------------------------- |
| 413 |
|
// |
| 414 |
|
// |
| 415 |
|
//-------------------------------------- |
| 416 |
|
void TrkTrack::Delete(){ |
| 417 |
|
Clear(); |
| 418 |
|
clx->Delete(); |
| 419 |
|
cly->Delete(); |
| 420 |
|
}; |
| 421 |
|
//-------------------------------------- |
| 422 |
|
// |
| 423 |
|
// |
| 424 |
|
//-------------------------------------- |
| 425 |
|
|
| 426 |
//-------------------------------------- |
//-------------------------------------- |
| 427 |
// |
// |
| 428 |
// |
// |
| 462 |
// |
// |
| 463 |
//-------------------------------------- |
//-------------------------------------- |
| 464 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
| 465 |
good2 = -1; |
// good2 = -1; |
| 466 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
| 467 |
crc[i] = -1; |
// crc[i] = -1; |
| 468 |
}; |
good[i] = -1; |
| 469 |
|
}; |
| 470 |
Track = new TClonesArray("TrkTrack"); |
Track = new TClonesArray("TrkTrack"); |
| 471 |
SingletX = new TClonesArray("TrkSinglet"); |
SingletX = new TClonesArray("TrkSinglet"); |
| 472 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletY = new TClonesArray("TrkSinglet"); |
| 479 |
// |
// |
| 480 |
//-------------------------------------- |
//-------------------------------------- |
| 481 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
| 482 |
|
|
| 483 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
| 484 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
| 485 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
| 486 |
|
// |
| 487 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
| 488 |
cout << endl << "good2 : " << good2; |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
|
cout << endl << "crc : "; for(int i=0; i<12; i++) cout << crc[i]; |
|
| 489 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
| 490 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
| 491 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
| 501 |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
| 502 |
*/ |
*/ |
| 503 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
| 504 |
// |
|
| 505 |
// Track = new TClonesArray("TrkTrack"); |
// temporary objects: |
|
// SingletX = new TClonesArray("TrkSinglet"); |
|
|
// SingletY = new TClonesArray("TrkSinglet"); |
|
|
// temporary objects: |
|
| 506 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
| 507 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
| 508 |
// general variables |
|
| 509 |
good2 = l2->good2; |
// **** general variables **** |
| 510 |
|
// good2 = l2->good2; |
| 511 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
| 512 |
crc[i] = l2->crc[i]; |
// crc[i] = l2->crc[i]; |
| 513 |
}; |
good[i] = l2->good[i]; |
| 514 |
// *** TRACKS *** |
}; |
| 515 |
|
// *** TRACKS *** |
| 516 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
| 517 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
| 518 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
| 519 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
| 520 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
| 521 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
| 522 |
|
t_track->nstep = l2->nstep_nt[i]; |
| 523 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
| 524 |
t_track->al[it1] = l2->al_nt[i][it1]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
| 525 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
| 585 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
| 586 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
| 587 |
// general variables |
// general variables |
| 588 |
good2 = l2->good2; |
// good2 = l2->good2; |
| 589 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
| 590 |
crc[i] = l2->crc[i]; |
// crc[i] = l2->crc[i]; |
| 591 |
|
good[i] = l2->good[i]; |
| 592 |
}; |
}; |
| 593 |
// *** TRACKS *** |
// *** TRACKS *** |
| 594 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
| 597 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
| 598 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
| 599 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
| 600 |
|
t_track->nstep = l2->nstep_nt[i]; |
| 601 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
| 602 |
t_track->al[it1] = l2->al_nt[i][it1]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
| 603 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
| 624 |
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
| 625 |
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
| 626 |
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
| 627 |
|
// 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; |
| 628 |
|
// 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; |
| 629 |
//----------------------------------------------------- |
//----------------------------------------------------- |
| 630 |
}; |
}; |
| 631 |
new(t[i]) TrkTrack(*t_track); |
new(t[i]) TrkTrack(*t_track); |
| 641 |
//----------------------------------------------------- |
//----------------------------------------------------- |
| 642 |
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
| 643 |
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
| 644 |
|
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
| 645 |
//----------------------------------------------------- |
//----------------------------------------------------- |
| 646 |
new(sx[i]) TrkSinglet(*t_singlet); |
new(sx[i]) TrkSinglet(*t_singlet); |
| 647 |
t_singlet->Clear(); |
t_singlet->Clear(); |
| 655 |
//----------------------------------------------------- |
//----------------------------------------------------- |
| 656 |
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
| 657 |
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
| 658 |
|
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
| 659 |
//----------------------------------------------------- |
//----------------------------------------------------- |
| 660 |
new(sy[i]) TrkSinglet(*t_singlet); |
new(sy[i]) TrkSinglet(*t_singlet); |
| 661 |
t_singlet->Clear(); |
t_singlet->Clear(); |
| 671 |
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
| 672 |
|
|
| 673 |
// general variables |
// general variables |
| 674 |
l2->good2 = good2 ; |
// l2->good2 = good2 ; |
| 675 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
| 676 |
l2->crc[i] = crc[i]; |
// l2->crc[i] = crc[i]; |
| 677 |
|
l2->good[i] = good[i]; |
| 678 |
}; |
}; |
| 679 |
// *** TRACKS *** |
// *** TRACKS *** |
| 680 |
|
|
| 682 |
for(Int_t i=0;i<l2->ntrk;i++){ |
for(Int_t i=0;i<l2->ntrk;i++){ |
| 683 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
| 684 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
| 685 |
for(int it1=0;it1<5;it1++){ |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
| 686 |
|
for(int it1=0;it1<5;it1++){ |
| 687 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
| 688 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
| 689 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
| 727 |
// |
// |
| 728 |
//-------------------------------------- |
//-------------------------------------- |
| 729 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
| 730 |
good2 = -1; |
// good2 = -1; |
| 731 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
| 732 |
crc[i] = -1; |
// crc[i] = -1; |
| 733 |
}; |
good[i] = -1; |
| 734 |
|
}; |
| 735 |
/* Track->RemoveAll(); |
/* Track->RemoveAll(); |
| 736 |
SingletX->RemoveAll(); |
SingletX->RemoveAll(); |
| 737 |
SingletY->RemoveAll();*/ |
SingletY->RemoveAll();*/ |
| 744 |
// |
// |
| 745 |
// |
// |
| 746 |
//-------------------------------------- |
//-------------------------------------- |
| 747 |
|
void TrkLevel2::Delete(){ |
| 748 |
|
|
| 749 |
|
Clear(); |
| 750 |
|
Track->Delete(); |
| 751 |
|
SingletX->Delete(); |
| 752 |
|
SingletY->Delete(); |
| 753 |
|
} |
| 754 |
|
//-------------------------------------- |
| 755 |
|
// |
| 756 |
|
// |
| 757 |
|
//-------------------------------------- |
| 758 |
/** |
/** |
| 759 |
* Sort physical tracks and stores them in a TObjectArray, ordering by increasing chi**2 value (in case of track image, it selects the one with lower chi**2). The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it). |
* Sort physical tracks and stores them in a TObjectArray, ordering by increasing chi**2 value (in case of track image, it selects the one with lower chi**2). The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it). |
| 760 |
* This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used. |
* This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used. |
| 761 |
*/ |
*/ |
|
// TClonesArray *TrkLevel2::GetTracks(){ |
|
|
// TClonesArray *sorted = GetTracks_NFitSorted(); |
|
|
// return sorted; |
|
|
// }; |
|
|
|
|
|
/*TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){ |
|
|
|
|
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
int N=this->ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
float chi2ref=1000000; |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->image != -1 ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
} |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
m[indi] = 0; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
return sorted; |
|
|
}*/ |
|
|
/*TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
|
|
|
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
// TClonesArray &ts = *PhysicalTrack; |
|
|
int N = ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
int nfit =0; |
|
|
float chi2ref = numeric_limits<float>::max(); |
|
|
// first loop to search maximum num. of fit points |
|
|
for(int i=0; i < ntrk(); i++){ |
|
|
// if(N==ntrk())cout << "** "<<i<< " " << ((TrkTrack *)t[i])->GetImageSeqNo()<< " " <<((TrkTrack *)t[i])->GetNtot() << " " <<((TrkTrack *)t[i])->chi2 << endl; |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
|
} |
|
|
} |
|
|
//second loop to search minimum chi2 among selected |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
|
|
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
|
|
&& m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
|
|
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
|
|
} |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
m[indi] = 0; |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
m.clear(); |
|
|
return sorted; |
|
|
// return PhysicalTrack; |
|
|
}*/ |
|
|
//TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
| 762 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
| 763 |
|
|
|
// cout << "GetTracks_NFitSorted(it): new TRefArray()"<< endl; |
|
|
// TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
// TClonesArray &ts = *sorted; |
|
| 764 |
TRefArray *sorted = new TRefArray(); |
TRefArray *sorted = new TRefArray(); |
| 765 |
|
|
| 766 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
| 796 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
| 797 |
N--; |
N--; |
| 798 |
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
|
|
|
| 799 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
| 800 |
}; |
}; |
|
// new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
// cout << "GetTracks_NFitSorted(it): Add("<<indo<<")"<< endl; |
|
| 801 |
sorted->Add( (TrkTrack*)t[indi] ); |
sorted->Add( (TrkTrack*)t[indi] ); |
| 802 |
|
|
| 803 |
m[indi] = 0; |
m[indi] = 0; |
| 877 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
| 878 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
| 879 |
*/ |
*/ |
| 880 |
/*TrkTrack *TrkLevel2::GetTrack(int it){ |
|
|
|
|
|
if(it >= this->GetNTracks()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
|
|
return 0; |
|
|
} |
|
|
TClonesArray* sorted = GetTracks(); |
|
|
TClonesArray &ts = *sorted; |
|
|
|
|
|
// TrkTrack *track = (TrkTrack*)ts[it]; |
|
|
TrkTrack *track = new TrkTrack( *(TrkTrack*)ts[it] ); //copia |
|
|
sorted->Delete("all");////TEMPORANEO |
|
|
return track; |
|
|
}*/ |
|
| 881 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
| 882 |
|
|
| 883 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
| 898 |
|
|
| 899 |
Float_t ntot=0; |
Float_t ntot=0; |
| 900 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
| 901 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
| 902 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
| 903 |
else ntot+=0.5; |
else ntot+=0.5; |
| 904 |
} |
} |
| 913 |
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
| 914 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
| 915 |
*/ |
*/ |
|
/*TrkTrack *TrkLevel2::GetTrackImage(int it){ |
|
|
|
|
|
if(it >= this->GetNTracks()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
|
|
return 0; |
|
|
} |
|
|
|
|
|
TClonesArray* sorted = GetTracks(); |
|
|
TClonesArray &ts = *sorted; |
|
|
TrkTrack *track = (TrkTrack*)ts[it]; |
|
|
// TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
|
|
|
|
if(!track->HasImage()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
|
|
return 0; |
|
|
} |
|
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
|
|
|
|
|
// GetTracks()->Delete(); ////TEMPORANEO |
|
|
sorted->Delete(); ////TEMPORANEO |
|
|
|
|
|
return image; |
|
|
|
|
|
}*/ |
|
| 916 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
| 917 |
|
|
| 918 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
| 943 |
* Loads the magnetic field. |
* Loads the magnetic field. |
| 944 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
| 945 |
*/ |
*/ |
| 946 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
| 947 |
readb_(s.Data()); |
// |
| 948 |
|
strcpy(path_.path,path.Data()); |
| 949 |
|
path_.pathlen = path.Length(); |
| 950 |
|
path_.error = 0; |
| 951 |
|
readb_(); |
| 952 |
|
// |
| 953 |
}; |
}; |
| 954 |
//-------------------------------------- |
//-------------------------------------- |
| 955 |
// |
// |
| 1096 |
|
|
| 1097 |
} |
} |
| 1098 |
|
|
| 1099 |
|
|
| 1100 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
| 1101 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |
| 1102 |
ClassImp(TrkTrack); |
ClassImp(TrkTrack); |