18 |
// |
// |
19 |
//-------------------------------------- |
//-------------------------------------- |
20 |
TrkTrack::TrkTrack(){ |
TrkTrack::TrkTrack(){ |
21 |
image = 0; |
seqno = -1; |
22 |
|
image = -1; |
23 |
chi2 = 0; |
chi2 = 0; |
24 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
25 |
al[it1] = 0; |
al[it1] = 0; |
48 |
// |
// |
49 |
//-------------------------------------- |
//-------------------------------------- |
50 |
TrkTrack::TrkTrack(const TrkTrack& t){ |
TrkTrack::TrkTrack(const TrkTrack& t){ |
51 |
|
seqno = t.seqno; |
52 |
image = t.image; |
image = t.image; |
53 |
chi2 = t.chi2; |
chi2 = t.chi2; |
54 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
240 |
Track = new TClonesArray("TrkTrack"); |
Track = new TClonesArray("TrkTrack"); |
241 |
SingletX = new TClonesArray("TrkSinglet"); |
SingletX = new TClonesArray("TrkSinglet"); |
242 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletY = new TClonesArray("TrkSinglet"); |
243 |
|
// Track = 0; |
244 |
|
// Singlet = 0; |
245 |
|
// SingletY = 0; |
246 |
} |
} |
247 |
//-------------------------------------- |
//-------------------------------------- |
248 |
// |
// |
271 |
* 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). |
272 |
*/ |
*/ |
273 |
void TrkLevel2::FillCommonVar(cTrkLevel2 *l2){ |
void TrkLevel2::FillCommonVar(cTrkLevel2 *l2){ |
274 |
|
// |
275 |
|
// Track = new TClonesArray("TrkTrack"); |
276 |
|
// SingletX = new TClonesArray("TrkSinglet"); |
277 |
|
// SingletY = new TClonesArray("TrkSinglet"); |
278 |
// temporary objects: |
// temporary objects: |
279 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
280 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
286 |
// *** TRACKS *** |
// *** TRACKS *** |
287 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
288 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
289 |
|
t_track->seqno = i; |
290 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
291 |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
292 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
293 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
294 |
t_track->al[it1] = l2->al_nt[i][it1]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
333 |
new(sy[i]) TrkSinglet(*t_singlet); |
new(sy[i]) TrkSinglet(*t_singlet); |
334 |
t_singlet->Clear(); |
t_singlet->Clear(); |
335 |
}; |
}; |
336 |
|
|
337 |
|
delete t_track; |
338 |
|
delete t_singlet; |
339 |
} |
} |
340 |
//-------------------------------------- |
//-------------------------------------- |
341 |
// |
// |
346 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
347 |
crc[i] = -1; |
crc[i] = -1; |
348 |
}; |
}; |
349 |
Track->RemoveAll(); |
/* Track->RemoveAll(); |
350 |
SingletX->RemoveAll(); |
SingletX->RemoveAll(); |
351 |
SingletY->RemoveAll(); |
SingletY->RemoveAll();*/ |
352 |
|
// modify to avoid memory leakage |
353 |
|
Track->Clear(); |
354 |
|
SingletX->Clear(); |
355 |
|
SingletY->Clear(); |
356 |
} |
} |
357 |
//-------------------------------------- |
//-------------------------------------- |
358 |
// |
// |
363 |
* 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. |
364 |
*/ |
*/ |
365 |
TClonesArray *TrkLevel2::GetTracks(){ |
TClonesArray *TrkLevel2::GetTracks(){ |
366 |
|
TClonesArray *sorted = GetTracks_NFitSorted(); |
367 |
|
return sorted; |
368 |
|
}; |
369 |
|
|
370 |
|
TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){ |
371 |
|
|
372 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
373 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
396 |
} |
} |
397 |
return sorted; |
return sorted; |
398 |
} |
} |
399 |
|
TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
400 |
|
|
401 |
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
402 |
|
TClonesArray &t = *Track; |
403 |
|
TClonesArray &ts = *sorted; |
404 |
|
int N=this->ntrk(); |
405 |
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
406 |
|
|
407 |
|
int indo=0; |
408 |
|
int indi=0; |
409 |
|
while(N != 0){ |
410 |
|
int nfit =0; |
411 |
|
float chi2ref=1000000; |
412 |
|
// first loop to search maximum num. of fit points |
413 |
|
for(int i=0; i<this->ntrk(); i++){ |
414 |
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
415 |
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
416 |
|
// cout << "1** "<<i<< " " << nfit<<endl; |
417 |
|
} |
418 |
|
} |
419 |
|
//second loop to search minimum chi2 among selected |
420 |
|
for(int i=0; i<this->ntrk(); i++){ |
421 |
|
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
422 |
|
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
423 |
|
&& m[i]==1){ |
424 |
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
425 |
|
indi = i; |
426 |
|
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
427 |
|
} |
428 |
|
} |
429 |
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
430 |
|
m[((TrkTrack *)t[indi])->image] = 0; |
431 |
|
N--; |
432 |
|
|
433 |
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
434 |
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
435 |
|
|
436 |
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
437 |
|
} |
438 |
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
439 |
|
m[indi] = 0; |
440 |
|
N--; |
441 |
|
indo++; |
442 |
|
} |
443 |
|
return sorted; |
444 |
|
} |
445 |
//-------------------------------------- |
//-------------------------------------- |
446 |
// |
// |
447 |
// |
// |
478 |
return 0; |
return 0; |
479 |
} |
} |
480 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
481 |
|
GetTracks()->Delete();////TEMPORANEO |
482 |
return track; |
return track; |
483 |
} |
} |
484 |
|
Int_t TrkLevel2::GetNTracks(){ |
485 |
|
Int_t ntot=0; |
486 |
|
ntot = GetTracks()->GetEntries(); |
487 |
|
GetTracks()->Delete();////TEMPORANEO |
488 |
|
return ntot; |
489 |
|
}; |
490 |
//-------------------------------------- |
//-------------------------------------- |
491 |
// |
// |
492 |
// |
// |