| 112 |
|
|
| 113 |
void PamLevel2::Initialize(){ |
void PamLevel2::Initialize(){ |
| 114 |
|
|
|
// trk2_obj = TrkLevel2::GetTrkLevel2(); |
|
|
// trk1_obj = TrkLevel1::GetTrkLevel1(); |
|
|
// trkh_obj = TrkHough::GetTrkHough(); |
|
|
// calo1_obj = CaloLevel1::GetCaloLevel1(); |
|
|
// calo2_obj = CaloLevel2::GetCaloLevel2(); |
|
|
// tof_obj = ToFLevel2::GetToFLevel2(); |
|
|
// trig_obj = TrigLevel2::GetTrigLevel2(); |
|
|
// s4_obj = S4Level2::GetS4Level2(); |
|
|
// nd_obj = NDLevel2::GetNDLevel2(); |
|
|
// ac_obj = AcLevel2::GetAcLevel2(); |
|
|
// orb_obj = OrbitalInfo::GetOrbitalInfo(); |
|
|
|
|
| 115 |
h0_obj = 0; |
h0_obj = 0; |
| 116 |
trk0_obj = 0; |
trk0_obj = 0; |
| 117 |
calo0_obj = 0; |
calo0_obj = 0; |
| 150 |
pam_tree = NULL; |
pam_tree = NULL; |
| 151 |
for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL; |
for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL; |
| 152 |
|
|
| 153 |
|
totdltime[0] = 0LL; |
| 154 |
|
totdltime[1] = 0LL; |
| 155 |
|
|
| 156 |
host = "mysql://localhost/pamelaprod"; |
host = "mysql://localhost/pamelaprod"; |
| 157 |
user = "anonymous"; |
user = "anonymous"; |
| 158 |
psw = ""; |
psw = ""; |
| 189 |
|
|
| 190 |
SELLI = -1; |
SELLI = -1; |
| 191 |
|
|
| 192 |
|
ISGP = false; |
| 193 |
|
|
| 194 |
tsorted=0; |
tsorted=0; |
| 195 |
timage=0; |
timage=0; |
| 196 |
|
|
| 297 |
|
|
| 298 |
if(h0_obj) h0_obj->Clear(); |
if(h0_obj) h0_obj->Clear(); |
| 299 |
// if(trk0_obj) trk0_obj->Clear(); |
// if(trk0_obj) trk0_obj->Clear(); |
|
if(calo0_obj) calo0_obj->Clear(); |
|
| 300 |
if(trk1_obj) trk1_obj->Clear(); |
if(trk1_obj) trk1_obj->Clear(); |
| 301 |
if(trk2_obj) trk2_obj->Clear(); |
if(trk2_obj) trk2_obj->Clear(); |
| 302 |
if(trkh_obj) trkh_obj->Clear(); |
if(trkh_obj) trkh_obj->Clear(); |
| 303 |
|
if(calo0_obj) calo0_obj->Clear(); |
| 304 |
if(calo1_obj)calo1_obj->Clear(); |
if(calo1_obj)calo1_obj->Clear(); |
| 305 |
if(calo2_obj)calo2_obj->Clear(); |
if(calo2_obj)calo2_obj->Clear(); |
| 306 |
if(tof_obj) tof_obj->Clear(); |
if(tof_obj) tof_obj->Clear(); |
| 394 |
runfirstentry = 0ULL; |
runfirstentry = 0ULL; |
| 395 |
runlastentry = 0ULL; |
runlastentry = 0ULL; |
| 396 |
// |
// |
| 397 |
|
totdltime[0] = 0LL; |
| 398 |
|
totdltime[1] = 0LL; |
| 399 |
|
// |
| 400 |
}; |
}; |
| 401 |
|
|
| 402 |
Bool_t PamLevel2::IsGood(){ |
Bool_t PamLevel2::IsGood(){ |
| 654 |
TClonesArray &ttimage = *timage; |
TClonesArray &ttimage = *timage; |
| 655 |
|
|
| 656 |
|
|
| 657 |
// loop over the tracks sorted by the tracker |
|
| 658 |
|
//-------------------------------------------------- |
| 659 |
|
// retrieve sorting method |
| 660 |
|
//-------------------------------------------------- |
| 661 |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
| 662 |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
| 663 |
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
| 671 |
}; |
}; |
| 672 |
|
|
| 673 |
// cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl; |
// cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl; |
| 674 |
|
|
| 675 |
|
|
| 676 |
|
//-------------------------------------------------- |
| 677 |
|
// loop over "physical" tracks sorted by the tracker |
| 678 |
|
//-------------------------------------------------- |
| 679 |
for(Int_t i=0; i < trk2_obj->TrkLevel2::GetNTracks(); i++){ |
for(Int_t i=0; i < trk2_obj->TrkLevel2::GetNTracks(); i++){ |
| 680 |
|
|
| 681 |
TrkTrack *ts = 0; |
TrkTrack *ts = 0; |
| 683 |
ToFTrkVar *os = 0; |
ToFTrkVar *os = 0; |
| 684 |
|
|
| 685 |
// get tracker tracks |
// get tracker tracks |
| 686 |
TrkTrack *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker |
TrkTrack *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker |
| 687 |
CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
| 688 |
ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
| 689 |
|
|
| 690 |
TrkTrack *ti = 0; //tracker (image) |
TrkTrack *ti = 0; //tracker (image) |
| 691 |
CaloTrkVar *ci = 0; |
CaloTrkVar *ci = 0; |
| 692 |
ToFTrkVar *oi = 0; |
ToFTrkVar *oi = 0; |
| 693 |
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
| 704 |
Int_t tp_score = 0; //main track sorted by the tracker |
Int_t tp_score = 0; //main track sorted by the tracker |
| 705 |
Int_t ti_score = 0; //image track |
Int_t ti_score = 0; //image track |
| 706 |
|
|
| 707 |
// ------------------------ |
// ----------------------------------------------------------------------------------------- |
| 708 |
// calorimeter check |
// calorimeter check |
| 709 |
// ------------------------ |
// ----------------------------------------------------------------------------------------- |
| 710 |
// check the Y spatial residual on the first calorimeter plane |
// check the Y spatial residual on the first calorimeter plane |
| 711 |
// (cut on calorimeter variables from Emiliano) |
// (cut on calorimeter variables from Emiliano) |
| 712 |
if( use_CAL && !calo2_obj ){ |
if( use_CAL && !calo2_obj ){ |
| 713 |
cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but CaloLevel2 not loaded !!!"; |
cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but CaloLevel2 not loaded !!!"; |
| 714 |
return; |
return; |
| 715 |
}; |
}; |
| 716 |
|
if( use_CAL && !cp && ci )ti_score++; |
| 717 |
|
if( use_CAL && cp && !ci )tp_score++; |
| 718 |
if( |
if( |
| 719 |
use_CAL && |
use_CAL && |
| 720 |
calo2_obj->npcfit[1] > 5 && //no. of fit planes on Y view |
// calo2_obj->npcfit[1] > 5 && //no. of fit planes on Y view |
| 721 |
calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
// calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
| 722 |
cp && ci && |
cp && ci && |
| 723 |
true){ |
true){ |
| 724 |
|
|
| 725 |
|
|
| 726 |
Float_t resy_p = cp->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
// Float_t resy_p = cp->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
| 727 |
Float_t resy_i = ci->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
// Float_t resy_i = ci->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
| 728 |
|
|
| 729 |
if(resy_p <= resy_i) tp_score++; |
// if(resy_p <= resy_i) tp_score++; |
| 730 |
else ti_score++; |
// else ti_score++; |
| 731 |
|
|
| 732 |
|
|
| 733 |
|
if( cp->npresh > ci->npresh) tp_score++; |
| 734 |
|
if( cp->npresh < ci->npresh) ti_score++; |
| 735 |
|
else ;//niente |
| 736 |
|
|
| 737 |
// cout << "CALO "<<tp_score<<ti_score<<endl; |
// cout << "CALO "<<tp_score<<ti_score<<endl; |
| 738 |
|
|
| 739 |
}; |
}; |
| 740 |
// ------------------------ |
// ----------------------------------------------------------------------------------------- |
| 741 |
// TOF check |
// TOF check |
| 742 |
// ------------------------ |
// ----------------------------------------------------------------------------------------- |
| 743 |
// check the number of hit pmts along the track |
// check the number of hit pmts along the track |
| 744 |
// on S12 S21 and S32, where paddles are parallel to Y axis |
// on S12 S21 and S32, where paddles are parallel to Y axis |
| 745 |
if( use_TOF && !tof_obj ){ |
if( use_TOF && !tof_obj ){ |
| 746 |
cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but ToFLevel2 not loaded !!!"; |
cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but ToFLevel2 not loaded !!!"; |
| 747 |
return; |
return; |
| 748 |
}; |
}; |
| 749 |
|
if( use_TOF && !op && oi )ti_score++; |
| 750 |
|
if( use_TOF && op && !oi )tp_score++; |
| 751 |
if( use_TOF && op && oi ){ |
if( use_TOF && op && oi ){ |
| 752 |
|
|
| 753 |
// |
// |
| 887 |
cout << "image: npmtadc "<< oi->npmtadc << endl; |
cout << "image: npmtadc "<< oi->npmtadc << endl; |
| 888 |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
| 889 |
|
|
| 890 |
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
// for (Int_t ih=0; ih < op->npmtadc; ih++){ |
| 891 |
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
// Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
| 892 |
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
// if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
| 893 |
|
// }; |
| 894 |
|
|
| 895 |
|
// for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
| 896 |
|
// Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
| 897 |
|
// if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
| 898 |
|
// }; |
| 899 |
|
// --- modified to count tdc signals (more efficient?) |
| 900 |
|
// --- and to implement check on tdcflag |
| 901 |
|
for (Int_t ih=0; ih < op->npmttdc; ih++){ |
| 902 |
|
// Int_t pl = tof_obj->GetPlaneIndex( (op->pmttdc).At(ih) ); |
| 903 |
|
// if( (op->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_p++; |
| 904 |
|
if( (op->tdcflag).At(ih)==0 )nphit_p++; |
| 905 |
}; |
}; |
| 906 |
|
|
| 907 |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
for (Int_t ih=0; ih < oi->npmttdc; ih++){ |
| 908 |
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
// Int_t pl = tof_obj->GetPlaneIndex( (oi->pmttdc).At(ih) ); |
| 909 |
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
// if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++; |
| 910 |
|
if( (oi->tdcflag).At(ih)==0 )nphit_i++; |
| 911 |
}; |
}; |
| 912 |
|
|
| 913 |
if( |
if( |
|
use_TOF && |
|
| 914 |
(nphit_p+nphit_i) !=0 && |
(nphit_p+nphit_i) !=0 && |
| 915 |
true){ |
true){ |
| 916 |
|
|
| 917 |
if( nphit_p >= nphit_i) tp_score++; |
if ( nphit_p > nphit_i) tp_score++; |
| 918 |
else ti_score++; |
else if( nphit_p < nphit_i) ti_score++; |
| 919 |
|
else ;//niente |
| 920 |
}; |
}; |
| 921 |
}; |
}; |
| 922 |
// cout << "TOF "<<tp_score<<ti_score<<endl; |
// cout << "TOF "<<tp_score<<ti_score<<endl; |
| 923 |
}; |
}; |
| 924 |
if(tp_score == ti_score) use_TRK = true; |
|
| 925 |
// ------------------------ |
|
| 926 |
|
// if(tp_score == ti_score) use_TRK = true; |
| 927 |
|
|
| 928 |
|
|
| 929 |
|
// ----------------------------------------------------------------------------------------- |
| 930 |
// tracker check |
// tracker check |
| 931 |
// ------------------------ |
// ----------------------------------------------------------------------------------------- |
| 932 |
// chi**2 difference is not always large enough to distinguish among |
// chi**2 difference is not always large enough to distinguish among |
| 933 |
// the real track and its image. |
// the real track and its image. |
| 934 |
// Tracker check will be applied always when calorimeter and tof information is ambiguous. |
// Tracker check will be applied always when calorimeter and tof information is ambiguous. |
| 935 |
|
// *** MODIFIED ON AUGUST 2007 *** |
| 936 |
if(use_TRK){ |
if(use_TRK){ |
| 937 |
if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
// if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
| 938 |
else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
// else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
| 939 |
|
|
| 940 |
|
// CHECK 1 : number of points along X |
| 941 |
|
if ( tp->GetNX() >= ti->GetNX() )tp_score++ ; |
| 942 |
|
if ( tp->GetNX() <= ti->GetNX() )ti_score++ ; |
| 943 |
|
// CHECK 2 : number of points along Y |
| 944 |
|
if ( tp->GetNY() >= ti->GetNY() )tp_score++ ; |
| 945 |
|
if ( tp->GetNY() <= ti->GetNY() )ti_score++ ; |
| 946 |
|
// CHECK 3 : chi**2 along X |
| 947 |
|
// if( tp->GetChi2X() > 0 && (tp->GetChi2X() < ti->GetChi2X() || ti->GetChi2X() <=0) ) tp_score++ ; |
| 948 |
|
// if( ti->GetChi2X() > 0 && (ti->GetChi2X() < tp->GetChi2X() || tp->GetChi2X() <=0) ) ti_score++ ; |
| 949 |
|
// CHECK 4 : chi**2 along Y |
| 950 |
|
// if( tp->GetChi2Y() > 0 && (tp->GetChi2Y() < ti->GetChi2Y() || ti->GetChi2Y() <=0) ) tp_score++ ; |
| 951 |
|
// if( ti->GetChi2Y() > 0 && (ti->GetChi2Y() < tp->GetChi2Y() || tp->GetChi2Y() <=0) ) ti_score++ ; |
| 952 |
|
// CHECK 5 : total chi**2 |
| 953 |
|
// if( tp->chi2 > 0 && (tp->chi2 < ti->chi2 || ti->chi2 <=0) ) tp_score++ ; |
| 954 |
|
// if( ti->chi2 > 0 && (ti->chi2 < tp->chi2 || tp->chi2 <=0) ) ti_score++ ; |
| 955 |
|
|
| 956 |
// cout << "TRK "<<tp_score<<ti_score<<endl; |
// cout << "TRK "<<tp_score<<ti_score<<endl; |
| 957 |
}; |
}; |
| 958 |
|
|
| 959 |
// ------------------------ |
|
| 960 |
|
|
| 961 |
|
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* |
| 962 |
// the winner is.... |
// the winner is.... |
| 963 |
// ------------------------ |
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* |
| 964 |
if (tp_score > ti_score) { |
if (tp_score > ti_score) { |
| 965 |
// ts = tp;//the track sorted by the tracker!! |
|
|
// cs = cp; |
|
|
// os = op; |
|
|
// cout << "It's primary!" << endl; |
|
| 966 |
|
|
| 967 |
}else if (tp_score < ti_score) { |
}else if (tp_score < ti_score) { |
| 968 |
|
|
|
// cout << "It's image!" << endl; |
|
| 969 |
|
|
| 970 |
ts = ti;//its image!! |
ts = ti;//its image!! |
| 971 |
cs = ci; |
cs = ci; |
| 981 |
|
|
| 982 |
|
|
| 983 |
}else { |
}else { |
| 984 |
// ts = tp; |
|
|
// cs = cp; |
|
|
// os = op; |
|
| 985 |
// cout << "Warning - track image ambiguity not solved" << endl; |
// cout << "Warning - track image ambiguity not solved" << endl; |
| 986 |
// cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; |
|
| 987 |
}; |
}; |
| 988 |
|
|
| 989 |
}else{ |
}else{ |
| 1918 |
// |
// |
| 1919 |
// the absolute time is necessary to relate the event with the run |
// the absolute time is necessary to relate the event with the run |
| 1920 |
// |
// |
| 1921 |
if( !GetOrbitalInfo() ){ |
if( !GetOrbitalInfo() && !ISGP){ |
| 1922 |
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
| 1923 |
return(false); |
return(false); |
| 1924 |
} |
} |
| 1925 |
|
|
| 1926 |
|
ULong64_t abstime = 0; |
| 1927 |
|
if( GetOrbitalInfo() )abstime=GetOrbitalInfo()->absTime; |
| 1928 |
|
|
| 1929 |
|
|
| 1930 |
// |
// |
| 1931 |
// the first time the routine is called, set run search from the beginning |
// the first time the routine is called, set run search from the beginning |
| 1932 |
// |
// |
| 1936 |
runfirstentry = 0LL; |
runfirstentry = 0LL; |
| 1937 |
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
| 1938 |
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; |
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; |
| 1939 |
|
|
| 1940 |
|
if( ISGP && run->GetEntries()!=1 ){ |
| 1941 |
|
cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run->GetEntries() << endl; |
| 1942 |
|
cout << "** WARNING ** run will not be updated"<<endl; |
| 1943 |
|
} |
| 1944 |
|
|
| 1945 |
}; |
}; |
| 1946 |
// |
// |
| 1947 |
if ( irun == run->GetEntries()-1LL && |
if(ISGP)abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO |
| 1948 |
!(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && |
// |
| 1949 |
GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) |
if ( irun == run->GetEntries()-1LL && |
| 1950 |
|
!(abstime >= GetRunInfo()->RUNHEADER_TIME && |
| 1951 |
|
abstime <= GetRunInfo()->RUNTRAILER_TIME) |
| 1952 |
){ |
){ |
| 1953 |
irun = -1LL; |
irun = -1LL; |
| 1954 |
runfirstentry = 0LL; |
runfirstentry = 0LL; |
| 1959 |
// |
// |
| 1960 |
bool fromfirst = true; |
bool fromfirst = true; |
| 1961 |
// |
// |
| 1962 |
while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries()-1LL ){ |
while ( !(abstime >= GetRunInfo()->RUNHEADER_TIME && abstime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries()-1LL ){ |
| 1963 |
// while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
// while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
| 1964 |
irun++; |
irun++; |
| 1965 |
run->GetEntry(irun); |
run->GetEntry(irun); |
| 1969 |
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
| 1970 |
// cout << "runfirstentry "<<runfirstentry<<endl; |
// cout << "runfirstentry "<<runfirstentry<<endl; |
| 1971 |
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
| 1972 |
// printf(" abstime %u trailertime %u \n",GetOrbitalInfo()->absTime,GetRunInfo()->RUNTRAILER_TIME); |
// printf(" abstime %u trailertime %u \n",abstime,GetRunInfo()->RUNTRAILER_TIME); |
| 1973 |
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
| 1974 |
// |
// |
| 1975 |
// prevshift = 0; |
// prevshift = 0; |
| 1976 |
// |
// |
| 1977 |
if ( irun == (Long64_t)(run->GetEntries()-1LL) && fromfirst && !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)){ |
if ( irun == (Long64_t)(run->GetEntries()-1LL) && fromfirst && !(abstime >= GetRunInfo()->RUNHEADER_TIME && abstime <= GetRunInfo()->RUNTRAILER_TIME)){ |
| 1978 |
printf(" resetting irun (it should NOT happen!!!)\n"); |
printf(" resetting irun (it should NOT happen!!!)\n"); |
| 1979 |
fromfirst = false; |
fromfirst = false; |
| 1980 |
irun = 0; |
irun = 0; |
| 1987 |
}; |
}; |
| 1988 |
// |
// |
| 1989 |
if ( |
if ( |
| 1990 |
!(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && |
!(abstime >= GetRunInfo()->RUNHEADER_TIME && |
| 1991 |
GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) |
abstime <= GetRunInfo()->RUNTRAILER_TIME) |
| 1992 |
) { |
) { |
| 1993 |
printf(" Something very wrong here: cannot find RUN containing absolute time %u \n",GetOrbitalInfo()->absTime); |
printf(" Something very wrong here: cannot find RUN containing absolute time %llu \n",abstime); |
| 1994 |
return false; |
return false; |
| 1995 |
} |
} |
| 1996 |
// |
// |
| 2042 |
if(SELLI==0){ |
if(SELLI==0){ |
| 2043 |
|
|
| 2044 |
// --------------------------------------------------------------- |
// --------------------------------------------------------------- |
| 2045 |
|
// increment dead and live-time counters |
| 2046 |
|
// --------------------------------------------------------------- |
| 2047 |
|
if( GetTrigLevel2() ){ |
| 2048 |
|
totdltime[0]+=GetTrigLevel2()->dltime[0]; |
| 2049 |
|
totdltime[1]+=GetTrigLevel2()->dltime[1]; |
| 2050 |
|
} |
| 2051 |
|
totdltime[2]++; |
| 2052 |
|
|
| 2053 |
|
// cout << setw(10)<<totdltime[0]<<setw(10)<<totdltime[1]<<setw(10)<<totdltime[2]<<endl; |
| 2054 |
|
|
| 2055 |
|
// --------------------------------------------------------------- |
| 2056 |
|
// retrieve OBT and absolute time of the event |
| 2057 |
|
// --------------------------------------------------------------- |
| 2058 |
|
ULong64_t abstime = 0; |
| 2059 |
|
ULong64_t obt = 0; |
| 2060 |
|
if( GetOrbitalInfo() ){ |
| 2061 |
|
abstime = GetOrbitalInfo()->absTime; |
| 2062 |
|
obt = GetOrbitalInfo()->OBT; |
| 2063 |
|
} |
| 2064 |
|
// --------------------------------------------------------------- |
| 2065 |
// the absolute time is necessary to relate the event with the run |
// the absolute time is necessary to relate the event with the run |
| 2066 |
// --------------------------------------------------------------- |
// --------------------------------------------------------------- |
| 2067 |
if( !GetOrbitalInfo() ){ |
if( !GetOrbitalInfo() && !ISGP ){ |
| 2068 |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
| 2069 |
return(false); |
return(false); |
| 2070 |
} |
} |
| 2077 |
irunentry = 0; |
irunentry = 0; |
| 2078 |
prevshift = 0; |
prevshift = 0; |
| 2079 |
run_tree->GetEntry(irun); |
run_tree->GetEntry(irun); |
| 2080 |
|
|
| 2081 |
|
if( ISGP && run_tree->GetEntries()!=1 ){ |
| 2082 |
|
cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run_tree->GetEntries() << endl; |
| 2083 |
|
cout << "** WARNING ** run will not be updated"<<endl; |
| 2084 |
|
} |
| 2085 |
}; |
}; |
| 2086 |
|
|
| 2087 |
|
// ----------------------------------------------------------------------- |
| 2088 |
|
// if it is simulation, assigh abstime by hand (temporaneo!!!) |
| 2089 |
|
// ----------------------------------------------------------------------- |
| 2090 |
|
if(ISGP){ |
| 2091 |
|
abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO |
| 2092 |
|
obt = GetRunInfo()->RUNHEADER_OBT; // BARBATRUCCO |
| 2093 |
|
} |
| 2094 |
// |
// |
| 2095 |
bool fromfirst = true; // first loop over runs |
bool fromfirst = true; // first loop over runs |
| 2096 |
|
|
| 2104 |
while ( |
while ( |
| 2105 |
( |
( |
| 2106 |
( |
( |
| 2107 |
!(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && // check on absolute time (s) |
!(abstime >= GetRunInfo()->RUNHEADER_TIME && // check on absolute time (s) |
| 2108 |
GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && |
abstime <= GetRunInfo()->RUNTRAILER_TIME) && |
| 2109 |
!(GetOrbitalInfo()->OBT >= GetRunInfo()->RUNHEADER_OBT && // additional check on OBT (ms) |
!(obt >= GetRunInfo()->RUNHEADER_OBT && // additional check on OBT (ms) |
| 2110 |
GetOrbitalInfo()->OBT <= GetRunInfo()->RUNTRAILER_OBT) |
obt <= GetRunInfo()->RUNTRAILER_OBT) |
| 2111 |
) |
) |
| 2112 |
|| GetRunInfo()->NEVENTS==0 |
|| GetRunInfo()->NEVENTS==0 |
| 2113 |
|| !(irunentry < GetRunInfo()->NEVENTS-1-prevshift) |
|| !(irunentry < GetRunInfo()->NEVENTS-1-prevshift) |
| 2114 |
) |
) |
| 2115 |
&& irun < run_tree->GetEntries() ){ |
&& irun < run_tree->GetEntries() ){ |
| 2116 |
|
|
| 2117 |
|
|
| 2118 |
|
|
| 2119 |
|
|
| 2120 |
|
// ----------------------------------------- |
| 2121 |
|
// store dead and live-time of previous run |
| 2122 |
|
// ----------------------------------------- |
| 2123 |
|
if(fromfirst){ |
| 2124 |
|
if(oldrun==irun){ |
| 2125 |
|
/// decrement counters |
| 2126 |
|
if( GetTrigLevel2()){ |
| 2127 |
|
totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time |
| 2128 |
|
totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time |
| 2129 |
|
} |
| 2130 |
|
totdltime[2]--; //event counter |
| 2131 |
|
cout << endl; |
| 2132 |
|
cout << "n.events : "<<totdltime[2]<<endl; |
| 2133 |
|
cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl; |
| 2134 |
|
cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl; |
| 2135 |
|
}else{ |
| 2136 |
|
totdltime[0]=0;//live-time |
| 2137 |
|
totdltime[1]=0;//dead-time |
| 2138 |
|
totdltime[2]=0; //event counter |
| 2139 |
|
cout << " *** JUMP RUN *** irun "<<irun<<endl; |
| 2140 |
|
} |
| 2141 |
|
/// add an entry |
| 2142 |
|
if(run_tree_clone) |
| 2143 |
|
if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) |
| 2144 |
|
run_tree_clone->GetBranch("DeadLiveTime")->Fill(); |
| 2145 |
|
/// reset counters |
| 2146 |
|
if( GetTrigLevel2() ){ |
| 2147 |
|
totdltime[0]=GetTrigLevel2()->dltime[0];//live-time |
| 2148 |
|
totdltime[1]=0; //dead-time |
| 2149 |
|
} |
| 2150 |
|
totdltime[2]=1; //event counter |
| 2151 |
|
} |
| 2152 |
|
|
| 2153 |
|
|
| 2154 |
irun++; |
irun++; |
| 2155 |
// ------------------------------------ |
// ------------------------------------ |
| 2156 |
// if the end of run tree is reached... |
// if the end of run tree is reached... |
| 2178 |
// ------------------------------------------------------------------- |
// ------------------------------------------------------------------- |
| 2179 |
if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift; |
if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift; |
| 2180 |
irunentry = 0; |
irunentry = 0; |
| 2181 |
prevshift = 0; |
prevshift = 0; |
| 2182 |
run_tree->GetEntry(irun); |
run_tree->GetEntry(irun); |
| 2183 |
if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){ |
if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){ |
| 2184 |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<" has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl; |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<" has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl; |
| 2198 |
|
|
| 2199 |
// -------------------------------------- |
// -------------------------------------- |
| 2200 |
// ... otherwise |
// ... otherwise |
| 2201 |
|
// -------------------------------------- |
| 2202 |
|
|
| 2203 |
|
|
| 2204 |
|
|
| 2205 |
|
// // ----------------------------------------- |
| 2206 |
|
// // store dead and live-time of previous run |
| 2207 |
|
// // ----------------------------------------- |
| 2208 |
|
// // -------------------------------------------------------------- |
| 2209 |
|
// // if the run is empty, fill the dead-live time branch with zeros |
| 2210 |
|
// // -------------------------------------------------------------- |
| 2211 |
|
// /// if some runs have been jumped, fill with zeros |
| 2212 |
|
// if(irun-oldrun>1){ |
| 2213 |
|
// ULong64_t temp[3]; |
| 2214 |
|
// temp[0]=totdltime[0]; |
| 2215 |
|
// temp[1]=totdltime[1]; |
| 2216 |
|
// temp[2]=totdltime[2]; |
| 2217 |
|
// for(int i=oldrun+1; i<irun; irun++){ |
| 2218 |
|
// totdltime[0]=0; |
| 2219 |
|
// totdltime[1]=0; |
| 2220 |
|
// totdltime[2]=0; |
| 2221 |
|
// cout << " ** JUMPED RUN **"<<endl; |
| 2222 |
|
// if(run_tree_clone) |
| 2223 |
|
// if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) |
| 2224 |
|
// run_tree_clone->GetBranch("DeadLiveTime")->Fill(); |
| 2225 |
|
// } |
| 2226 |
|
// totdltime[0]=temp[0]; |
| 2227 |
|
// totdltime[1]=temp[1]; |
| 2228 |
|
// totdltime[2]=temp[2]; |
| 2229 |
|
// } |
| 2230 |
|
// /// decrement counters |
| 2231 |
|
// if( GetTrigLevel2() ){ |
| 2232 |
|
// totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time |
| 2233 |
|
// totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time |
| 2234 |
|
// } |
| 2235 |
|
// totdltime[2]--; //event counter |
| 2236 |
|
// /// add an entry |
| 2237 |
|
// if(irun>0 ){ |
| 2238 |
|
// cout << endl; |
| 2239 |
|
// cout << "n.events : "<<totdltime[2]<<endl; |
| 2240 |
|
// cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl; |
| 2241 |
|
// cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl; |
| 2242 |
|
// if(run_tree_clone) |
| 2243 |
|
// if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) |
| 2244 |
|
// run_tree_clone->GetBranch("DeadLiveTime")->Fill(); |
| 2245 |
|
// } |
| 2246 |
|
// /// reset counters |
| 2247 |
|
// if( GetTrigLevel2() ){ |
| 2248 |
|
// totdltime[0]=GetTrigLevel2()->dltime[0];//live-time |
| 2249 |
|
// totdltime[1]=0; //dead-time |
| 2250 |
|
// } |
| 2251 |
|
// totdltime[2]=1; //event counter |
| 2252 |
|
|
| 2253 |
|
|
| 2254 |
|
// -------------------------------------- |
| 2255 |
// ---> exit with TRUE |
// ---> exit with TRUE |
| 2256 |
// -------------------------------------- |
// -------------------------------------- |
| 2257 |
cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
| 2266 |
true ){ |
true ){ |
| 2267 |
cout << "* fragment *"<<endl; |
cout << "* fragment *"<<endl; |
| 2268 |
} |
} |
| 2269 |
|
|
| 2270 |
return(true); |
return(true); |
| 2271 |
}; |
}; |
| 2272 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
| 2946 |
} |
} |
| 2947 |
cout << "----------------------------------------------------"<<endl; |
cout << "----------------------------------------------------"<<endl; |
| 2948 |
|
|
| 2949 |
|
// ------------------------------------ |
| 2950 |
|
// add branch with dead and live times |
| 2951 |
|
// ------------------------------------ |
| 2952 |
|
run_tree_clone->Branch("DeadLiveTime",totdltime,"dltime[3]/l"); |
| 2953 |
|
cout << "Run : branch DeadLiveTime"<<endl; |
| 2954 |
|
|
| 2955 |
|
|
| 2956 |
sel_tree_clone = new TTree("SelectionList","List of selected events "); |
sel_tree_clone = new TTree("SelectionList","List of selected events "); |
| 2957 |
sel_tree_clone->Branch("RunEntry",&irun,"runentry/L"); |
sel_tree_clone->Branch("RunEntry",&irun,"runentry/L"); |
| 3078 |
void PamLevel2::WriteCloneTrees(){ |
void PamLevel2::WriteCloneTrees(){ |
| 3079 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
| 3080 |
cout << "Write clones of PAMELA trees "<<endl; |
cout << "Write clones of PAMELA trees "<<endl; |
| 3081 |
cout << run_tree_clone->GetName()<<endl; |
cout << run_tree_clone->GetName()<<endl; |
| 3082 |
|
if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) |
| 3083 |
|
run_tree_clone->GetBranch("DeadLiveTime")->Fill(); |
| 3084 |
run_tree_clone->Write(); |
run_tree_clone->Write(); |
| 3085 |
cout << sel_tree_clone->GetName()<<endl; |
cout << sel_tree_clone->GetName()<<endl; |
| 3086 |
sel_tree_clone->Write(); |
sel_tree_clone->Write(); |
| 3151 |
// cout << "irunentry "<<irunentry << endl; |
// cout << "irunentry "<<irunentry << endl; |
| 3152 |
// cout << "runfirstentry "<<runfirstentry << endl; |
// cout << "runfirstentry "<<runfirstentry << endl; |
| 3153 |
// cout << "nevents "<<GetRunInfo()->NEVENTS<< endl; |
// cout << "nevents "<<GetRunInfo()->NEVENTS<< endl; |
| 3154 |
if( TRK0 || CAL0 || TOF0 ){ |
|
| 3155 |
if( !GetYodaEntry( ) ){ |
// if( TRK0 || CAL0 || TOF0 ){ |
| 3156 |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading level0 tree"<<endl; |
// if( !GetYodaEntry( ) ){ |
| 3157 |
return 0; |
// cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading level0 tree"<<endl; |
| 3158 |
} |
// return 0; |
| 3159 |
} |
// } |
| 3160 |
|
// } |
| 3161 |
|
|
| 3162 |
|
|
| 3163 |
return 1; |
return 1; |
| 3164 |
|
|
| 3165 |
} |
} |
| 3166 |
|
|
| 3167 |
|
TrkLevel0 *PamLevel2::GetTrkLevel0(){ |
| 3168 |
|
if( !TRK0 )return NULL; |
| 3169 |
|
if( !GetYodaEntry( ) ){ |
| 3170 |
|
cout << " Int_t PamLevel2::GetTrkLevel0() -- ERROR -- error reading level0 tree"<<endl; |
| 3171 |
|
return 0; |
| 3172 |
|
} |
| 3173 |
|
return trk0_obj; |
| 3174 |
|
}; |
| 3175 |
|
CaloLevel0 *PamLevel2::GetCaloLevel0(){ |
| 3176 |
|
if( !CAL0 )return NULL; |
| 3177 |
|
if( !GetYodaEntry( ) ){ |
| 3178 |
|
cout << " Int_t PamLevel2::GetCaloLevel0() -- ERROR -- error reading level0 tree"<<endl; |
| 3179 |
|
return 0; |
| 3180 |
|
} |
| 3181 |
|
return calo0_obj; |
| 3182 |
|
}; |
| 3183 |
|
|
| 3184 |
|
|
| 3185 |
/** |
/** |
| 3186 |
* Method to retrieve the level0 tree (YODA tree) that contains the current event. |
* Method to retrieve the level0 tree (YODA tree) that contains the current event. |
| 3187 |
* Given the run ID (...), if needed it query the DB and load the proper file. |
* Given the run ID (...), if needed it query the DB and load the proper file. |
| 3259 |
}; |
}; |
| 3260 |
l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent()); |
l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent()); |
| 3261 |
} |
} |
| 3262 |
//--------------------------------------------------- |
//-------------------------------------------------- |
| 3263 |
// CALORIMETER: |
// CALORIMETER: |
| 3264 |
if(CAL0){ |
if(CAL0){ |
| 3265 |
if(!calo0_obj){ |
if(!calo0_obj){ |
| 3322 |
|
|
| 3323 |
// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
| 3324 |
// cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
// cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
| 3325 |
// cout << " time "<< GetOrbitalInfo()->absTime << endl; |
// cout << " time "<< abstime << endl; |
| 3326 |
// cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl; |
// cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl; |
| 3327 |
|
|
| 3328 |
if( !GetOrbitalInfo() ){ |
ULong64_t obt = 0; |
| 3329 |
|
ULong64_t pktn = 0; |
| 3330 |
|
if( GetOrbitalInfo() ){ |
| 3331 |
|
obt = GetOrbitalInfo()->OBT; |
| 3332 |
|
pktn = GetOrbitalInfo()->pkt_num; |
| 3333 |
|
} |
| 3334 |
|
|
| 3335 |
|
if( !GetOrbitalInfo() && !ISGP){ |
| 3336 |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl; |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl; |
| 3337 |
return 0; |
return 0; |
| 3338 |
} |
} |
| 3339 |
if( GetOrbitalInfo()->OBT==0 && GetOrbitalInfo()->pkt_num==0 ){ |
if( obt==0 && pktn==0 && !ISGP ){ |
| 3340 |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<<endl; |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<<endl; |
| 3341 |
return 0; |
return 0; |
| 3342 |
} |
} |
| 3358 |
Int_t maxshift = 10; |
Int_t maxshift = 10; |
| 3359 |
do{ |
do{ |
| 3360 |
if(shift>0){ |
if(shift>0){ |
| 3361 |
cout << " PKTNUM L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
cout << " PKTNUM L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
| 3362 |
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; |
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; |
| 3363 |
cout << " L2 <--> L0 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl; |
cout << " L2 <--> L0 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl; |
| 3364 |
} |
} |
| 3368 |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl; |
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl; |
| 3369 |
return 0; |
return 0; |
| 3370 |
} |
} |
| 3371 |
// cout << "PKTNUM "<<shift<<" == L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
|
| 3372 |
// cout << " L2 --- "<< GetOrbitalInfo()->OBT << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<<endl; |
if(ISGP){ |
| 3373 |
|
obt = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()); //BARBATRUCCO |
| 3374 |
|
pktn = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()); //BARBATRUCCO |
| 3375 |
|
} |
| 3376 |
|
|
| 3377 |
|
// cout << "PKTNUM "<<shift<<" == L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
| 3378 |
|
// cout << " L2 --- "<< obt << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<<endl; |
| 3379 |
// if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl; |
// if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl; |
| 3380 |
// cout << " GetOrbitalInfo()->OBT "<< GetOrbitalInfo()->OBT << endl; |
// cout << " obt "<< obt << endl; |
| 3381 |
// cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; |
// cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; |
| 3382 |
// cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl; |
// cout << " pktn "<< pktn << endl; |
| 3383 |
// cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
// cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
| 3384 |
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
| 3385 |
// |
// |
| 3388 |
shift = -1; |
shift = -1; |
| 3389 |
}; |
}; |
| 3390 |
|
|
| 3391 |
}while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift); |
}while( ( obt != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || |
| 3392 |
|
pktn != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()) ) |
| 3393 |
|
&& (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift); |
| 3394 |
|
|
| 3395 |
if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) { |
if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) { |
| 3396 |
cout << " Big trouble here, no such event in Level0 data! " <<endl; |
cout << " Big trouble here, no such event in Level0 data! " <<endl; |
| 3403 |
return answer; |
return answer; |
| 3404 |
|
|
| 3405 |
} |
} |
| 3406 |
|
/** |
| 3407 |
|
* \Brief Set DB connection |
| 3408 |
|
*/ |
| 3409 |
|
Bool_t PamLevel2::SetDBConnection(){ |
| 3410 |
|
|
| 3411 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 3412 |
|
cout<<"Connecting to DB"<<endl; |
| 3413 |
|
cout<<"HOST "<<host<<endl; |
| 3414 |
|
cout<<"USER "<<user<<endl; |
| 3415 |
|
cout<<"PSW "<<psw<<endl; |
| 3416 |
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 3417 |
|
if( !dbc )return false; |
| 3418 |
|
if( !dbc->IsConnected() )return false; |
| 3419 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
| 3420 |
|
return true; |
| 3421 |
|
|
| 3422 |
|
} |
| 3423 |
|
|
| 3424 |
|
/** |
| 3425 |
|
* \Brief Add a friend to the pamela chain. |
| 3426 |
|
* @param cname name of the chain to be added |
| 3427 |
|
*/ |
| 3428 |
|
|
| 3429 |
|
TChain* PamLevel2::AddFriend(TString cname){ |
| 3430 |
|
|
| 3431 |
|
if(!GetPamTree()){ |
| 3432 |
|
cout << " TChain* PamLevel2::AddFriend(TString cname) --- a pamela tree must be created first"<<endl; |
| 3433 |
|
return NULL; |
| 3434 |
|
} |
| 3435 |
|
|
| 3436 |
|
|
| 3437 |
|
TChain *c = new TChain( cname.Data() ); |
| 3438 |
|
|
| 3439 |
|
TIter next( GetPamTree()->GetListOfFiles() ); |
| 3440 |
|
Int_t nf = 0; |
| 3441 |
|
TChainElement* element = 0; |
| 3442 |
|
while ((element = (TChainElement*) next())) { |
| 3443 |
|
c->Add(element->GetTitle()); |
| 3444 |
|
nf++; |
| 3445 |
|
} |
| 3446 |
|
|
| 3447 |
|
GetPamTree()->AddFriend(cname.Data()); |
| 3448 |
|
|
| 3449 |
|
cout << "external chain created and added to pamela friends :"<<cname<<endl; |
| 3450 |
|
cout << "n.files "<<nf<<endl; |
| 3451 |
|
|
| 3452 |
|
|
| 3453 |
|
return c; |
| 3454 |
|
|
| 3455 |
|
} |