30 |
void GPamela::Delete() { |
void GPamela::Delete() { |
31 |
|
|
32 |
Clear(); |
Clear(); |
33 |
|
/* EM all these are in the stack not in the heap, so no need to delete by hand... |
34 |
delete[] Ipltof; |
delete[] Ipltof; |
35 |
delete[] Ipaddle; |
delete[] Ipaddle; |
36 |
delete[] Ipartof; |
delete[] Ipartof; |
131 |
delete[] Timecard; |
delete[] Timecard; |
132 |
delete[] Pathcard; |
delete[] Pathcard; |
133 |
delete[] P0card; |
delete[] P0card; |
134 |
|
*/ |
135 |
} |
} |
136 |
; |
|
137 |
|
|
138 |
void GPamela::SetBranchAddress(TChain* fhBookTree) { |
void GPamela::SetBranchAddress(TChain* fhBookTree) { |
139 |
|
|
278 |
*/ |
*/ |
279 |
PamTrack::PamTrack() { |
PamTrack::PamTrack() { |
280 |
trk_track = 0; |
trk_track = 0; |
281 |
|
trk_ext_track = 0; |
282 |
calo_track = 0; |
calo_track = 0; |
283 |
tof_track = 0; |
tof_track = 0; |
284 |
orb_track = 0; |
orb_track = 0; |
296 |
*/ |
*/ |
297 |
PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o, OrbitalInfoTrkVar *r) { |
PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o, OrbitalInfoTrkVar *r) { |
298 |
|
|
299 |
|
trk_ext_track = 0; |
300 |
trk_track = 0; |
trk_track = 0; |
301 |
calo_track = 0; |
calo_track = 0; |
302 |
tof_track = 0; |
tof_track = 0; |
304 |
// if(t)trk_track = new TrkTrack(*t); |
// if(t)trk_track = new TrkTrack(*t); |
305 |
// if(c)calo_track = new CaloTrkVar(*c); |
// if(c)calo_track = new CaloTrkVar(*c); |
306 |
// if(o)tof_track = new ToFTrkVar(*o); |
// if(o)tof_track = new ToFTrkVar(*o); |
307 |
if (t) |
// if (t) |
308 |
trk_track = t; |
// trk_track = t; |
309 |
|
// if (c) |
310 |
|
// calo_track = c; |
311 |
|
// if (o) |
312 |
|
// tof_track = o; |
313 |
|
// if (r) |
314 |
|
// orb_track = r; |
315 |
|
|
316 |
|
// candeleteobj = 0; |
317 |
|
|
318 |
|
|
319 |
|
if (t){ |
320 |
|
trk_track = new TrkTrack(*t); |
321 |
|
trk_ext_track = new ExtTrack(*t);//NB!! ha dimensione 6 invece che 8 |
322 |
|
} |
323 |
if (c) |
if (c) |
324 |
calo_track = c; |
calo_track = new CaloTrkVar(*c); |
325 |
if (o) |
if (o) |
326 |
tof_track = o; |
tof_track = new ToFTrkVar(*o); |
327 |
if (r) |
if (r) |
328 |
orb_track = r; |
orb_track = new OrbitalInfoTrkVar(*r); |
329 |
|
candeleteobj = 1; |
330 |
|
|
331 |
candeleteobj = 0; |
} |
332 |
|
; |
333 |
|
/** |
334 |
|
* Constructor |
335 |
|
*/ |
336 |
|
PamTrack::PamTrack(ExtTrack* t, CaloTrkVar* c, ToFTrkVar* o, OrbitalInfoTrkVar *r) { |
337 |
|
|
338 |
|
trk_ext_track = 0; |
339 |
|
trk_track = 0; |
340 |
|
calo_track = 0; |
341 |
|
tof_track = 0; |
342 |
|
orb_track = 0; |
343 |
|
// if(t)trk_track = new TrkTrack(*t); |
344 |
|
// if(c)calo_track = new CaloTrkVar(*c); |
345 |
|
// if(o)tof_track = new ToFTrkVar(*o); |
346 |
|
// if (t) |
347 |
|
// trk_track = t; |
348 |
|
// if (c) |
349 |
|
// calo_track = c; |
350 |
|
// if (o) |
351 |
|
// tof_track = o; |
352 |
|
// if (r) |
353 |
|
// orb_track = r; |
354 |
|
|
355 |
|
// candeleteobj = 0; |
356 |
|
|
357 |
|
|
358 |
|
if (t){ |
359 |
|
//// trk_track = new TrkTrack(*t);//in this case TrkTrack object remains null |
360 |
|
trk_ext_track = new ExtTrack(*t); |
361 |
|
} |
362 |
|
if (c) |
363 |
|
calo_track = new CaloTrkVar(*c); |
364 |
|
if (o) |
365 |
|
tof_track = new ToFTrkVar(*o); |
366 |
|
if (r) |
367 |
|
orb_track = new OrbitalInfoTrkVar(*r); |
368 |
|
candeleteobj = 1; |
369 |
|
pscore = 0; |
370 |
|
iscore = 0; |
371 |
|
|
372 |
} |
} |
373 |
; |
; |
374 |
PamTrack::PamTrack(const PamTrack& track) { |
PamTrack::PamTrack(const PamTrack& track) { |
375 |
|
|
376 |
TrkTrack *t = track.trk_track; |
TrkTrack *t = track.trk_track; |
377 |
|
ExtTrack *e = track.trk_ext_track; |
378 |
CaloTrkVar *c = track.calo_track; |
CaloTrkVar *c = track.calo_track; |
379 |
ToFTrkVar *o = track.tof_track; |
ToFTrkVar *o = track.tof_track; |
380 |
OrbitalInfoTrkVar *r = track.orb_track; |
OrbitalInfoTrkVar *r = track.orb_track; |
381 |
|
|
382 |
trk_track = 0; |
trk_ext_track = 0; |
383 |
calo_track = 0; |
trk_track = 0; |
384 |
tof_track = 0; |
calo_track = 0; |
385 |
orb_track = 0; |
tof_track = 0; |
386 |
|
orb_track = 0; |
387 |
|
if(e) |
388 |
|
trk_ext_track = new ExtTrack(*e); |
389 |
if (t) |
if (t) |
390 |
trk_track = new TrkTrack(*t); |
trk_track = new TrkTrack(*t); |
391 |
if (c) |
if (c) |
394 |
tof_track = new ToFTrkVar(*o); |
tof_track = new ToFTrkVar(*o); |
395 |
if (r) |
if (r) |
396 |
orb_track = new OrbitalInfoTrkVar(*r); |
orb_track = new OrbitalInfoTrkVar(*r); |
397 |
|
|
398 |
candeleteobj = 1; |
candeleteobj = 1; |
399 |
|
pscore = 0; |
400 |
|
iscore = 0; |
401 |
|
|
402 |
} |
} |
403 |
void PamTrack::Clear() { |
void PamTrack::Clear(Option_t *option) { |
404 |
|
|
405 |
// cout << "PamTrack::Clear() "<<candeleteobj<<endl; |
// cout << "PamTrack::Clear( "<<option<<" ) "<<candeleteobj<<endl; |
406 |
if (candeleteobj) { |
if (candeleteobj) { |
407 |
|
|
408 |
|
if (trk_ext_track) |
409 |
|
trk_ext_track->ExtTrack::Clear(option); |
410 |
if (trk_track) |
if (trk_track) |
411 |
trk_track->TrkTrack::Clear(); |
trk_track->TrkTrack::Clear(); |
412 |
if (calo_track) |
if (calo_track) |
417 |
orb_track->OrbitalInfoTrkVar::Clear();//??? |
orb_track->OrbitalInfoTrkVar::Clear();//??? |
418 |
} |
} |
419 |
else { |
else { |
420 |
|
trk_ext_track = 0; |
421 |
trk_track = 0; |
trk_track = 0; |
422 |
calo_track = 0; |
calo_track = 0; |
423 |
tof_track = 0; |
tof_track = 0; |
430 |
void PamTrack::Delete() { |
void PamTrack::Delete() { |
431 |
// cout << "PamTrack::Delete() "<<candeleteobj<<endl; |
// cout << "PamTrack::Delete() "<<candeleteobj<<endl; |
432 |
if (candeleteobj) { |
if (candeleteobj) { |
433 |
|
if (trk_ext_track) { |
434 |
|
trk_ext_track->ExtTrack::Clear("C"); |
435 |
|
delete trk_ext_track; |
436 |
|
} |
437 |
if (trk_track) { |
if (trk_track) { |
438 |
trk_track->TrkTrack::Clear(); |
trk_track->TrkTrack::Clear(); |
439 |
delete trk_track; |
delete trk_track; |
455 |
Clear(); |
Clear(); |
456 |
} |
} |
457 |
} |
} |
458 |
|
|
459 |
|
|
460 |
|
|
461 |
|
|
462 |
//-------------------------------------- |
//-------------------------------------- |
463 |
// |
// |
464 |
// |
// |
469 |
PamLevel2::PamLevel2() { |
PamLevel2::PamLevel2() { |
470 |
Initialize(); |
Initialize(); |
471 |
} |
} |
472 |
; |
|
473 |
|
|
474 |
/** |
/** |
475 |
* Constructor |
* Constructor |
492 |
GetPamTree(listf, detlist); |
GetPamTree(listf, detlist); |
493 |
if (listf) |
if (listf) |
494 |
GetRunTree(listf); |
GetRunTree(listf); |
495 |
|
SetMaxShift(-1); |
496 |
} |
} |
497 |
; |
|
498 |
|
|
499 |
PamLevel2::PamLevel2(TString ddir, TList *llist, TString detlist) { |
PamLevel2::PamLevel2(TString ddir, TList *llist, TString detlist) { |
500 |
Initialize(); |
Initialize(); |
501 |
GetPamTree(llist, detlist); |
GetPamTree(llist, detlist); |
502 |
GetRunTree(llist); |
GetRunTree(llist); |
503 |
|
SetMaxShift(-1); |
504 |
} |
} |
505 |
; |
|
506 |
/** |
/** |
507 |
* Constructor |
* Constructor |
508 |
* @param ddir Name of directory where level2 files are stored. |
* @param ddir Name of directory where level2 files are stored. |
512 |
*/ |
*/ |
513 |
PamLevel2::PamLevel2(TString ddir, TString llist) { |
PamLevel2::PamLevel2(TString ddir, TString llist) { |
514 |
Initialize(); |
Initialize(); |
515 |
TList* listf = GetListOfLevel2Files(ddir, llist); |
TList* listf = GetListOfLevel2Files(ddir, llist); |
516 |
|
cout << "GetPamTree: "<<endl; |
517 |
GetPamTree(listf, ""); |
GetPamTree(listf, ""); |
518 |
|
cout << "GetRunTree: "<<endl; |
519 |
GetRunTree(listf); |
GetRunTree(listf); |
520 |
|
SetMaxShift(-1); |
521 |
} |
} |
522 |
; |
|
523 |
|
|
524 |
void PamLevel2::Initialize() { |
void PamLevel2::Initialize() { |
525 |
|
|
532 |
trkh_obj = 0; |
trkh_obj = 0; |
533 |
calo1_obj = 0; |
calo1_obj = 0; |
534 |
calo2_obj = 0; |
calo2_obj = 0; |
535 |
tof_obj = 0; |
tof2_obj = 0; |
536 |
trig_obj = 0; |
trig_obj = 0; |
537 |
s4_obj = 0; |
s4_obj = 0; |
538 |
nd_obj = 0; |
nd_obj = 0; |
539 |
ac_obj = 0; |
ac_obj = 0; |
540 |
orb_obj = 0; |
orb2_obj = 0; |
541 |
gp_obj = 0; |
gp_obj = 0; |
542 |
|
|
543 |
|
extAlgFlag=0; |
544 |
|
|
545 |
|
trk_ext_obj = 0; |
546 |
|
trk_ext_nuc_obj = 0; |
547 |
|
trk_nuc_obj = 0; |
548 |
|
|
549 |
|
calo_ext_obj = 0; |
550 |
|
calo_ext_nuc_obj = 0; |
551 |
|
calo_nuc_obj = 0; |
552 |
|
|
553 |
|
tof_ext_obj = 0; |
554 |
|
tof_ext_nuc_obj = 0; |
555 |
|
tof_nuc_obj = 0; |
556 |
|
|
557 |
|
orb_ext_obj = 0; |
558 |
|
orb_ext_nuc_obj = 0; |
559 |
|
orb_nuc_obj = 0; |
560 |
|
|
561 |
|
trk2_nuc_obj = 0; |
562 |
|
calo2_nuc_obj = 0; |
563 |
|
tof2_nuc_obj = 0; |
564 |
|
orb2_nuc_obj = 0; |
565 |
|
|
566 |
|
|
567 |
run_obj = 0;//new GL_RUN(); |
run_obj = 0;//new GL_RUN(); |
568 |
soft_obj = 0;// Emiliano |
soft_obj = 0;// Emiliano |
569 |
|
proc_obj = 0;// Emiliano |
570 |
irun = -1LL; |
irun = -1LL; |
571 |
irunt = -1LL; |
irunt = -1LL; |
572 |
|
totrunentry = 0LL; |
573 |
|
totrunentrymax = 0LL; |
574 |
|
totrunentrymin = 0LL; |
575 |
runfirstentry = 0LL; |
runfirstentry = 0LL; |
576 |
runlastentry = 0LL; |
runlastentry = 0LL; |
577 |
gltsync = 0; // Emiliano |
gltsync = 0; // Emiliano |
578 |
|
fUpdateRunInfo = true; // Emiliano |
579 |
|
fUseDBinRunInfo = true; // Emiliano |
580 |
|
fDiscarded = false; //EM |
581 |
|
isSync = false; // by default assume that the level2 file(s) is(are) not sinchronized between L0/DB and L2, that is we miss some packets in L2 due to nested/DV-skipped events |
582 |
|
il0entry = 0LL; |
583 |
|
// hasL0EE = true; |
584 |
|
|
585 |
l0_file = NULL; |
l0_file = NULL; |
586 |
l0_tree = NULL; |
l0_tree = NULL; |
588 |
dbc = 0; |
dbc = 0; |
589 |
|
|
590 |
prevshift = 0; |
prevshift = 0; |
591 |
maxshift = 10; //EMILIANO |
yprevshift = 0; |
592 |
|
maxshift = 10; //EMILIANO now overridden by SetMaxShift(-1) called by constructors |
593 |
|
|
594 |
run_tree = NULL; |
run_tree = NULL; |
595 |
run_tree_clone = NULL; |
run_tree_clone = NULL; |
596 |
|
|
597 |
|
proc_tree = NULL; |
598 |
|
proc_tree_clone = NULL; |
599 |
|
|
600 |
sel_tree = NULL; |
sel_tree = NULL; |
601 |
sel_tree_clone = NULL; |
sel_tree_clone = NULL; |
602 |
|
|
644 |
ND = true; |
ND = true; |
645 |
AC = true; |
AC = true; |
646 |
ORB = true; |
ORB = true; |
647 |
|
PROC = true; |
648 |
GP = false; |
GP = false; |
649 |
|
|
650 |
|
EXT = false; |
651 |
|
NUC = false; |
652 |
|
trkAlg = "STD";//default tracking algorythm |
653 |
|
|
654 |
RUN = true; |
RUN = true; |
655 |
|
|
656 |
SELLI = -1; |
SELLI = -1; |
661 |
|
|
662 |
tsorted = 0; |
tsorted = 0; |
663 |
timage = 0; |
timage = 0; |
664 |
|
text = 0 ; |
665 |
|
|
666 |
|
tsorted_nuc = 0; |
667 |
|
timage_nuc = 0; |
668 |
|
text_nuc = 0 ; |
669 |
|
|
670 |
howtosort = "+CAL+TOF"; |
howtosort = "+CAL+TOF"; |
671 |
//howtosort = "+TOF"; |
//howtosort = "+TOF"; |
673 |
|
|
674 |
issorted = false; |
issorted = false; |
675 |
lastsorted = -1; |
lastsorted = -1; |
676 |
|
issorted_new = false; |
677 |
|
lastsorted_new = -1; |
678 |
|
|
679 |
} |
} |
680 |
; |
; |
687 |
delete run_obj; |
delete run_obj; |
688 |
if (soft_obj) |
if (soft_obj) |
689 |
delete soft_obj; //Emiliano |
delete soft_obj; //Emiliano |
690 |
|
if (proc_obj) |
691 |
|
delete proc_obj; //Emiliano |
692 |
|
|
693 |
// cout << "void PamLevel2::Clear()"<<endl; |
// cout << "void PamLevel2::Clear()"<<endl; |
694 |
if (h0_obj) |
if (h0_obj) |
707 |
delete calo1_obj; |
delete calo1_obj; |
708 |
if (calo2_obj) |
if (calo2_obj) |
709 |
delete calo2_obj; |
delete calo2_obj; |
710 |
if (tof_obj) |
if (tof2_obj) |
711 |
delete tof_obj; |
delete tof2_obj; |
712 |
if (trig_obj) |
if (trig_obj) |
713 |
delete trig_obj; |
delete trig_obj; |
714 |
if (s4_obj) |
if (s4_obj) |
717 |
delete nd_obj; |
delete nd_obj; |
718 |
if (ac_obj) |
if (ac_obj) |
719 |
delete ac_obj; |
delete ac_obj; |
720 |
if (orb_obj) |
if (orb2_obj) |
721 |
delete orb_obj; |
delete orb2_obj; |
722 |
if (gp_obj) |
if (gp_obj) |
723 |
delete gp_obj; |
delete gp_obj; |
724 |
|
|
725 |
|
if(trk_nuc_obj)trk_nuc_obj->Delete(); |
726 |
|
if(trk_ext_obj)trk_ext_obj->Delete(); |
727 |
|
if(trk_ext_nuc_obj)trk_ext_nuc_obj->Delete(); |
728 |
|
|
729 |
|
if(calo_nuc_obj)calo_nuc_obj->Delete(); |
730 |
|
if(calo_ext_obj)calo_ext_obj->Delete(); |
731 |
|
if(calo_ext_nuc_obj)calo_ext_nuc_obj->Delete(); |
732 |
|
|
733 |
|
if(tof_nuc_obj)tof_nuc_obj->Delete(); |
734 |
|
if(tof_ext_obj)tof_ext_obj->Delete(); |
735 |
|
if(tof_ext_nuc_obj)tof_ext_nuc_obj->Delete(); |
736 |
|
|
737 |
|
if(orb_nuc_obj)orb_nuc_obj->Delete(); |
738 |
|
if(orb_ext_obj)orb_ext_obj->Delete(); |
739 |
|
if(orb_ext_nuc_obj)orb_ext_nuc_obj->Delete(); |
740 |
|
|
741 |
|
|
742 |
|
if(trk2_nuc_obj)trk2_nuc_obj->Delete();; |
743 |
|
if( calo2_nuc_obj)calo2_nuc_obj->Delete();; |
744 |
|
if(tof2_nuc_obj)tof2_nuc_obj->Delete();; |
745 |
|
if(orb2_nuc_obj)orb2_nuc_obj->Delete();; |
746 |
|
|
747 |
|
|
748 |
|
|
749 |
if (tsorted) { |
if (tsorted) { |
750 |
tsorted->Delete(); |
tsorted->Delete(); |
751 |
delete tsorted; |
delete tsorted; |
754 |
timage->Delete(); |
timage->Delete(); |
755 |
delete timage; |
delete timage; |
756 |
} |
} |
757 |
|
if (text) { |
758 |
|
text->Delete(); |
759 |
|
delete text; |
760 |
|
} |
761 |
|
if (tsorted_nuc) { |
762 |
|
tsorted_nuc->Delete(); |
763 |
|
delete tsorted_nuc; |
764 |
|
} |
765 |
|
if (timage_nuc) { |
766 |
|
timage_nuc->Delete(); |
767 |
|
delete timage_nuc; |
768 |
|
} |
769 |
|
if (text_nuc) { |
770 |
|
text_nuc->Delete(); |
771 |
|
delete text_nuc; |
772 |
|
} |
773 |
|
|
774 |
|
|
775 |
|
|
776 |
if (dbc) { |
if (dbc) { |
777 |
dbc->Close(); |
dbc->Close(); |
808 |
// |
// |
809 |
TIter next2(contents); |
TIter next2(contents); |
810 |
TChain *questa = 0; |
TChain *questa = 0; |
811 |
while (questa = (TChain*) next2()) { |
while ( (questa = (TChain*)next2()) ) { |
812 |
TString name = questa->GetName(); |
TString name = questa->GetName(); |
813 |
questa->Delete(); |
questa->Delete(); |
814 |
questa = NULL; |
questa = NULL; |
821 |
run_tree->Delete();; |
run_tree->Delete();; |
822 |
if (sel_tree) |
if (sel_tree) |
823 |
sel_tree->Delete();; |
sel_tree->Delete();; |
824 |
for (Int_t i = 0; i < NCLONES; i++) |
|
825 |
|
// The following lines are commented out since they may generate a double delete error |
826 |
|
// if the file containing the clone trees is closed. This is because the file owns the |
827 |
|
// clone trees which are written into it, so it will delete them when it is closed; if |
828 |
|
// also PamLevel2 will try to delete these trees, a double delete error will be generated |
829 |
|
// when exiting from analysis program. (Nicola 28/11/2011) |
830 |
|
|
831 |
|
/*for (Int_t i = 0; i < NCLONES; i++) |
832 |
if (pam_tree_clone[i]) |
if (pam_tree_clone[i]) |
833 |
pam_tree_clone[i]->Delete();; |
pam_tree_clone[i]->Delete();; |
834 |
if (run_tree_clone) |
if (run_tree_clone) |
835 |
run_tree_clone->Delete();; |
run_tree_clone->Delete();; |
836 |
if (sel_tree_clone) |
if (sel_tree_clone) |
837 |
sel_tree_clone->Delete();; |
sel_tree_clone->Delete();;*/ |
838 |
|
|
839 |
if (irunoffset) |
if (irunoffset) |
840 |
delete[] irunoffset; |
delete[] irunoffset; |
841 |
|
|
842 |
|
|
843 |
|
Initialize(); |
844 |
|
|
845 |
} |
} |
846 |
; |
; |
847 |
|
|
875 |
calo1_obj->Clear(); |
calo1_obj->Clear(); |
876 |
if (calo2_obj) |
if (calo2_obj) |
877 |
calo2_obj->Clear(); |
calo2_obj->Clear(); |
878 |
if (tof_obj) |
if (tof2_obj) |
879 |
tof_obj->Clear(); |
tof2_obj->Clear(); |
880 |
if (trig_obj) |
if (trig_obj) |
881 |
trig_obj->Clear(); |
trig_obj->Clear(); |
882 |
if (s4_obj) |
if (s4_obj) |
885 |
nd_obj->Clear(); |
nd_obj->Clear(); |
886 |
if (ac_obj) |
if (ac_obj) |
887 |
ac_obj->Clear(); |
ac_obj->Clear(); |
888 |
if (orb_obj) |
if (orb2_obj) |
889 |
orb_obj->Clear(); |
orb2_obj->Clear(); |
890 |
if (gp_obj) |
if (gp_obj) |
891 |
gp_obj->Clear(); |
gp_obj->Clear(); |
892 |
|
if (proc_obj) |
893 |
|
proc_obj->Clear(); |
894 |
|
|
895 |
// if(sorted_tracks)sorted_tracks->Clear(); |
// if(sorted_tracks)sorted_tracks->Clear(); |
896 |
// sorted_tracks.Clear(); |
// sorted_tracks.Clear(); |
897 |
|
|
898 |
if (tsorted) { |
if(trk_nuc_obj)trk_nuc_obj->Clear(); |
899 |
tsorted->Delete(); |
if(trk_ext_obj)trk_ext_obj->Clear(); |
900 |
} |
if(trk_ext_nuc_obj)trk_ext_nuc_obj->Clear(); |
901 |
if (timage) { |
|
902 |
timage->Delete(); |
if(calo_nuc_obj)calo_nuc_obj->Clear(); |
903 |
} |
if(calo_ext_obj)calo_ext_obj->Clear(); |
904 |
|
if(calo_ext_nuc_obj)calo_ext_nuc_obj->Clear(); |
905 |
|
|
906 |
|
if(tof_nuc_obj)tof_nuc_obj->Clear(); |
907 |
|
if(tof_ext_obj)tof_ext_obj->Clear(); |
908 |
|
if(tof_ext_nuc_obj)tof_ext_nuc_obj->Clear(); |
909 |
|
|
910 |
|
if(orb_nuc_obj)orb_nuc_obj->Clear(); |
911 |
|
if(orb_ext_obj)orb_ext_obj->Clear(); |
912 |
|
if(orb_ext_nuc_obj)orb_ext_nuc_obj->Clear(); |
913 |
|
|
914 |
|
if(trk2_nuc_obj)trk2_nuc_obj->Clear();; |
915 |
|
if( calo2_nuc_obj)calo2_nuc_obj->Clear();; |
916 |
|
if(tof2_nuc_obj)tof2_nuc_obj->Clear();; |
917 |
|
if(orb2_nuc_obj)orb2_nuc_obj->Clear();; |
918 |
|
|
919 |
|
if (tsorted)tsorted->Delete(); |
920 |
|
if (timage)timage->Delete(); |
921 |
|
if (text) text->Delete(); |
922 |
|
|
923 |
|
if (tsorted_nuc)tsorted_nuc->Delete(); |
924 |
|
if (timage_nuc)timage_nuc->Delete(); |
925 |
|
if (text_nuc) text_nuc->Delete(); |
926 |
} |
} |
927 |
; |
; |
928 |
|
|
956 |
// |
// |
957 |
TIter next2(contents); |
TIter next2(contents); |
958 |
TChain *questa = 0; |
TChain *questa = 0; |
959 |
while (questa = (TChain*) next2()) { |
while ( (questa = (TChain*) next2()) ) { |
960 |
TString name = questa->GetName(); |
TString name = questa->GetName(); |
961 |
questa->Delete(); |
questa->Delete(); |
962 |
questa = NULL; |
questa = NULL; |
987 |
trkh_obj = 0; |
trkh_obj = 0; |
988 |
calo1_obj = 0; |
calo1_obj = 0; |
989 |
calo2_obj = 0; |
calo2_obj = 0; |
990 |
tof_obj = 0; |
tof2_obj = 0; |
991 |
trig_obj = 0; |
trig_obj = 0; |
992 |
s4_obj = 0; |
s4_obj = 0; |
993 |
nd_obj = 0; |
nd_obj = 0; |
994 |
ac_obj = 0; |
ac_obj = 0; |
995 |
orb_obj = 0; |
orb2_obj = 0; |
996 |
gp_obj = 0; |
gp_obj = 0; |
997 |
|
proc_obj = 0; |
998 |
|
|
999 |
|
trk_ext_obj = 0; |
1000 |
|
trk_ext_nuc_obj = 0; |
1001 |
|
trk_nuc_obj = 0; |
1002 |
|
|
1003 |
|
calo_ext_obj = 0; |
1004 |
|
calo_ext_nuc_obj = 0; |
1005 |
|
calo_nuc_obj = 0; |
1006 |
|
|
1007 |
|
tof_ext_obj = 0; |
1008 |
|
tof_ext_nuc_obj = 0; |
1009 |
|
tof_nuc_obj = 0; |
1010 |
|
|
1011 |
|
orb_ext_obj = 0; |
1012 |
|
orb_ext_nuc_obj = 0; |
1013 |
|
orb_nuc_obj = 0; |
1014 |
|
|
1015 |
|
trk2_nuc_obj = 0; |
1016 |
|
calo2_nuc_obj = 0; |
1017 |
|
tof2_nuc_obj = 0; |
1018 |
|
orb2_nuc_obj = 0; |
1019 |
|
|
1020 |
|
trk2_nuc_obj = 0; |
1021 |
|
calo2_nuc_obj = 0; |
1022 |
|
tof2_nuc_obj = 0; |
1023 |
|
orb2_nuc_obj = 0; |
1024 |
// |
// |
1025 |
// Reset run pointers |
// Reset run pointers |
1026 |
// |
// |
1027 |
run_obj = 0;//new GL_RUN(); |
run_obj = 0;//new GL_RUN(); |
1028 |
soft_obj = 0;// Emiliano |
soft_obj = 0;// Emiliano |
1029 |
|
proc_obj = 0;// Emiliano |
1030 |
irun = -1; |
irun = -1; |
1031 |
irunt = -1; |
irunt = -1; |
1032 |
|
totrunentry = 0LL; |
1033 |
|
totrunentrymax = 0LL; |
1034 |
|
totrunentrymin = 0LL; |
1035 |
runfirstentry = 0ULL; |
runfirstentry = 0ULL; |
1036 |
runlastentry = 0ULL; |
runlastentry = 0ULL; |
1037 |
|
prevabstime = 0ULL; |
1038 |
|
prevpktnum = 0; |
1039 |
|
abstime = 0ULL; |
1040 |
|
pktnum = 0; |
1041 |
|
isFragment = false; |
1042 |
// |
// |
1043 |
totdltime[0] = 0LL; |
totdltime[0] = 0LL; |
1044 |
totdltime[1] = 0LL; |
totdltime[1] = 0LL; |
1056 |
if (strict) { |
if (strict) { |
1057 |
if (trk2_obj && trk2_obj->UnpackError() != 0) |
if (trk2_obj && trk2_obj->UnpackError() != 0) |
1058 |
goodev = false; |
goodev = false; |
1059 |
if (tof_obj && tof_obj->unpackError != 0) |
if (tof2_obj && tof2_obj->unpackError != 0) |
1060 |
goodev = false; |
goodev = false; |
1061 |
if (trig_obj && trig_obj->unpackError != 0) |
if (trig_obj && trig_obj->unpackError != 0) |
1062 |
goodev = false; |
goodev = false; |
1066 |
goodev = false; |
goodev = false; |
1067 |
if (ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0] >> 2) & 1) || ((ac_obj->status[1] >> 2) & 1))) |
if (ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0] >> 2) & 1) || ((ac_obj->status[1] >> 2) & 1))) |
1068 |
goodev = false; |
goodev = false; |
1069 |
// if(orb_obj) |
// if(orb2_obj) |
1070 |
} |
} |
1071 |
else { |
else { |
1072 |
if (nd_obj && nd_obj->unpackError != 0) |
if (nd_obj && nd_obj->unpackError != 0) |
1078 |
} |
} |
1079 |
; |
; |
1080 |
|
|
1081 |
|
void PamLevel2::SkipRunInfoUpdate(){ |
1082 |
|
printf("\n\n ******** WARNING ******** \n Skip DB connections, DO NOT USE PamLevel2::GetRunInfo() method! \n\n"); |
1083 |
|
fUpdateRunInfo = false; |
1084 |
|
this->SetSELLI(2); |
1085 |
|
printf(" ===============> W A R N I N G <================ \n"); |
1086 |
|
printf(" in case PamLevel2::CreateCloneTrees() will be called \n"); |
1087 |
|
printf(" it will be reverted to PadmeAmidala level2 structure , i.e. NO SELECTIONLIST WILL BE CREATED IN THE NEW LEVEL2 FILE! \n\n"); |
1088 |
|
if ( run_tree_clone ){ |
1089 |
|
printf(" ===============> W A R N I N G <================ \n"); |
1090 |
|
printf(" PamLevel2::SkipRunIndoUpdate or PamLevel2::NoDBconnections() has been called together with PamLevel2::CreateCloneTrees() \n"); |
1091 |
|
printf(" TO AVOID CRASHES call PamLevel2::CreateCloneTrees() after PamLevel2::SkipRunIndoUpdate or PamLevel2::NoDBconnections() \n"); |
1092 |
|
}; |
1093 |
|
} |
1094 |
|
|
1095 |
|
void PamLevel2::SetMaxShift(Int_t sh){ |
1096 |
|
if ( sh >= 0 ){ |
1097 |
|
printf("PamLevel2::SetMaxShift(Int_t) --WARNING-- the default is optimized by checking the level2 file\n it is strongly suggested to let PamLevel2 choose the max shift!\n"); |
1098 |
|
maxshift = sh; |
1099 |
|
} else { |
1100 |
|
ULong64_t nev = GetEntries(); |
1101 |
|
ULong64_t runnev = 0ULL; |
1102 |
|
for (Int_t r=0; r< run_tree->GetEntries();r++){ |
1103 |
|
run_tree->GetEntry(r);//update runinfo |
1104 |
|
runnev += GetRunInfo()->NEVENTS; |
1105 |
|
} |
1106 |
|
maxshift = (Int_t)(runnev-nev) + 10; // +10 just to be conservative |
1107 |
|
if ( (runnev-nev) == 0 ) isSync = true; |
1108 |
|
if (DBG) printf("PamLevel2::SetMaxShift(Int_t_) - sh negative %i - nev is %lld runnnev is %lld so maxshift set to %i \n",sh,nev,runnev,maxshift); |
1109 |
|
// printf("PamLevel2::SetMaxShift(Int_t_) - sh negative %i - nev is %lld runnnev is %lld so maxshift set to %i \n",sh,nev,runnev,maxshift); // TOGLITOGLI |
1110 |
|
} |
1111 |
|
} |
1112 |
|
|
1113 |
//-------------------------------------- |
//-------------------------------------- |
1114 |
// |
// |
1115 |
// |
// |
1152 |
return &calo2_obj; |
return &calo2_obj; |
1153 |
}; |
}; |
1154 |
if (!objname.CompareTo("ToFLevel2")) { |
if (!objname.CompareTo("ToFLevel2")) { |
1155 |
if (!tof_obj) { |
if (!tof2_obj) { |
1156 |
tof_obj = new ToFLevel2(); |
tof2_obj = new ToFLevel2(); |
1157 |
tof_obj->Set(); |
tof2_obj->Set(); |
1158 |
} |
} |
1159 |
return &tof_obj; |
return &tof2_obj; |
1160 |
}; |
}; |
1161 |
if (!objname.CompareTo("TrigLevel2")) { |
if (!objname.CompareTo("TrigLevel2")) { |
1162 |
if (!trig_obj) |
if (!trig_obj) |
1179 |
return &ac_obj; |
return &ac_obj; |
1180 |
}; |
}; |
1181 |
if (!objname.CompareTo("OrbitalInfo")) { |
if (!objname.CompareTo("OrbitalInfo")) { |
1182 |
if (!orb_obj) { |
if (!orb2_obj) { |
1183 |
orb_obj = new OrbitalInfo(); |
orb2_obj = new OrbitalInfo(); |
1184 |
orb_obj->Set(); |
orb2_obj->Set(); |
1185 |
} |
} |
1186 |
return &orb_obj; |
return &orb2_obj; |
1187 |
}; |
}; |
1188 |
// if(!objname.CompareTo("OrbitalInfo")){ |
// if(!objname.CompareTo("OrbitalInfo")){ |
1189 |
// if(!orb_obj) orb_obj = new OrbitalInfo(); |
// if(!orb2_obj) orb2_obj = new OrbitalInfo(); |
1190 |
// return &orb_obj; |
// return &orb2_obj; |
1191 |
// }; |
// }; |
1192 |
if (!objname.CompareTo("GPamela")) { |
if (!objname.CompareTo("GPamela")) { |
1193 |
if (!gp_obj) |
if (!gp_obj) |
1201 |
if (!objname.CompareTo("SoftInfo")) |
if (!objname.CompareTo("SoftInfo")) |
1202 |
return &soft_obj; // Emiliano |
return &soft_obj; // Emiliano |
1203 |
|
|
1204 |
|
if (!objname.CompareTo("ProcInfo")){ |
1205 |
|
if (!proc_obj) |
1206 |
|
proc_obj = new ProcInfo(); |
1207 |
|
return &proc_obj; // Emiliano |
1208 |
|
} |
1209 |
|
|
1210 |
return NULL; |
return NULL; |
1211 |
} |
} |
1212 |
; |
; |
1257 |
*/ |
*/ |
1258 |
ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno) { |
ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno) { |
1259 |
|
|
1260 |
if (!tof_obj) |
if (!tof2_obj) |
1261 |
return 0; |
return 0; |
1262 |
|
|
1263 |
if (tof_obj->ToFLevel2::ntrk() == 0) { |
if (tof2_obj->ToFLevel2::ntrk() == 0) { |
1264 |
cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo " << seqno << " but no ToF tracks are stored" |
cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo " << seqno << " but no ToF tracks are stored" |
1265 |
<< endl; |
<< endl; |
1266 |
return NULL; |
return NULL; |
1270 |
Int_t it_tof = 0; |
Int_t it_tof = 0; |
1271 |
|
|
1272 |
do { |
do { |
1273 |
c = tof_obj->ToFLevel2::GetToFTrkVar(it_tof); |
c = tof2_obj->ToFLevel2::GetToFTrkVar(it_tof); |
1274 |
it_tof++; |
it_tof++; |
1275 |
} while (c && seqno != c->trkseqno && it_tof < tof_obj->ToFLevel2::ntrk()); |
} while (c && seqno != c->trkseqno && it_tof < tof2_obj->ToFLevel2::ntrk()); |
1276 |
|
|
1277 |
if (!c || seqno != c->trkseqno) { |
if (!c || seqno != c->trkseqno) { |
1278 |
c = 0; |
c = 0; |
1295 |
*/ |
*/ |
1296 |
OrbitalInfoTrkVar *PamLevel2::GetOrbitalInfoStoredTrack(int seqno) { |
OrbitalInfoTrkVar *PamLevel2::GetOrbitalInfoStoredTrack(int seqno) { |
1297 |
|
|
1298 |
if (!orb_obj) |
if (!orb2_obj) |
1299 |
return 0; |
return 0; |
1300 |
|
|
1301 |
if (orb_obj->OrbitalInfo::ntrk() == 0) { |
if (orb2_obj->OrbitalInfo::ntrk() == 0) { |
1302 |
// // TRICK BEGIN |
// // TRICK BEGIN |
1303 |
// OrbitalInfoTrkVar *r = new OrbitalInfoTrkVar(); // TEMPORARY TRICK |
// OrbitalInfoTrkVar *r = new OrbitalInfoTrkVar(); // TEMPORARY TRICK |
1304 |
// Int_t nn = 0; |
// Int_t nn = 0; |
1305 |
// TClonesArray &tor = *orb_obj->OrbitalInfoTrk; |
// TClonesArray &tor = *orb2_obj->OrbitalInfoTrk; |
1306 |
// for(Int_t nt=0; nt < tof_obj->ToFLevel2::ntrk(); nt++){ |
// for(Int_t nt=0; nt < tof2_obj->ToFLevel2::ntrk(); nt++){ |
1307 |
// // |
// // |
1308 |
// ToFTrkVar *ptt = tof_obj->ToFLevel2::GetToFTrkVar(nt); |
// ToFTrkVar *ptt = tof2_obj->ToFLevel2::GetToFTrkVar(nt); |
1309 |
// if ( ptt->trkseqno != -1 ){ |
// if ( ptt->trkseqno != -1 ){ |
1310 |
// // |
// // |
1311 |
// r->trkseqno = ptt->trkseqno; |
// r->trkseqno = ptt->trkseqno; |
1327 |
// }; |
// }; |
1328 |
// delete r; |
// delete r; |
1329 |
// OrbitalInfoTrkVar *c = 0; |
// OrbitalInfoTrkVar *c = 0; |
1330 |
// c = orb_obj->OrbitalInfo::GetOrbitalInfoTrkVar(0); |
// c = orb2_obj->OrbitalInfo::GetOrbitalInfoTrkVar(0); |
1331 |
// return c; |
// return c; |
1332 |
// //TRICK END |
// //TRICK END |
1333 |
cout << "PamLevel2::GetOrbitalInfoStoredTrack(int) : requested tracker SeqNo " << seqno |
cout << "PamLevel2::GetOrbitalInfoStoredTrack(int) : requested tracker SeqNo " << seqno |
1339 |
Int_t it_tof = 0; |
Int_t it_tof = 0; |
1340 |
|
|
1341 |
do { |
do { |
1342 |
c = orb_obj->OrbitalInfo::GetOrbitalInfoTrkVar(it_tof); |
c = orb2_obj->OrbitalInfo::GetOrbitalInfoTrkVar(it_tof); |
1343 |
it_tof++; |
it_tof++; |
1344 |
} while (c && seqno != c->trkseqno && it_tof < orb_obj->OrbitalInfo::ntrk()); |
} while (c && seqno != c->trkseqno && it_tof < orb2_obj->OrbitalInfo::ntrk()); |
1345 |
|
|
1346 |
if (!c || seqno != c->trkseqno) { |
if (!c || seqno != c->trkseqno) { |
1347 |
c = 0; |
c = 0; |
1472 |
// create TCloneArrays to store tracks and its images |
// create TCloneArrays to store tracks and its images |
1473 |
if (!tsorted) |
if (!tsorted) |
1474 |
tsorted = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); |
tsorted = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); |
1475 |
tsorted->Delete(); |
tsorted->Clear("C+C");//Delete(); |
1476 |
TClonesArray &ttsorted = *tsorted; |
TClonesArray &ttsorted = *tsorted; |
1477 |
|
|
1478 |
if (!timage) |
if (!timage) |
1479 |
timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); |
timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); |
1480 |
timage->Delete(); |
timage->Clear("C+C");//Delete(); |
1481 |
TClonesArray &ttimage = *timage; |
TClonesArray &ttimage = *timage; |
1482 |
|
|
1483 |
|
|
1484 |
|
|
1485 |
//-------------------------------------------------- |
//-------------------------------------------------- |
1486 |
// retrieve sorting method |
// retrieve sorting method |
1487 |
//-------------------------------------------------- |
//-------------------------------------------------- |
1597 |
// ----------------------------------------------------------------------------------------- |
// ----------------------------------------------------------------------------------------- |
1598 |
// check the number of hit pmts along the track |
// check the number of hit pmts along the track |
1599 |
// on S12 S21 and S32, where paddles are parallel to Y axis |
// on S12 S21 and S32, where paddles are parallel to Y axis |
1600 |
if ((use_TOF || use_S1 || use_S2 || use_S3) && !tof_obj) { |
if ((use_TOF || use_S1 || use_S2 || use_S3) && !tof2_obj) { |
1601 |
cout << "void PamLevel2::SortTracks(): howtosort= " << how << " but ToFLevel2 not loaded !!!"; |
cout << "void PamLevel2::SortTracks(): howtosort= " << how << " but ToFLevel2 not loaded !!!"; |
1602 |
return; |
return; |
1603 |
}; |
}; |
1614 |
// |
// |
1615 |
Float_t sen = 0.; |
Float_t sen = 0.; |
1616 |
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
1617 |
Int_t pl = tof_obj->GetPlaneIndex((op->pmtadc).At(ih)); |
Int_t pl = tof2_obj->GetPlaneIndex((op->pmtadc).At(ih)); |
1618 |
if (pl == 2 || pl == 3 || pl == 4 || pl == 5) |
if (pl == 2 || pl == 3 || pl == 4 || pl == 5) |
1619 |
sen += (op->dedx).At(ih); |
sen += (op->dedx).At(ih); |
1620 |
}; |
}; |
1621 |
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
1622 |
Int_t pl = tof_obj->GetPlaneIndex((oi->pmtadc).At(ih)); |
Int_t pl = tof2_obj->GetPlaneIndex((oi->pmtadc).At(ih)); |
1623 |
if (pl == 2 || pl == 3 || pl == 4 || pl == 5) |
if (pl == 2 || pl == 3 || pl == 4 || pl == 5) |
1624 |
sen += (oi->dedx).At(ih); |
sen += (oi->dedx).At(ih); |
1625 |
}; |
}; |
1632 |
Int_t nz = 6; |
Int_t nz = 6; |
1633 |
Float_t zin[6]; // << define TOF z-coordinates |
Float_t zin[6]; // << define TOF z-coordinates |
1634 |
for (Int_t ip = 0; ip < nz; ip++) |
for (Int_t ip = 0; ip < nz; ip++) |
1635 |
zin[ip] = tof_obj->ToFLevel2::GetZTOF(tof_obj->ToFLevel2::GetToFPlaneID(ip)); // << read ToF plane z-coordinates |
zin[ip] = tof2_obj->ToFLevel2::GetZTOF(tof2_obj->ToFLevel2::GetToFPlaneID(ip)); // << read ToF plane z-coordinates |
1636 |
Trajectory *tr = new Trajectory(nz, zin); |
Trajectory *tr = new Trajectory(nz, zin); |
1637 |
// |
// |
1638 |
Int_t nphit_p = 0; |
Int_t nphit_p = 0; |
1641 |
Float_t enhit_i = 0.; |
Float_t enhit_i = 0.; |
1642 |
// |
// |
1643 |
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
1644 |
Int_t pl = tof_obj->GetPlaneIndex((op->pmtadc).At(ih)); |
Int_t pl = tof2_obj->GetPlaneIndex((op->pmtadc).At(ih)); |
1645 |
if (pl == 1 || pl == 2 || pl == 5) { |
if (pl == 1 || pl == 2 || pl == 5) { |
1646 |
nphit_p++; |
nphit_p++; |
1647 |
enhit_p += (op->dedx).At(ih); |
enhit_p += (op->dedx).At(ih); |
1652 |
// |
// |
1653 |
if (fabs(tr->y[0] - oi->ytofpos[0]) < 2.) { |
if (fabs(tr->y[0] - oi->ytofpos[0]) < 2.) { |
1654 |
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
1655 |
Int_t pl = tof_obj->GetPlaneIndex((op->pmtadc).At(ih)); |
Int_t pl = tof2_obj->GetPlaneIndex((op->pmtadc).At(ih)); |
1656 |
if (pl == 0) { |
if (pl == 0) { |
1657 |
nphit_p++; |
nphit_p++; |
1658 |
enhit_p += (op->dedx).At(ih); |
enhit_p += (op->dedx).At(ih); |
1661 |
}; |
}; |
1662 |
if (fabs(tr->y[3] - oi->ytofpos[1]) < 2.) { |
if (fabs(tr->y[3] - oi->ytofpos[1]) < 2.) { |
1663 |
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
1664 |
Int_t pl = tof_obj->GetPlaneIndex((op->pmtadc).At(ih)); |
Int_t pl = tof2_obj->GetPlaneIndex((op->pmtadc).At(ih)); |
1665 |
if (pl == 3) { |
if (pl == 3) { |
1666 |
nphit_p++; |
nphit_p++; |
1667 |
enhit_p += (op->dedx).At(ih); |
enhit_p += (op->dedx).At(ih); |
1670 |
}; |
}; |
1671 |
if (fabs(tr->y[4] - oi->ytofpos[2]) < 2.) { |
if (fabs(tr->y[4] - oi->ytofpos[2]) < 2.) { |
1672 |
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
1673 |
Int_t pl = tof_obj->GetPlaneIndex((op->pmtadc).At(ih)); |
Int_t pl = tof2_obj->GetPlaneIndex((op->pmtadc).At(ih)); |
1674 |
if (pl == 4) { |
if (pl == 4) { |
1675 |
nphit_p++; |
nphit_p++; |
1676 |
enhit_p += (op->dedx).At(ih); |
enhit_p += (op->dedx).At(ih); |
1679 |
}; |
}; |
1680 |
|
|
1681 |
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
1682 |
Int_t pl = tof_obj->GetPlaneIndex((oi->pmtadc).At(ih)); |
Int_t pl = tof2_obj->GetPlaneIndex((oi->pmtadc).At(ih)); |
1683 |
if (pl == 1 || pl == 2 || pl == 5) { |
if (pl == 1 || pl == 2 || pl == 5) { |
1684 |
nphit_i++; |
nphit_i++; |
1685 |
enhit_i += (op->dedx).At(ih); |
enhit_i += (op->dedx).At(ih); |
1690 |
// |
// |
1691 |
if (fabs(tr->y[0] - oi->ytofpos[0]) < 2.) { |
if (fabs(tr->y[0] - oi->ytofpos[0]) < 2.) { |
1692 |
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
1693 |
Int_t pl = tof_obj->GetPlaneIndex((oi->pmtadc).At(ih)); |
Int_t pl = tof2_obj->GetPlaneIndex((oi->pmtadc).At(ih)); |
1694 |
if (pl == 0) { |
if (pl == 0) { |
1695 |
nphit_i++; |
nphit_i++; |
1696 |
enhit_i += (op->dedx).At(ih); |
enhit_i += (op->dedx).At(ih); |
1699 |
}; |
}; |
1700 |
if (fabs(tr->y[3] - oi->ytofpos[1]) < 2.) { |
if (fabs(tr->y[3] - oi->ytofpos[1]) < 2.) { |
1701 |
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
1702 |
Int_t pl = tof_obj->GetPlaneIndex((oi->pmtadc).At(ih)); |
Int_t pl = tof2_obj->GetPlaneIndex((oi->pmtadc).At(ih)); |
1703 |
if (pl == 3) { |
if (pl == 3) { |
1704 |
nphit_i++; |
nphit_i++; |
1705 |
enhit_i += (op->dedx).At(ih); |
enhit_i += (op->dedx).At(ih); |
1708 |
}; |
}; |
1709 |
if (fabs(tr->y[4] - oi->ytofpos[2]) < 2.) { |
if (fabs(tr->y[4] - oi->ytofpos[2]) < 2.) { |
1710 |
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
1711 |
Int_t pl = tof_obj->GetPlaneIndex((oi->pmtadc).At(ih)); |
Int_t pl = tof2_obj->GetPlaneIndex((oi->pmtadc).At(ih)); |
1712 |
if (pl == 4) { |
if (pl == 4) { |
1713 |
nphit_i++; |
nphit_i++; |
1714 |
enhit_i += (op->dedx).At(ih); |
enhit_i += (op->dedx).At(ih); |
1752 |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
1753 |
|
|
1754 |
// for (Int_t ih=0; ih < op->npmtadc; ih++){ |
// for (Int_t ih=0; ih < op->npmtadc; ih++){ |
1755 |
// Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
// Int_t pl = tof2_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
1756 |
// if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
// if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
1757 |
// }; |
// }; |
1758 |
|
|
1759 |
// for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
// for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
1760 |
// Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
// Int_t pl = tof2_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
1761 |
// if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
// if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
1762 |
// }; |
// }; |
1763 |
// --- modified to count tdc signals (more efficient?) |
// --- modified to count tdc signals (more efficient?) |
1764 |
// --- and to implement check on tdcflag |
// --- and to implement check on tdcflag |
1765 |
for (Int_t ih = 0; ih < op->npmttdc; ih++) { |
for (Int_t ih = 0; ih < op->npmttdc; ih++) { |
1766 |
Int_t pl = tof_obj->GetPlaneIndex((op->pmttdc).At(ih)); |
Int_t pl = tof2_obj->GetPlaneIndex((op->pmttdc).At(ih)); |
1767 |
// if( (op->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_p++; |
// if( (op->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_p++; |
1768 |
if ((use_S1 && (pl == 0 || pl == 1)) || (use_S2 && (pl == 2 || pl == 3)) |
if ((use_S1 && (pl == 0 || pl == 1)) || (use_S2 && (pl == 2 || pl == 3)) |
1769 |
|| (use_S3 && (pl == 4 || pl == 5))) { |
|| (use_S3 && (pl == 4 || pl == 5))) { |
1773 |
}; |
}; |
1774 |
|
|
1775 |
for (Int_t ih = 0; ih < oi->npmttdc; ih++) { |
for (Int_t ih = 0; ih < oi->npmttdc; ih++) { |
1776 |
Int_t pl = tof_obj->GetPlaneIndex((oi->pmttdc).At(ih)); |
Int_t pl = tof2_obj->GetPlaneIndex((oi->pmttdc).At(ih)); |
1777 |
// if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++; |
// if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++; |
1778 |
if ((use_S1 && (pl == 0 || pl == 1)) || (use_S2 && (pl == 2 || pl == 3)) |
if ((use_S1 && (pl == 0 || pl == 1)) || (use_S2 && (pl == 2 || pl == 3)) |
1779 |
|| (use_S3 && (pl == 4 || pl == 5))) { |
|| (use_S3 && (pl == 4 || pl == 5))) { |
1948 |
|
|
1949 |
} |
} |
1950 |
; |
; |
1951 |
|
// |
1952 |
|
//-------------------------------------- |
1953 |
|
/** |
1954 |
|
* Sort physical (tracker) tracks. |
1955 |
|
* @param how String to set the sorting cryterium (es: "CAL" or "TRK+CAL+TOF" ecc...). |
1956 |
|
* Sorting cryteria: |
1957 |
|
* TRK: lower chi**2 |
1958 |
|
* CAL: lower Y spatial residual on the first calorimeter plane |
1959 |
|
* TOF: bigger numebr of hit PMTs along the track, on S12 S21 S32 (where paddles are along the Y axis). |
1960 |
|
* S1: (ask Emiliano) |
1961 |
|
* S2: (ask Emiliano) |
1962 |
|
* S3: (ask Emiliano) |
1963 |
|
* GP: more GP hits |
1964 |
|
* The default sorting cryterium is "TOF+CAL". |
1965 |
|
* |
1966 |
|
* The total number of physical tracks is always given by GetNTracks() and the it-th physical track can be retrieved by means of the methods GetTrack(int it) and GetTrack(int it, TString how). |
1967 |
|
* |
1968 |
|
* New version, with handling of extended tracks and nuclei tracks. |
1969 |
|
*/ |
1970 |
|
void PamLevel2::SortTracksNew() { |
1971 |
|
|
1972 |
|
//-------------------------------------------------- |
1973 |
|
//Check if the current event has already been sorted |
1974 |
|
//-------------------------------------------------- |
1975 |
|
if (issorted_new && lastsorted_new == GetReadEntry()) { |
1976 |
|
return; //already done for this event |
1977 |
|
} |
1978 |
|
|
1979 |
|
|
1980 |
|
// cout << "SORT" << endl; |
1981 |
|
|
1982 |
|
//Reset the sort flags, just in case something will go wrong... |
1983 |
|
issorted_new = false; |
1984 |
|
lastsorted_new = -1; |
1985 |
|
|
1986 |
|
//-------------------------------------------------- |
1987 |
|
// set input variables |
1988 |
|
//-------------------------------------------------- |
1989 |
|
|
1990 |
|
TString how = howtosort; |
1991 |
|
//Save current Object count |
1992 |
|
Int_t ObjectNumber = TProcessID::GetObjectCount(); |
1993 |
|
|
1994 |
|
|
1995 |
|
|
1996 |
|
|
1997 |
|
TrkLevel2 * trk2 ; |
1998 |
|
CaloLevel2 * calo2; |
1999 |
|
ToFLevel2 * tof2 ; |
2000 |
|
OrbitalInfo * orb2 ; |
2001 |
|
|
2002 |
|
TClonesArray * trkext ; |
2003 |
|
TClonesArray * caloext; |
2004 |
|
TClonesArray * tofext ; |
2005 |
|
TClonesArray * orbext ; |
2006 |
|
|
2007 |
|
|
2008 |
|
// cout << "trk2_obj" << trk2_obj<< endl; |
2009 |
|
// cout << "trk2_nuc_obj" << trk2_nuc_obj<< endl; |
2010 |
|
// cout << " trk_ext_obj "<<trk_ext_obj<< endl; |
2011 |
|
// cout << " trk_ext_nuc_obj "<<trk_ext_nuc_obj<< endl; |
2012 |
|
|
2013 |
|
//----------------------------------------------------------- |
2014 |
|
// create/reset TCloneArrays to store tracks and their images |
2015 |
|
//----------------------------------------------------------- |
2016 |
|
|
2017 |
|
// cout << " PamLevel2::SortTracksNew() --- Clear TClonesArray objects"<<endl; |
2018 |
|
|
2019 |
|
// main tracks from standard alg |
2020 |
|
// if (!tsorted) |
2021 |
|
// tsorted = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); |
2022 |
|
// tsorted->Clear("C+C");//Delete(); |
2023 |
|
// // track images from standard alg |
2024 |
|
// if (!timage) |
2025 |
|
// timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); |
2026 |
|
// timage->Clear("C+C");//Delete(); |
2027 |
|
// // tracks from extended algorythm |
2028 |
|
// if(EXT && !text) |
2029 |
|
// text = new TClonesArray("PamTrack",trk_ext_obj->GetEntries()); |
2030 |
|
// if(text)text->Clear("C+C");//Delete(); |
2031 |
|
|
2032 |
|
if(tsorted)delete tsorted; |
2033 |
|
if(timage) delete timage; |
2034 |
|
if(text) delete text; |
2035 |
|
tsorted = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); |
2036 |
|
timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); |
2037 |
|
text = new TClonesArray("PamTrack",trk_ext_obj->GetEntries()); |
2038 |
|
|
2039 |
|
//----------------------------------------------------------- |
2040 |
|
// create/reset TCloneArrays to store tracks and their images |
2041 |
|
//----------------------------------------------------------- |
2042 |
|
if(NUC){ |
2043 |
|
|
2044 |
|
|
2045 |
|
if(tsorted_nuc)delete tsorted_nuc; |
2046 |
|
if(timage_nuc) delete timage_nuc; |
2047 |
|
if(text_nuc) delete text_nuc; |
2048 |
|
tsorted_nuc = new TClonesArray("PamTrack", trk2_nuc_obj->GetNTracks()); |
2049 |
|
timage_nuc = new TClonesArray("PamTrack", trk2_nuc_obj->GetNTracks()); |
2050 |
|
text_nuc = new TClonesArray("PamTrack",trk_ext_nuc_obj->GetEntries()); |
2051 |
|
|
2052 |
|
// main tracks from standard alg |
2053 |
|
// if (!tsorted_nuc) |
2054 |
|
// tsorted_nuc = new TClonesArray("PamTrack", trk2_nuc_obj->GetNTracks()); |
2055 |
|
// tsorted_nuc->Clear("C+C");//Delete(); |
2056 |
|
// // track images from standard alg |
2057 |
|
// if (!timage_nuc) |
2058 |
|
// timage_nuc = new TClonesArray("PamTrack", trk2_nuc_obj->GetNTracks()); |
2059 |
|
// timage_nuc->Clear("C+C");//Delete(); |
2060 |
|
// // tracks from extended algorythm |
2061 |
|
// if(EXT && !text_nuc) |
2062 |
|
// text_nuc = new TClonesArray("PamTrack",trk_ext_nuc_obj->GetEntries()); |
2063 |
|
// if(text_nuc)text_nuc->Clear("C+C");//Delete(); |
2064 |
|
|
2065 |
|
} |
2066 |
|
//-------------------------------------------------- |
2067 |
|
// retrieve sorting method |
2068 |
|
//-------------------------------------------------- |
2069 |
|
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
2070 |
|
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
2071 |
|
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
2072 |
|
Bool_t use_S1 = how.Contains("S1", TString::kIgnoreCase); |
2073 |
|
Bool_t use_S2 = how.Contains("S2", TString::kIgnoreCase); |
2074 |
|
Bool_t use_S3 = how.Contains("S3", TString::kIgnoreCase); |
2075 |
|
Bool_t use_GP = how.Contains("GP", TString::kIgnoreCase); |
2076 |
|
|
2077 |
|
if (use_TOF) { |
2078 |
|
use_S1 = true; |
2079 |
|
use_S2 = true; |
2080 |
|
use_S3 = true; |
2081 |
|
}; |
2082 |
|
if (!CAL2 && use_CAL) |
2083 |
|
use_CAL = false; |
2084 |
|
if (!TOF) { |
2085 |
|
use_TOF = false; |
2086 |
|
use_S1 = false; |
2087 |
|
use_S2 = false; |
2088 |
|
use_S3 = false; |
2089 |
|
} |
2090 |
|
if (!GP) { |
2091 |
|
use_GP = false; |
2092 |
|
} |
2093 |
|
|
2094 |
|
if (!TRK2) { |
2095 |
|
cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl; |
2096 |
|
return; |
2097 |
|
}; |
2098 |
|
|
2099 |
|
|
2100 |
|
/////////////////////////////////////////////////////////////////////////////////// |
2101 |
|
// |
2102 |
|
// sort tracks and fill PamTrack arrays |
2103 |
|
// |
2104 |
|
/////////////////////////////////////////////////////////////////////////////////// |
2105 |
|
for(int doit=0; doit<2; doit++){ |
2106 |
|
|
2107 |
|
// cout << "doit "<<doit<<endl; |
2108 |
|
|
2109 |
|
|
2110 |
|
if(doit == 0){ |
2111 |
|
|
2112 |
|
trk2 = trk2_obj; |
2113 |
|
calo2 = calo2_obj; |
2114 |
|
tof2 = tof2_obj; |
2115 |
|
orb2 = orb2_obj; |
2116 |
|
|
2117 |
|
trkext = trk_ext_obj; |
2118 |
|
caloext = calo_ext_obj; |
2119 |
|
tofext = tof_ext_obj; |
2120 |
|
orbext = orb_ext_obj; |
2121 |
|
|
2122 |
|
|
2123 |
|
|
2124 |
|
|
2125 |
|
|
2126 |
|
}else if (doit == 1){ |
2127 |
|
|
2128 |
|
if(!NUC)break; |
2129 |
|
|
2130 |
|
|
2131 |
|
trk2 = trk2_nuc_obj; |
2132 |
|
calo2 = calo2_nuc_obj; |
2133 |
|
tof2 = tof2_nuc_obj; |
2134 |
|
orb2 = orb2_nuc_obj; |
2135 |
|
|
2136 |
|
trkext = trk_ext_nuc_obj; |
2137 |
|
caloext = calo_ext_nuc_obj; |
2138 |
|
tofext = tof_ext_nuc_obj; |
2139 |
|
orbext = orb_ext_nuc_obj; |
2140 |
|
|
2141 |
|
|
2142 |
|
|
2143 |
|
|
2144 |
|
} |
2145 |
|
|
2146 |
|
// cout << "trk2" << trk2<<endl; |
2147 |
|
// cout << "calo2" << calo2<<endl; |
2148 |
|
// cout << "tof2" << tof2<<endl; |
2149 |
|
// cout << "orb2" << orb2<<endl; |
2150 |
|
// cout << "trkext" <<trkext <<endl; |
2151 |
|
// cout << "tofext" << tofext<<endl; |
2152 |
|
// cout << "caloext" << caloext<<endl; |
2153 |
|
// cout << "orbext" << orbext<<endl; |
2154 |
|
|
2155 |
|
TClonesArray &ttext = (doit==0 ? *text : *text_nuc); |
2156 |
|
TClonesArray &ttimage = (doit==0 ? *timage : *timage_nuc); |
2157 |
|
TClonesArray &ttsorted = (doit==0 ? *tsorted : *tsorted_nuc); |
2158 |
|
|
2159 |
|
// cout << "tsorted + timage "<<doit<<endl; |
2160 |
|
|
2161 |
|
//-------------------------------------------------- |
2162 |
|
// loop over "physical" tracks sorted by the tracker |
2163 |
|
//-------------------------------------------------- |
2164 |
|
for (Int_t i = 0; i < trk2->TrkLevel2::GetNTracks(); i++) { |
2165 |
|
|
2166 |
|
TrkTrack *ts = 0; |
2167 |
|
CaloTrkVar *cs = 0; |
2168 |
|
ToFTrkVar *os = 0; |
2169 |
|
OrbitalInfoTrkVar *rs = 0; |
2170 |
|
|
2171 |
|
// get tracker tracks |
2172 |
|
TrkTrack *tp = trk2->GetTrack(i); //tracker |
2173 |
|
CaloTrkVar *cp = calo2->GetCaloStoredTrack(tp->GetSeqNo()); |
2174 |
|
ToFTrkVar *op = tof2->GetToFStoredTrack(tp->GetSeqNo()); |
2175 |
|
OrbitalInfoTrkVar *rp = orb2->GetOrbitalInfoStoredTrack(tp->GetSeqNo()); |
2176 |
|
|
2177 |
|
TrkTrack *ti = 0; //tracker (image) |
2178 |
|
CaloTrkVar *ci = 0; |
2179 |
|
ToFTrkVar *oi = 0; |
2180 |
|
OrbitalInfoTrkVar *ri = 0; |
2181 |
|
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
2182 |
|
// if track has an image, check image selection |
2183 |
|
|
2184 |
|
Int_t tp_score = 0; //main track sorted by the tracker |
2185 |
|
Int_t ti_score = 0; //image track |
2186 |
|
Int_t totp_score = 0; //main track sorted by the tracker |
2187 |
|
Int_t toti_score = 0; //image track |
2188 |
|
|
2189 |
|
if (tp->HasImage()) { |
2190 |
|
|
2191 |
|
ti = trk2->GetTrackImage(i); //tracker (image) |
2192 |
|
ci = calo2->GetCaloStoredTrack(ti->GetSeqNo()); |
2193 |
|
oi = tof2->GetToFStoredTrack(ti->GetSeqNo()); |
2194 |
|
ri = orb2->GetOrbitalInfoStoredTrack(ti->GetSeqNo()); |
2195 |
|
|
2196 |
|
// cout << "its image "<<i << " "<<hex<< ti <<dec<< endl; |
2197 |
|
|
2198 |
|
//assign starting scores |
2199 |
|
tp_score = 0; //main track sorted by the tracker |
2200 |
|
ti_score = 0; //image track |
2201 |
|
|
2202 |
|
// ----------------------------------------------------------------------------------------- |
2203 |
|
// ***************************************************************************************** |
2204 |
|
// ----------------------------------------------------------------------------------------- |
2205 |
|
// calorimeter check |
2206 |
|
// ----------------------------------------------------------------------------------------- |
2207 |
|
if (use_CAL && !calo2) { |
2208 |
|
cout << "void PamLevel2::SortTracks(): howtosort= " << how << " but CaloLevel2 not loaded !!!"; |
2209 |
|
return; |
2210 |
|
}; |
2211 |
|
if (use_CAL && !cp && ci) { |
2212 |
|
ti_score++; |
2213 |
|
toti_score++; |
2214 |
|
}; |
2215 |
|
if (use_CAL && cp && !ci) { |
2216 |
|
tp_score++; |
2217 |
|
totp_score++; |
2218 |
|
}; |
2219 |
|
if (use_CAL && cp && ci && true) { |
2220 |
|
|
2221 |
|
if (cp->npresh > ci->npresh && true) { |
2222 |
|
tp_score++; |
2223 |
|
totp_score++; |
2224 |
|
}; |
2225 |
|
if (cp->npresh < ci->npresh && true) { |
2226 |
|
ti_score++; |
2227 |
|
toti_score++; |
2228 |
|
}; |
2229 |
|
|
2230 |
|
// cout << "CALO "<<tp_score<<ti_score<<endl; |
2231 |
|
|
2232 |
|
}; |
2233 |
|
// ----------------------------------------------------------------------------------------- |
2234 |
|
// ***************************************************************************************** |
2235 |
|
// ----------------------------------------------------------------------------------------- |
2236 |
|
// TOF check |
2237 |
|
// ----------------------------------------------------------------------------------------- |
2238 |
|
// check the number of hit pmts along the track |
2239 |
|
// on S12 S21 and S32, where paddles are parallel to Y axis |
2240 |
|
if ((use_TOF || use_S1 || use_S2 || use_S3) && !tof2) { |
2241 |
|
cout << "void PamLevel2::SortTracks(): howtosort= " << how << " but ToFLevel2 not loaded !!!"; |
2242 |
|
return; |
2243 |
|
}; |
2244 |
|
// |
2245 |
|
if ((use_TOF || use_S1 || use_S2 || use_S3) && !op && oi) { |
2246 |
|
ti_score++; |
2247 |
|
toti_score++; |
2248 |
|
}; |
2249 |
|
if ((use_TOF || use_S1 || use_S2 || use_S3) && op && !oi) { |
2250 |
|
tp_score++; |
2251 |
|
totp_score++; |
2252 |
|
}; |
2253 |
|
if ((use_TOF || use_S1 || use_S2 || use_S3) && op && oi) { |
2254 |
|
// |
2255 |
|
Float_t sen = 0.; |
2256 |
|
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
2257 |
|
Int_t pl = tof2->GetPlaneIndex((op->pmtadc).At(ih)); |
2258 |
|
if (pl == 2 || pl == 3 || pl == 4 || pl == 5) |
2259 |
|
sen += (op->dedx).At(ih); |
2260 |
|
}; |
2261 |
|
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
2262 |
|
Int_t pl = tof2->GetPlaneIndex((oi->pmtadc).At(ih)); |
2263 |
|
if (pl == 2 || pl == 3 || pl == 4 || pl == 5) |
2264 |
|
sen += (oi->dedx).At(ih); |
2265 |
|
}; |
2266 |
|
// |
2267 |
|
if (sen >= sortthr && false) { // temporary disabled NUCLEI special algorithm since the new one should work for every particle (to be checked!) |
2268 |
|
//printf(" IS A NUCLEUS! en = %f \n",sen); |
2269 |
|
// |
2270 |
|
// is a nucleus use a different algorithm |
2271 |
|
// |
2272 |
|
Int_t nz = 6; |
2273 |
|
Float_t zin[6]; // << define TOF z-coordinates |
2274 |
|
for (Int_t ip = 0; ip < nz; ip++) |
2275 |
|
zin[ip] = tof2->GetZTOF(tof2->GetToFPlaneID(ip)); // << read ToF plane z-coordinates |
2276 |
|
Trajectory *tr = new Trajectory(nz, zin); |
2277 |
|
// |
2278 |
|
Int_t nphit_p = 0; |
2279 |
|
Int_t nphit_i = 0; |
2280 |
|
Float_t enhit_p = 0.; |
2281 |
|
Float_t enhit_i = 0.; |
2282 |
|
// |
2283 |
|
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
2284 |
|
Int_t pl = tof2->GetPlaneIndex((op->pmtadc).At(ih)); |
2285 |
|
if (pl == 1 || pl == 2 || pl == 5) { |
2286 |
|
nphit_p++; |
2287 |
|
enhit_p += (op->dedx).At(ih); |
2288 |
|
}; |
2289 |
|
}; |
2290 |
|
// |
2291 |
|
tp->DoTrack2(tr); |
2292 |
|
// |
2293 |
|
if (fabs(tr->y[0] - oi->ytofpos[0]) < 2.) { |
2294 |
|
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
2295 |
|
Int_t pl = tof2->GetPlaneIndex((op->pmtadc).At(ih)); |
2296 |
|
if (pl == 0) { |
2297 |
|
nphit_p++; |
2298 |
|
enhit_p += (op->dedx).At(ih); |
2299 |
|
}; |
2300 |
|
}; |
2301 |
|
}; |
2302 |
|
if (fabs(tr->y[3] - oi->ytofpos[1]) < 2.) { |
2303 |
|
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
2304 |
|
Int_t pl = tof2->GetPlaneIndex((op->pmtadc).At(ih)); |
2305 |
|
if (pl == 3) { |
2306 |
|
nphit_p++; |
2307 |
|
enhit_p += (op->dedx).At(ih); |
2308 |
|
}; |
2309 |
|
}; |
2310 |
|
}; |
2311 |
|
if (fabs(tr->y[4] - oi->ytofpos[2]) < 2.) { |
2312 |
|
for (Int_t ih = 0; ih < op->npmtadc; ih++) { |
2313 |
|
Int_t pl = tof2->GetPlaneIndex((op->pmtadc).At(ih)); |
2314 |
|
if (pl == 4) { |
2315 |
|
nphit_p++; |
2316 |
|
enhit_p += (op->dedx).At(ih); |
2317 |
|
}; |
2318 |
|
}; |
2319 |
|
}; |
2320 |
|
|
2321 |
|
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
2322 |
|
Int_t pl = tof2->GetPlaneIndex((oi->pmtadc).At(ih)); |
2323 |
|
if (pl == 1 || pl == 2 || pl == 5) { |
2324 |
|
nphit_i++; |
2325 |
|
enhit_i += (op->dedx).At(ih); |
2326 |
|
}; |
2327 |
|
}; |
2328 |
|
// |
2329 |
|
ti->DoTrack2(tr); |
2330 |
|
// |
2331 |
|
if (fabs(tr->y[0] - oi->ytofpos[0]) < 2.) { |
2332 |
|
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
2333 |
|
Int_t pl = tof2->GetPlaneIndex((oi->pmtadc).At(ih)); |
2334 |
|
if (pl == 0) { |
2335 |
|
nphit_i++; |
2336 |
|
enhit_i += (op->dedx).At(ih); |
2337 |
|
}; |
2338 |
|
}; |
2339 |
|
}; |
2340 |
|
if (fabs(tr->y[3] - oi->ytofpos[1]) < 2.) { |
2341 |
|
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
2342 |
|
Int_t pl = tof2->GetPlaneIndex((oi->pmtadc).At(ih)); |
2343 |
|
if (pl == 3) { |
2344 |
|
nphit_i++; |
2345 |
|
enhit_i += (op->dedx).At(ih); |
2346 |
|
}; |
2347 |
|
}; |
2348 |
|
}; |
2349 |
|
if (fabs(tr->y[4] - oi->ytofpos[2]) < 2.) { |
2350 |
|
for (Int_t ih = 0; ih < oi->npmtadc; ih++) { |
2351 |
|
Int_t pl = tof2->GetPlaneIndex((oi->pmtadc).At(ih)); |
2352 |
|
if (pl == 4) { |
2353 |
|
nphit_i++; |
2354 |
|
enhit_i += (op->dedx).At(ih); |
2355 |
|
}; |
2356 |
|
}; |
2357 |
|
}; |
2358 |
|
|
2359 |
|
if ((use_TOF || use_S1 || use_S2 || use_S3) && (nphit_p + nphit_i) != 0 && true) { |
2360 |
|
|
2361 |
|
// printf(" seqno %i nphit_p %i nphit_i %i enhit_p %f enhit_i %f \n",trk2_obj->TrkLevel2::GetSeqNo(i),nphit_p,nphit_i,enhit_p,enhit_i); |
2362 |
|
// printf(" score p %i score i %i \n",tp_score,ti_score); |
2363 |
|
// if( enhit_p > enhit_i ) tp_score++; |
2364 |
|
// if( nphit_p >= nphit_i && enhit_p > enhit_i ) tp_score++; |
2365 |
|
if (nphit_p > nphit_i) |
2366 |
|
tp_score++; |
2367 |
|
if (nphit_p < nphit_i) |
2368 |
|
ti_score++; |
2369 |
|
if (nphit_p == nphit_i) { |
2370 |
|
if (enhit_p > enhit_i) |
2371 |
|
tp_score++; |
2372 |
|
else |
2373 |
|
ti_score++; |
2374 |
|
}; |
2375 |
|
// printf(" dopo score p %i score i %i \n",tp_score,ti_score); |
2376 |
|
}; |
2377 |
|
delete tr; |
2378 |
|
// |
2379 |
|
} |
2380 |
|
else { |
2381 |
|
// ------------- |
2382 |
|
// NOT a NUCLEUS |
2383 |
|
// ------------- |
2384 |
|
//printf(" NOT a NUCLEUS! en = %f \n",sen); |
2385 |
|
|
2386 |
|
Int_t nphit_p = 0; |
2387 |
|
Int_t nphit_i = 0; |
2388 |
|
|
2389 |
|
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
2390 |
|
cout << "track: npmttdc "<< op->npmttdc << endl; |
2391 |
|
cout << "image: npmtadc "<< oi->npmtadc << endl; |
2392 |
|
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
2393 |
|
|
2394 |
|
// for (Int_t ih=0; ih < op->npmtadc; ih++){ |
2395 |
|
// Int_t pl = tof2_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
2396 |
|
// if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
2397 |
|
// }; |
2398 |
|
|
2399 |
|
// for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
2400 |
|
// Int_t pl = tof2_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
2401 |
|
// if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
2402 |
|
// }; |
2403 |
|
// --- modified to count tdc signals (more efficient?) |
2404 |
|
// --- and to implement check on tdcflag |
2405 |
|
for (Int_t ih = 0; ih < op->npmttdc; ih++) { |
2406 |
|
Int_t pl = tof2->GetPlaneIndex((op->pmttdc).At(ih)); |
2407 |
|
// if( (op->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_p++; |
2408 |
|
if ((use_S1 && (pl == 0 || pl == 1)) || (use_S2 && (pl == 2 || pl == 3)) |
2409 |
|
|| (use_S3 && (pl == 4 || pl == 5))) { |
2410 |
|
if ((op->tdcflag).At(ih) == 0) |
2411 |
|
nphit_p++; |
2412 |
|
}; |
2413 |
|
}; |
2414 |
|
|
2415 |
|
for (Int_t ih = 0; ih < oi->npmttdc; ih++) { |
2416 |
|
Int_t pl = tof2->GetPlaneIndex((oi->pmttdc).At(ih)); |
2417 |
|
// if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++; |
2418 |
|
if ((use_S1 && (pl == 0 || pl == 1)) || (use_S2 && (pl == 2 || pl == 3)) |
2419 |
|
|| (use_S3 && (pl == 4 || pl == 5))) { |
2420 |
|
if ((oi->tdcflag).At(ih) == 0) |
2421 |
|
nphit_i++; |
2422 |
|
}; |
2423 |
|
}; |
2424 |
|
|
2425 |
|
if ((nphit_p + nphit_i) != 0 && true) { |
2426 |
|
|
2427 |
|
if (nphit_p != nphit_i) { |
2428 |
|
totp_score += nphit_p; |
2429 |
|
toti_score += nphit_i; |
2430 |
|
tp_score += nphit_p; |
2431 |
|
ti_score += nphit_i; |
2432 |
|
}; |
2433 |
|
// if ( nphit_p > nphit_i) tp_score+=nphit_p; |
2434 |
|
// else if( nphit_p < nphit_i) ti_score+=nphit_i; |
2435 |
|
// else ;//niente |
2436 |
|
}; |
2437 |
|
}; |
2438 |
|
// cout << "TOF "<<tp_score<<ti_score<<endl; |
2439 |
|
}; |
2440 |
|
|
2441 |
|
// if(tp_score == ti_score) use_TRK = true; |
2442 |
|
|
2443 |
|
|
2444 |
|
// ----------------------------------------------------------------------------------------- |
2445 |
|
// ***************************************************************************************** |
2446 |
|
// ----------------------------------------------------------------------------------------- |
2447 |
|
// tracker check |
2448 |
|
// ----------------------------------------------------------------------------------------- |
2449 |
|
// chi**2 difference is not always large enough to distinguish among |
2450 |
|
// the real track and its image. |
2451 |
|
// Tracker check will be applied always when calorimeter and tof information is ambiguous. |
2452 |
|
// *** MODIFIED ON AUGUST 2007 *** |
2453 |
|
if (use_TRK) { |
2454 |
|
// if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
2455 |
|
// else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
2456 |
|
|
2457 |
|
// CHECK 1 : number of points along X |
2458 |
|
if (tp->GetNX() >= ti->GetNX()) { |
2459 |
|
tp_score++; |
2460 |
|
totp_score++; |
2461 |
|
}; |
2462 |
|
if (tp->GetNX() <= ti->GetNX()) { |
2463 |
|
ti_score++; |
2464 |
|
toti_score++; |
2465 |
|
}; |
2466 |
|
// CHECK 2 : number of points along Y |
2467 |
|
if (tp->GetNY() >= ti->GetNY()) { |
2468 |
|
tp_score++; |
2469 |
|
totp_score++; |
2470 |
|
}; |
2471 |
|
if (tp->GetNY() <= ti->GetNY()) { |
2472 |
|
ti_score++; |
2473 |
|
toti_score++; |
2474 |
|
}; |
2475 |
|
|
2476 |
|
// cout << "TRK "<<tp_score<<ti_score<<endl; |
2477 |
|
}; |
2478 |
|
|
2479 |
|
// ----------------------------------------------------------------------------------------- |
2480 |
|
// ***************************************************************************************** |
2481 |
|
// ----------------------------------------------------------------------------------------- |
2482 |
|
// GPamela check |
2483 |
|
// ----------------------------------------------------------------------------------------- |
2484 |
|
|
2485 |
|
//--------------------------------------------------- |
2486 |
|
// count the number of GP hits |
2487 |
|
//--------------------------------------------------- |
2488 |
|
if (use_GP) { |
2489 |
|
int ngphits_p = 0; |
2490 |
|
int ngphits_i = 0; |
2491 |
|
float toll = 0.02; //200 micron |
2492 |
|
for (int ih = 0; ih < GetGPamela()->Nthspe; ih++) { |
2493 |
|
int ip = (Int_t) GetGPamela()->Itrpb[ih] - 1; |
2494 |
|
if (tp && tp->YGood(ip) && fabs(tp->ym[ip] - GetGPamela()->Yavspe[ih]) < toll && true) |
2495 |
|
ngphits_p++; |
2496 |
|
if (ti && ti->YGood(ip) && fabs(ti->ym[ip] - GetGPamela()->Yavspe[ih]) < toll && true) |
2497 |
|
ngphits_i++; |
2498 |
|
} |
2499 |
|
if (ngphits_p > ngphits_i && true) { |
2500 |
|
tp_score++; |
2501 |
|
totp_score++; |
2502 |
|
} |
2503 |
|
if (ngphits_p < ngphits_i && true) { |
2504 |
|
ti_score++; |
2505 |
|
toti_score++; |
2506 |
|
} |
2507 |
|
} |
2508 |
|
|
2509 |
|
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* |
2510 |
|
// the winner is.... |
2511 |
|
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* |
2512 |
|
if (tp_score > ti_score) { |
2513 |
|
|
2514 |
|
} |
2515 |
|
else if (tp_score < ti_score) { |
2516 |
|
|
2517 |
|
ts = ti;//its image!! |
2518 |
|
cs = ci; |
2519 |
|
os = oi; |
2520 |
|
rs = ri; |
2521 |
|
Int_t totis = toti_score; |
2522 |
|
|
2523 |
|
ti = tp;//its image!! |
2524 |
|
ci = cp; |
2525 |
|
oi = op; |
2526 |
|
ri = rp; |
2527 |
|
|
2528 |
|
tp = ts;//its image!! |
2529 |
|
cp = cs; |
2530 |
|
op = os; |
2531 |
|
rp = rs; |
2532 |
|
|
2533 |
|
toti_score = totp_score; |
2534 |
|
totp_score = totis; |
2535 |
|
|
2536 |
|
} |
2537 |
|
else { |
2538 |
|
|
2539 |
|
// cout << "Warning - track image ambiguity not solved" << endl; |
2540 |
|
|
2541 |
|
}; |
2542 |
|
|
2543 |
|
} |
2544 |
|
else { |
2545 |
|
totp_score = 1; |
2546 |
|
toti_score = 0; |
2547 |
|
|
2548 |
|
// ts = tp; |
2549 |
|
// cs = cp; |
2550 |
|
// os = op; |
2551 |
|
}; |
2552 |
|
|
2553 |
|
// cout <<" SortTracks() "<<i<<" -- "<<ts<<endl; |
2554 |
|
// sorted_tracks->Add(ts);//save the track in the sorted array |
2555 |
|
// sorted_tracks.Add(ts);//save the track in the sorted array |
2556 |
|
// sorted_tracks.Add(tp);//save the track in the sorted array |
2557 |
|
// cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl; |
2558 |
|
// cout<<"o "<<tp<<endl; |
2559 |
|
// cout<<"o "<<cp<<endl; |
2560 |
|
// cout<<"o "<<op<<endl; |
2561 |
|
|
2562 |
|
new (ttsorted[i]) PamTrack(tp, cp, op, rp); |
2563 |
|
new (ttimage[i]) PamTrack(ti, ci, oi, ri); |
2564 |
|
|
2565 |
|
((PamTrack*) (ttsorted[i]))->SetPScore(totp_score); |
2566 |
|
((PamTrack*) (ttsorted[i]))->SetIScore(toti_score); |
2567 |
|
((PamTrack*) (ttimage[i]))->SetPScore(totp_score); |
2568 |
|
((PamTrack*) (ttimage[i]))->SetIScore(toti_score); |
2569 |
|
}; |
2570 |
|
|
2571 |
|
|
2572 |
|
|
2573 |
|
|
2574 |
|
|
2575 |
|
// if (tsorted->GetEntries() != trk2->GetNTracks()) { |
2576 |
|
// cout << "void PamLevel2::SortTracks(): tsorted->GetEntries() " << tsorted->GetEntries() |
2577 |
|
// << " != trk2->GetNTracks() = " << trk2->GetNTracks() << endl; |
2578 |
|
// tsorted->Delete(); |
2579 |
|
// tsorted = 0; |
2580 |
|
// timage->Delete(); |
2581 |
|
// timage = 0; |
2582 |
|
// } |
2583 |
|
|
2584 |
|
|
2585 |
|
// cout << "text "<<doit<<endl; |
2586 |
|
|
2587 |
|
|
2588 |
|
//-------------------------------------------------- |
2589 |
|
// fill array with extended tracks (this is easy...) |
2590 |
|
//-------------------------------------------------- |
2591 |
|
if(EXT){ |
2592 |
|
for(int it=0; it<trkext->GetEntries(); it++){ |
2593 |
|
|
2594 |
|
new (ttext[it]) PamTrack((ExtTrack*)(*trkext)[it], (CaloTrkVar*)(*caloext)[it], (ToFTrkVar*)(*tofext)[it], (OrbitalInfoTrkVar*)(*orbext)[it]); |
2595 |
|
|
2596 |
|
} |
2597 |
|
} |
2598 |
|
|
2599 |
|
|
2600 |
|
|
2601 |
|
}; |
2602 |
|
|
2603 |
|
|
2604 |
|
//Restore Object count |
2605 |
|
//To save space in the table keeping track of all referenced objects |
2606 |
|
//We reset the object count to what it was at the beginning of the event. |
2607 |
|
TProcessID::SetObjectCount(ObjectNumber); |
2608 |
|
|
2609 |
|
//Everything went fine so the current event can be tagged as sorted |
2610 |
|
issorted_new = true; |
2611 |
|
lastsorted_new = GetReadEntry(); |
2612 |
|
|
2613 |
|
// cout << " tsorted "<< tsorted << " "<<(tsorted ? tsorted->GetEntries() : 0)<<endl; |
2614 |
|
// cout << " timage "<< timage << " "<<(timage ? timage->GetEntries() : 0)<<endl; |
2615 |
|
// cout << " text "<< text << " "<<(text ? text->GetEntries() : 0)<<endl; |
2616 |
|
|
2617 |
|
|
2618 |
|
}; |
2619 |
//-------------------------------------- |
//-------------------------------------- |
2620 |
// |
// |
2621 |
// |
// |
2624 |
* This method overrides TrkLevel2::GetTracks(), where sorting is done by decreasing number of fit points and increasing chi^2. |
* This method overrides TrkLevel2::GetTracks(), where sorting is done by decreasing number of fit points and increasing chi^2. |
2625 |
* PamLevel2::GetTracks() keeps the same track order given by TrkLevel2::GetTracks(), but checks image selection by using calorimeter and ToF tracking information. |
* PamLevel2::GetTracks() keeps the same track order given by TrkLevel2::GetTracks(), but checks image selection by using calorimeter and ToF tracking information. |
2626 |
*/ |
*/ |
2627 |
|
|
2628 |
// TRefArray *PamLevel2::GetTracks(){ |
// TRefArray *PamLevel2::GetTracks(){ |
2629 |
|
|
2630 |
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
2635 |
// return &sorted_tracks; |
// return &sorted_tracks; |
2636 |
|
|
2637 |
// }; |
// }; |
|
TClonesArray *PamLevel2::GetTracks() { |
|
|
|
|
|
// *-*-*-*-*-*-*-*-*-*-*-*-* |
|
|
SortTracks(); |
|
|
// *-*-*-*-*-*-*-*-*-*-*-*-* |
|
2638 |
|
|
|
return tsorted; |
|
2639 |
|
|
|
} |
|
|
; |
|
2640 |
//-------------------------------------- |
//-------------------------------------- |
2641 |
// |
// |
2642 |
// |
// |
2643 |
//-------------------------------------- |
//-------------------------------------- |
2644 |
|
|
2645 |
/** |
/** |
2646 |
* Retrieves the it-th Pamela "physical" track. |
* Retrieves the it-th Pamela "physical" track. |
2647 |
* It override TrkLevel2::GetTrack(int it). |
* It override TrkLevel2::GetTrack(int it). |
2648 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
2649 |
*/ |
*/ |
2650 |
PamTrack *PamLevel2::GetTrack(int it) { |
PamTrack *PamLevel2::GetTrackOld(int it) { |
|
|
|
|
// if(!trk2_obj) return 0; |
|
2651 |
|
|
2652 |
// // *-*-*-*+-*-*-*-*-*-*-*-*-* |
PamTrack *track = NULL; |
|
// SortTracks("+CAL+TOF"); |
|
|
// // *-*-*-*-*-*-*-*-*-*-*-*-* |
|
|
// // if(!sorted_tracks)return 0; |
|
|
// if(sorted_tracks.IsEmpty())return 0; |
|
|
|
|
|
// PamTrack *track = 0; |
|
|
|
|
|
// if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() && it<sorted_tracks.GetEntriesFast() ){ |
|
|
// TrkTrack *t = (TrkTrack*)sorted_tracks.At(it); |
|
|
// track = GetPamTrackAlong(t); |
|
|
// }else{ |
|
|
// cout << "PamLevel2::GetTrack(int) : tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl; |
|
|
// }; |
|
|
|
|
|
// return track; |
|
2653 |
|
|
|
// cout << "PamLevel2::GetTrack(int it) "<<endl; |
|
2654 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
2655 |
SortTracks(); |
SortTracks(); |
2656 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
2657 |
if (!tsorted) |
if (!tsorted) |
2658 |
return 0; |
return track; |
2659 |
if (!tsorted->GetEntries()) |
if (!tsorted->GetEntries()) |
2660 |
return 0; |
return track; |
2661 |
|
|
|
PamTrack *track = 0; |
|
2662 |
|
|
2663 |
if (it >= 0 && it < trk2_obj->TrkLevel2::GetNTracks()) { |
if (it >= 0 && it < trk2_obj->TrkLevel2::GetNTracks()) { |
|
// TrkTrack *t = (TrkTrack*)sorted_tracks.At(it); |
|
|
// track = GetPamTrackAlong(t); |
|
|
//TClonesArray &t = *(tsorted); |
|
|
//track = (PamTrack*)t[it]; |
|
2664 |
track = (PamTrack*)((*tsorted)[it]); |
track = (PamTrack*)((*tsorted)[it]); |
2665 |
} |
} |
2666 |
else { |
else { |
2667 |
cout << "PamLevel2::GetTrack(int) : tracker track SeqNo " << it << " does not exist (GetNTracks() = " |
cout << "PamLevel2::GetTrackOld(int) : tracker track SeqNo " << it << " does not exist (GetNTracks() = " |
2668 |
<< trk2_obj->TrkLevel2::GetNTracks() << ")" << endl; |
<< trk2_obj->TrkLevel2::GetNTracks() << ")" << endl; |
2669 |
}; |
}; |
2670 |
|
|
2671 |
return track; |
return track; |
2672 |
|
|
2673 |
|
}; |
2674 |
|
|
2675 |
|
//PamTrack *PamLevel2::GetTrack(int it) { return GetTrack(it,trkAlg); }; |
2676 |
|
|
2677 |
|
/** |
2678 |
|
* Retrieves the it-th Pamela "physical" track. |
2679 |
|
* It override TrkLevel2::GetTrack(int it). |
2680 |
|
* @param it Track number, ranging from 0 to GetNTracks(). |
2681 |
|
* @param alg Algorythm, see SetTrakingAlgorythm(char *alg) for explanation. |
2682 |
|
*/ |
2683 |
|
PamTrack *PamLevel2::GetTrack(int it, const char* alg) { |
2684 |
|
|
2685 |
|
TString s(alg); |
2686 |
|
if(!s.CompareTo("") ||!s.CompareTo("STD") )return GetTrackOld(it); //old algorythm |
2687 |
|
|
2688 |
|
|
2689 |
|
SortTracksNew(); |
2690 |
|
// >> fill tsorted, timage and text |
2691 |
|
|
2692 |
|
if ( ( !s.Contains("EXTF", TString::kIgnoreCase) || !EXT )){ //not forced exteded-alg requested (or exteded-data missing) |
2693 |
|
|
2694 |
|
if( s.Contains("NUC")){ |
2695 |
|
if( |
2696 |
|
tsorted_nuc && |
2697 |
|
it < tsorted_nuc->GetEntries() && //enough tracks found |
2698 |
|
it >= 0 && //valid index |
2699 |
|
true) return (PamTrack*)((*tsorted_nuc)[it]); //ok return the track |
2700 |
|
}else{ |
2701 |
|
if( |
2702 |
|
tsorted && |
2703 |
|
it < tsorted->GetEntries() && //enough tracks found |
2704 |
|
it >= 0 && //valid index |
2705 |
|
true )return (PamTrack*)((*tsorted)[it]); //ok return the track |
2706 |
|
} |
2707 |
|
|
2708 |
|
} |
2709 |
|
|
2710 |
|
|
2711 |
|
///////////////////////////////////////////////////////////////////////// |
2712 |
|
/// if requested get track from extended algorythm output |
2713 |
|
///////////////////////////////////////////////////////////////////////// |
2714 |
|
|
2715 |
|
if(s.Contains("EXT", TString::kIgnoreCase) && EXT){//if exteded-alg requested |
2716 |
|
|
2717 |
|
if(s.Contains("NUC")){ |
2718 |
|
if( |
2719 |
|
text_nuc && |
2720 |
|
it < text_nuc->GetEntries() && //enough tracks found |
2721 |
|
it >= 0 && //valid index |
2722 |
|
true) return (PamTrack*)((*text_nuc)[it]); |
2723 |
|
}else{ |
2724 |
|
if( |
2725 |
|
text && |
2726 |
|
it < text->GetEntries() && //enough tracks found |
2727 |
|
it >= 0 && //valid index |
2728 |
|
true) return (PamTrack*)((*text)[it]); |
2729 |
|
} |
2730 |
|
|
2731 |
|
}; |
2732 |
|
|
2733 |
|
|
2734 |
|
cout << "PamTrack *PamLevel2::GetTrack("<<it<<","<<alg<<") -- wrong track number or unrecognised algorithm"<<endl; |
2735 |
|
|
2736 |
|
return NULL; |
2737 |
|
|
2738 |
|
} |
2739 |
|
; |
2740 |
|
TClonesArray *PamLevel2::GetTracks() { |
2741 |
|
|
2742 |
|
// *-*-*-*-*-*-*-*-*-*-*-*-* |
2743 |
|
SortTracks(); |
2744 |
|
// *-*-*-*-*-*-*-*-*-*-*-*-* |
2745 |
|
|
2746 |
|
return tsorted; |
2747 |
|
|
2748 |
} |
} |
2749 |
; |
; |
2750 |
|
Int_t PamLevel2::GetNTracks(const char* alg) { |
2751 |
|
|
2752 |
|
|
2753 |
|
// cout << " trk_nuc_obj->GetEntries() "<<trk_nuc_obj->GetEntries()<<" trk2_nuc_obj->GetNTracks() "<<trk2_nuc_obj->GetNTracks()<<endl; |
2754 |
|
|
2755 |
|
TString s(alg); |
2756 |
|
|
2757 |
|
if(!s.CompareTo("") || !s.CompareTo("STD"))return trk2_obj->TrkLevel2::GetNTracks(); //standard algorythm |
2758 |
|
|
2759 |
|
if(s.Contains("EXTF", TString::kIgnoreCase) && EXT){ |
2760 |
|
if(s.Contains("NUC", TString::kIgnoreCase) && NUC)return trk_ext_nuc_obj->GetEntries();//ok |
2761 |
|
return trk_ext_obj->GetEntries();//ok |
2762 |
|
} |
2763 |
|
if( s.Contains("EXT", TString::kIgnoreCase) && EXT) { |
2764 |
|
if(s.Contains("NUC", TString::kIgnoreCase) && NUC) |
2765 |
|
return (trk2_nuc_obj->TrkLevel2::GetNTracks() ? trk2_nuc_obj->TrkLevel2::GetNTracks() : trk_ext_nuc_obj->GetEntries() ); |
2766 |
|
return (trk2_obj->TrkLevel2::GetNTracks() ? trk2_obj->TrkLevel2::GetNTracks() : trk_ext_obj->GetEntries() ); |
2767 |
|
} |
2768 |
|
if(s.Contains("NUC", TString::kIgnoreCase) && NUC ) |
2769 |
|
return trk2_nuc_obj->TrkLevel2::GetNTracks(); |
2770 |
|
|
2771 |
|
cout << "Int_t PamLevel2::GetNTracks("<<alg<<") -- unrecognised algorithm"<<endl; |
2772 |
|
|
2773 |
|
return 0; |
2774 |
|
|
2775 |
|
} |
2776 |
|
|
2777 |
|
|
2778 |
//-------------------------------------- |
//-------------------------------------- |
2779 |
// |
// |
2783 |
* Retrieves (if present) the image of the it-th Pamela "physical" track, sorted by the method PamLevel2::SortTracks(). |
* Retrieves (if present) the image of the it-th Pamela "physical" track, sorted by the method PamLevel2::SortTracks(). |
2784 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
2785 |
*/ |
*/ |
2786 |
PamTrack *PamLevel2::GetTrackImage(int it) { |
PamTrack *PamLevel2::GetTrackImageOld(int it) { |
2787 |
|
|
2788 |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
// *-*-*-*-*-*-*-*-*-*-*-*-* |
2789 |
SortTracks(); |
SortTracks(); |
2807 |
}; |
}; |
2808 |
} |
} |
2809 |
else { |
else { |
2810 |
cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo " << it << " does not exist (GetNTracks() = " |
cout << "PamLevel2::GetTrackImageOld(int) : Tracker track SeqNo " << it << " does not exist (GetNTracks() = " |
2811 |
<< trk2_obj->TrkLevel2::GetNTracks() << ")" << endl; |
<< trk2_obj->TrkLevel2::GetNTracks() << ")" << endl; |
2812 |
}; |
}; |
2813 |
|
|
2814 |
return image; |
return image; |
2815 |
} |
} |
|
|
|
|
//-------------------------------------- |
|
|
// |
|
|
// |
|
|
//-------------------------------------- |
|
2816 |
/** |
/** |
2817 |
* Get the Pamela detector trees in a single file and make them friends. |
* Retrieves (if present) the image of the it-th Pamela "physical" track, sorted by the method PamLevel2::SortTracks(). |
2818 |
* @param f TFile pointer |
* @param it Track number, ranging from 0 to GetNTracks(). |
2819 |
|
* @param alg Algorythm, see SetTrakingAlgorythm(char *alg) for explanation. |
2820 |
|
*/ |
2821 |
|
PamTrack *PamLevel2::GetTrackImage(int it, const char* alg) { |
2822 |
|
|
2823 |
|
TString s(alg); |
2824 |
|
if(!s.CompareTo("") || !s.CompareTo("STD"))return GetTrackImageOld(it); //old algorythm |
2825 |
|
|
2826 |
|
|
2827 |
|
SortTracksNew(); |
2828 |
|
// >> fill tsorted, timage and text |
2829 |
|
|
2830 |
|
if ( ( !s.Contains("EXTF", TString::kIgnoreCase) || !EXT )){ //not forced exteded-alg requested (or exteded-data missing) |
2831 |
|
|
2832 |
|
if( s.Contains("NUC")){ |
2833 |
|
if( |
2834 |
|
tsorted_nuc && |
2835 |
|
it < tsorted_nuc->GetEntries() && //enough tracks found |
2836 |
|
it >= 0 && //valid index |
2837 |
|
true){ |
2838 |
|
TClonesArray &t = *(tsorted_nuc); |
2839 |
|
PamTrack *temp = (PamTrack*) t[it]; |
2840 |
|
if (temp->GetTrkTrack()->HasImage()) { |
2841 |
|
return (PamTrack*)((*timage_nuc)[it]); //ok return the track |
2842 |
|
}else{ |
2843 |
|
return NULL; |
2844 |
|
} |
2845 |
|
|
2846 |
|
} |
2847 |
|
}else{ |
2848 |
|
if( |
2849 |
|
tsorted && |
2850 |
|
it < tsorted->GetEntries() && //enough tracks found |
2851 |
|
it >= 0 && //valid index |
2852 |
|
true ){ |
2853 |
|
TClonesArray &t = *(tsorted); |
2854 |
|
PamTrack *temp = (PamTrack*) t[it]; |
2855 |
|
if (temp->GetTrkTrack()->HasImage()) { |
2856 |
|
return (PamTrack*)((*timage)[it]); //ok return the track |
2857 |
|
}else{ |
2858 |
|
return NULL; |
2859 |
|
} |
2860 |
|
} |
2861 |
|
} |
2862 |
|
|
2863 |
|
} |
2864 |
|
|
2865 |
|
cout << "PamTrack *PamLevel2::GetTrackImage("<<it<<","<<alg<<") -- wrong track number or unrecognised algorithm"<<endl; |
2866 |
|
|
2867 |
|
return NULL; |
2868 |
|
|
2869 |
|
} |
2870 |
|
; |
2871 |
|
|
2872 |
|
//-------------------------------------- |
2873 |
|
// |
2874 |
|
// |
2875 |
|
//-------------------------------------- |
2876 |
|
/** |
2877 |
|
* Get the Pamela detector trees in a single file and make them friends. |
2878 |
|
* @param f TFile pointer |
2879 |
* @param detlist String to select trees to be included |
* @param detlist String to select trees to be included |
2880 |
* @return Pointer to a TTree |
* @return Pointer to a TTree |
2881 |
*/ |
*/ |
2957 |
if (!Trout) |
if (!Trout) |
2958 |
Trout = T; |
Trout = T; |
2959 |
else |
else |
2960 |
Trout->AddFriend(T); |
Trout->AddFriend(T); |
2961 |
} |
} |
2962 |
else { |
else { |
2963 |
cout << "Tracker : missing tree" << endl; |
cout << "Tracker : missing tree" << endl; |
3194 |
if (file.EndsWith(".root")) { |
if (file.EndsWith(".root")) { |
3195 |
TString filedir; |
TString filedir; |
3196 |
cout << ddir << endl; |
cout << ddir << endl; |
3197 |
if (ddir != "") { |
if ( ddir != "" ) { |
3198 |
filedir = ddir; // take the input dir |
filedir = ddir; // take the input dir |
3199 |
} |
} |
3200 |
else { |
else { |
3202 |
filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir |
filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir |
3203 |
}; |
}; |
3204 |
filedir.Append("/"); |
filedir.Append("/"); |
3205 |
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir), gSystem->BaseName(file)); |
// char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir), gSystem->BaseName(file)); |
3206 |
|
char *fullpath = gSystem->ConcatFileName(filedir.Data(), gSystem->BaseName(file)); |
3207 |
contents->Add(new TSystemFile(fullpath, gSystem->DirName(fullpath)));// add file to the list |
contents->Add(new TSystemFile(fullpath, gSystem->DirName(fullpath)));// add file to the list |
3208 |
cout << fullpath << endl; |
cout << fullpath << endl; |
3209 |
delete fullpath; |
delete fullpath; |
3322 |
TChain *G = 0; |
TChain *G = 0; |
3323 |
|
|
3324 |
TChain *L = 0; |
TChain *L = 0; |
3325 |
|
TChain *P = 0; |
3326 |
|
|
3327 |
if (TRK2 || TRK1 || TRKh) |
if (TRK2 || TRK1 || TRKh) |
3328 |
T = new TChain("Tracker"); |
T = new TChain("Tracker"); |
3342 |
B = new TChain("OrbitalInfo"); |
B = new TChain("OrbitalInfo"); |
3343 |
if (GP) |
if (GP) |
3344 |
G = new TChain("h20"); |
G = new TChain("h20"); |
3345 |
|
if (PROC) |
3346 |
|
P = new TChain("ProcessingInfo"); |
3347 |
L = new TChain("SelectionList"); |
L = new TChain("SelectionList"); |
3348 |
|
|
3349 |
// loop over files and create chains |
// loop over files and create chains |
3371 |
B->Add(name); |
B->Add(name); |
3372 |
if (GP) |
if (GP) |
3373 |
G->Add(name); |
G->Add(name); |
3374 |
|
if (P) |
3375 |
|
P->Add(name); |
3376 |
if (SELLI == 1) |
if (SELLI == 1) |
3377 |
L->Add(name); |
L->Add(name); |
3378 |
}; |
}; |
3379 |
}; |
}; |
3380 |
|
|
3381 |
cout << "done chains\n"; |
cout << "done data-tree chains "<< T->GetNtrees() <<" \n"; |
3382 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; |
cout << "----------------------------------------------------" << endl; |
3383 |
|
|
3384 |
// ------------------------------------------- |
// ------------------------------------------- |
3385 |
// make friends |
// make friends |
3462 |
// ===================================== |
// ===================================== |
3463 |
// SET BRANCH-ADDRESS AFTER CHAIN+FRIEND |
// SET BRANCH-ADDRESS AFTER CHAIN+FRIEND |
3464 |
// ===================================== |
// ===================================== |
3465 |
SetBranchAddress(Trout); |
if( Trout->GetNtrees() )SetBranchAddress(Trout); |
3466 |
|
|
3467 |
// ------------------------------------ |
// ------------------------------------ |
3468 |
// finally handle selection trees... |
// finally handle selection trees... |
3469 |
// (it is not friend of pamela tree) |
// (it is not friend of pamela tree) |
3470 |
// ------------------------------------ |
// ------------------------------------ |
3471 |
|
|
3472 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; |
cout << "----------------------------------------------------" << endl; |
3473 |
|
|
3474 |
// Selection List |
// Selection List |
3475 |
if (L && SELLI == 1) { |
if (L && SELLI == 1) { |
3479 |
cout << "SelectionList: set branch address RunEntry" << endl; |
cout << "SelectionList: set branch address RunEntry" << endl; |
3480 |
L->SetBranchAddress("EventEntry", &irunentry); |
L->SetBranchAddress("EventEntry", &irunentry); |
3481 |
cout << "SelectionList: set branch address EventEntry" << endl; |
cout << "SelectionList: set branch address EventEntry" << endl; |
3482 |
|
/* if ( L->GetBranch("L0EventEntry") ){ |
3483 |
|
hasL0EE = true; |
3484 |
|
L->SetBranchAddress("L0EventEntry", &il0entry); |
3485 |
|
cout << "SelectionList: set branch address L0EventEntry" << endl; |
3486 |
|
} else { |
3487 |
|
hasL0EE = false; // backward compatibility with old preselected files... |
3488 |
|
}*/ |
3489 |
sel_tree = L; |
sel_tree = L; |
3490 |
// if(!Trout)Trout=O; |
// if(!Trout)Trout=O; |
3491 |
// else Trout->AddFriend("SelectionList"); |
// else Trout->AddFriend("SelectionList"); |
3492 |
cout << "+SelectionList" << endl; |
cout << "+SelectionList" << endl; |
3493 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; |
cout << "----------------------------------------------------" << endl; |
3494 |
} |
} |
3495 |
else { |
else { |
3496 |
// cout << "SelectionList : missing tree"<<endl; |
// cout << "SelectionList : missing tree"<<endl; |
3498 |
L->Delete(); |
L->Delete(); |
3499 |
}; |
}; |
3500 |
|
|
3501 |
|
//ProcessingInfo EM |
3502 |
|
if ( P && P->GetEntries() ){ |
3503 |
|
cout << "----------------------------------------------------" << endl; |
3504 |
|
cout << ">>> Found ProcessingInfo <<<" << endl; |
3505 |
|
// L->SetBranchAddress("RunEntry",&irun); |
3506 |
|
P->SetBranchAddress("ProcInfo", &proc_obj);//NEWNEW |
3507 |
|
} |
3508 |
// -------------------------------------------- |
// -------------------------------------------- |
3509 |
// return the pamela chain with all the friends |
// return the pamela chain with all the friends |
3510 |
// -------------------------------------------- |
// -------------------------------------------- |
3523 |
*/ |
*/ |
3524 |
void PamLevel2::SetBranchAddress(TTree *t) { |
void PamLevel2::SetBranchAddress(TTree *t) { |
3525 |
|
|
3526 |
TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); |
// TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); |
3527 |
TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); |
// TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); |
3528 |
TRKh = TRKh & t->GetBranchStatus("TrkHough"); |
// TRKh = TRKh & t->GetBranchStatus("TrkHough"); |
3529 |
CAL2 = CAL2 & t->GetBranchStatus("CaloLevel2"); |
// CAL2 = CAL2 & t->GetBranchStatus("CaloLevel2"); |
3530 |
CAL1 = CAL1 & t->GetBranchStatus("CaloLevel1"); |
// CAL1 = CAL1 & t->GetBranchStatus("CaloLevel1"); |
3531 |
TOF = TOF & t->GetBranchStatus("ToFLevel2"); |
// TOF = TOF & t->GetBranchStatus("ToFLevel2"); |
3532 |
TRG = TRG & t->GetBranchStatus("TrigLevel2"); |
// TRG = TRG & t->GetBranchStatus("TrigLevel2"); |
3533 |
S4 = S4 & t->GetBranchStatus("S4Level2"); |
// S4 = S4 & t->GetBranchStatus("S4Level2"); |
3534 |
ND = ND & t->GetBranchStatus("NDLevel2"); |
// ND = ND & t->GetBranchStatus("NDLevel2"); |
3535 |
AC = AC & t->GetBranchStatus("AcLevel2"); |
// AC = AC & t->GetBranchStatus("AcLevel2"); |
3536 |
ORB = ORB & t->GetBranchStatus("OrbitalInfo"); |
// ORB = ORB & t->GetBranchStatus("OrbitalInfo"); |
3537 |
GP = GP & t->GetBranchStatus("h20"); |
// GP = GP & t->GetBranchStatus("h20"); |
3538 |
|
|
3539 |
|
|
3540 |
// Tracker |
// Tracker |
3541 |
if (TRK1) { |
if (TRK1) { |
3545 |
if (TRK2) { |
if (TRK2) { |
3546 |
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel1")); |
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel1")); |
3547 |
cout << "Tracker : set branch address TrkLevel2" << endl; |
cout << "Tracker : set branch address TrkLevel2" << endl; |
3548 |
|
NUC = t->GetBranchStatus("TrackNuclei"); |
3549 |
|
EXT = t->GetBranchStatus("RecoveredTrack") && (NUC ? t->GetBranchStatus("RecoveredTrackNuclei"): true ); |
3550 |
}; |
}; |
3551 |
if (TRKh) { |
if (TRKh) { |
3552 |
t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
3607 |
|
|
3608 |
cout << "h20 : set branch address GPamela " << endl; |
cout << "h20 : set branch address GPamela " << endl; |
3609 |
}; |
}; |
3610 |
|
if(NUC){ |
3611 |
|
|
3612 |
|
cout << "Found nuclei-track branches" << endl; |
3613 |
|
|
3614 |
|
if( !trk_nuc_obj )trk_nuc_obj = new TClonesArray("TrkTrack"); |
3615 |
|
if( !calo_nuc_obj)calo_nuc_obj= new TClonesArray("CaloTrkVar"); |
3616 |
|
if( !tof_nuc_obj)tof_nuc_obj= new TClonesArray("ToFTrkVar"); |
3617 |
|
if( !orb_nuc_obj)orb_nuc_obj= new TClonesArray("OrbitalInfoTrkVar"); |
3618 |
|
if (TRK2)t-> SetBranchAddress("TrackNuclei",&trk_nuc_obj); |
3619 |
|
if (CAL2)t->GetFriend("Calorimeter")->SetBranchAddress("TrackNuclei",&calo_nuc_obj); |
3620 |
|
if (TOF )t->GetFriend("ToF")-> SetBranchAddress("TrackNuclei",&tof_nuc_obj); |
3621 |
|
if (ORB )t->GetFriend("OrbitalInfo")->SetBranchAddress("TrackNuclei",&orb_nuc_obj); |
3622 |
|
|
3623 |
|
///copy the vector content inside a "fake" object (all aother info are missing) |
3624 |
|
|
3625 |
|
if( !trk2_nuc_obj )trk2_nuc_obj = new TrkLevel2(); |
3626 |
|
if( !calo2_nuc_obj )calo2_nuc_obj = new CaloLevel2(); |
3627 |
|
if( !tof2_nuc_obj )tof2_nuc_obj = new ToFLevel2(); |
3628 |
|
if( !orb2_nuc_obj )orb2_nuc_obj = new OrbitalInfo(); |
3629 |
|
// *(trk2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*trk_nuc_obj); |
3630 |
|
// *(calo2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*calo_nuc_obj); |
3631 |
|
// *(tof2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*tof_nuc_obj); |
3632 |
|
// *(orb2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*orb_nuc_obj); |
3633 |
|
|
3634 |
|
trk2_nuc_obj->SetTrackArray( trk_nuc_obj ); |
3635 |
|
calo2_nuc_obj->SetTrackArray( calo_nuc_obj ); |
3636 |
|
tof2_nuc_obj->SetTrackArray( tof_nuc_obj ); |
3637 |
|
orb2_nuc_obj->SetTrackArray( orb_nuc_obj ); |
3638 |
|
|
3639 |
|
|
3640 |
|
} |
3641 |
|
|
3642 |
|
if(EXT){ |
3643 |
|
|
3644 |
|
cout << "Found extended tracking algorythm branches" << endl; |
3645 |
|
|
3646 |
|
if( !trk_ext_obj )trk_ext_obj = new TClonesArray("ExtTrack"); |
3647 |
|
if( !calo_ext_obj)calo_ext_obj= new TClonesArray("CaloTrkVar"); |
3648 |
|
if( !tof_ext_obj)tof_ext_obj= new TClonesArray("ToFTrkVar"); |
3649 |
|
if( !orb_ext_obj)orb_ext_obj= new TClonesArray("OrbitalInfoTrkVar"); |
3650 |
|
|
3651 |
|
if (TRK2)t-> SetBranchAddress("RecoveredTrack",&trk_ext_obj); |
3652 |
|
if (CAL2)t->GetFriend("Calorimeter")->SetBranchAddress("RecoveredTrack",&calo_ext_obj); |
3653 |
|
if (TOF )t->GetFriend("ToF")-> SetBranchAddress("RecoveredTrack",&tof_ext_obj); |
3654 |
|
if (ORB )t->GetFriend("OrbitalInfo")->SetBranchAddress("RecoveredTrack",&orb_ext_obj); |
3655 |
|
|
3656 |
|
|
3657 |
|
if(NUC){ |
3658 |
|
if( !trk_ext_nuc_obj )trk_ext_nuc_obj = new TClonesArray("ExtTrack"); |
3659 |
|
if( !calo_ext_nuc_obj)calo_ext_nuc_obj= new TClonesArray("CaloTrkVar"); |
3660 |
|
if( !tof_ext_nuc_obj)tof_ext_nuc_obj= new TClonesArray("ToFTrkVar"); |
3661 |
|
if( !orb_ext_nuc_obj)orb_ext_nuc_obj= new TClonesArray("OrbitalInfoTrkVar"); |
3662 |
|
if (TRK2)t-> SetBranchAddress("RecoveredTrackNuclei",&trk_ext_nuc_obj); |
3663 |
|
if (CAL2)t->GetFriend("Calorimeter")->SetBranchAddress("RecoveredTrackNuclei",&calo_ext_nuc_obj); |
3664 |
|
if (TOF )t->GetFriend("ToF")-> SetBranchAddress("RecoveredTrackNuclei",&tof_ext_nuc_obj); |
3665 |
|
if (ORB )t->GetFriend("OrbitalInfo")->SetBranchAddress("RecoveredTrackNuclei",&orb_ext_nuc_obj); |
3666 |
|
} |
3667 |
|
} |
3668 |
} |
} |
3669 |
/** |
/** |
3670 |
* Set branch addresses for Pamela friend trees |
* Set branch addresses for Pamela friend trees |
3688 |
if (TRK2) { |
if (TRK2) { |
3689 |
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
3690 |
cout << "Tracker : set branch address TrkLevel2" << endl; |
cout << "Tracker : set branch address TrkLevel2" << endl; |
3691 |
|
NUC = t->GetBranchStatus("TrackNuclei"); |
3692 |
|
EXT = t->GetBranchStatus("RecoveredTrack") && (NUC ? t->GetBranchStatus("RecoveredTrackNuclei"): true ); |
3693 |
}; |
}; |
3694 |
if (TRK1) { |
if (TRK1) { |
3695 |
t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
3703 |
// Calorimeter |
// Calorimeter |
3704 |
if (CAL2) { |
if (CAL2) { |
3705 |
t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
3706 |
cout << "Calorimeter : set branch address CaloLevel2" << endl; |
cout << "Calorimeter : set branch address CaloLevel2" << endl; |
3707 |
}; |
}; |
3708 |
if (CAL1) { |
if (CAL1) { |
3709 |
t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
3761 |
// cout << "SelectionList: set branch address EventEntry"<<endl; |
// cout << "SelectionList: set branch address EventEntry"<<endl; |
3762 |
|
|
3763 |
// } |
// } |
3764 |
|
if(NUC){ |
3765 |
|
|
3766 |
|
cout << "Found nuclei-track branches" << endl; |
3767 |
|
|
3768 |
|
if( !trk_nuc_obj )trk_nuc_obj = new TClonesArray("TrkTrack"); |
3769 |
|
if( !calo_nuc_obj)calo_nuc_obj= new TClonesArray("CaloTrkVar"); |
3770 |
|
if( !tof_nuc_obj)tof_nuc_obj= new TClonesArray("ToFTrkVar"); |
3771 |
|
if( !orb_nuc_obj)orb_nuc_obj= new TClonesArray("OrbitalInfoTrkVar"); |
3772 |
|
if (TRK2)t-> SetBranchAddress("TrackNuclei",&trk_nuc_obj); |
3773 |
|
if (CAL2)t->GetFriend("Calorimeter")->SetBranchAddress("TrackNuclei",&calo_nuc_obj); |
3774 |
|
if (TOF )t->GetFriend("ToF")-> SetBranchAddress("TrackNuclei",&tof_nuc_obj); |
3775 |
|
if (ORB )t->GetFriend("OrbitalInfo")->SetBranchAddress("TrackNuclei",&orb_nuc_obj); |
3776 |
|
|
3777 |
|
///copy the vector content inside a "fake" object (all aother info are missing) |
3778 |
|
|
3779 |
|
if( !trk2_nuc_obj )trk2_nuc_obj = new TrkLevel2(); |
3780 |
|
if( !calo2_nuc_obj )calo2_nuc_obj = new CaloLevel2(); |
3781 |
|
if( !tof2_nuc_obj )tof2_nuc_obj = new ToFLevel2(); |
3782 |
|
if( !orb2_nuc_obj )orb2_nuc_obj = new OrbitalInfo(); |
3783 |
|
|
3784 |
|
// *(trk2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*trk_nuc_obj); |
3785 |
|
// *(calo2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*calo_nuc_obj); |
3786 |
|
// *(tof2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*tof_nuc_obj); |
3787 |
|
// *(orb2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*orb_nuc_obj); |
3788 |
|
trk2_nuc_obj->SetTrackArray( trk_nuc_obj ); |
3789 |
|
calo2_nuc_obj->SetTrackArray( calo_nuc_obj ); |
3790 |
|
tof2_nuc_obj->SetTrackArray( tof_nuc_obj ); |
3791 |
|
orb2_nuc_obj->SetTrackArray( orb_nuc_obj ); |
3792 |
|
|
3793 |
|
} |
3794 |
|
if(EXT){ |
3795 |
|
|
3796 |
|
cout << "Found extended tracking algorythm branches" << endl; |
3797 |
|
|
3798 |
|
t->SetBranchAddress("extAlgFlag",&extAlgFlag); |
3799 |
|
|
3800 |
|
if( !trk_ext_obj )trk_ext_obj = new TClonesArray("ExtTrack"); |
3801 |
|
if( !calo_ext_obj)calo_ext_obj= new TClonesArray("CaloTrkVar"); |
3802 |
|
if( !tof_ext_obj)tof_ext_obj= new TClonesArray("ToFTrkVar"); |
3803 |
|
if( !orb_ext_obj)orb_ext_obj= new TClonesArray("OrbitalInfoTrkVar"); |
3804 |
|
|
3805 |
|
if (TRK2)t-> SetBranchAddress("RecoveredTrack",&trk_ext_obj); |
3806 |
|
if (CAL2)t->GetFriend("Calorimeter")->SetBranchAddress("RecoveredTrack",&calo_ext_obj); |
3807 |
|
if (TOF )t->GetFriend("ToF")-> SetBranchAddress("RecoveredTrack",&tof_ext_obj); |
3808 |
|
if (ORB )t->GetFriend("OrbitalInfo")->SetBranchAddress("RecoveredTrack",&orb_ext_obj); |
3809 |
|
|
3810 |
|
if(NUC){ |
3811 |
|
if( !trk_ext_nuc_obj )trk_ext_nuc_obj = new TClonesArray("ExtTrack"); |
3812 |
|
if( !calo_ext_nuc_obj)calo_ext_nuc_obj= new TClonesArray("CaloTrkVar"); |
3813 |
|
if( !tof_ext_nuc_obj)tof_ext_nuc_obj= new TClonesArray("ToFTrkVar"); |
3814 |
|
if( !orb_ext_nuc_obj)orb_ext_nuc_obj= new TClonesArray("OrbitalInfoTrkVar"); |
3815 |
|
if (TRK2)t-> SetBranchAddress("RecoveredTrackNuclei",&trk_ext_nuc_obj); |
3816 |
|
if (CAL2)t->GetFriend("Calorimeter")->SetBranchAddress("RecoveredTrackNuclei",&calo_ext_nuc_obj); |
3817 |
|
if (TOF )t->GetFriend("ToF")-> SetBranchAddress("RecoveredTrackNuclei",&tof_ext_nuc_obj); |
3818 |
|
if (ORB )t->GetFriend("OrbitalInfo")->SetBranchAddress("RecoveredTrackNuclei",&orb_ext_nuc_obj); |
3819 |
|
} |
3820 |
|
} |
3821 |
|
|
3822 |
} |
} |
3823 |
|
|
3824 |
|
/** |
3825 |
|
* Set the tracking algorythm |
3826 |
|
* @param alg String to choose the track. |
3827 |
|
* "" --> take the output of the standard tracking algorythm |
3828 |
|
* "STD" --> take the output of the standard tracking algorythm |
3829 |
|
* "NUC" --> take the output of the standard tracking algorythm for nuclei cluster selection |
3830 |
|
* "EXT" --> in case the standard tracking algorythm has not found any track, take the output of the extended one |
3831 |
|
* "EXTF" --> force the extended tracking algorythm |
3832 |
|
* "NUCEXT" --> as "EXT", but for nuclei |
3833 |
|
* "NUCEXTF" --> as "EXTF", but for nuclei |
3834 |
|
*/ |
3835 |
|
// void PamLevel2::SetTrackingAlgorythm(const char *alg){ |
3836 |
|
|
3837 |
|
|
3838 |
|
// TString s(alg); |
3839 |
|
// if(s.Contains("NUC", TString::kIgnoreCase) && !NUC) |
3840 |
|
// cout << "Warning! NUC algorythm requested, but branches are missing"<<endl; |
3841 |
|
// if(s.Contains("EXT", TString::kIgnoreCase) && !EXT) |
3842 |
|
// cout << "Warning! EXT algorythm requested, but branches are missing"<<endl;; |
3843 |
|
|
3844 |
|
// trkAlg = alg; |
3845 |
|
|
3846 |
|
// }; |
3847 |
|
// const char* PamLevel2::GetTrackingAlgorythm(){ |
3848 |
|
|
3849 |
|
|
3850 |
|
// cout<<endl<<" Implemented tracking algorythm: "; |
3851 |
|
// cout<<endl<<" \"\" or \"STD\" --> take the output of the standard tracking algorythm"; |
3852 |
|
// cout<<endl<<" \"NUC\" --> take the output of the standard tracking algorythm for nuclei cluster selection"; |
3853 |
|
// cout<<endl<<" \"EXT\" --> in case the standard tracking algorythm has not found any track,"; |
3854 |
|
// cout<<endl<<" take the output of the extended one"; |
3855 |
|
// cout<<endl<<" \"EXTF\" --> force the extended tracking algorythm"; |
3856 |
|
// cout<<endl<<" \"NUCEXT\" --> as \"EXT\", but for nuclei "; |
3857 |
|
// cout<<endl<<" \"NUCEXTF\" --> as \"EXTF\", but for nuclei"; |
3858 |
|
|
3859 |
|
// cout<<endl; |
3860 |
|
// cout<<" <<Currently set algorythm>> "<<trkAlg<<endl; |
3861 |
|
// cout<<endl; |
3862 |
|
|
3863 |
|
// return trkAlg; |
3864 |
|
// }; |
3865 |
|
|
3866 |
|
|
3867 |
|
|
3868 |
//-------------------------------------- |
//-------------------------------------- |
3869 |
// |
// |
3870 |
// |
// |
3898 |
}; |
}; |
3899 |
} |
} |
3900 |
|
|
3901 |
|
cout << "done run chain "<< R->GetNtrees() <<" \n"; |
3902 |
|
|
3903 |
|
|
3904 |
if (RUN && R->GetNtrees()) { |
if (RUN && R->GetNtrees()) { |
3905 |
|
|
3906 |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
3940 |
cout << "----------------------------------------------------" << endl; |
cout << "----------------------------------------------------" << endl; |
3941 |
|
|
3942 |
} |
} |
3943 |
else { |
// else { |
3944 |
delete R; |
// delete R; |
3945 |
R = 0; |
// R = 0; |
3946 |
} |
// } |
3947 |
|
|
3948 |
run_tree = R; |
run_tree = R; |
3949 |
|
|
3982 |
return T; |
return T; |
3983 |
|
|
3984 |
} |
} |
|
/** |
|
|
* Update the runinfo informations (to be used to have Run infos event by event basis) |
|
|
* @param run Pointer to the chain/tree which contains run infos |
|
|
* @return true if a new run has been read, false if it is still the same run |
|
|
*/ |
|
|
Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev) { |
|
|
// |
|
|
// check if we have already called once GetEntry, if not call it |
|
|
// |
|
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev) --- ATTENZIONE --- NON E` MANTENUTA!!!!!!!.... " |
|
|
<< endl; |
|
|
if (!run) { |
|
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing RunInfo tree " << endl; |
|
|
return (false); |
|
|
} |
|
|
if (run->GetEntries() <= 0) |
|
|
return (false); |
|
|
// |
|
|
|
|
|
// Int_t oldrun = irun; |
|
|
Long64_t oldrun = irun; |
|
|
|
|
|
// -------------------------------------- |
|
|
// if it is a full file (not preselected) |
|
|
// -------------------------------------- |
|
|
if (SELLI == 0) { |
|
|
|
|
|
// |
|
|
// the absolute time is necessary to relate the event with the run |
|
|
// |
|
|
if (!GetOrbitalInfo() && !ISGP) { |
|
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo " << endl; |
|
|
return (false); |
|
|
} |
|
|
|
|
|
ULong64_t abstime = 0; |
|
|
if (GetOrbitalInfo()) |
|
|
abstime = GetOrbitalInfo()->absTime; |
|
|
|
|
|
// |
|
|
// the first time the routine is called, set run search from the beginning |
|
|
// |
|
|
if (irun < 0LL) { |
|
|
irun = 0LL; |
|
|
run->GetEntry(irun); |
|
|
runfirstentry = 0LL; |
|
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
|
|
if ((Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL) |
|
|
runlastentry -= 1LL; |
|
|
|
|
|
if (ISGP && run->GetEntries() != 1) { |
|
|
cout << "** WARNING ** simulated files are assumed to have 1 single run, not " << run->GetEntries() << endl; |
|
|
cout << "** WARNING ** run will not be updated" << endl; |
|
|
} |
|
|
|
|
|
}; |
|
|
// |
|
|
if (ISGP) |
|
|
abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO |
|
|
// |
|
|
if (irun == run->GetEntries() - 1LL && !(abstime >= GetRunInfo()->RUNHEADER_TIME && abstime |
|
|
<= GetRunInfo()->RUNTRAILER_TIME)) { |
|
|
irun = -1LL; |
|
|
irunt = -1LL; |
|
|
runfirstentry = 0LL; |
|
|
runlastentry = -1LL; |
|
|
}; |
|
|
// modificato il controllo sull'aggiornamento del run, per evitare problemi |
|
|
// dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!) |
|
|
// |
|
|
bool fromfirst = true; |
|
|
// |
|
|
while (!(abstime >= GetRunInfo()->RUNHEADER_TIME && abstime <= GetRunInfo()->RUNTRAILER_TIME) && irun |
|
|
< run->GetEntries() - 1LL) { |
|
|
// while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
|
|
irun++; |
|
|
run->GetEntry(irun); |
|
|
runfirstentry = runlastentry; |
|
|
if ((Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL) |
|
|
runfirstentry += 1LL; |
|
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
|
|
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
|
|
// cout << "runfirstentry "<<runfirstentry<<endl; |
|
|
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
|
|
// printf(" abstime %u trailertime %u \n",abstime,GetRunInfo()->RUNTRAILER_TIME); |
|
|
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
|
|
// |
|
|
// prevshift = 0; |
|
|
// |
|
|
if (irun == (Long64_t)(run->GetEntries() - 1LL) && fromfirst && !(abstime >= GetRunInfo()->RUNHEADER_TIME |
|
|
&& abstime <= GetRunInfo()->RUNTRAILER_TIME)) { |
|
|
printf(" resetting irun (it should NOT happen!!!)\n"); |
|
|
fromfirst = false; |
|
|
irun = 0; |
|
|
run->GetEntry(irun); |
|
|
runfirstentry = 0ULL; |
|
|
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
|
|
if ((Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL) |
|
|
runlastentry -= 1LL; |
|
|
}; |
|
|
// |
|
|
}; |
|
|
// |
|
|
if (!(abstime >= GetRunInfo()->RUNHEADER_TIME && abstime <= GetRunInfo()->RUNTRAILER_TIME)) { |
|
|
printf(" Something very wrong here: cannot find RUN containing absolute time %llu \n", abstime); |
|
|
return false; |
|
|
} |
|
|
// |
|
|
if (irun == oldrun || irun >= run->GetEntries()) |
|
|
return (false); |
|
|
// |
|
|
// printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); |
|
|
// |
|
|
prevshift = 0; |
|
|
cout << " ))))) UPDATE RUN INFO ((((( @iev " << iev << " run " << GetRunInfo()->ID << " irun " << irun << endl; |
|
|
// cout << "runfirstentry "<<runfirstentry<<endl; |
|
|
return (true); |
|
|
}; |
|
|
// ---------------------------------------------------- |
|
|
// if it is a preselected file (there is SelectionList) |
|
|
// NBNB - the event tree MUST be read first |
|
|
// ---------------------------------------------------- |
|
|
if (SELLI == 1) { |
|
|
sel_tree->GetEntry(iev); |
|
|
// cout << irun << " "<< irunentry << endl; |
|
|
if (irun != oldrun) { |
|
|
run->GetEntry(irun); |
|
|
cout << " ))))) UPDATE RUN INFO ((((( @iev " << iev << " run " << GetRunInfo()->ID << " irun " << irun << endl; |
|
|
prevshift = 0; |
|
|
return true; |
|
|
} |
|
|
return false; |
|
|
} |
|
|
|
|
|
return false; |
|
|
// |
|
|
} |
|
|
; |
|
3985 |
|
|
3986 |
Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) { |
Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) { |
3987 |
|
|
3988 |
|
if (DBG) printf("PamLevel2::UpdateRunInfo(Long64_t) - inside\n"); |
3989 |
|
|
3990 |
if (!run_tree) { |
if (!run_tree) { |
3991 |
cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree not loaded" << endl; |
cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree not loaded" << endl; |
3992 |
return false; |
return false; |
3996 |
return (false); |
return (false); |
3997 |
} |
} |
3998 |
|
|
3999 |
|
|
4000 |
Int_t oldrun = irun; // store current run index |
Int_t oldrun = irun; // store current run index |
4001 |
|
|
4002 |
// ----------------------------------------------------------------------- |
// ----------------------------------------------------------------------- |
4006 |
if (irun < 0) { |
if (irun < 0) { |
4007 |
irun = 0LL; |
irun = 0LL; |
4008 |
irunt = 0LL; |
irunt = 0LL; |
4009 |
irunentry = 0; |
totrunentry = 0LL; |
4010 |
|
totrunentrymin = 0LL; |
4011 |
|
totrunentrymax = 0LL; |
4012 |
|
irunentry = 0LL; |
4013 |
|
il0entry = 0LL; |
4014 |
prevshift = 0; |
prevshift = 0; |
4015 |
|
yprevshift = 0; |
4016 |
|
prevabstime = 0; |
4017 |
|
prevpktnum = 0; |
4018 |
|
abstime = 0ULL; |
4019 |
|
pktnum = 0; |
4020 |
|
isFragment = false; |
4021 |
run_tree->GetEntry(irun); |
run_tree->GetEntry(irun); |
4022 |
if (!GetOrbitalInfo()) |
if (!GetOrbitalInfo()) |
4023 |
cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated " << endl; |
cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated " << endl; |
4024 |
if (gltsync) |
if ( fUseDBinRunInfo ){ |
4025 |
delete gltsync; //Emiliano |
if (gltsync) |
4026 |
if (!dbc || (dbc && !dbc->IsConnected())) |
delete gltsync; //Emiliano |
4027 |
SetDBConnection(); //Emiliano |
if (!dbc || (dbc && !dbc->IsConnected())) |
4028 |
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); //Emiliano // the "false" means not to use level0 file (not necessary here) |
SetDBConnection(); //Emiliano |
4029 |
if (dbc){ |
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); //Emiliano // the "false" means not to use level0 file (not necessary here) |
4030 |
dbc->Close();// Emiliano |
if (dbc){ |
4031 |
dbc=0; |
dbc->Close();// Emiliano |
4032 |
}; |
delete dbc; |
4033 |
}; |
dbc=0; |
4034 |
|
} |
4035 |
|
} |
4036 |
|
} |
4037 |
// --------------------------------------------------------------- |
// --------------------------------------------------------------- |
4038 |
// retrieve OBT and absolute time of the event |
// retrieve OBT and absolute time of the event |
4039 |
// --------------------------------------------------------------- |
// --------------------------------------------------------------- |
|
ULong64_t abstime = 0LL; |
|
|
// ULong64_t obt = 0LL; // Emiliano |
|
4040 |
Long64_t obt = 0LL; // Emiliano, Long64_t GL_TIMESYNC::DBobt(UInt_t obt) since depending on the situation OBT is lowered or boosted |
Long64_t obt = 0LL; // Emiliano, Long64_t GL_TIMESYNC::DBobt(UInt_t obt) since depending on the situation OBT is lowered or boosted |
4041 |
|
prevabstime = abstime; |
4042 |
|
prevpktnum = pktnum; |
4043 |
if (GetOrbitalInfo()) { |
if (GetOrbitalInfo()) { |
4044 |
abstime = GetOrbitalInfo()->absTime; |
abstime = GetOrbitalInfo()->absTime; |
4045 |
obt = gltsync->DBobt(GetOrbitalInfo()->OBT); // Emiliano |
if ( fUseDBinRunInfo ) obt = gltsync->DBobt(GetOrbitalInfo()->OBT); // Emiliano |
4046 |
|
pktnum = GetOrbitalInfo()->pkt_num; // Emiliano |
4047 |
} |
} |
4048 |
else { |
else { |
4049 |
abstime = GetRunInfo()->RUNHEADER_TIME; |
abstime = GetRunInfo()->RUNHEADER_TIME; |
4050 |
obt = gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT); // Emiliano |
if ( fUseDBinRunInfo ) obt = gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT); // Emiliano |
4051 |
|
pktnum = GetRunInfo()->RUNHEADER_PKT; // Emiliano |
4052 |
|
} |
4053 |
|
|
4054 |
|
if (DBG){ |
4055 |
|
printf("0abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); |
4056 |
|
printf("0 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); |
4057 |
|
printf("0 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); |
4058 |
|
if ( fUseDBinRunInfo ) printf("0 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); |
4059 |
|
printf("0 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); |
4060 |
|
printf("0 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry); |
4061 |
} |
} |
4062 |
|
|
4063 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
4078 |
} |
} |
4079 |
|
|
4080 |
// |
// |
4081 |
bool fromfirst = true; // first loop over runs |
bool a = true; |
4082 |
|
bool b = true; |
4083 |
|
if ( fUseDBinRunInfo ){ |
4084 |
|
a = false; |
4085 |
|
b = false; |
4086 |
|
if ( obt < gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) ) a = true; |
4087 |
|
if ( obt > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ) b = true; |
4088 |
|
} |
4089 |
|
if ( iev < totrunentrymin || iev > totrunentrymax // entry is outside run limits |
4090 |
|
|| iev == 0 // or it is the first entry |
4091 |
|
|| (!isSync && ( |
4092 |
|
(abstime <= GetRunInfo()->RUNHEADER_TIME && a ) // or it is outside obt limits (and abstime limits for security reasons) |
4093 |
|
|| (abstime >= GetRunInfo()->RUNTRAILER_TIME && b ) ))// or it is outside obt limits (and abstime limits for security reasons) |
4094 |
|
){ // check on abstime and obt needed to handle nested+DV_skipped packets |
4095 |
|
|
4096 |
|
// check for a new run (ma prima il primo!) |
4097 |
|
if (DBG){ |
4098 |
|
printf("1abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); |
4099 |
|
printf("1 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); |
4100 |
|
printf("1 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); |
4101 |
|
if ( fUseDBinRunInfo ) printf("1 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); |
4102 |
|
printf("1 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); |
4103 |
|
printf("1 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry); |
4104 |
|
} |
4105 |
|
// printf("1abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); |
4106 |
|
// printf("1 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); |
4107 |
|
// printf("1 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); |
4108 |
|
// printf("1 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); |
4109 |
|
// printf("1 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); |
4110 |
|
// printf("1 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry);//TOGLITOGLI |
4111 |
|
|
4112 |
// ------------------------------------------------------ |
totrunentry = 0LL; |
4113 |
// loop over runs to find the one that contains the event |
runfirstentry = 0LL; |
4114 |
// ------------------------------------------------------ |
for (Int_t r=0; r< run_tree->GetEntries();r++){ |
4115 |
while (( |
// ------------------------------------------------------------------- |
4116 |
// ( |
// save the index of the first entry of the run, relative to pam_tree, |
4117 |
// !(abstime >= GetRunInfo()->RUNHEADER_TIME && // check on absolute time (s) |
// and read a new run |
4118 |
// abstime <= GetRunInfo()->RUNTRAILER_TIME) && |
// ------------------------------------------------------------------- |
4119 |
// !(obt >= GetRunInfo()->RUNHEADER_OBT && // additional check on OBT (ms) |
run_tree->GetEntry(r);//update runinfo |
4120 |
// obt <= GetRunInfo()->RUNTRAILER_OBT) |
if ( r > 0 ){ |
4121 |
// ) |
totrunentrymin = totrunentrymax+1; |
4122 |
|
} else { |
4123 |
!(abstime >= GetRunInfo()->RUNHEADER_TIME && // check on absolute time (s) |
totrunentrymin = 0LL; |
4124 |
abstime <= GetRunInfo()->RUNTRAILER_TIME) || !(obt >= gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) && // additional check on OBT (ms) // Emiliano |
} |
4125 |
obt <= gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) // Emiliano |
totrunentry += GetRunInfo()->NEVENTS; |
4126 |
|| GetRunInfo()->NEVENTS == 0 |
totrunentrymax = totrunentry - 1 - prevshift; // prevshift is needed to handle nested+DV_skipped packets |
4127 |
// || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift) // ERRORE!!! fa saltare i run con 1 evento |
irun = r; |
4128 |
|| !(irunentry <= GetRunInfo()->NEVENTS - 1 - prevshift)) && irun < run_tree->GetEntries()) { |
if ( fUseDBinRunInfo ){ |
4129 |
|
a = false; |
4130 |
// if( !(abstime >= GetRunInfo()->RUNHEADER_TIME &&abstime <= GetRunInfo()->RUNTRAILER_TIME) )cout << "ABS TIME "<<abstime << " " <<GetRunInfo()->RUNTRAILER_TIME <<endl; |
b = false; |
4131 |
// if( !(obt >= GetRunInfo()->RUNHEADER_OBT && obt <= GetRunInfo()->RUNTRAILER_OBT) )cout << "OBT TIME "<< obt <<" "<< GetRunInfo()->RUNTRAILER_OBT << endl; |
if ( obt < gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) ) a = true; |
4132 |
// if( GetRunInfo()->NEVENTS==0 )cout <<"GetRunInfo()->NEVENTS==0 "<<endl; |
if ( obt > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ) b = true; |
4133 |
// if( !(irunentry <= GetRunInfo()->NEVENTS-1-prevshift) ) cout << "irunentry > "<<GetRunInfo()->NEVENTS-1-prevshift << endl; |
} |
4134 |
// - - - - - - - - - - - - - |
if ( (iev >= totrunentrymin && iev <= totrunentrymax) || // entry is inside run limits |
4135 |
// irunentry = position of current entry, relative to the run |
( !isSync && |
4136 |
// prevshift = shift needed to synchronize l0 and l2 data (nested events) |
( abstime >= GetRunInfo()->RUNHEADER_TIME && a // or it is inside obt limits (and abstime limits for security reasons) |
4137 |
// - - - - - - - - - - - - - |
&& abstime <= GetRunInfo()->RUNTRAILER_TIME && b)) // or it is inside obt limits (and abstime limits for security reasons) |
4138 |
|
){ // check on abstime and obt needed to handle nested+DV_skipped packets |
4139 |
// ----------------------------------------- |
if ( totrunentrymin > iev ){ // there is a shift (nested+DV_skipped packets) |
4140 |
// store dead and live-time of previous run |
if ( !isSync ){ |
4141 |
// ----------------------------------------- |
if (DBG) printf("PamLevel2::UpdateRunInfo(Long64_t) - unconsistent iev - nevents, probable DBL0-L2 async\n"); |
4142 |
// if(SELLI==0){ |
if (DBG) printf("PamLevel2::UpdateRunInfo(Long64_t) - totrunentrymin %lld iev %lld prevshift %lld totrunentrymax %lld \n",totrunentrymin,iev,prevshift,totrunentrymax); |
4143 |
if (SELLI != 2) { |
// printf("PamLevel2::UpdateRunInfo(Long64_t) - unconsistent iev - nevents, probable DBL0-L2 async\n"); |
4144 |
if (fromfirst) { |
// printf("PamLevel2::UpdateRunInfo(Long64_t) - totrunentrymin %lld iev %lld prevshift %lld totrunentrymax %lld \n",totrunentrymin,iev,prevshift,totrunentrymax);//TOGLITOGLI |
4145 |
if (oldrun == irun) { |
prevshift += (totrunentrymin-iev); // add the new shift to total shift |
4146 |
/// decrement counters |
totrunentrymin -= (totrunentrymin-iev); // shift run position min |
4147 |
if (GetTrigLevel2()) { |
totrunentrymax -= (totrunentrymin-iev); // shift run position max |
4148 |
totdltime[0] -= GetTrigLevel2()->dltime[0];//live-time |
if (DBG) printf("PamLevel2::UpdateRunInfo(Long64_t) - totrunentrymin %lld iev %lld prevshift %lld totrunentrymax %lld \n",totrunentrymin,iev,prevshift,totrunentrymax); |
4149 |
totdltime[1] -= GetTrigLevel2()->dltime[1];//dead-time |
// printf("PamLevel2::UpdateRunInfo(Long64_t) - totrunentrymin %lld iev %lld prevshift %lld totrunentrymax %lld \n",totrunentrymin,iev,prevshift,totrunentrymax);//TOGLITOGLI |
4150 |
} |
} else { |
4151 |
totdltime[2]--; //event counter |
printf(" PamLevel2::UpdateRunInfo(Long64_t) ERROR! sync file but unconsistent totrunetrymin %lld and iev %lld!!! \n",totrunentrymin,iev); |
4152 |
if (DBG) { |
cout << " OK this is a bug, write to Emiliano, Emiliano.Mocchiutti@ts.infn.it " << endl; |
4153 |
cout << endl; |
cout << "\nFor bug reporting instructions, please see for example:\n"; |
4154 |
cout << "n.events : " << totdltime[2] << endl; |
cout << " <http://www.ts.infn.it/~mocchiut/bugs/bugs.html>.\n"; |
4155 |
cout << "RUN LIVE-TIME: " << totdltime[0] * 0.16 << " ms" << endl; |
cout << " " << endl; |
|
cout << "RUN DEAD-TIME: " << totdltime[1] * 0.01 << " ms" << endl; |
|
4156 |
} |
} |
4157 |
} |
} |
4158 |
else { |
runfirstentry = totrunentrymin; // first entry of the run in the level2 |
4159 |
totdltime[0] = 0;//live-time |
|
4160 |
totdltime[1] = 0;//dead-time |
|
4161 |
totdltime[2] = 0; //event counter |
// |
4162 |
if (DBG) |
if ( fUseDBinRunInfo ){ |
4163 |
cout << " *** JUMP RUN *** irun " << irun << endl; |
if (gltsync) |
4164 |
|
delete gltsync; // Emiliano |
4165 |
|
if (!dbc || (dbc && !dbc->IsConnected())) |
4166 |
|
SetDBConnection(); //Emiliano |
4167 |
|
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); // Emiliano |
4168 |
|
TrkParams::Set(GetRunInfo(), dbc); |
4169 |
|
if (dbc){ |
4170 |
|
dbc->Close(); // Emiliano |
4171 |
|
delete dbc; |
4172 |
|
dbc=0; |
4173 |
|
} |
4174 |
|
if (gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) { // Emiliano |
4175 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun " << irun |
4176 |
|
<< " has RUNHEADER_OBT>=RUNTRAILER_OBT " << endl; |
4177 |
|
cout |
4178 |
|
<< " (NB!! in this case some events could be assigned to a wrong run)" |
4179 |
|
<< endl; |
4180 |
|
} |
4181 |
} |
} |
4182 |
/// add an entry |
// |
4183 |
if (run_tree_clone) |
if (DBG) printf(" found \n"); |
4184 |
if (run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) |
// printf(" found \n");//TOGLITOGLI |
4185 |
run_tree_clone->GetBranch("DeadLiveTime")->Fill(); |
// |
4186 |
/// reset counters |
break; |
4187 |
|
} |
4188 |
|
} // loop over run |
4189 |
|
|
4190 |
|
// -------------------------------------- |
4191 |
|
// if there was no need to update the run |
4192 |
|
// ---> exit with FALSE |
4193 |
|
// -------------------------------------- |
4194 |
|
if (irun == oldrun){ |
4195 |
|
if (DBG) printf(" no new run \n"); |
4196 |
|
// printf(" no new run \n");//TOGLITOGLI |
4197 |
|
return (false); |
4198 |
|
} |
4199 |
|
// -------------------------------------- |
4200 |
|
// ... otherwise |
4201 |
|
// ---> exit with TRUE |
4202 |
|
// -------------------------------------- |
4203 |
|
|
4204 |
|
if (SELLI != 2) { |
4205 |
|
/// decrement counters since this event belongs to a new run |
4206 |
|
if (GetTrigLevel2()) { |
4207 |
|
totdltime[0] -= GetTrigLevel2()->dltime[0];//live-time |
4208 |
|
totdltime[1] -= GetTrigLevel2()->dltime[1];//dead-time |
4209 |
|
} |
4210 |
|
totdltime[2]--; //event counter |
4211 |
|
if (DBG) { |
4212 |
|
cout << endl; |
4213 |
|
cout << "n.events : " << totdltime[2] << endl; |
4214 |
|
cout << "RUN LIVE-TIME: " << totdltime[0] * 0.16 << " ms" << endl; |
4215 |
|
cout << "RUN DEAD-TIME: " << totdltime[1] * 0.01 << " ms" << endl; |
4216 |
|
} |
4217 |
|
// add an entry |
4218 |
|
if (run_tree_clone && totdltime[2] > 0) |
4219 |
|
if (run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) |
4220 |
|
run_tree_clone->GetBranch("DeadLiveTime")->Fill(); |
4221 |
|
// reset counters |
4222 |
|
if ( totdltime[2] > 0 ){ |
4223 |
if (GetTrigLevel2()) { |
if (GetTrigLevel2()) { |
4224 |
totdltime[0] = GetTrigLevel2()->dltime[0];//live-time |
totdltime[0] = GetTrigLevel2()->dltime[0];//live-time |
4225 |
totdltime[1] = 0; //dead-time |
totdltime[1] = 0; //dead-time |
4227 |
totdltime[2] = 1; //event counter |
totdltime[2] = 1; //event counter |
4228 |
} |
} |
4229 |
} |
} |
|
// } |
|
4230 |
|
|
4231 |
irun++; |
if (DBG){ |
4232 |
// ------------------------------------ |
cout << endl << " ))))) UPDATE RUN INFO ((((( @iev " << iev << " run " << GetRunInfo()->ID << " irun " << irun |
4233 |
// if the end of run tree is reached... |
<< endl; |
4234 |
// ------------------------------------ |
printf("2abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); |
4235 |
if (irun == run_tree->GetEntries()) { |
printf("2 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); |
4236 |
if (!fromfirst) { |
printf("2 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); |
4237 |
// ----------------------------------------------------- |
if ( fUseDBinRunInfo ) printf("2 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); |
4238 |
// if it happened already once and the run was not found |
printf("2 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); |
4239 |
// ---> exit with error |
printf("2 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry); |
|
// ----------------------------------------------------- |
|
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- event entry #" << iev |
|
|
<< " does not belong to any run (should not happen)" << endl; |
|
|
return false; |
|
|
} |
|
|
// ----------------------------------------- |
|
|
// ...otherwise repeat search from beginning |
|
|
// ----------------------------------------- |
|
|
cout |
|
|
<< "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- reached end of run tree. searchin again from beginning " |
|
|
<< endl; |
|
|
fromfirst = false; |
|
|
irun = 0LL; |
|
|
runfirstentry = 0LL; |
|
4240 |
} |
} |
4241 |
// ------------------------------------------------------------------- |
// printf("2abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); |
4242 |
// save the index of the first entry of the run, relative to pam_tree, |
// printf("2 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); |
4243 |
// and read a new run |
// printf("2 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); |
4244 |
// ------------------------------------------------------------------- |
// printf("2 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); |
4245 |
if (irun > 0) |
// printf("2 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); |
4246 |
runfirstentry += (GetRunInfo()->NEVENTS) - prevshift; |
// printf("2 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry);//TOGLITOGLI |
4247 |
irunentry = 0; |
|
4248 |
prevshift = 0; |
return (true); |
4249 |
run_tree->GetEntry(irun);//update runinfo |
} // need for run upgrade |
4250 |
irunt = irun - irunoffset[run_tree->GetTreeNumber()]; |
if (DBG) printf("return false\n"); |
4251 |
if (gltsync) |
return (false); |
4252 |
delete gltsync; // Emiliano |
}// SELLI = 0 SELLI = 2 |
4253 |
if (!dbc || (dbc && !dbc->IsConnected())) |
|
|
SetDBConnection(); //Emiliano |
|
|
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); // Emiliano |
|
|
if (dbc){ |
|
|
dbc->Close(); // Emiliano |
|
|
dbc=0; |
|
|
}; |
|
|
if (gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) { // Emiliano |
|
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun " << irun |
|
|
<< " has RUNHEADER_OBT>=RUNTRAILER_OBT " << endl; |
|
|
cout |
|
|
<< " (NB!! in this case some events are assigned to a wrong run)" |
|
|
<< endl; |
|
|
} |
|
|
// if(hasfrag && fragid != GetRunInfo()->ID){ |
|
|
// cout << "... where is the next fragment ??"<<endl; |
|
|
// } |
|
|
}; |
|
|
|
|
|
// -------------------------------------- |
|
|
// if there was no need to update the run |
|
|
// ---> exit with FALSE |
|
|
// -------------------------------------- |
|
|
if (irun == oldrun) |
|
|
return (false); |
|
|
|
|
|
// -------------------------------------- |
|
|
// ... otherwise |
|
|
// -------------------------------------- |
|
|
|
|
|
|
|
|
// -------------------------------------- |
|
|
// ---> exit with TRUE |
|
|
// -------------------------------------- |
|
|
if (DBG) |
|
|
cout << endl << " ))))) UPDATE RUN INFO ((((( @iev " << iev << " run " << GetRunInfo()->ID << " irun " << irun |
|
|
<< endl; |
|
|
// ---------------------------------------------------- |
|
|
// update the tracker parameters |
|
|
// (non ho trovato nessun altro modo sicuro di farlo...) |
|
|
// ---------------------------------------------------- |
|
|
if (!dbc || (dbc && !dbc->IsConnected())) |
|
|
SetDBConnection(); |
|
|
TrkParams::Set(GetRunInfo(), dbc); |
|
|
if (dbc){ |
|
|
dbc->Close(); |
|
|
dbc=0; |
|
|
}; |
|
|
|
|
|
// ---------------------------------------------------- |
|
|
// then check if the run has a fragment |
|
|
// in this case we have to switch to the next fragment |
|
|
// when the end of the first fragment is reached |
|
|
// ---------------------------------------------------- |
|
|
if (GetRunInfo()->ID_RUN_FRAG != 0 && |
|
|
// GetRunInfo()->ID_RUN_FRAG != GetRunInfo()->ID && |
|
|
DBG && true) { |
|
|
cout << "* fragment *" << endl; |
|
|
} |
|
|
|
|
|
return (true); |
|
|
}; |
|
4254 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
4255 |
// if it is a preselected file (there is SelectionList) |
// if it is a preselected file (there is SelectionList) |
4256 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
4325 |
// update the tracker parameters |
// update the tracker parameters |
4326 |
// (non ho trovato nessun altro modo sicuro di farlo...) |
// (non ho trovato nessun altro modo sicuro di farlo...) |
4327 |
// ---------------------------------------------------- |
// ---------------------------------------------------- |
4328 |
if (!dbc || (dbc && !dbc->IsConnected())) |
if ( fUseDBinRunInfo ){ |
4329 |
SetDBConnection(); |
if (!dbc || (dbc && !dbc->IsConnected())) |
4330 |
TrkParams::Set(GetRunInfo(), dbc); |
SetDBConnection(); |
4331 |
if (dbc){ |
TrkParams::Set(GetRunInfo(), dbc); |
4332 |
dbc->Close(); |
if (dbc){ |
4333 |
dbc=0; |
dbc->Close(); |
4334 |
}; |
delete dbc; |
4335 |
|
dbc=0; |
4336 |
|
} |
4337 |
|
} |
4338 |
// cout << endl; |
// cout << endl; |
4339 |
prevshift = 0; |
prevshift = 0; |
4340 |
|
yprevshift = 0; |
4341 |
return true; |
return true; |
4342 |
} |
} |
4343 |
return false; |
return false; |
4346 |
return false; |
return false; |
4347 |
// |
// |
4348 |
} |
} |
4349 |
; |
|
4350 |
|
/** |
4351 |
|
* Update the runinfo informations (to be used to have Run infos event by event basis) |
4352 |
|
* @param run Pointer to the chain/tree which contains run infos |
4353 |
|
* @return true if a new run has been read, false if it is still the same run |
4354 |
|
*/ |
4355 |
|
Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev) { |
4356 |
|
return (UpdateRunInfo(iev)); |
4357 |
|
} |
4358 |
|
|
4359 |
/** |
/** |
4360 |
* Update the runinfo informations (to be used to have Run infos event by event basis) |
* Update the runinfo informations (to be used to have Run infos event by event basis) |
4361 |
* @param run Pointer to the chain/tree which contains run infos |
* @param run Pointer to the chain/tree which contains run infos |
4364 |
Bool_t PamLevel2::UpdateRunInfo(TTree *run, Long64_t iev) { |
Bool_t PamLevel2::UpdateRunInfo(TTree *run, Long64_t iev) { |
4365 |
return (UpdateRunInfo((TChain*) run, iev)); |
return (UpdateRunInfo((TChain*) run, iev)); |
4366 |
} |
} |
4367 |
; |
|
4368 |
|
|
4369 |
//-------------------------------------- |
//-------------------------------------- |
4370 |
// |
// |
4602 |
// cout << "Checking file: "<<f->GetName()<<endl; |
// cout << "Checking file: "<<f->GetName()<<endl; |
4603 |
if (!f || f->IsZombie()) { |
if (!f || f->IsZombie()) { |
4604 |
cout << "File: " << f->GetName() << " Non valid root file" << endl; |
cout << "File: " << f->GetName() << " Non valid root file" << endl; |
4605 |
|
fDiscarded = true; |
4606 |
return; |
return; |
4607 |
} |
} |
4608 |
|
|
4809 |
TFile *f = new TFile(name.Data()); |
TFile *f = new TFile(name.Data()); |
4810 |
if (!f || f->IsZombie()) { |
if (!f || f->IsZombie()) { |
4811 |
cout << "File: " << f->GetName() << " discarded ---- Non valid root file" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Non valid root file" << endl; |
4812 |
|
fDiscarded = true; |
4813 |
return false; |
return false; |
4814 |
} |
} |
4815 |
// cout << "Get list of keys: "<<f<<endl; |
// cout << "Get list of keys: "<<f<<endl; |
4848 |
if (nev && nevt != nev) { |
if (nev && nevt != nev) { |
4849 |
cout << "File: " << f->GetName() << " discarded ---- SelectionList tree has " << nevt |
cout << "File: " << f->GetName() << " discarded ---- SelectionList tree has " << nevt |
4850 |
<< " events instead of " << nev << endl; |
<< " events instead of " << nev << endl; |
4851 |
|
fDiscarded = true; |
4852 |
return false; |
return false; |
4853 |
} |
} |
4854 |
nev = nevt; |
nev = nevt; |
4863 |
if (nev && nevt != nev) { |
if (nev && nevt != nev) { |
4864 |
cout << "File: " << f->GetName() << " discarded ---- Trigger tree has " << nevt << " events instead of " |
cout << "File: " << f->GetName() << " discarded ---- Trigger tree has " << nevt << " events instead of " |
4865 |
<< nev << endl; |
<< nev << endl; |
4866 |
|
fDiscarded = true; |
4867 |
return false; |
return false; |
4868 |
} |
} |
4869 |
nev = nevt; |
nev = nevt; |
4877 |
if (nev && nevt != nev) { |
if (nev && nevt != nev) { |
4878 |
cout << "File: " << f->GetName() << " discarded ---- ToF tree has " << nevt << " events instead of " << nev |
cout << "File: " << f->GetName() << " discarded ---- ToF tree has " << nevt << " events instead of " << nev |
4879 |
<< endl; |
<< endl; |
4880 |
|
fDiscarded = true; |
4881 |
return false; |
return false; |
4882 |
} |
} |
4883 |
nev = nevt; |
nev = nevt; |
4891 |
if (nev && nevt != nev) { |
if (nev && nevt != nev) { |
4892 |
cout << "File: " << f->GetName() << " discarded ---- S4 tree has " << nevt << " events instead of " << nev |
cout << "File: " << f->GetName() << " discarded ---- S4 tree has " << nevt << " events instead of " << nev |
4893 |
<< endl; |
<< endl; |
4894 |
|
fDiscarded = true; |
4895 |
return false; |
return false; |
4896 |
} |
} |
4897 |
nev = nevt; |
nev = nevt; |
4906 |
if (nev && nevt != nev) { |
if (nev && nevt != nev) { |
4907 |
cout << "File: " << f->GetName() << " discarded ---- NeutronD tree has " << nevt << " events instead of " |
cout << "File: " << f->GetName() << " discarded ---- NeutronD tree has " << nevt << " events instead of " |
4908 |
<< nev << endl; |
<< nev << endl; |
4909 |
|
fDiscarded = true; |
4910 |
return false; |
return false; |
4911 |
} |
} |
4912 |
nev = nevt; |
nev = nevt; |
4920 |
if (nev && nevt != nev) { |
if (nev && nevt != nev) { |
4921 |
cout << "File: " << f->GetName() << " discarded ---- Anticounter tree has " << nevt << " events instead of " |
cout << "File: " << f->GetName() << " discarded ---- Anticounter tree has " << nevt << " events instead of " |
4922 |
<< nev << endl; |
<< nev << endl; |
4923 |
|
fDiscarded = true; |
4924 |
return false; |
return false; |
4925 |
} |
} |
4926 |
nev = nevt; |
nev = nevt; |
4934 |
if (nev && nevt != nev) { |
if (nev && nevt != nev) { |
4935 |
cout << "File: " << f->GetName() << " discarded ---- OrbitalInfo tree has " << nevt << " events instead of " |
cout << "File: " << f->GetName() << " discarded ---- OrbitalInfo tree has " << nevt << " events instead of " |
4936 |
<< nev << endl; |
<< nev << endl; |
4937 |
|
fDiscarded = true; |
4938 |
return false; |
return false; |
4939 |
} |
} |
4940 |
nev = nevt; |
nev = nevt; |
4948 |
if (nev && nevt != nev) { |
if (nev && nevt != nev) { |
4949 |
cout << "File: " << f->GetName() << " discarded ---- Tracker tree has " << nevt << " events instead of " |
cout << "File: " << f->GetName() << " discarded ---- Tracker tree has " << nevt << " events instead of " |
4950 |
<< nev << endl; |
<< nev << endl; |
4951 |
|
fDiscarded = true; |
4952 |
return false; |
return false; |
4953 |
} |
} |
4954 |
nev = nevt; |
nev = nevt; |
4972 |
if (nev && nevt != nev) { |
if (nev && nevt != nev) { |
4973 |
cout << "File: " << f->GetName() << " discarded ---- Calorimeter tree has " << nevt << " events instead of " |
cout << "File: " << f->GetName() << " discarded ---- Calorimeter tree has " << nevt << " events instead of " |
4974 |
<< nev << endl; |
<< nev << endl; |
4975 |
|
fDiscarded = true; |
4976 |
return false; |
return false; |
4977 |
} |
} |
4978 |
nev = nevt; |
nev = nevt; |
4995 |
if (nev && nevt != nev) { |
if (nev && nevt != nev) { |
4996 |
cout << "File: " << f->GetName() << " discarded ---- h20 tree has " << nevt << " events instead of " << nev |
cout << "File: " << f->GetName() << " discarded ---- h20 tree has " << nevt << " events instead of " << nev |
4997 |
<< endl; |
<< endl; |
4998 |
|
fDiscarded = true; |
4999 |
return false; |
return false; |
5000 |
} |
} |
5001 |
nev = nevt; |
nev = nevt; |
5008 |
SELLI = (Int_t) SELLI__ok; |
SELLI = (Int_t) SELLI__ok; |
5009 |
if (SELLI == 0 && SELLI__ok) { |
if (SELLI == 0 && SELLI__ok) { |
5010 |
cout << "File: " << f->GetName() << " discarded ---- found SelectionList (it is not a full-event file)" << endl; |
cout << "File: " << f->GetName() << " discarded ---- found SelectionList (it is not a full-event file)" << endl; |
5011 |
|
fDiscarded = true; |
5012 |
return false; |
return false; |
5013 |
} |
} |
5014 |
if (SELLI == 1 && !SELLI__ok) { |
if (SELLI == 1 && !SELLI__ok) { |
5015 |
cout << "File: " << f->GetName() << " discarded ---- SelectionList missing" << endl; |
cout << "File: " << f->GetName() << " discarded ---- SelectionList missing" << endl; |
5016 |
|
fDiscarded = true; |
5017 |
return false; |
return false; |
5018 |
} |
} |
5019 |
|
|
5052 |
|
|
5053 |
if (CAL1 && !CAL1__ok) { |
if (CAL1 && !CAL1__ok) { |
5054 |
cout << "File: " << f->GetName() << " discarded ---- Missing CaloLevel1 branch" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Missing CaloLevel1 branch" << endl; |
5055 |
|
fDiscarded = true; |
5056 |
return false; |
return false; |
5057 |
}; |
}; |
5058 |
if (CAL2 && !CAL2__ok) { |
if (CAL2 && !CAL2__ok) { |
5059 |
cout << "File: " << f->GetName() << " discarded ---- Missing CaloLevel2 branch" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Missing CaloLevel2 branch" << endl; |
5060 |
|
fDiscarded = true; |
5061 |
return false; |
return false; |
5062 |
}; |
}; |
5063 |
if (TRK2 && !TRK2__ok) { |
if (TRK2 && !TRK2__ok) { |
5064 |
cout << "File: " << f->GetName() << " discarded ---- Missing TrkLevel2 branch" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Missing TrkLevel2 branch" << endl; |
5065 |
|
fDiscarded = true; |
5066 |
return false; |
return false; |
5067 |
}; |
}; |
5068 |
if (TRK1 && !TRK1__ok) { |
if (TRK1 && !TRK1__ok) { |
5069 |
cout << "File: " << f->GetName() << " discarded ---- Missing TrkLevel1 branch" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Missing TrkLevel1 branch" << endl; |
5070 |
|
fDiscarded = true; |
5071 |
return false; |
return false; |
5072 |
}; |
}; |
5073 |
if (TRKh && !TRKh__ok) { |
if (TRKh && !TRKh__ok) { |
5074 |
cout << "File: " << f->GetName() << " discarded ---- Missing TrkHough branch" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Missing TrkHough branch" << endl; |
5075 |
|
fDiscarded = true; |
5076 |
return false; |
return false; |
5077 |
}; |
}; |
5078 |
if (ORB && !ORB__ok) { |
if (ORB && !ORB__ok) { |
5079 |
cout << "File: " << f->GetName() << " discarded ---- Missing ORB tree" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Missing ORB tree" << endl; |
5080 |
|
fDiscarded = true; |
5081 |
return false; |
return false; |
5082 |
}; |
}; |
5083 |
if (AC && !AC__ok) { |
if (AC && !AC__ok) { |
5084 |
cout << "File: " << f->GetName() << " discarded ---- Missing AC tree" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Missing AC tree" << endl; |
5085 |
|
fDiscarded = true; |
5086 |
return false; |
return false; |
5087 |
}; |
}; |
5088 |
if (S4 && !S4__ok) { |
if (S4 && !S4__ok) { |
5089 |
cout << "File: " << f->GetName() << " discarded ---- Missing S4 tree" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Missing S4 tree" << endl; |
5090 |
|
fDiscarded = true; |
5091 |
return false; |
return false; |
5092 |
}; |
}; |
5093 |
if (TOF && !TOF__ok) { |
if (TOF && !TOF__ok) { |
5094 |
cout << "File: " << f->GetName() << " discarded ---- Missing ToF tree" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Missing ToF tree" << endl; |
5095 |
|
fDiscarded = true; |
5096 |
return false; |
return false; |
5097 |
}; |
}; |
5098 |
|
|
5099 |
if (ND && !ND__ok) { |
if (ND && !ND__ok) { |
5100 |
cout << "File: " << f->GetName() << " discarded ---- Missing ND tree" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Missing ND tree" << endl; |
5101 |
|
fDiscarded = true; |
5102 |
return false; |
return false; |
5103 |
}; |
}; |
5104 |
if (TRG && !TRG__ok) { |
if (TRG && !TRG__ok) { |
5105 |
cout << "File: " << f->GetName() << " discarded ---- Missing Trigger tree" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Missing Trigger tree" << endl; |
5106 |
|
fDiscarded = true; |
5107 |
return false; |
return false; |
5108 |
}; |
}; |
5109 |
if (GP && !GP__ok) { |
if (GP && !GP__ok) { |
5110 |
cout << "File: " << f->GetName() << " discarded ---- Missing h20 tree" << endl; |
cout << "File: " << f->GetName() << " discarded ---- Missing h20 tree" << endl; |
5111 |
|
fDiscarded = true; |
5112 |
return false; |
return false; |
5113 |
}; |
}; |
5114 |
|
|
5208 |
// cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl; |
// cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl; |
5209 |
run_tree_clone->Fill(); |
run_tree_clone->Fill(); |
5210 |
} |
} |
5211 |
cout << "----------------------------------------------------" << endl; |
if ( PROC ){ |
5212 |
|
proc_tree_clone = new TTree("ProcessingInfo","Log of data processing"); |
5213 |
|
proc_tree_clone->Branch("ProcInfo", "ProcInfo", GetPointerTo("ProcInfo")); |
5214 |
|
cout << "ProcessingInfo: branch ProcessingInfo" << endl; |
5215 |
|
// ------------------ |
5216 |
|
// replicate processinginfo tree |
5217 |
|
// ------------------ |
5218 |
|
// cout << "----------------------------------------------------"<<endl; |
5219 |
|
// cout << "irun\t | RUN\t NEVENTS\t absolute time"<<endl; |
5220 |
|
for (Int_t i = 0; i < proc_tree->GetEntries(); i++) { |
5221 |
|
proc_tree->GetEntry(i); |
5222 |
|
// cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl; |
5223 |
|
proc_tree_clone->Fill(); |
5224 |
|
} |
5225 |
|
if ( SELLI != 2 || true ){ |
5226 |
|
proc_obj->runID = 0; |
5227 |
|
TTimeStamp *dt = new TTimeStamp(); |
5228 |
|
proc_obj->date = dt->AsString(); |
5229 |
|
delete dt; |
5230 |
|
proc_obj->commandLine = Form("PamelaLevel2 was called"); |
5231 |
|
proc_obj->outputFilename = ""; |
5232 |
|
proc_obj->localDir = gSystem->WorkingDirectory(); |
5233 |
|
proc_obj->uname = gSystem->GetFromPipe("uname -a"); |
5234 |
|
proc_obj->DB = Form("mysql://%s/%s",dbc->GetHost(),dbc->GetDB()); |
5235 |
|
proc_tree_clone->Fill(); |
5236 |
|
} |
5237 |
|
cout << "----------------------------------------------------" << endl; |
5238 |
|
} |
5239 |
// ------------------------------------ |
// ------------------------------------ |
5240 |
// add branch with dead and live times |
// add branch with dead and live times |
5241 |
// ------------------------------------ |
// ------------------------------------ |
5247 |
// sel_tree_clone->Branch("RunEntry",&irun,"runentry/L"); |
// sel_tree_clone->Branch("RunEntry",&irun,"runentry/L"); |
5248 |
sel_tree_clone->Branch("RunEntry", &irunt, "runentry/L");//NEWNEW |
sel_tree_clone->Branch("RunEntry", &irunt, "runentry/L");//NEWNEW |
5249 |
sel_tree_clone->Branch("EventEntry", &irunentry, "eventry/L"); |
sel_tree_clone->Branch("EventEntry", &irunentry, "eventry/L"); |
5250 |
|
// if ( hasL0EE ) sel_tree_clone->Branch("L0EventEntry", &il0entry, "l0eventry/L"); |
5251 |
}; |
}; |
5252 |
|
|
5253 |
Int_t i = 0; |
Int_t i = 0; |
5267 |
pam_tree_clone[i]->Branch("TrkHough", "TrkHough", GetPointerTo("TrkHough")); |
pam_tree_clone[i]->Branch("TrkHough", "TrkHough", GetPointerTo("TrkHough")); |
5268 |
cout << "Tracker : branch TrkHough" << endl; |
cout << "Tracker : branch TrkHough" << endl; |
5269 |
}; |
}; |
5270 |
|
if(NUC){ |
5271 |
|
pam_tree_clone[i]->Branch("TrackNuclei","TClonesArray",&trk_nuc_obj); |
5272 |
|
cout << "Tracker : branch TrackNuclei" << endl; |
5273 |
|
} |
5274 |
|
if(EXT){ |
5275 |
|
pam_tree_clone[i]->Branch("extAlgFlag",&extAlgFlag,"extAlgFlag/I"); |
5276 |
|
pam_tree_clone[i]->Branch("RecoveredTrack","TClonesArray",&trk_ext_obj); |
5277 |
|
cout << "Tracker : branch RecoveredTrack" << endl; |
5278 |
|
if(NUC){ |
5279 |
|
pam_tree_clone[i]->Branch("RecoveredTrackNuclei","TClonesArray",&trk_ext_nuc_obj); |
5280 |
|
cout << "Tracker : branch RecoveredTrackNuclei" << endl; |
5281 |
|
} |
5282 |
|
} |
5283 |
|
|
5284 |
i++; |
i++; |
5285 |
} |
} |
5286 |
|
|
5295 |
pam_tree_clone[i]->Branch("CaloLevel2", "CaloLevel2", GetPointerTo("CaloLevel2")); |
pam_tree_clone[i]->Branch("CaloLevel2", "CaloLevel2", GetPointerTo("CaloLevel2")); |
5296 |
cout << "Calorimeter : branch CaloLevel2" << endl; |
cout << "Calorimeter : branch CaloLevel2" << endl; |
5297 |
}; |
}; |
5298 |
|
if(NUC){ |
5299 |
|
pam_tree_clone[i]->Branch("TrackNuclei","TClonesArray",&calo_nuc_obj); |
5300 |
|
cout << "Calorimeter : branch TrackNuclei" << endl; |
5301 |
|
} |
5302 |
|
if(EXT){ |
5303 |
|
pam_tree_clone[i]->Branch("RecoveredTrack","TClonesArray",&calo_ext_obj); |
5304 |
|
cout << "Calorimeter : branch RecoveredTrack" << endl; |
5305 |
|
if(NUC){ |
5306 |
|
pam_tree_clone[i]->Branch("RecoveredTrackNuclei","TClonesArray",&calo_ext_nuc_obj); |
5307 |
|
cout << "Calorimeter : branch RecoveredTrackNuclei" << endl; |
5308 |
|
} |
5309 |
|
} |
5310 |
i++; |
i++; |
5311 |
} |
} |
5312 |
|
|
5315 |
pam_tree_clone[i] = new TTree("ToF", "PAMELA ToF level2 data "); |
pam_tree_clone[i] = new TTree("ToF", "PAMELA ToF level2 data "); |
5316 |
pam_tree_clone[i]->Branch("ToFLevel2", "ToFLevel2", GetPointerTo("ToFLevel2")); |
pam_tree_clone[i]->Branch("ToFLevel2", "ToFLevel2", GetPointerTo("ToFLevel2")); |
5317 |
cout << "ToF : branch ToFLevel2" << endl; |
cout << "ToF : branch ToFLevel2" << endl; |
5318 |
|
if(NUC){ |
5319 |
|
pam_tree_clone[i]->Branch("TrackNuclei","TClonesArray",&tof_nuc_obj); |
5320 |
|
cout << "ToF : branch TrackNuclei" << endl; |
5321 |
|
} |
5322 |
|
if(EXT){ |
5323 |
|
pam_tree_clone[i]->Branch("RecoveredTrack","TClonesArray",&tof_ext_obj); |
5324 |
|
cout << "ToF : branch RecoveredTrack" << endl; |
5325 |
|
if(NUC){ |
5326 |
|
pam_tree_clone[i]->Branch("RecoveredTrackNuclei","TClonesArray",&tof_ext_nuc_obj); |
5327 |
|
cout << "ToF : branch RecoveredTrackNuclei" << endl; |
5328 |
|
} |
5329 |
|
} |
5330 |
i++; |
i++; |
5331 |
}; |
}; |
5332 |
// Trigger |
// Trigger |
5362 |
pam_tree_clone[i] = new TTree("OrbitalInfo", "PAMELA orbital info "); |
pam_tree_clone[i] = new TTree("OrbitalInfo", "PAMELA orbital info "); |
5363 |
pam_tree_clone[i]->Branch("OrbitalInfo", "OrbitalInfo", GetPointerTo("OrbitalInfo")); |
pam_tree_clone[i]->Branch("OrbitalInfo", "OrbitalInfo", GetPointerTo("OrbitalInfo")); |
5364 |
cout << "OrbitalInfo : branch OrbitalInfo" << endl; |
cout << "OrbitalInfo : branch OrbitalInfo" << endl; |
5365 |
|
if(NUC){ |
5366 |
|
pam_tree_clone[i]->Branch("TrackNuclei","TClonesArray",&orb_nuc_obj); |
5367 |
|
cout << "OrbitalInfo : branch TrackNuclei" << endl; |
5368 |
|
} |
5369 |
|
if(EXT){ |
5370 |
|
pam_tree_clone[i]->Branch("RecoveredTrack","TClonesArray",&orb_ext_obj); |
5371 |
|
cout << "OrbitalInfo : branch RecoveredTrack" << endl; |
5372 |
|
if(NUC){ |
5373 |
|
pam_tree_clone[i]->Branch("RecoveredTrackNuclei","TClonesArray",&orb_ext_nuc_obj); |
5374 |
|
cout << "OrbitalInfo : branch RecoveredTrackNuclei" << endl; |
5375 |
|
} |
5376 |
|
} |
5377 |
i++; |
i++; |
5378 |
}; |
}; |
5379 |
// GPamela |
// GPamela |
5380 |
if (GP) { |
if (GP) { |
5381 |
pam_tree_clone[i] = new TTree("h20", "GPAMELA info "); |
pam_tree_clone[i] = new TTree("h20", "GPAMELA info "); |
5382 |
pam_tree_clone[i]->Branch("GPamela", "GPamela", GetPointerTo("GPamela"), 32000, 1);//split |
pam_tree_clone[i]->Branch("GPamela", "GPamela", GetPointerTo("GPamela"), 32000, 1);//split |
5383 |
cout << "OrbitalInfo : branch OrbitalInfo" << endl; |
cout << "GPamela : branch GPamela" << endl; |
5384 |
i++; |
i++; |
5385 |
}; |
}; |
5386 |
|
|
5387 |
|
|
5388 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; |
5389 |
|
|
5390 |
} |
} |
5426 |
if (!name.CompareTo(na)) |
if (!name.CompareTo(na)) |
5427 |
return sel_tree_clone; |
return sel_tree_clone; |
5428 |
} |
} |
5429 |
|
if (proc_tree_clone && PROC) { |
5430 |
|
TString na = proc_tree_clone->GetName(); |
5431 |
|
if (!name.CompareTo(na)) |
5432 |
|
return proc_tree_clone; |
5433 |
|
} |
5434 |
return NULL; |
return NULL; |
5435 |
|
|
5436 |
} |
} |
5450 |
for (Int_t i = 0; i < NCLONES; i++) { |
for (Int_t i = 0; i < NCLONES; i++) { |
5451 |
if (pam_tree_clone[i]) { |
if (pam_tree_clone[i]) { |
5452 |
cout << pam_tree_clone[i]->GetName() << endl; |
cout << pam_tree_clone[i]->GetName() << endl; |
5453 |
pam_tree_clone[i]->Write(); |
pam_tree_clone[i]->Write(pam_tree_clone[i]->GetName(),TObject::kOverwrite); |
5454 |
}; |
}; |
5455 |
} |
} |
5456 |
|
|
5457 |
|
if ( PROC ){ |
5458 |
|
proc_tree_clone->Write("ProcessingInfo",TObject::kOverwrite); |
5459 |
|
} |
5460 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; |
5461 |
|
|
5462 |
} |
} |
5464 |
/** |
/** |
5465 |
* Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry. |
* Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry. |
5466 |
*/ |
*/ |
|
//Int_t PamLevel2::GetEntry(Int_t iee){ |
|
5467 |
Int_t PamLevel2::GetEntry(Long64_t iee) { |
Int_t PamLevel2::GetEntry(Long64_t iee) { |
5468 |
|
|
|
// cout << "-------------------------------------"<<endl; |
|
|
// cout << "Int_t PamLevel2::GetEntry("<<iee<<")"<<endl; |
|
|
|
|
5469 |
if (!pam_tree) { |
if (!pam_tree) { |
5470 |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded" << endl; |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded" << endl; |
5471 |
return 0; |
return 0; |
5479 |
// return 0; |
// return 0; |
5480 |
// } |
// } |
5481 |
|
|
|
Long64_t ii = 0; |
|
5482 |
//------------------------------- |
//------------------------------- |
5483 |
ii = iee; |
if (!pam_tree->GetEntry(iee)) { |
|
if (!pam_tree->GetEntry(ii)) { |
|
5484 |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree" << endl; |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree" << endl; |
5485 |
return 0; |
return 0; |
5486 |
} |
} |
5500 |
} |
} |
5501 |
|
|
5502 |
//------------------------------- |
//------------------------------- |
5503 |
ii = iee; |
// |
5504 |
// Bool_t UPDATED = UpdateRunInfo(run_tree,ii); |
if ( fUpdateRunInfo ) UpdateRunInfo(iee); // Emiliano |
5505 |
// Bool_t UPDATED = UpdateRunInfo(ii); |
if (SELLI == 0 || SELLI == 2) irunentry = iee - runfirstentry; |
|
UpdateRunInfo(ii); |
|
|
if (SELLI == 0 || SELLI == 2) |
|
|
irunentry = iee - runfirstentry; |
|
|
// if(UPDATED && run_tree_clone)run_tree_clone->Fill(); |
|
|
|
|
|
// cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl; |
|
|
|
|
|
// cout << "irunentry "<<irunentry << endl; |
|
|
// cout << "runfirstentry "<<runfirstentry << endl; |
|
|
// cout << "nevents "<<GetRunInfo()->NEVENTS<< endl; |
|
|
|
|
|
// if( TRK0 || CAL0 || TOF0 ){ |
|
|
// if( !GetYodaEntry( ) ){ |
|
|
// cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading level0 tree"<<endl; |
|
|
// return 0; |
|
|
// } |
|
|
// } |
|
|
|
|
5506 |
|
|
5507 |
return 1; |
return 1; |
5508 |
|
|
5543 |
//=================================== |
//=================================== |
5544 |
if (irun < 0) { |
if (irun < 0) { |
5545 |
cout << "PamLevel2::GetYodaTree() -- ERROR -- irun = " << irun << endl; |
cout << "PamLevel2::GetYodaTree() -- ERROR -- irun = " << irun << endl; |
5546 |
// cout << "In order to use this method you have to first load the RunInfo tree "<<endl; |
if (DBG) cout << "In order to use this method you have to first load the RunInfo tree "<<endl; |
5547 |
return NULL; |
return NULL; |
5548 |
} |
} |
5549 |
Int_t irootnew = run_obj->ID_ROOT_L0; |
Int_t irootnew = GetRunInfo()->ID_ROOT_L0; |
5550 |
// cout << "iroot "<<iroot<<endl; |
if (DBG){ |
5551 |
// cout << "irootnew "<<irootnew<<endl; |
cout << "iroot "<<iroot<<endl; |
5552 |
|
cout << "irootnew "<<irootnew<<endl; |
5553 |
|
} |
5554 |
|
|
5555 |
//=================================== |
//=================================== |
5556 |
// load the level0 file |
// load the level0 file |
5588 |
if (!h0_obj) |
if (!h0_obj) |
5589 |
h0_obj = new EventHeader(); |
h0_obj = new EventHeader(); |
5590 |
l0_tree->SetBranchAddress("Header", &h0_obj); |
l0_tree->SetBranchAddress("Header", &h0_obj); |
5591 |
prevshift = 0; |
yprevshift = 0; // yes, yprevshift is the shift in the level0, prevshift is the shift in the level2 |
5592 |
//--------------------------------------------------- |
//--------------------------------------------------- |
5593 |
// TRACKER: |
// TRACKER: |
5594 |
if (TRK0) { |
if (TRK0) { |
5606 |
calo0_obj->Set(); |
calo0_obj->Set(); |
5607 |
}; |
}; |
5608 |
l0_tree->SetBranchAddress("Calorimeter", calo0_obj->GetPointerToCalorimeterEvent()); |
l0_tree->SetBranchAddress("Calorimeter", calo0_obj->GetPointerToCalorimeterEvent()); |
|
// cout << "PamLevel2::GetYodaTree() --- level0 calorimeter not implemented "<<endl; |
|
5609 |
} |
} |
5610 |
//--------------------------------------------------- |
//--------------------------------------------------- |
5611 |
// TOF: |
// TOF: |
5614 |
} |
} |
5615 |
|
|
5616 |
dbc->Close(); // EMILIANO, do not leave open connections, open only when needed |
dbc->Close(); // EMILIANO, do not leave open connections, open only when needed |
5617 |
|
delete dbc; |
5618 |
dbc=0; |
dbc=0; |
5619 |
|
|
5620 |
}; |
}; |
5621 |
|
|
|
// if(!dbc || (dbc && !dbc->IsConnected())){ |
|
|
// cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<<endl; |
|
|
// } |
|
|
|
|
5622 |
if (TRK0) { |
if (TRK0) { |
5623 |
// TrkParams::Load(6); |
if(!dbc || (dbc && !dbc->IsConnected()))SetDBConnection(); |
|
// if( !TrkParams::IsLoaded(6) ){ |
|
|
// cout << " TTree* PamLevel2::GetYodaTree( ) -- WARNING -- VK-mask not loaded"<<endl; |
|
|
// }; |
|
|
if(!dbc || (dbc && !dbc->IsConnected()))SetDBConnection(); // PERCHE` ERA COMMENTATA QUESTA RIGA? |
|
5624 |
TrkParams::SetCalib(run_obj, dbc); |
TrkParams::SetCalib(run_obj, dbc); |
5625 |
TrkParams::LoadCalib(); |
TrkParams::LoadCalib(); |
5626 |
if (!TrkParams::CalibIsLoaded()) { |
if (!TrkParams::CalibIsLoaded()) { |
5628 |
}; |
}; |
5629 |
if(dbc){ |
if(dbc){ |
5630 |
dbc->Close(); // EMILIANO, do not leave open connections, open only when needed |
dbc->Close(); // EMILIANO, do not leave open connections, open only when needed |
5631 |
|
delete dbc; |
5632 |
dbc=0; |
dbc=0; |
5633 |
}; |
}; |
5634 |
} |
} |
|
|
|
|
// cout << l0_tree << endl; |
|
5635 |
return l0_tree; |
return l0_tree; |
|
|
|
5636 |
} |
} |
5637 |
|
|
5638 |
/** |
/** |
5640 |
*/ |
*/ |
5641 |
Int_t PamLevel2::GetYodaEntry() { |
Int_t PamLevel2::GetYodaEntry() { |
5642 |
|
|
5643 |
// cout << "Int_t PamLevel2::GetYodaEntry()"<<endl; |
Long64_t iev = this->GetReadEntry(); |
|
if (!GetYodaTree()) |
|
|
return 0; |
|
5644 |
|
|
5645 |
// patch |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
5646 |
if (irunentry < 0) { |
// if it is a full file (not preselected) |
5647 |
// cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
5648 |
irunentry = 0LL; |
// if (SELLI == 0 || SELLI == 2 || !hasL0EE) { |
|
} |
|
|
// --------------------------------- |
|
|
// if file is NOT a preselected file |
|
|
// --------------------------------- |
|
|
Long64_t quellagiusta = irunentry + (Long64_t)(run_obj->EV_FROM); |
|
|
// cout << " irunentry "<<irunentry<<endl; |
|
|
// cout << " EV_FROM "<<run_obj->EV_FROM<<endl; |
|
|
// cout << " quellagiusta = irunentry + EV_FROM "<< quellagiusta << endl; |
|
|
|
|
|
// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
|
|
// cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
|
|
// cout << " time "<< abstime << endl; |
|
|
// cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl; |
|
5649 |
|
|
5650 |
ULong64_t obt = 0; |
if (!GetYodaTree()){ |
5651 |
ULong64_t pktn = 0; |
printf(" PamLevel2::GetYodaEntry() : ERROR no level0 file loaded!\n"); |
5652 |
if (GetOrbitalInfo()) { |
return 0; |
5653 |
obt = GetOrbitalInfo()->OBT; |
} |
|
pktn = GetOrbitalInfo()->pkt_num; |
|
|
} |
|
5654 |
|
|
5655 |
if (!GetOrbitalInfo() && !ISGP) { |
if (irunentry < 0) { |
5656 |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo " << endl; |
if (DBG) cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; |
5657 |
return 0; |
// cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; // TOGLITOGLI |
5658 |
} |
irunentry = 0LL; |
5659 |
if (obt == 0 && pktn == 0 && !ISGP) { |
} |
5660 |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? " << endl; |
// --------------------------------- |
5661 |
return 0; |
// if file is NOT a preselected file |
5662 |
} |
// --------------------------------- |
5663 |
|
Long64_t quellagiusta = irunentry + (Long64_t)(run_obj->EV_FROM); // prevshift already included in irunentry |
5664 |
|
|
5665 |
|
if (DBG){ |
5666 |
|
cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
5667 |
|
cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
5668 |
|
cout << " time "<< abstime << endl; |
5669 |
|
} |
5670 |
|
|
5671 |
|
ULong64_t obt = 0; |
5672 |
|
ULong64_t pktn = 0; |
5673 |
|
if (GetOrbitalInfo()) { |
5674 |
|
obt = GetOrbitalInfo()->OBT; |
5675 |
|
pktn = GetOrbitalInfo()->pkt_num; |
5676 |
|
} |
5677 |
|
|
5678 |
// --------------------------------------------------------------------- |
if (!GetOrbitalInfo() && !ISGP) { |
5679 |
// ATTENTION!!! |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo " << endl; |
5680 |
// If data are not pre-processed with cleaner, the level0 tree may contain |
return 0; |
|
// spurious nested physics packets. |
|
|
// The GL_RUN variables EV_FROM, EV_TO and NEVENTS counts also these entries |
|
|
// while level2 tree DOES NOT!! |
|
|
// This means that "quellagiusta" in these cases is not correct. |
|
|
// In order to retrieve the correct level0 event, I implemented a check |
|
|
// of the OBT and pkt-number. In case of mismatch, the level0 entry number |
|
|
// is shift forward until when the packets match. |
|
|
// --------------------------------------------------------------------- |
|
|
Int_t answer = 0; |
|
|
Int_t shift = 0; |
|
|
// printf(" siamo qui %i %i \n",shift,prevshift); |
|
|
// Int_t maxshift = 50; // EMILIANO |
|
|
do { |
|
|
if (shift > 0) { |
|
|
cout << " PKTNUM L2 --- " << pktn << " --- L0 --- " << GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
|
|
if (DBG) |
|
|
cout << " RUN: ID " << GetRunInfo()->ID << " ID_ROOT_L0 " << run_obj->ID_ROOT_L0 << " ID_RUN_FRAG " |
|
|
<< GetRunInfo()->ID_RUN_FRAG << " EV_FROM " << GetRunInfo()->EV_FROM << endl; |
|
|
if (DBG) |
|
|
cout << " L2 <--> L0 mismatch ( irun " << irun << " irunentry " << irunentry << " shift " << shift |
|
|
<< " prevshift " << prevshift << " )" << endl; |
|
5681 |
} |
} |
5682 |
answer = l0_tree->GetEntry(quellagiusta + (Long64_t) shift + (Long64_t) prevshift); |
if (obt == 0 && pktn == 0 && !ISGP) { |
5683 |
shift++; |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? " << endl; |
|
if (!GetEventHeader()) { |
|
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader " << endl; |
|
5684 |
return 0; |
return 0; |
5685 |
} |
} |
5686 |
|
|
5687 |
|
// --------------------------------------------------------------------- |
5688 |
|
// ATTENTION!!! |
5689 |
|
// If data are not pre-processed with cleaner, the level0 tree may contain |
5690 |
|
// spurious nested physics packets. |
5691 |
|
// The GL_RUN variables EV_FROM, EV_TO and NEVENTS counts also these entries |
5692 |
|
// while level2 tree DOES NOT!! |
5693 |
|
// This means that "quellagiusta" in these cases is not correct. |
5694 |
|
// In order to retrieve the correct level0 event, I implemented a check |
5695 |
|
// of the OBT and pkt-number. In case of mismatch, the level0 entry number |
5696 |
|
// is shift forward until when the packets match. |
5697 |
|
// --------------------------------------------------------------------- |
5698 |
|
Long64_t shift = 0LL; |
5699 |
|
Long64_t answer = quellagiusta + shift + yprevshift; |
5700 |
|
Int_t readl0 = 0; |
5701 |
|
readl0 = l0_tree->GetEntry(answer); // prevshift already included in irunentry |
5702 |
|
|
5703 |
|
if (DBG){ |
5704 |
|
printf(" siamo qui shift %lld yprevshift %lld answer %lld \n",shift,yprevshift,answer); |
5705 |
|
} |
5706 |
|
|
5707 |
|
|
5708 |
if (ISGP) { |
if (ISGP) { |
5709 |
obt = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()); //BARBATRUCCO |
obt = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()); //BARBATRUCCO |
5710 |
pktn = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()); //BARBATRUCCO |
pktn = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()); //BARBATRUCCO |
5711 |
} |
} |
5712 |
|
|
5713 |
// cout << "PKTNUM "<<shift<<" == L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
while ( (obt != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || pktn != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta + (Long64_t) shift) < GetYodaTree()->GetEntries() && shift < maxshift ){ |
5714 |
// cout << " L2 --- "<< obt << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<<endl; |
if ( isSync && shift == 0LL ){ |
5715 |
// if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl; |
printf(" PamLevel2::GetYodaEntry() ERROR! sync file but the level0 entry not found in place!!! \n"); |
5716 |
// cout << " obt "<< obt << endl; |
cout << " OK this is a bug, write to Emiliano, Emiliano.Mocchiutti@ts.infn.it " << endl; |
5717 |
// cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; |
cout << "\nFor bug reporting instructions, please see for example:\n"; |
5718 |
// cout << " pktn "<< pktn << endl; |
cout << " <http://www.ts.infn.it/~mocchiut/bugs/bugs.html>.\n"; |
5719 |
// cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
cout << " " << endl; |
5720 |
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
} |
5721 |
// |
if (shift > 0) { |
5722 |
if (prevshift != 0 && (quellagiusta + (Long64_t) shift) == GetYodaTree()->GetEntries()) { |
if (DBG) cout << " PKTNUM L2 --- " << pktn << " --- L0 --- " << GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
5723 |
prevshift = 0; |
if (DBG) |
5724 |
shift = -1; |
cout << " RUN: ID " << GetRunInfo()->ID << " ID_ROOT_L0 " << run_obj->ID_ROOT_L0 << " ID_RUN_FRAG " |
5725 |
}; |
<< GetRunInfo()->ID_RUN_FRAG << " EV_FROM " << GetRunInfo()->EV_FROM << endl; |
5726 |
|
if (DBG) |
5727 |
|
cout << " L2 <--> L0 mismatch ( irun " << irun << " irunentry " << irunentry << " shift " << shift |
5728 |
|
<< " prevshift " << prevshift << " )" << endl; |
5729 |
|
} |
5730 |
|
answer = quellagiusta + shift+ yprevshift; |
5731 |
|
readl0 = l0_tree->GetEntry(answer); |
5732 |
|
// printf(" inside while shift %lld yprevshift %lld answer %lld \n",shift,yprevshift,answer);//TOGLITOGLI |
5733 |
|
|
5734 |
} while ((obt != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || pktn != (UInt_t)( |
if (!GetEventHeader()) { |
5735 |
GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta + (Long64_t) shift) |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader " << endl; |
5736 |
< GetYodaTree()->GetEntries() && shift < maxshift); |
return 0; |
5737 |
|
} |
5738 |
|
|
5739 |
if ((quellagiusta + (Long64_t) shift + (Long64_t) prevshift) > GetYodaTree()->GetEntries() || shift == maxshift) { |
// |
5740 |
cout << " Big trouble here, no such event in Level0 data! (NB maxshift set to " << maxshift << " )" << endl; |
if (yprevshift != 0 && (quellagiusta + (Long64_t) shift) == GetYodaTree()->GetEntries()) { |
5741 |
return 0; |
if (DBG) printf(" reset inside while shift %lld yprevshift %lld answer %lld \n",shift,yprevshift,answer); |
5742 |
} |
// printf(" reset inside while shift %lld yprevshift %lld answer %lld \n",shift,yprevshift,answer);//TOGLITOGLI |
5743 |
// cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
yprevshift = 0LL; |
5744 |
// return GetYodaTree()->GetEntry(quellagiusta); |
shift = -1LL; |
5745 |
if (shift > 1) |
}; |
5746 |
prevshift += (shift - 1); |
|
5747 |
|
shift++; |
5748 |
|
} |
5749 |
|
|
5750 |
|
|
5751 |
|
if ( obt != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || pktn != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()) ){ |
5752 |
|
if ( isSync ){ |
5753 |
|
printf(" PamLevel2::GetYodaEntry() ERROR! sync file but the level0 entry not found AT ALL!!! \n"); |
5754 |
|
cout << " OK this is a bug, write to Emiliano, Emiliano.Mocchiutti@ts.infn.it " << endl; |
5755 |
|
cout << "\nFor bug reporting instructions, please see for example:\n"; |
5756 |
|
cout << " <http://www.ts.infn.it/~mocchiut/bugs/bugs.html>.\n"; |
5757 |
|
cout << " " << endl; |
5758 |
|
} |
5759 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- WARNING -- " << endl; |
5760 |
|
cout << " Big trouble here, no such event in Level0 data! (NB maxshift set to " << maxshift << " )" << endl; |
5761 |
|
cout << " Nested and/or DarthVader skipped packets in fragmented run? checking and trying to fix " <<endl; |
5762 |
|
// query the DB for runs containing the event, loop over LEVEL0 files which could contain the level0 event and try to find it |
5763 |
|
// ma nel mezzo del cammin per ogni run che pesco devo vedere la posizione relativa di iev rispetto al runheader nel livello2 per andare a cercare nel posto giusto |
5764 |
|
// connect to db |
5765 |
|
if (!dbc || (dbc && !dbc->IsConnected())) SetDBConnection(); //Emiliano |
5766 |
|
// |
5767 |
|
if (GetOrbitalInfo()){ |
5768 |
|
abstime = GetOrbitalInfo()->absTime; |
5769 |
|
} else { |
5770 |
|
printf(" PamLevel2::GetYodaEntry() ERROR! no OrbitalInfo, cannot get the absolute time for event \n"); |
5771 |
|
return 0; |
5772 |
|
} |
5773 |
|
// query DB looking for runs containing the processed event |
5774 |
|
TSQLResult *pResult; |
5775 |
|
TSQLRow *Row = NULL; |
5776 |
|
TString myquery = Form("select ID,NEVENTS from GL_RUN where RUNHEADER_TIME<=%lld and RUNTRAILER_TIME>=%lld;",abstime,abstime); |
5777 |
|
if ( DBG ) printf(" query is %s \n",myquery.Data()); |
5778 |
|
// printf(" query is %s \n",myquery.Data());// TOGLITOGLI |
5779 |
|
pResult = dbc->Query(myquery.Data()); |
5780 |
|
if (!pResult->GetRowCount()){ |
5781 |
|
printf(" PamLevel2::GetYodaEntry() ERROR! event is not included in any run!!! \n"); |
5782 |
|
cout << " OK this is a bug, write to Emiliano, Emiliano.Mocchiutti@ts.infn.it " << endl; |
5783 |
|
cout << "\nFor bug reporting instructions, please see for example:\n"; |
5784 |
|
cout << " <http://www.ts.infn.it/~mocchiut/bugs/bugs.html>.\n"; |
5785 |
|
cout << " " << endl; |
5786 |
|
return 0; |
5787 |
|
} |
5788 |
|
if ( pResult->GetRowCount() == 1 ){ |
5789 |
|
if (DBG) printf(" PamLevel2::GetYodaEntry() - WARNING - YodaEntry not found but only one run containing the event, it should not happen \n"); |
5790 |
|
// printf(" PamLevel2::GetYodaEntry() - WARNING - YodaEntry not found but only one run containing the event, it should not happen \n");//TOGLITOGLI |
5791 |
|
} |
5792 |
|
for( Int_t ru=0; ru < pResult->GetRowCount(); ru++){ // loop over runs containing the event |
5793 |
|
if (Row) delete Row; |
5794 |
|
Row = pResult->Next(); |
5795 |
|
if( Row == NULL ) break; |
5796 |
|
UInt_t idrun = (UInt_t)atoll(Row->GetField(0)); |
5797 |
|
UInt_t nev = (UInt_t)atoll(Row->GetField(1)); |
5798 |
|
if (DBG) printf(" inside loop over runs: ru %i idrun %i nev %i \n",ru,idrun,nev); |
5799 |
|
// printf(" inside loop over runs: ru %i idrun %i nev %i \n",ru,idrun,nev);//TOGLITOGLI |
5800 |
|
|
5801 |
|
// now look for this run in the level2 file, it must be present! code is taken from updateruninfo of course |
5802 |
|
Bool_t rfound = false; |
5803 |
|
totrunentry = 0LL; |
5804 |
|
runfirstentry = 0LL; |
5805 |
|
for (Int_t r=0; r< run_tree->GetEntries();r++){ |
5806 |
|
run_tree->GetEntry(r);//update runinfo |
5807 |
|
if ( r > 0 ){ |
5808 |
|
totrunentrymin = totrunentrymax+1; |
5809 |
|
} else { |
5810 |
|
totrunentrymin = 0LL; |
5811 |
|
} |
5812 |
|
totrunentry += GetRunInfo()->NEVENTS; |
5813 |
|
totrunentrymax = totrunentry - 1 - prevshift; // prevshift is needed to handle nested+DV_skipped packets |
5814 |
|
irun = r; |
5815 |
|
|
5816 |
|
if (idrun == GetRunInfo()->ID){ |
5817 |
|
if ( totrunentrymin > iev ){ // there is a shift (nested+DV_skipped packets) |
5818 |
|
if (DBG) printf("PamLevel2::GetYodaEntry - unconsistent iev - nevents, probable DBL0-L2 async\n"); |
5819 |
|
if (DBG) printf("PamLevel2::GetYodaEntry - totrunentrymin %lld iev %lld prevshift %lld totrunentrymax %lld \n",totrunentrymin,iev,prevshift,totrunentrymax); |
5820 |
|
// printf("PamLevel2::GetYodaEntry - unconsistent iev - nevents, probable DBL0-L2 async\n"); |
5821 |
|
// printf("PamLevel2::GetYodaEntry - totrunentrymin %lld iev %lld prevshift %lld totrunentrymax %lld \n",totrunentrymin,iev,prevshift,totrunentrymax);//TOGLITOGLI |
5822 |
|
prevshift += (totrunentrymin-iev); // add the new shift to total shift |
5823 |
|
totrunentrymin -= (totrunentrymin-iev); // shift run position min |
5824 |
|
totrunentrymax -= (totrunentrymin-iev); // shift run position max |
5825 |
|
if (DBG) printf("PamLevel2::GetYodaEntry - totrunentrymin %lld iev %lld prevshift %lld totrunentrymax %lld \n",totrunentrymin,iev,prevshift,totrunentrymax); |
5826 |
|
// printf("PamLevel2::GetYodaEntry - totrunentrymin %lld iev %lld prevshift %lld totrunentrymax %lld \n",totrunentrymin,iev,prevshift,totrunentrymax);//TOGLITOGLI |
5827 |
|
} |
5828 |
|
runfirstentry = totrunentrymin; // first entry of the run in the level2 |
5829 |
|
|
5830 |
|
|
5831 |
|
// |
5832 |
|
if (gltsync) |
5833 |
|
delete gltsync; // Emiliano |
5834 |
|
if (!dbc || (dbc && !dbc->IsConnected())) |
5835 |
|
SetDBConnection(); //Emiliano |
5836 |
|
gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); // Emiliano |
5837 |
|
if (dbc){ |
5838 |
|
dbc->Close(); // Emiliano |
5839 |
|
delete dbc; |
5840 |
|
dbc=0; |
5841 |
|
} |
5842 |
|
if (gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) { // Emiliano |
5843 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun " << irun |
5844 |
|
<< " has RUNHEADER_OBT>=RUNTRAILER_OBT " << endl; |
5845 |
|
cout |
5846 |
|
<< " (NB!! in this case some events could be assigned to a wrong run)" |
5847 |
|
<< endl; |
5848 |
|
} |
5849 |
|
// |
5850 |
|
if (DBG) printf(" found \n"); |
5851 |
|
// printf(" found \n");//TOGLITOGLI |
5852 |
|
rfound = true; |
5853 |
|
// |
5854 |
|
break; |
5855 |
|
} |
5856 |
|
} // loop over run |
5857 |
|
if ( !rfound ){ |
5858 |
|
printf(" PamLevel2::GetYodaEntry() ERROR! run is not present in the level2 file!!! \n"); |
5859 |
|
cout << " OK this is a bug, write to Emiliano, Emiliano.Mocchiutti@ts.infn.it " << endl; |
5860 |
|
cout << "\nFor bug reporting instructions, please see for example:\n"; |
5861 |
|
cout << " <http://www.ts.infn.it/~mocchiut/bugs/bugs.html>.\n"; |
5862 |
|
cout << " " << endl; |
5863 |
|
return 0; |
5864 |
|
} |
5865 |
|
|
5866 |
return answer; |
// here we got the first run and we can check if it contains the level0 event |
5867 |
|
if (!GetYodaTree()){ |
5868 |
|
printf(" PamLevel2::GetYodaEntry() : ERROR no level0 file loaded!\n"); |
5869 |
|
return 0; |
5870 |
|
} |
5871 |
|
|
5872 |
|
// get the current run entry |
5873 |
|
irunentry = iev - runfirstentry; |
5874 |
|
if (irunentry < 0) { |
5875 |
|
if (DBG) cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; |
5876 |
|
// cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; // TOGLITOGLI |
5877 |
|
irunentry = 0LL; |
5878 |
|
} |
5879 |
|
// --------------------------------- |
5880 |
|
// if file is NOT a preselected file |
5881 |
|
// --------------------------------- |
5882 |
|
quellagiusta = irunentry + (Long64_t)(run_obj->EV_FROM); // prevshift already included in irunentry |
5883 |
|
|
5884 |
|
if (DBG){ |
5885 |
|
cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
5886 |
|
cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
5887 |
|
cout << " time "<< abstime << endl; |
5888 |
|
} |
5889 |
|
// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
5890 |
|
// cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
5891 |
|
// cout << " time "<< abstime << endl; // TOGLITOGLI |
5892 |
|
|
5893 |
|
shift = 0; |
5894 |
|
answer = quellagiusta + shift + yprevshift; // prevshift already included in irunentry |
5895 |
|
readl0 = l0_tree->GetEntry(answer); // prevshift already included in irunentry |
5896 |
|
|
5897 |
|
if (DBG){ |
5898 |
|
printf(" siamo qua shift %lld yprevshift %lld answer %lld \n",shift,yprevshift,answer); |
5899 |
|
} |
5900 |
|
// printf(" siamo qua shift %lld yprevshift %lld answer %lld \n",shift,yprevshift,answer);//TOGLITOGLI |
5901 |
|
|
5902 |
|
while ( (obt != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || pktn != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta + (Long64_t) shift) < GetYodaTree()->GetEntries() && shift < maxshift ){ |
5903 |
|
if (shift > 0) { |
5904 |
|
if (DBG) cout << " PKTNUM L2 --- " << pktn << " --- L0 --- " << GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
5905 |
|
if (DBG) |
5906 |
|
cout << " RUN: ID " << GetRunInfo()->ID << " ID_ROOT_L0 " << run_obj->ID_ROOT_L0 << " ID_RUN_FRAG " |
5907 |
|
<< GetRunInfo()->ID_RUN_FRAG << " EV_FROM " << GetRunInfo()->EV_FROM << endl; |
5908 |
|
if (DBG) |
5909 |
|
cout << " L2 <--> L0 mismatch ( irun " << irun << " irunentry " << irunentry << " shift " << shift |
5910 |
|
<< " prevshift " << prevshift << " )" << endl; |
5911 |
|
} |
5912 |
|
answer = quellagiusta + shift+ yprevshift; |
5913 |
|
readl0 = l0_tree->GetEntry(answer); |
5914 |
|
// printf(" inside inside while shift %lld yprevshift %lld answer %lld \n",shift,yprevshift,answer);//TOGLITOGLI |
5915 |
|
|
5916 |
|
if (!GetEventHeader()) { |
5917 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader " << endl; |
5918 |
|
return 0; |
5919 |
|
} |
5920 |
|
// |
5921 |
|
if (yprevshift != 0 && (quellagiusta + (Long64_t) shift) == GetYodaTree()->GetEntries()) { |
5922 |
|
if (DBG) printf(" reset inside while shift %lld yprevshift %lld answer %lld \n",shift,yprevshift,answer); |
5923 |
|
// printf(" reset inside while shift %lld yprevshift %lld answer %lld \n",shift,yprevshift,answer);//TOGLITOGLI |
5924 |
|
yprevshift = 0; |
5925 |
|
shift = -1; |
5926 |
|
}; |
5927 |
|
|
5928 |
|
shift++; |
5929 |
|
} |
5930 |
|
|
5931 |
|
if ( obt != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || pktn != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()) ){ |
5932 |
|
//still not the good run... continue with the nex one! |
5933 |
|
printf("still not the good run... continue with the nex one!\n"); |
5934 |
|
} else { |
5935 |
|
if (DBG) cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
5936 |
|
// cout << "LA ENTRY GIUSTA E`: "<<answer<<" (spero...)"<<endl;//TOGLITOGLI |
5937 |
|
if (shift > 1) yprevshift = (shift - 1); |
5938 |
|
if (Row) delete Row; |
5939 |
|
delete pResult; |
5940 |
|
if (dbc){ |
5941 |
|
dbc->Close(); // Emiliano |
5942 |
|
delete dbc; |
5943 |
|
dbc=0; |
5944 |
|
} |
5945 |
|
il0entry = answer; |
5946 |
|
return readl0; |
5947 |
|
} |
5948 |
|
// perhaps it is all |
5949 |
|
}// loop over runs containing the event |
5950 |
|
if (Row) delete Row; |
5951 |
|
delete pResult; |
5952 |
|
if (dbc){ |
5953 |
|
dbc->Close(); // Emiliano |
5954 |
|
delete dbc; |
5955 |
|
dbc=0; |
5956 |
|
} |
5957 |
|
// arriving here it means no run found, cannot be! error! |
5958 |
|
printf(" PamLevel2::GetYodaEntry() ERROR! run is not present in the level0 files!!! \n"); |
5959 |
|
cout << " OK this is a bug, write to Emiliano, Emiliano.Mocchiutti@ts.infn.it " << endl; |
5960 |
|
cout << "\nFor bug reporting instructions, please see for example:\n"; |
5961 |
|
cout << " <http://www.ts.infn.it/~mocchiut/bugs/bugs.html>.\n"; |
5962 |
|
cout << " " << endl; |
5963 |
|
return 0; |
5964 |
|
} else { |
5965 |
|
if (DBG) cout << "=> LA ENTRY GIUSTA E`: "<<answer<<" (spero...)"<<endl; |
5966 |
|
// cout << "=> LA ENTRY GIUSTA E`: "<<answer<<" (spero...)"<<endl; |
5967 |
|
// printf("obt %lld (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) %i pktn %lld (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter() %i \n",obt,(UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()), pktn, (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()) ); |
5968 |
|
if (shift > 1) yprevshift = (shift - 1); |
5969 |
|
il0entry = answer; |
5970 |
|
return readl0; |
5971 |
|
} |
5972 |
|
|
5973 |
|
/* } // if selli 0 || 2 |
5974 |
|
if ( SELLI == 1 && hasL0EE ){ |
5975 |
|
sel_tree->GetEntry(iev); |
5976 |
|
Long64_t answer = il0entry; |
5977 |
|
Int_t readl0 = 0; |
5978 |
|
readl0 = l0_tree->GetEntry(answer); |
5979 |
|
return readl0; |
5980 |
|
}*/ |
5981 |
|
printf(" PamLevel2::GetYodaEntry() ERROR! \n"); |
5982 |
|
cout << " Entry not found! OK this is a bug, write to Emiliano, Emiliano.Mocchiutti@ts.infn.it " << endl; |
5983 |
|
cout << "\nFor bug reporting instructions, please see for example:\n"; |
5984 |
|
cout << " <http://www.ts.infn.it/~mocchiut/bugs/bugs.html>.\n"; |
5985 |
|
cout << " " << endl; |
5986 |
|
return 0; |
5987 |
} |
} |
5988 |
|
|
5989 |
/** |
/** |
5990 |
* \Brief Set DB connection |
* \Brief Set DB connection |
5991 |
*/ |
*/ |
6078 |
void PamLevel2::SetSortingMethod(TString how) { |
void PamLevel2::SetSortingMethod(TString how) { |
6079 |
if (howtosort != how) { |
if (howtosort != how) { |
6080 |
issorted = false; |
issorted = false; |
6081 |
|
issorted_new = false; |
6082 |
} |
} |
6083 |
howtosort = how; |
howtosort = how; |
6084 |
} |
} |