1327 |
}; |
}; |
1328 |
|
|
1329 |
cout << "done chain \n"; |
cout << "done chain \n"; |
1330 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
1331 |
|
|
1332 |
// UInt_t *found=0; |
// UInt_t *found=0; |
1333 |
// Tracker |
// Tracker |
1413 |
}else{ |
}else{ |
1414 |
cout << "OrbitalInfo : missing tree"<<endl; |
cout << "OrbitalInfo : missing tree"<<endl; |
1415 |
}; |
}; |
1416 |
|
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
1417 |
|
|
1418 |
// Selection List |
// Selection List |
1419 |
if(L && SELLI==1) { |
if(L && SELLI==1) { |
1425 |
sel_tree = L; |
sel_tree = L; |
1426 |
// if(!Trout)Trout=O; |
// if(!Trout)Trout=O; |
1427 |
// else Trout->AddFriend("SelectionList"); |
// else Trout->AddFriend("SelectionList"); |
1428 |
|
cout << "----------------------------------------------------" <<endl; |
1429 |
}else{ |
}else{ |
1430 |
// cout << "SelectionList : missing tree"<<endl; |
// cout << "SelectionList : missing tree"<<endl; |
1431 |
if(L)L->Delete(); |
if(L)L->Delete(); |
1695 |
// |
// |
1696 |
// check if we have already called once GetEntry, if not call it |
// check if we have already called once GetEntry, if not call it |
1697 |
// |
// |
1698 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev) --- NON FUNZIONA BENISSIMO.... "<<endl; |
1699 |
if(!run){ |
if(!run){ |
1700 |
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing RunInfo tree "<<endl; |
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing RunInfo tree "<<endl; |
1701 |
return(false); |
return(false); |
1711 |
// -------------------------------------- |
// -------------------------------------- |
1712 |
if(SELLI==0){ |
if(SELLI==0){ |
1713 |
|
|
1714 |
|
// |
1715 |
|
// the absolute time is necessary to relate the event with the run |
1716 |
|
// |
1717 |
if( !GetOrbitalInfo() ){ |
if( !GetOrbitalInfo() ){ |
1718 |
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; |
1719 |
return(false); |
return(false); |
1720 |
} |
} |
1721 |
|
|
1722 |
|
// |
1723 |
|
// the first time the routine is called, set run search from the beginning |
1724 |
|
// |
1725 |
if ( irun < 0LL ){ |
if ( irun < 0LL ){ |
1726 |
irun = 0LL; |
irun = 0LL; |
1727 |
run->GetEntry(irun); |
run->GetEntry(irun); |
1728 |
runfirstentry = 0LL; |
runfirstentry = 0LL; |
1729 |
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); |
1730 |
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; |
if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; |
|
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
|
|
// cout << "runfirstentry "<<runfirstentry<<endl; |
|
|
// return(true); |
|
1731 |
}; |
}; |
1732 |
// |
// |
1733 |
if ( irun == run->GetEntries()-1LL && |
if ( irun == run->GetEntries()-1LL && |
1807 |
// |
// |
1808 |
}; |
}; |
1809 |
|
|
1810 |
// Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev){ |
Bool_t PamLevel2::UpdateRunInfo(Long64_t iev){ |
1811 |
// // |
|
1812 |
// // check if we have already called once GetEntry, if not call it |
if(!run_tree){ |
1813 |
// // |
cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree not loaded"<<endl; |
1814 |
// if(!run_tree){ |
return false; |
1815 |
// cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree not loaded"<<endl; |
} |
1816 |
// return false; |
if ( run_tree->GetEntries() <= 0 ) { |
1817 |
// } |
cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree is empty"<<endl; |
1818 |
// if ( run_tree->GetEntries() <= 0 ) { |
return(false); |
1819 |
// cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree is empty"<<endl; |
} |
|
// return(false); |
|
|
// } |
|
|
// // |
|
1820 |
|
|
1821 |
// Int_t oldrun = irun; |
Int_t oldrun = irun; // store current run index |
1822 |
// // -------------------------------------- |
|
1823 |
// // if it is a full file (not preselected) |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
1824 |
// // -------------------------------------- |
// if it is a full file (not preselected) |
1825 |
// if(SELLI==0){ |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
1826 |
|
if(SELLI==0){ |
1827 |
// if( !GetOrbitalInfo() ){ |
|
1828 |
// cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
// --------------------------------------------------------------- |
1829 |
// return(false); |
// the absolute time is necessary to relate the event with the run |
1830 |
// } |
// --------------------------------------------------------------- |
1831 |
|
if( !GetOrbitalInfo() ){ |
1832 |
// if ( irun < 0 ){ |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
1833 |
// irun = 0; |
return(false); |
1834 |
// run_tree->GetEntry(irun); |
} |
1835 |
// runfirstentry = iev; |
|
1836 |
// if( iev != 0){ |
// ----------------------------------------------------------------------- |
1837 |
// cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- WARNING -- "<<endl; |
// the first time the routine is called, set run search from the beginning |
1838 |
// } |
// ----------------------------------------------------------------------- |
1839 |
// }; |
if ( irun < 0 ){ |
1840 |
|
irun = 0LL; |
1841 |
// bool fromfirst = true; |
run_tree->GetEntry(irun); |
1842 |
|
}; |
1843 |
// while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries() ){ |
// |
1844 |
// irun++; |
bool fromfirst = true; // first loop over runs |
1845 |
// if( irun == run->GetEntries() ){ |
// ------------------------------------------------------ |
1846 |
// if(!fromfirst){ |
// loop over runs to find the one that contains the event |
1847 |
// cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- event entry #"<<iev<<" does not belong to any run (should not happen)" <<endl; |
// ------------------------------------------------------ |
1848 |
// return false; |
while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && // check on absolute time (s) |
1849 |
// } |
GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && |
1850 |
// cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- reached end of run tree. searchin again from beginning (should not happen)" <<endl; |
!(GetOrbitalInfo()->OBT >= GetRunInfo()->RUNHEADER_OBT && // additional check on OBT (ms) |
1851 |
// fromfirst = false; |
GetOrbitalInfo()->OBT <= GetRunInfo()->RUNTRAILER_OBT) && |
1852 |
// irun =0; |
irun < run_tree->GetEntries() ){ |
1853 |
// } |
irun++; |
1854 |
// run_tree->GetEntry(irun); |
// ------------------------------------ |
1855 |
// runfirstentry = iev; |
// if the end of run tree is reached... |
1856 |
// }; |
// ------------------------------------ |
1857 |
// // |
if( irun == run_tree->GetEntries() ){ |
1858 |
// if ( irun == oldrun ) return(false); |
if(!fromfirst){ |
1859 |
// // |
// ----------------------------------------------------- |
1860 |
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
// if it happened already once and the run was not found |
1861 |
// cout << "runfirstentry "<<runfirstentry<<endl; |
// ---> exit with error |
1862 |
// prevshift = 0; |
// ----------------------------------------------------- |
1863 |
// return(true); |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- event entry #"<<iev<<" does not belong to any run (should not happen)" <<endl; |
1864 |
// }; |
return false; |
1865 |
// // ---------------------------------------------------- |
} |
1866 |
// // if it is a preselected file (there is SelectionList) |
// ----------------------------------------- |
1867 |
// // NBNB - the event tree MUST be read first |
// ...otherwise repeat search from beginning |
1868 |
// // ---------------------------------------------------- |
// ----------------------------------------- |
1869 |
// if(SELLI==1){ |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- reached end of run tree. searchin again from beginning " <<endl; |
1870 |
// sel_tree->GetEntry(iev); |
fromfirst = false; |
1871 |
// if(irun != oldrun){ |
irun = 0LL; |
1872 |
// run->GetEntry(irun); |
runfirstentry = 0LL; |
1873 |
// cout << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
} |
1874 |
// prevshift = 0; |
// ------------------------------------------------------------------- |
1875 |
// return true; |
// save the index of the first entry of the run, relative to pam_tree, |
1876 |
// } |
// and read a new run |
1877 |
// return false; |
// ------------------------------------------------------------------- |
1878 |
// } |
if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS); |
1879 |
|
run_tree->GetEntry(irun); |
1880 |
// return false; |
if(GetRunInfo()->RUNHEADER_OBT>=GetRunInfo()->RUNTRAILER_OBT ){ |
1881 |
// // |
cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<" has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl; |
1882 |
// }; |
cout << " (NB!! in this case some events are assigned to a wrong run)"<<endl; |
1883 |
|
} |
1884 |
|
}; |
1885 |
|
// -------------------------------------- |
1886 |
|
// if there was no need to update the run |
1887 |
|
// ---> exit with FALSE |
1888 |
|
// -------------------------------------- |
1889 |
|
if ( irun == oldrun ) return(false); |
1890 |
|
|
1891 |
|
// -------------------------------------- |
1892 |
|
// ... otherwise |
1893 |
|
// ---> exit with TRUE |
1894 |
|
// -------------------------------------- |
1895 |
|
cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
1896 |
|
prevshift = 0; |
1897 |
|
return(true); |
1898 |
|
}; |
1899 |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
1900 |
|
// if it is a preselected file (there is SelectionList) |
1901 |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
1902 |
|
if(SELLI==1){ |
1903 |
|
sel_tree->GetEntry(iev); |
1904 |
|
if(irun != oldrun){ |
1905 |
|
run_tree->GetEntry(irun); |
1906 |
|
cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl; |
1907 |
|
prevshift = 0; |
1908 |
|
return true; |
1909 |
|
} |
1910 |
|
return false; |
1911 |
|
} |
1912 |
|
|
1913 |
|
return false; |
1914 |
|
// |
1915 |
|
}; |
1916 |
/** |
/** |
1917 |
* 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) |
1918 |
* @param run Pointer to the chain/tree which contains run infos |
* @param run Pointer to the chain/tree which contains run infos |
2553 |
cout << "Run : branch RunInfo"<<endl; |
cout << "Run : branch RunInfo"<<endl; |
2554 |
run_tree_clone->Branch("SoftInfo","SoftInfo",GetPointerTo("SoftInfo")); |
run_tree_clone->Branch("SoftInfo","SoftInfo",GetPointerTo("SoftInfo")); |
2555 |
cout << "Run : branch SoftInfo"<<endl; |
cout << "Run : branch SoftInfo"<<endl; |
2556 |
|
// ------------------ |
2557 |
|
// replicate run tree |
2558 |
|
// ------------------ |
2559 |
|
cout << "----------------------------------------------------"<<endl; |
2560 |
|
cout << "irun\t | RUN\t NEVENTS\t absolute time"<<endl; |
2561 |
|
for (Int_t i=0; i<run_tree->GetEntries(); i++){ |
2562 |
|
run_tree->GetEntry(i); |
2563 |
|
cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl; |
2564 |
|
run_tree_clone->Fill(); |
2565 |
|
} |
2566 |
|
cout << "----------------------------------------------------"<<endl; |
2567 |
|
|
2568 |
|
|
2569 |
sel_tree_clone = new TTree("SelectionList","List of selected events "); |
sel_tree_clone = new TTree("SelectionList","List of selected events "); |
2578 |
pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
2579 |
pam_tree_clone[i]->BranchRef(); |
pam_tree_clone[i]->BranchRef(); |
2580 |
cout << "Tracker : branch TrkLevel1"<<endl; |
cout << "Tracker : branch TrkLevel1"<<endl; |
2581 |
cout << "CreateCloneTrees " << GetTrkLevel1()<<endl; |
// cout << "CreateCloneTrees " << GetTrkLevel1()<<endl; |
2582 |
}; |
}; |
2583 |
if(TRK2) { |
if(TRK2) { |
2584 |
pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
2739 |
// |
// |
2740 |
if(!run_tree ){ |
if(!run_tree ){ |
2741 |
if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1? |
if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1? |
2742 |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl; |
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl; |
2743 |
return 0; |
return 0; |
2744 |
} else { |
} else { |
2745 |
return 1; //cosi` se non c'e` run esce qua... |
return 1; //cosi` se non c'e` run esce qua... |
2746 |
} |
} |
2747 |
} |
} |
2748 |
|
|
2749 |
//------------------------------- |
//------------------------------- |
2750 |
ii = iee; |
ii = iee; |
2751 |
// Bool_t UPDATED = UpdateRunInfo(run_tree,ii); |
// Bool_t UPDATED = UpdateRunInfo(run_tree,ii); |
2752 |
Bool_t UPDATED = UpdateRunInfo(ii); |
// Bool_t UPDATED = UpdateRunInfo(ii); |
2753 |
|
UpdateRunInfo(ii); |
2754 |
if(SELLI==0)irunentry = iee-runfirstentry; |
if(SELLI==0)irunentry = iee-runfirstentry; |
2755 |
if(UPDATED && run_tree_clone)run_tree_clone->Fill(); |
// if(UPDATED && run_tree_clone)run_tree_clone->Fill(); |
2756 |
|
|
2757 |
// cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl; |
// cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl; |
2758 |
|
|
2759 |
if( TRK0 || CAL0 || TOF0 )GetYodaEntry( ); |
// cout << " irunentry "<<irunentry << endl; |
2760 |
|
|
2761 |
|
if( TRK0 || CAL0 || TOF0 ){ |
2762 |
|
if( !GetYodaEntry( ) ){ |
2763 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading level0 tree"<<endl; |
2764 |
|
return 0; |
2765 |
|
} |
2766 |
|
} |
2767 |
return 1; |
return 1; |
2768 |
|
|
2769 |
} |
} |
2895 |
|
|
2896 |
// patch |
// patch |
2897 |
if( irunentry < 0){ |
if( irunentry < 0){ |
2898 |
cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; |
// cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; |
2899 |
irunentry=0LL; |
irunentry=0LL; |
2900 |
} |
} |
2901 |
// --------------------------------- |
// --------------------------------- |
2902 |
// if file is NOT a preselected file |
// if file is NOT a preselected file |
2903 |
// --------------------------------- |
// --------------------------------- |
2904 |
Long64_t quellagiusta = irunentry + (Long64_t)(run_obj->EV_FROM); |
Long64_t quellagiusta = irunentry + (Long64_t)(run_obj->EV_FROM); |
2905 |
|
// cout << " irunentry "<<irunentry<<endl; |
2906 |
|
// cout << " EV_FROM "<<run_obj->EV_FROM<<endl; |
2907 |
|
// cout << " quellagiusta = irunentry + EV_FROM "<< quellagiusta << endl; |
2908 |
|
|
2909 |
// 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; |
2910 |
// 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; |
2934 |
Int_t answer = 0; |
Int_t answer = 0; |
2935 |
Int_t shift =0; |
Int_t shift =0; |
2936 |
// printf(" siamo qui %i %i \n",shift,prevshift); |
// printf(" siamo qui %i %i \n",shift,prevshift); |
2937 |
|
Int_t maxshift = 100; |
2938 |
do{ |
do{ |
2939 |
if(shift>0){ |
if(shift>0){ |
2940 |
cout << " level0 <--> level2 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl; |
cout << " PKTNUM L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl; |
2941 |
|
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; |
2942 |
|
cout << " L2 <--> L0 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl; |
2943 |
} |
} |
2944 |
answer = l0_tree->GetEntry(quellagiusta+(Long64_t)shift+(Long64_t)prevshift); |
answer = l0_tree->GetEntry(quellagiusta+(Long64_t)shift+(Long64_t)prevshift); |
2945 |
shift++; |
shift++; |
2961 |
shift = -1; |
shift = -1; |
2962 |
}; |
}; |
2963 |
|
|
2964 |
}while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() ); |
}while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift); |
|
|
|
|
if ( (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() ) cout << " Big trouble here, no such event in Level0 data! " <<endl; |
|
2965 |
|
|
2966 |
|
if ( (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() || shift == maxshift ) { |
2967 |
|
cout << " Big trouble here, no such event in Level0 data! " <<endl; |
2968 |
|
return 0; |
2969 |
|
} |
2970 |
// cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
// cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
2971 |
// return GetYodaTree()->GetEntry(quellagiusta); |
// return GetYodaTree()->GetEntry(quellagiusta); |
2972 |
if ( shift > 1 ) prevshift += (shift-1); |
if ( shift > 1 ) prevshift += (shift-1); |