100 |
// nd_obj = NDLevel2::GetNDLevel2(); |
// nd_obj = NDLevel2::GetNDLevel2(); |
101 |
// ac_obj = AcLevel2::GetAcLevel2(); |
// ac_obj = AcLevel2::GetAcLevel2(); |
102 |
// orb_obj = OrbitalInfo::GetOrbitalInfo(); |
// orb_obj = OrbitalInfo::GetOrbitalInfo(); |
103 |
|
|
104 |
|
h0_obj = 0; |
105 |
|
trk0_obj = 0; |
106 |
|
calo0_obj = 0; |
107 |
|
|
108 |
trk2_obj = 0; |
trk2_obj = 0; |
109 |
trk1_obj = 0; |
trk1_obj = 0; |
110 |
trkh_obj = 0; |
trkh_obj = 0; |
123 |
runfirstentry = 0ULL; |
runfirstentry = 0ULL; |
124 |
runlastentry = 0ULL; |
runlastentry = 0ULL; |
125 |
|
|
126 |
for(Int_t i=0; i<8; i++ )tree_clone[i]=NULL; |
l0_file = NULL; |
127 |
|
l0_tree = NULL; |
128 |
|
iroot = -1; |
129 |
|
dbc = 0; |
130 |
|
|
131 |
|
prevshift = 0; |
132 |
|
|
133 |
|
irun = -1; |
134 |
|
run_tree = NULL; |
135 |
|
run_tree_clone = NULL; |
136 |
|
sel_tree = NULL; |
137 |
|
sel_tree_clone = NULL; |
138 |
|
|
139 |
|
irunentry = -1; |
140 |
|
pam_tree = NULL; |
141 |
|
for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL; |
142 |
|
|
143 |
|
host = "mysql://localhost/pamelaprod"; |
144 |
|
user = "anonymous"; |
145 |
|
psw = ""; |
146 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
147 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
148 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
149 |
|
if ( !pamdbhost ) pamdbhost = ""; |
150 |
|
if ( !pamdbuser ) pamdbuser = ""; |
151 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
152 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
153 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
154 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
155 |
|
|
156 |
|
|
157 |
|
|
158 |
// sorted_tracks = 0;//new TRefArray(); |
// sorted_tracks = 0;//new TRefArray(); |
159 |
|
|
160 |
|
CAL0 = false; |
161 |
CAL1 = true; |
CAL1 = true; |
162 |
CAL2 = true; |
CAL2 = true; |
163 |
TRK2 = true; |
TRK2 = true; |
164 |
TRK1 = false; |
TRK1 = false; |
165 |
TRKh = false; |
TRKh = false; |
166 |
TRG = true; |
TRKh = false; |
167 |
TOF = true; |
TRG = true; |
168 |
S4 = true; |
TOF = true; |
169 |
ND = true; |
TOF0 = false; |
170 |
AC = true; |
S4 = true; |
171 |
ORB = true; |
ND = true; |
172 |
|
AC = true; |
173 |
|
ORB = true; |
174 |
|
|
175 |
RUN = true; |
RUN = true; |
176 |
|
|
177 |
|
SELLI = -1; |
178 |
|
|
179 |
tsorted=0; |
tsorted=0; |
180 |
timage=0; |
timage=0; |
189 |
if(soft_obj)delete soft_obj; //Emiliano |
if(soft_obj)delete soft_obj; //Emiliano |
190 |
|
|
191 |
// cout << "void PamLevel2::Clear()"<<endl; |
// cout << "void PamLevel2::Clear()"<<endl; |
192 |
|
if(h0_obj) delete h0_obj; |
193 |
|
if(trk0_obj) delete trk0_obj; |
194 |
|
if(calo0_obj) delete calo0_obj; |
195 |
if(trk1_obj) delete trk1_obj; |
if(trk1_obj) delete trk1_obj; |
196 |
if(trk2_obj) delete trk2_obj; |
if(trk2_obj) delete trk2_obj; |
197 |
if(trkh_obj) delete trkh_obj; |
if(trkh_obj) delete trkh_obj; |
212 |
timage->Delete(); |
timage->Delete(); |
213 |
delete timage; |
delete timage; |
214 |
} |
} |
215 |
|
|
216 |
|
if(dbc){ |
217 |
|
dbc->Close(); |
218 |
|
delete dbc; |
219 |
|
} |
220 |
|
|
221 |
|
if(l0_file)l0_file->Close(); |
222 |
|
if(pam_tree)pam_tree->Delete();; |
223 |
|
if(run_tree)run_tree->Delete();; |
224 |
|
if(sel_tree)sel_tree->Delete();; |
225 |
|
for(Int_t i=0; i<NCLONES; i++ )if(pam_tree_clone[i])pam_tree_clone[i]->Delete();; |
226 |
|
if(run_tree_clone)run_tree_clone->Delete();; |
227 |
|
if(sel_tree_clone)sel_tree_clone->Delete();; |
228 |
|
|
229 |
|
|
230 |
}; |
}; |
231 |
|
|
232 |
/** |
/** |
244 |
// if(run_obj) run_obj->Clear(); // Emiliano: Do not deallocate run_obj here, it will give segmentation fault! call clear instead |
// if(run_obj) run_obj->Clear(); // Emiliano: Do not deallocate run_obj here, it will give segmentation fault! call clear instead |
245 |
// if(soft_obj) soft_obj->Clear(); |
// if(soft_obj) soft_obj->Clear(); |
246 |
|
|
247 |
|
if(h0_obj) h0_obj->Clear(); |
248 |
|
if(trk0_obj) trk0_obj->Clear(); |
249 |
|
if(calo0_obj) calo0_obj->Clear(); |
250 |
if(trk1_obj) trk1_obj->Clear(); |
if(trk1_obj) trk1_obj->Clear(); |
251 |
if(trk2_obj) trk2_obj->Clear(); |
if(trk2_obj) trk2_obj->Clear(); |
252 |
if(trkh_obj) trkh_obj->Clear(); |
if(trkh_obj) trkh_obj->Clear(); |
559 |
use_CAL && |
use_CAL && |
560 |
calo2_obj->npcfit[1] > 15 && //no. of fit planes on Y view |
calo2_obj->npcfit[1] > 15 && //no. of fit planes on Y view |
561 |
calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
562 |
|
cp && ci && |
563 |
true){ |
true){ |
564 |
|
|
565 |
|
|
581 |
cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but ToFLevel2 not loaded !!!"; |
cout << "void PamLevel2::SortTracks(TString how): how= "<<how<<" but ToFLevel2 not loaded !!!"; |
582 |
return; |
return; |
583 |
}; |
}; |
584 |
if( use_TOF ){ |
if( use_TOF && op && oi ){ |
585 |
|
|
586 |
Int_t nphit_p =0; |
Int_t nphit_p =0; |
587 |
Int_t nphit_i =0; |
Int_t nphit_i =0; |
837 |
|
|
838 |
// if( !detlist.IsNull() ) SetWhichTrees(detlist); |
// if( !detlist.IsNull() ) SetWhichTrees(detlist); |
839 |
// else GetWhichTrees(f); |
// else GetWhichTrees(f); |
840 |
|
|
841 |
|
cout << "TTree *PamLevel2::GetPamTree(TFile *f, TString detlist ) -- obsolte "<<endl; |
842 |
|
|
843 |
SetWhichTrees(detlist); |
SetWhichTrees(detlist); |
844 |
|
|
845 |
TTree *Trout =0; |
TTree *Trout =0; |
847 |
TString fname = f->GetName(); |
TString fname = f->GetName(); |
848 |
if(!CheckLevel2File(fname))return NULL; |
if(!CheckLevel2File(fname))return NULL; |
849 |
|
|
850 |
UInt_t *found=0; |
// UInt_t *found=0; |
851 |
|
|
852 |
cout<< "GetPamTree(TFile*,TString): detector list --> "; |
cout<< "GetPamTree(TFile*,TString): detector list --> "; |
853 |
if(TRK1)cout<<"TRK1 "; |
if(TRK1)cout<<"TRK1 "; |
862 |
if(S4)cout<<"S4 "; |
if(S4)cout<<"S4 "; |
863 |
if(ORB)cout<<"ORB "; |
if(ORB)cout<<"ORB "; |
864 |
cout << endl; |
cout << endl; |
865 |
|
if(SELLI)cout<<">>> Found selection-list <<<"<<endl; |
866 |
|
|
867 |
f->cd(); |
f->cd(); |
868 |
|
|
870 |
TTree *T = (TTree*)f->Get("Tracker"); |
TTree *T = (TTree*)f->Get("Tracker"); |
871 |
if(T && (TRK2||TRK1||TRKh)) { |
if(T && (TRK2||TRK1||TRKh)) { |
872 |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
873 |
else T->SetBranchStatus("TrkLevel2",0,found); |
// else T->SetBranchStatus("TrkLevel2",0,found); |
874 |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
875 |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
876 |
else T->SetBranchStatus("TrkLevel1",0,found); |
// else T->SetBranchStatus("TrkLevel1",0,found); |
877 |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
878 |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
879 |
else T->SetBranchStatus("TrkHough",0,found); |
// else T->SetBranchStatus("TrkHough",0,found); |
880 |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
881 |
if(!Trout)Trout=T; |
if(!Trout)Trout=T; |
882 |
else Trout->AddFriend(T); |
else Trout->AddFriend(T); |
887 |
TTree *C = (TTree*)f->Get("Calorimeter"); |
TTree *C = (TTree*)f->Get("Calorimeter"); |
888 |
if(C && (CAL2||CAL1)) { |
if(C && (CAL2||CAL1)) { |
889 |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
890 |
else C->SetBranchStatus("CaloLevel2",0,found); |
// else C->SetBranchStatus("CaloLevel2",0,found); |
891 |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
892 |
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
893 |
else C->SetBranchStatus("CaloLevel1",0,found); |
// else C->SetBranchStatus("CaloLevel1",0,found); |
894 |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
895 |
if(!Trout)Trout=C; |
if(!Trout)Trout=C; |
896 |
else Trout->AddFriend(C); |
else Trout->AddFriend(C); |
958 |
}else{ |
}else{ |
959 |
cout << "OrbitalInfo : missing tree"<<endl; |
cout << "OrbitalInfo : missing tree"<<endl; |
960 |
}; |
}; |
961 |
|
|
962 |
|
TTree *L = (TTree*)f->Get("SelectionList"); |
963 |
|
if(L && SELLI==1) { |
964 |
|
// L->SetBranchAddress("RunEntry",&irun); |
965 |
|
// cout << "SelectionList: set branch address RunEntry"<<endl; |
966 |
|
// L->SetBranchAddress("EventEntry",&irunentry); |
967 |
|
// cout << "SelectionList: set branch address EventEntry"<<endl; |
968 |
|
// if(!Trout)Trout=O; |
969 |
|
// else Trout->AddFriend("SelectionList"); |
970 |
|
cout << " TTree *PamLevel2::GetPamTree(TFile, TString) >>> SelectionList not implemente!!!!"<<endl; |
971 |
|
sel_tree = 0; |
972 |
|
}else{ |
973 |
|
cout << "SelectionList : missing tree"<<endl; |
974 |
|
}; |
975 |
|
|
976 |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
977 |
|
|
978 |
|
pam_tree = (TChain*)Trout; |
979 |
|
|
980 |
return Trout; |
return Trout; |
981 |
|
|
1014 |
// return 0; |
// return 0; |
1015 |
// } |
// } |
1016 |
// flisttxt = fullpath; |
// flisttxt = fullpath; |
1017 |
|
if ( !flisttxt.EndsWith(".root") ){ |
1018 |
|
|
1019 |
flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
1020 |
|
|
1046 |
// cout <<"(2) " << file << endl; |
// cout <<"(2) " << file << endl; |
1047 |
// if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
// if( gSystem->IsFileInIncludePath(file,&fullpath) ){ |
1048 |
// if( (fullpath = gSystem->FindFile(ddir,file)) ){ |
// if( (fullpath = gSystem->FindFile(ddir,file)) ){ |
1049 |
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(file)); |
if( file.EndsWith(".root") ){ |
1050 |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(file)); |
1051 |
delete fullpath; |
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
1052 |
|
delete fullpath; |
1053 |
|
} |
1054 |
// }else{ |
// }else{ |
1055 |
// if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl; |
// if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl; |
1056 |
// }; |
// }; |
1057 |
}; |
}; |
1058 |
in.close(); |
in.close(); |
1059 |
|
} else { |
1060 |
|
char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); |
1061 |
|
contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list |
1062 |
|
delete fullpath; |
1063 |
|
}; |
1064 |
}else{ |
}else{ |
1065 |
|
|
1066 |
cout << "No input file list given."<<endl; |
cout << "No input file list given."<<endl; |
1138 |
TChain *N = 0; |
TChain *N = 0; |
1139 |
TChain *A = 0; |
TChain *A = 0; |
1140 |
TChain *B = 0; |
TChain *B = 0; |
1141 |
|
|
1142 |
|
TChain *L = 0; |
1143 |
|
|
1144 |
if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); |
if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); |
1145 |
if(CAL2||CAL1) C = new TChain("Calorimeter"); |
if(CAL2||CAL1) C = new TChain("Calorimeter"); |
1149 |
if(ND) N = new TChain("NeutronD"); |
if(ND) N = new TChain("NeutronD"); |
1150 |
if(AC) A = new TChain("Anticounter"); |
if(AC) A = new TChain("Anticounter"); |
1151 |
if(ORB) B = new TChain("OrbitalInfo"); |
if(ORB) B = new TChain("OrbitalInfo"); |
1152 |
|
|
1153 |
|
L = new TChain("SelectionList"); |
1154 |
|
|
1155 |
// loop over files and create chains |
// loop over files and create chains |
1156 |
TIter next(fl); |
TIter next(fl); |
1167 |
if(ND) N->Add(name); |
if(ND) N->Add(name); |
1168 |
if(AC) A->Add(name); |
if(AC) A->Add(name); |
1169 |
if(ORB) B->Add(name); |
if(ORB) B->Add(name); |
1170 |
|
if(SELLI==1) L->Add(name); |
1171 |
}; |
}; |
1172 |
} |
} |
1173 |
|
|
1174 |
cout << "done chain \n"; |
cout << "done chain \n"; |
1175 |
|
|
1176 |
UInt_t *found=0; |
// UInt_t *found=0; |
1177 |
// Tracker |
// Tracker |
1178 |
if(T && (TRK2||TRK1||TRKh)) { |
if(T && (TRK2||TRK1||TRKh)) { |
1179 |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); |
1180 |
else T->SetBranchStatus("TrkLevel2",0,found); |
// else T->SetBranchStatus("TrkLevel2",0,found); |
1181 |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl; |
1182 |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); |
1183 |
else T->SetBranchStatus("TrkLevel1",0,found); |
// else T->SetBranchStatus("TrkLevel1",0,found); |
1184 |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl; |
1185 |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); |
1186 |
else T->SetBranchStatus("TrkHough",0,found); |
// else T->SetBranchStatus("TrkHough",0,found); |
1187 |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl; |
1188 |
if(!Trout)Trout=T; |
if(!Trout)Trout=T; |
1189 |
else Trout->AddFriend("Tracker"); |
else Trout->AddFriend("Tracker"); |
1193 |
// Calorimeter |
// Calorimeter |
1194 |
if(C && (CAL2||CAL1)) { |
if(C && (CAL2||CAL1)) { |
1195 |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); |
1196 |
else C->SetBranchStatus("CaloLevel2",0,found); |
// else C->SetBranchStatus("CaloLevel2",0,found); |
1197 |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
1198 |
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); |
1199 |
else C->SetBranchStatus("CaloLevel1",0,found); |
// else C->SetBranchStatus("CaloLevel1",0,found); |
1200 |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl; |
1201 |
if(!Trout)Trout=C; |
if(!Trout)Trout=C; |
1202 |
else Trout->AddFriend("Calorimeter"); |
else Trout->AddFriend("Calorimeter"); |
1257 |
}else{ |
}else{ |
1258 |
cout << "OrbitalInfo : missing tree"<<endl; |
cout << "OrbitalInfo : missing tree"<<endl; |
1259 |
}; |
}; |
1260 |
|
|
1261 |
|
// Selection List |
1262 |
|
if(L && SELLI==1) { |
1263 |
|
cout<<">>> Found selection-list <<<"<<endl; |
1264 |
|
L->SetBranchAddress("RunEntry",&irun); |
1265 |
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
1266 |
|
L->SetBranchAddress("EventEntry",&irunentry); |
1267 |
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
1268 |
|
sel_tree = L; |
1269 |
|
// if(!Trout)Trout=O; |
1270 |
|
// else Trout->AddFriend("SelectionList"); |
1271 |
|
}else{ |
1272 |
|
// cout << "SelectionList : missing tree"<<endl; |
1273 |
|
if(L)L->Delete(); |
1274 |
|
}; |
1275 |
|
|
1276 |
// cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
// cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
1277 |
|
|
1278 |
|
pam_tree = Trout; |
1279 |
// // Tracker |
|
|
// if(TRK2||TRK1||TRKh){ |
|
|
// if(!Tout)Tout=T; |
|
|
// else Tout->AddFriend("Tracker"); |
|
|
// } |
|
|
// // Calorimeter |
|
|
// if(CAL2||CAL1) { |
|
|
// if(!Tout)Tout=C; |
|
|
// else Tout->AddFriend("Calorimeter"); |
|
|
// }; |
|
|
// // ToF |
|
|
// if(TOF) { |
|
|
// if(!Tout)Tout=O; |
|
|
// else Tout->AddFriend("ToF"); |
|
|
// }; |
|
|
// // Trigger |
|
|
// if(TRG) { |
|
|
// if(!Tout)Tout=R; |
|
|
// else Tout->AddFriend("Trigger"); |
|
|
// }; |
|
|
// // S4 |
|
|
// if(S4) { |
|
|
// if(!Tout)Tout=S; |
|
|
// else Tout->AddFriend("S4"); |
|
|
// }; |
|
|
// // Neutron Detector |
|
|
// if(ND) { |
|
|
// if(!Tout)Tout=N; |
|
|
// else Tout->AddFriend("NeutronD"); |
|
|
// }; |
|
|
// // Anticounters |
|
|
// if(AC) { |
|
|
// if(!Tout)Tout=A; |
|
|
// else Tout->AddFriend("Anticounter"); |
|
|
// }; |
|
|
// // OrbitalInfo |
|
|
// if(ORB) { |
|
|
// if(!Tout)Tout=B; |
|
|
// else Tout->AddFriend("OrbitalInfo"); |
|
|
// }; |
|
|
|
|
|
// cout<<endl<<" Number of entries: "<<Tout->GetEntries()<<endl<<endl; |
|
|
|
|
|
// if( Tout->GetEntries() )PamLevel2::SetBranchAddress( Tout ); |
|
|
|
|
1280 |
return Trout; |
return Trout; |
1281 |
} |
} |
1282 |
|
|
1358 |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1359 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1360 |
}; |
}; |
1361 |
|
// SelectionList |
1362 |
|
if(SELLI==1) { |
1363 |
|
t->SetBranchAddress("RunEntry", &irun); |
1364 |
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
1365 |
|
t->SetBranchAddress("EventEntry", &irunentry); |
1366 |
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
1367 |
|
}; |
1368 |
|
|
1369 |
} |
} |
1370 |
/** |
/** |
1438 |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); |
1439 |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
1440 |
}; |
}; |
1441 |
|
// SelectionList |
1442 |
|
if(SELLI==1) { |
1443 |
|
t->SetBranchAddress("RunEntry", &irun); |
1444 |
|
cout << "SelectionList: set branch address RunEntry"<<endl; |
1445 |
|
t->SetBranchAddress("EventEntry", &irunentry); |
1446 |
|
cout << "SelectionList: set branch address EventEntry"<<endl; |
1447 |
|
}; |
1448 |
|
|
1449 |
} |
} |
1450 |
|
|
1472 |
R->Add(name); |
R->Add(name); |
1473 |
}; |
}; |
1474 |
} |
} |
1475 |
|
|
1476 |
|
if(R->GetNtrees()){ |
1477 |
|
|
1478 |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
1479 |
cout << "Run : set branch address RunInfo"<<endl; |
cout << "Run : set branch address RunInfo"<<endl; |
1480 |
R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
1481 |
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
1482 |
|
}else{ |
1483 |
|
delete R; |
1484 |
|
R=0; |
1485 |
|
} |
1486 |
|
|
1487 |
|
run_tree = R; |
1488 |
|
|
1489 |
return R; |
return R; |
1490 |
|
|
1491 |
} |
} |
1500 |
*/ |
*/ |
1501 |
TTree *PamLevel2::GetRunTree(TFile *f){ |
TTree *PamLevel2::GetRunTree(TFile *f){ |
1502 |
|
|
1503 |
|
cout << "TTree *PamLevel2::GetRunTree(TFile *f) -- obsolte "<<endl; |
1504 |
|
|
1505 |
TTree *R = (TTree*)f->Get("Run"); |
TTree *R = (TTree*)f->Get("Run"); |
1506 |
|
|
1507 |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
if(R){ |
1508 |
cout << "Run : set branch address RunInfo"<<endl; |
R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); |
1509 |
R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
cout << "Run : set branch address RunInfo"<<endl; |
1510 |
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano |
1511 |
|
cout << "Software : set branch address SoftInfo"<<endl; // Emiliano |
1512 |
|
} |
1513 |
|
|
1514 |
|
run_tree = (TChain*)R; |
1515 |
|
|
1516 |
return R; |
return R; |
1517 |
|
|
1518 |
} |
} |
1527 |
// |
// |
1528 |
if ( run->GetEntries() <= 0 ) return(false); |
if ( run->GetEntries() <= 0 ) return(false); |
1529 |
// |
// |
1530 |
|
|
1531 |
Int_t oldrun = irun; |
Int_t oldrun = irun; |
1532 |
if ( irun < 0 ){ |
// -------------------------------------- |
1533 |
irun = 0; |
// if it is a full file (not preselected) |
1534 |
run->GetEntry(0); |
// -------------------------------------- |
1535 |
runfirstentry = 0ULL; |
if(SELLI==0){ |
1536 |
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS) - 1ULL; |
if ( irun < 0 ){ |
1537 |
|
irun = 0; |
1538 |
|
run->GetEntry(irun); |
1539 |
|
runfirstentry = 0ULL; |
1540 |
|
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); |
1541 |
|
if ( (ULong64_t)(this->GetRunInfo()->NEVENTS) > 0ULL ) runlastentry -= 1ULL; |
1542 |
|
return(true); |
1543 |
|
}; |
1544 |
|
|
1545 |
|
if( !GetOrbitalInfo() ){ |
1546 |
|
cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl; |
1547 |
|
return(false); |
1548 |
|
} |
1549 |
|
// modificato il controllo sull'aggiornamento del run, per evitare problemi |
1550 |
|
// dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!) |
1551 |
|
// |
1552 |
|
bool fromfirst = true; |
1553 |
|
// |
1554 |
|
while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries() ){ |
1555 |
|
// while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
1556 |
|
irun++; |
1557 |
|
run->GetEntry(irun); |
1558 |
|
runfirstentry = runlastentry; |
1559 |
|
if ( (ULong64_t)(this->GetRunInfo()->NEVENTS) > 0ULL ) runfirstentry += 1ULL; |
1560 |
|
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); |
1561 |
|
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
1562 |
|
// printf(" abstime %u trailertime %u \n",GetOrbitalInfo()->absTime,GetRunInfo()->RUNTRAILER_TIME); |
1563 |
|
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
1564 |
|
// |
1565 |
|
prevshift = 0; |
1566 |
|
// |
1567 |
|
if ( irun == run->GetEntries()-1 && fromfirst && !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)){ |
1568 |
|
// printf(" resetting irun \n"); |
1569 |
|
fromfirst = false; |
1570 |
|
irun = 0; |
1571 |
|
run->GetEntry(irun); |
1572 |
|
runfirstentry = 0ULL; |
1573 |
|
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); |
1574 |
|
if ( (ULong64_t)(this->GetRunInfo()->NEVENTS) > 0ULL ) runlastentry -= 1ULL; |
1575 |
|
}; |
1576 |
|
// |
1577 |
|
}; |
1578 |
|
// |
1579 |
|
if ( !fromfirst && !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) ) printf(" Something very wrong here: cannot find RUN containing absolute time %u \n",GetOrbitalInfo()->absTime); |
1580 |
|
// |
1581 |
|
if ( irun == oldrun || irun >= run->GetEntries() ) return(false); |
1582 |
|
// |
1583 |
|
// printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); |
1584 |
|
// |
1585 |
|
return(true); |
1586 |
}; |
}; |
1587 |
while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ |
// ---------------------------------------------------- |
1588 |
// printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); |
// if it is a preselected file (there is SelectionList) |
1589 |
irun++; |
// NBNB - the event tree MUST be read first |
1590 |
run->GetEntry(irun); |
// ---------------------------------------------------- |
1591 |
runfirstentry = runlastentry+1ULL; |
if(SELLI==1){ |
1592 |
runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); |
sel_tree->GetEntry(iev); |
1593 |
}; |
if(irun != oldrun){ |
1594 |
// |
run->GetEntry(irun); |
1595 |
if ( irun == oldrun || irun >= run->GetEntries() ) return(false); |
return true; |
1596 |
// |
} |
1597 |
// printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); |
return false; |
1598 |
// |
} |
1599 |
return(true); |
|
1600 |
|
return false; |
1601 |
// |
// |
1602 |
}; |
}; |
1603 |
/** |
/** |
1620 |
void PamLevel2::SetWhichTrees(TString detlist){ |
void PamLevel2::SetWhichTrees(TString detlist){ |
1621 |
|
|
1622 |
if(detlist.IsNull() || detlist.Contains("+ALL", TString::kIgnoreCase)){ |
if(detlist.IsNull() || detlist.Contains("+ALL", TString::kIgnoreCase)){ |
1623 |
|
CAL0 = false; |
1624 |
CAL1 = true; |
CAL1 = true; |
1625 |
CAL2 = true; |
CAL2 = true; |
1626 |
TRK2 = true; |
TRK2 = true; |
1627 |
TRK1 = false; |
TRK1 = false; |
1628 |
TRKh = false; |
TRKh = false; |
1629 |
|
TRK0 = false; |
1630 |
TRG = true; |
TRG = true; |
1631 |
TOF = true; |
TOF = true; |
1632 |
|
TOF0 = false; |
1633 |
S4 = true; |
S4 = true; |
1634 |
ND = true; |
ND = true; |
1635 |
AC = true; |
AC = true; |
1636 |
ORB = true; |
ORB = true; |
1637 |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
}else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){ |
1638 |
|
CAL0 = false; |
1639 |
CAL1 = false; |
CAL1 = false; |
1640 |
CAL2 = false; |
CAL2 = false; |
1641 |
TRK2 = false; |
TRK2 = false; |
1642 |
TRK1 = false; |
TRK1 = false; |
1643 |
TRKh = false; |
TRKh = false; |
1644 |
|
TRK0 = false; |
1645 |
TRG = false; |
TRG = false; |
1646 |
TOF = false; |
TOF = false; |
1647 |
|
TOF0 = false; |
1648 |
S4 = false; |
S4 = false; |
1649 |
ND = false; |
ND = false; |
1650 |
AC = false; |
AC = false; |
1656 |
if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false; |
if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false; |
1657 |
if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true; |
if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true; |
1658 |
}; |
}; |
1659 |
|
|
1660 |
|
if( detlist.Contains("CAL0", TString::kIgnoreCase) ){ |
1661 |
|
if ( detlist.Contains("-CAL0", TString::kIgnoreCase) )CAL0=false; |
1662 |
|
if ( detlist.Contains("+CAL0", TString::kIgnoreCase) )CAL0=true; |
1663 |
|
}; |
1664 |
|
|
1665 |
if( detlist.Contains("CAL2", TString::kIgnoreCase)){ |
if( detlist.Contains("CAL2", TString::kIgnoreCase)){ |
1666 |
if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false; |
if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false; |
1673 |
CAL1=false; |
CAL1=false; |
1674 |
} |
} |
1675 |
// ------------------------------------------------------------------------- |
// ------------------------------------------------------------------------- |
1676 |
|
if( detlist.Contains("TRK0", TString::kIgnoreCase) ){ |
1677 |
|
if ( detlist.Contains("-TRK0", TString::kIgnoreCase) )TRK0=false; |
1678 |
|
if ( detlist.Contains("+TRK0", TString::kIgnoreCase) )TRK0=true; |
1679 |
|
}; |
1680 |
|
|
1681 |
if( detlist.Contains("TRK1", TString::kIgnoreCase) ){ |
if( detlist.Contains("TRK1", TString::kIgnoreCase) ){ |
1682 |
if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false; |
if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false; |
1683 |
if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true; |
if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true; |
1706 |
|
|
1707 |
if( detlist.Contains("-TOF", TString::kIgnoreCase) )TOF = false; |
if( detlist.Contains("-TOF", TString::kIgnoreCase) )TOF = false; |
1708 |
else if( detlist.Contains("+TOF", TString::kIgnoreCase) )TOF = true; |
else if( detlist.Contains("+TOF", TString::kIgnoreCase) )TOF = true; |
1709 |
|
|
1710 |
|
if( detlist.Contains("-TOF0", TString::kIgnoreCase) )TOF0 = false; |
1711 |
|
else if( detlist.Contains("+TOF0", TString::kIgnoreCase) )TOF0 = true; |
1712 |
|
|
1713 |
if( detlist.Contains("-S4", TString::kIgnoreCase) )S4 = false; |
if( detlist.Contains("-S4", TString::kIgnoreCase) )S4 = false; |
1714 |
else if( detlist.Contains("+S4", TString::kIgnoreCase) )S4 = true; |
else if( detlist.Contains("+S4", TString::kIgnoreCase) )S4 = true; |
1743 |
* Set tree/branch detector flags from the content of a tree |
* Set tree/branch detector flags from the content of a tree |
1744 |
*/ |
*/ |
1745 |
void PamLevel2::GetWhichTrees(TFile* f){ |
void PamLevel2::GetWhichTrees(TFile* f){ |
1746 |
|
|
1747 |
|
|
1748 |
|
|
1749 |
|
cout << "void PamLevel2::GetWhichTrees(TFile* f) --- WARNING!! --- ...potrebbe non funzionare "<<endl; |
1750 |
// ----------- |
// ----------- |
1751 |
// reset flags |
// reset flags |
1752 |
// ----------- |
// ----------- |
1918 |
|
|
1919 |
Bool_t RUN__ok = false; |
Bool_t RUN__ok = false; |
1920 |
|
|
1921 |
|
Bool_t SELLI__ok = false; |
1922 |
|
|
1923 |
cout << "Checking file: "<<name<<endl; |
cout << "Checking file: "<<name<<endl; |
1924 |
TFile *f = new TFile(name.Data()); |
TFile *f = new TFile(name.Data()); |
1935 |
|
|
1936 |
while( (key = (TKey*)next()) ){ |
while( (key = (TKey*)next()) ){ |
1937 |
|
|
1938 |
|
// cout << key->GetName() << endl; |
1939 |
// cout << key->GetName() << ""<<key->GetClassName()<<endl; |
// cout << key->GetName() << ""<<key->GetClassName()<<endl; |
1940 |
// cout << " Get tree: " << f->Get(key->GetName())<<endl; |
// cout << " Get tree: " << f->Get(key->GetName())<<endl; |
1941 |
// nev_previous = nev; |
// nev_previous = nev; |
1946 |
// return false; |
// return false; |
1947 |
// }; |
// }; |
1948 |
|
|
1949 |
|
|
1950 |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true; |
1951 |
|
|
1952 |
//========================================================= |
//========================================================= |
1953 |
|
if( !strcmp(key->GetName(),"SelectionList" ) ){ |
1954 |
|
SELLI__ok = true; |
1955 |
|
if(SELLI==1){ |
1956 |
|
Int_t nevt = ((TTree*)f->Get("SelectionList"))->GetEntries(); |
1957 |
|
if( nev && nevt!=nev){ |
1958 |
|
cout << "File: "<< f->GetName() <<" discarded ---- SelectionList tree has "<<nevt<<" events instead of "<<nev<< endl; |
1959 |
|
return false; |
1960 |
|
} |
1961 |
|
nev=nevt; |
1962 |
|
} |
1963 |
|
} |
1964 |
|
|
1965 |
|
//========================================================= |
1966 |
if( !strcmp(key->GetName(),"Trigger" ) ){ |
if( !strcmp(key->GetName(),"Trigger" ) ){ |
1967 |
TRG__ok = true; |
TRG__ok = true; |
1968 |
if(TRG){ |
if(TRG){ |
2074 |
}; |
}; |
2075 |
|
|
2076 |
}; |
}; |
2077 |
|
|
2078 |
|
if( SELLI==-1 )SELLI = (Int_t)SELLI__ok; |
2079 |
|
if( SELLI==0 && SELLI__ok ){ |
2080 |
|
cout << "File: "<< f->GetName() <<" discarded ---- found SelectionList (it is not a full-event file)" << endl; |
2081 |
|
return false; |
2082 |
|
} |
2083 |
|
if( SELLI==1 && !SELLI__ok ){ |
2084 |
|
cout << "File: "<< f->GetName() <<" discarded ---- SelectionList missing" << endl; |
2085 |
|
return false; |
2086 |
|
} |
2087 |
|
|
2088 |
|
// cout << "SELLI "<<SELLI<<endl; |
2089 |
|
|
2090 |
// cout<< "CheckLevel2File(TString): detector list --> "; |
// cout<< "CheckLevel2File(TString): detector list --> "; |
2091 |
// if(TRK1__ok)cout<<"TRK1 "; |
// if(TRK1__ok)cout<<"TRK1 "; |
2092 |
// if(TRK2__ok)cout<<"TRK2 "; |
// if(TRK2__ok)cout<<"TRK2 "; |
2195 |
cout << "Create clones of PAMELA trees "<<endl; |
cout << "Create clones of PAMELA trees "<<endl; |
2196 |
|
|
2197 |
Int_t i=0; |
Int_t i=0; |
2198 |
tree_clone[i] = fChain->GetTree()->CloneTree(0); |
pam_tree_clone[i] = fChain->GetTree()->CloneTree(0); |
2199 |
TString name = tree_clone[i]->GetName(); |
TString name = pam_tree_clone[i]->GetName(); |
2200 |
name.Append("_clone"); |
name.Append("_clone"); |
2201 |
// tree_clone[i]->SetName(name.Data()); |
// pam_tree_clone[i]->SetName(name.Data()); |
2202 |
cout << tree_clone[i]->GetName() <<endl; |
cout << pam_tree_clone[i]->GetName() <<endl; |
2203 |
i++; |
i++; |
2204 |
|
|
2205 |
TList *li = fChain->GetListOfFriends(); |
TList *li = fChain->GetListOfFriends(); |
2209 |
while( (T_friend = (TFriendElement*)next()) ){ |
while( (T_friend = (TFriendElement*)next()) ){ |
2210 |
// cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
// cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
2211 |
// cout<<T_friend->GetTree()->GetName()<< endl; |
// cout<<T_friend->GetTree()->GetName()<< endl; |
2212 |
tree_clone[i] = T_friend->GetTree()->CloneTree(0); |
pam_tree_clone[i] = T_friend->GetTree()->CloneTree(0); |
2213 |
tree_clone[i]->SetAutoSave(1000000); |
pam_tree_clone[i]->SetAutoSave(1000000); |
2214 |
name = tree_clone[i]->GetName(); |
name = pam_tree_clone[i]->GetName(); |
2215 |
name.Append("_clone"); |
name.Append("_clone"); |
2216 |
// tree_clone[i]->SetName(name.Data()); |
// pam_tree_clone[i]->SetName(name.Data()); |
2217 |
cout << tree_clone[i]->GetName() << endl; |
cout << pam_tree_clone[i]->GetName() << endl; |
2218 |
i++; |
i++; |
2219 |
} |
} |
2220 |
|
|
2234 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2235 |
cout << "Create new PAMELA trees "<<endl; |
cout << "Create new PAMELA trees "<<endl; |
2236 |
|
|
|
Int_t i=0; |
|
2237 |
|
|
2238 |
|
run_tree_clone = new TTree("Run","PAMELA Level2 data from the GL_RUN table "); |
2239 |
|
run_tree_clone->Branch("RunInfo","GL_RUN",GetPointerTo("RunInfo")); |
2240 |
|
cout << "Run : branch RunInfo"<<endl; |
2241 |
|
run_tree_clone->Branch("SoftInfo","SoftInfo",GetPointerTo("SoftInfo")); |
2242 |
|
cout << "Run : branch SoftInfo"<<endl; |
2243 |
|
|
2244 |
|
|
2245 |
|
|
2246 |
|
sel_tree_clone = new TTree("SelectionList","List of selected events "); |
2247 |
|
sel_tree_clone->Branch("RunEntry",&irun,"runentry/I"); |
2248 |
|
sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/I"); |
2249 |
|
|
2250 |
|
|
2251 |
|
Int_t i=0; |
2252 |
if(TRK1||TRK2||TRKh){ |
if(TRK1||TRK2||TRKh){ |
2253 |
tree_clone[i] = new TTree("Tracker","PAMELA tracker level2 data "); |
pam_tree_clone[i] = new TTree("Tracker","PAMELA tracker level2 data "); |
2254 |
if(TRK1) { |
if(TRK1) { |
2255 |
tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); |
2256 |
tree_clone[i]->BranchRef(); |
pam_tree_clone[i]->BranchRef(); |
2257 |
cout << "Tracker : branch TrkLevel1"<<endl; |
cout << "Tracker : branch TrkLevel1"<<endl; |
2258 |
|
cout << "CreateCloneTrees " << GetTrkLevel1()<<endl; |
2259 |
}; |
}; |
2260 |
if(TRK2) { |
if(TRK2) { |
2261 |
tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
pam_tree_clone[i]->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); |
2262 |
cout << "Tracker : branch TrkLevel2"<<endl; |
cout << "Tracker : branch TrkLevel2"<<endl; |
2263 |
}; |
}; |
2264 |
if(TRKh) { |
if(TRKh) { |
2265 |
tree_clone[i]->Branch("TrkHough","TrkHough", GetPointerTo("TrkHough")); |
pam_tree_clone[i]->Branch("TrkHough","TrkHough", GetPointerTo("TrkHough")); |
2266 |
cout << "Tracker : branch TrkHough"<<endl; |
cout << "Tracker : branch TrkHough"<<endl; |
2267 |
}; |
}; |
2268 |
i++; |
i++; |
2270 |
|
|
2271 |
// Calorimeter |
// Calorimeter |
2272 |
if(CAL1||CAL2){ |
if(CAL1||CAL2){ |
2273 |
tree_clone[i] = new TTree("Calorimeter","PAMELA calorimeter level2 data "); |
pam_tree_clone[i] = new TTree("Calorimeter","PAMELA calorimeter level2 data "); |
2274 |
if(CAL1) { |
if(CAL1) { |
2275 |
tree_clone[i]->Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1")); |
pam_tree_clone[i]->Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1")); |
2276 |
cout << "Calorimeter : branch CaloLevel1"<<endl; |
cout << "Calorimeter : branch CaloLevel1"<<endl; |
2277 |
}; |
}; |
2278 |
if(CAL2) { |
if(CAL2) { |
2279 |
tree_clone[i]->Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2")); |
pam_tree_clone[i]->Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2")); |
2280 |
cout << "Calorimeter : branch CaloLevel2"<<endl; |
cout << "Calorimeter : branch CaloLevel2"<<endl; |
2281 |
}; |
}; |
2282 |
i++; |
i++; |
2284 |
|
|
2285 |
// ToF |
// ToF |
2286 |
if(TOF) { |
if(TOF) { |
2287 |
tree_clone[i] = new TTree("ToF","PAMELA ToF level2 data "); |
pam_tree_clone[i] = new TTree("ToF","PAMELA ToF level2 data "); |
2288 |
tree_clone[i]->Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2")); |
pam_tree_clone[i]->Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2")); |
2289 |
cout << "ToF : branch ToFLevel2"<<endl; |
cout << "ToF : branch ToFLevel2"<<endl; |
2290 |
i++; |
i++; |
2291 |
}; |
}; |
2292 |
// Trigger |
// Trigger |
2293 |
if(TRG) { |
if(TRG) { |
2294 |
tree_clone[i] = new TTree("Trigger","PAMELA trigger level2 data "); |
pam_tree_clone[i] = new TTree("Trigger","PAMELA trigger level2 data "); |
2295 |
tree_clone[i]->Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2")); |
pam_tree_clone[i]->Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2")); |
2296 |
cout << "Trigger : branch TrigLevel2"<<endl; |
cout << "Trigger : branch TrigLevel2"<<endl; |
2297 |
i++; |
i++; |
2298 |
}; |
}; |
2299 |
// S4 |
// S4 |
2300 |
if(S4) { |
if(S4) { |
2301 |
tree_clone[i] = new TTree("S4","PAMELA S4 level2 data "); |
pam_tree_clone[i] = new TTree("S4","PAMELA S4 level2 data "); |
2302 |
tree_clone[i]->Branch("S4Level2","S4Level2", GetPointerTo("S4Level2")); |
pam_tree_clone[i]->Branch("S4Level2","S4Level2", GetPointerTo("S4Level2")); |
2303 |
cout << "S4 : branch S4Level2"<<endl; |
cout << "S4 : branch S4Level2"<<endl; |
2304 |
i++; |
i++; |
2305 |
}; |
}; |
2306 |
// Neutron Detector |
// Neutron Detector |
2307 |
if(ND) { |
if(ND) { |
2308 |
tree_clone[i] = new TTree("NeutronD","PAMELA neutron detector level2 data "); |
pam_tree_clone[i] = new TTree("NeutronD","PAMELA neutron detector level2 data "); |
2309 |
tree_clone[i]->Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2")); |
pam_tree_clone[i]->Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2")); |
2310 |
cout << "NeutronD : branch NDLevel2"<<endl; |
cout << "NeutronD : branch NDLevel2"<<endl; |
2311 |
i++; |
i++; |
2312 |
}; |
}; |
2313 |
// Anticounters |
// Anticounters |
2314 |
if(AC) { |
if(AC) { |
2315 |
tree_clone[i] = new TTree("Anticounter","PAMELA anticounter detector level2 data "); |
pam_tree_clone[i] = new TTree("Anticounter","PAMELA anticounter detector level2 data "); |
2316 |
tree_clone[i]->Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2")); |
pam_tree_clone[i]->Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2")); |
2317 |
cout << "Anticounter : branch AcLevel2"<<endl; |
cout << "Anticounter : branch AcLevel2"<<endl; |
2318 |
i++; |
i++; |
2319 |
}; |
}; |
2320 |
// OrbitalInfo |
// OrbitalInfo |
2321 |
if(ORB) { |
if(ORB) { |
2322 |
tree_clone[i] = new TTree("OrbitalInfo","PAMELA oribital info "); |
pam_tree_clone[i] = new TTree("OrbitalInfo","PAMELA oribital info "); |
2323 |
tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); |
pam_tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); |
2324 |
cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
2325 |
i++; |
i++; |
2326 |
}; |
}; |
2335 |
*/ |
*/ |
2336 |
//void PamLevel2::FillNewPamTree(TTree *T){ |
//void PamLevel2::FillNewPamTree(TTree *T){ |
2337 |
void PamLevel2::FillCloneTrees(){ |
void PamLevel2::FillCloneTrees(){ |
2338 |
|
|
2339 |
for(Int_t i=0; i<8; i++){ |
// cout << "PamLevel2::FillCloneTrees()" << irunentry << endl; |
2340 |
if(tree_clone[i])tree_clone[i]->Fill(); |
|
2341 |
|
for(Int_t i=0; i<NCLONES; i++){ |
2342 |
|
if(pam_tree_clone[i])pam_tree_clone[i]->Fill(); |
2343 |
} |
} |
2344 |
|
if(sel_tree_clone)sel_tree_clone->Fill(); |
2345 |
|
|
2346 |
} |
} |
2347 |
|
|
2348 |
|
|
2349 |
TTree* PamLevel2::GetCloneTree(TString name){ |
TTree* PamLevel2::GetCloneTree(TString name){ |
2350 |
|
|
2351 |
for(Int_t i=0; i<8; i++){ |
for(Int_t i=0; i<NCLONES; i++){ |
2352 |
if(tree_clone[i]){ |
if(pam_tree_clone[i]){ |
2353 |
TString na = tree_clone[i]->GetName(); |
TString na = pam_tree_clone[i]->GetName(); |
2354 |
if(!name.CompareTo(na))return tree_clone[i]; |
if(!name.CompareTo(na))return pam_tree_clone[i]; |
2355 |
}; |
}; |
2356 |
} |
} |
2357 |
|
if(run_tree_clone){ |
2358 |
|
TString na = run_tree_clone->GetName(); |
2359 |
|
if(!name.CompareTo(na))return run_tree_clone; |
2360 |
|
} |
2361 |
|
if(sel_tree_clone){ |
2362 |
|
TString na = sel_tree_clone->GetName(); |
2363 |
|
if(!name.CompareTo(na))return sel_tree_clone; |
2364 |
|
} |
2365 |
return NULL; |
return NULL; |
2366 |
|
|
2367 |
} |
} |
2368 |
void PamLevel2::WriteCloneTrees(){ |
void PamLevel2::WriteCloneTrees(){ |
2369 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2370 |
cout << "Write clones of PAMELA trees "<<endl; |
cout << "Write clones of PAMELA trees "<<endl; |
2371 |
for(Int_t i=0; i<8; i++){ |
cout << run_tree_clone->GetName()<<endl; |
2372 |
if(tree_clone[i]){ |
run_tree_clone->Write(); |
2373 |
cout << tree_clone[i]->GetName()<<endl; |
cout << sel_tree_clone->GetName()<<endl; |
2374 |
tree_clone[i]->Write(); |
sel_tree_clone->Write(); |
2375 |
|
for(Int_t i=0; i<NCLONES; i++){ |
2376 |
|
if(pam_tree_clone[i]){ |
2377 |
|
cout << pam_tree_clone[i]->GetName()<<endl; |
2378 |
|
pam_tree_clone[i]->Write(); |
2379 |
}; |
}; |
2380 |
} |
} |
2381 |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
2383 |
} |
} |
2384 |
|
|
2385 |
/** |
/** |
2386 |
* Create a new (empty) Pamela trees |
* Method to get level2-trees entry, the corresponding run entry and (if required) the level0 entry. |
2387 |
*/ |
*/ |
2388 |
// TTree* PamLevel2::GetNewPamTree(){ |
Int_t PamLevel2::GetEntry(Int_t iee){ |
2389 |
|
|
2390 |
|
if(!pam_tree){ |
2391 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- level2 trees not loaded"<<endl; |
2392 |
|
return 0; |
2393 |
|
} |
2394 |
|
|
2395 |
|
|
2396 |
|
// |
2397 |
|
// This is a sort of bug: if you don't have the run tree you don't want to exit here you want to have loaded the event anyway... |
2398 |
|
// |
2399 |
|
// if(!run_tree ){ |
2400 |
|
// cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loeaded"<<endl; |
2401 |
|
// return 0; |
2402 |
|
// } |
2403 |
|
|
2404 |
|
Int_t ii=0; |
2405 |
|
//------------------------------- |
2406 |
|
ii = iee; |
2407 |
|
if( !pam_tree->GetEntry(ii) ) return 0; |
2408 |
|
|
2409 |
|
// |
2410 |
|
// ... that's way I put it here. Notice that nothing change in the code (is backward compatible) since in any case you return with 0. |
2411 |
|
// in theory one would like to return 1 if run is not loaded but now I don't have the will to add that 2 lines of code and it is not |
2412 |
|
// a problem if you don't check the return code of getentry. |
2413 |
|
// |
2414 |
|
if(!run_tree ){ |
2415 |
|
if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1? |
2416 |
|
cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl; |
2417 |
|
return 0; |
2418 |
|
} else { |
2419 |
|
return 1; //cosi` se non c'e` run esce qua... |
2420 |
|
} |
2421 |
|
} |
2422 |
|
|
2423 |
|
//------------------------------- |
2424 |
|
ii = iee; |
2425 |
|
Bool_t UPDATED = UpdateRunInfo(run_tree,ii); |
2426 |
|
if(SELLI==0)irunentry = iee-runfirstentry; |
2427 |
|
if(UPDATED && run_tree_clone)run_tree_clone->Fill(); |
2428 |
|
|
2429 |
|
// cout << "PamLevel2::GetEntry("<<iee<<") "<<irun<<" "<<runfirstentry<<" "<<irunentry<<endl; |
2430 |
|
|
2431 |
|
if( TRK0 || CAL0 || TOF0 )GetYodaEntry( ); |
2432 |
|
|
2433 |
|
return 1; |
2434 |
|
|
2435 |
|
} |
2436 |
|
|
2437 |
|
/** |
2438 |
|
* Method to retrieve the level0 tree (YODA tree) that contains the current event. |
2439 |
|
* Given the run ID (...), if needed it query the DB and load the proper file. |
2440 |
|
* @return Pointer to the tree |
2441 |
|
*/ |
2442 |
|
|
2443 |
|
|
2444 |
|
TTree* PamLevel2::GetYodaTree( ){ |
2445 |
|
|
2446 |
|
// cout << "TTree* PamLevel2::GetYodaTree( )"<<endl; |
2447 |
|
//=================================== |
2448 |
|
// check if iroot has changed |
2449 |
|
//=================================== |
2450 |
|
if( irun<0 ){ |
2451 |
|
cout << "PamLevel2::GetYodaTree() -- ERROR "<<endl; |
2452 |
|
cout << "In order to use this method you have to load the RunInfo tree "<<endl; |
2453 |
|
cout << "with the method TChain* PamLevel2::GetRunTree(TString, TString)"<<endl; |
2454 |
|
// cout << " - read the event with PamLevel2::GetEntry(Int_t)"<<endl; |
2455 |
|
return NULL; |
2456 |
|
} |
2457 |
|
Int_t irootnew = run_obj->ID_ROOT_L0; |
2458 |
|
// cout << "iroot "<<iroot<<endl; |
2459 |
|
// cout << "irootnew "<<irootnew<<endl; |
2460 |
|
|
2461 |
|
//=================================== |
2462 |
|
// load the level0 file |
2463 |
|
// (if not already loaded) |
2464 |
|
//=================================== |
2465 |
|
if( iroot != irootnew || !l0_tree){ |
2466 |
|
iroot = irootnew; |
2467 |
|
//=================================== |
2468 |
|
// open the DB connection |
2469 |
|
// (if not already opened) |
2470 |
|
//=================================== |
2471 |
|
if(!dbc || (dbc && !dbc->IsConnected())){ |
2472 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
2473 |
|
cout<<"Connecting to DB"<<endl; |
2474 |
|
cout<<"HOST "<<host<<endl; |
2475 |
|
cout<<"USER "<<user<<endl; |
2476 |
|
cout<<"PSW "<<psw<<endl; |
2477 |
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
2478 |
|
if( !dbc )return NULL; |
2479 |
|
if( !dbc->IsConnected() )return NULL; |
2480 |
|
// cout<<"...done"<<endl; |
2481 |
|
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; |
2482 |
|
}else{ |
2483 |
|
// cout<<"DB already connected"<<endl; |
2484 |
|
} |
2485 |
|
GL_ROOT glroot = GL_ROOT(); |
2486 |
|
if( glroot.Query_GL_ROOT(iroot,dbc) ){ |
2487 |
|
cout << "TTree* PamLevel2::GetYodaTree( ) -- ERROR -- level0 file iroot = "<<iroot<< " does not exists"<<endl; |
2488 |
|
return NULL; |
2489 |
|
}; |
2490 |
|
TString filename = glroot.PATH + glroot.NAME; |
2491 |
|
if(l0_file){ |
2492 |
|
l0_file->Close(); |
2493 |
|
l0_file->Delete(); |
2494 |
|
} |
2495 |
|
cout << "Opening LEVEL0 file: "<< filename << endl; |
2496 |
|
FileStat_t t; |
2497 |
|
if( gSystem->GetPathInfo(filename.Data(),t) ){ |
2498 |
|
cout << " PamLevel2::GetYodaTree() -- ERROR opening file "<<endl; |
2499 |
|
return NULL; |
2500 |
|
} |
2501 |
|
l0_file = new TFile(filename); |
2502 |
|
if( !l0_file )return NULL; |
2503 |
|
l0_tree = (TTree*)l0_file->Get("Physics"); |
2504 |
|
if(!h0_obj)h0_obj = new EventHeader(); |
2505 |
|
l0_tree->SetBranchAddress("Header" ,&h0_obj); |
2506 |
|
prevshift = 0; |
2507 |
|
//--------------------------------------------------- |
2508 |
|
// TRACKER: |
2509 |
|
if(TRK0){ |
2510 |
|
if(!trk0_obj){ |
2511 |
|
trk0_obj = new TrkLevel0(); |
2512 |
|
trk0_obj->Set(); |
2513 |
|
}; |
2514 |
|
l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent()); |
2515 |
|
} |
2516 |
|
//--------------------------------------------------- |
2517 |
|
// CALORIMETER: |
2518 |
|
if(CAL0){ |
2519 |
|
if(!calo0_obj){ |
2520 |
|
calo0_obj = new CaloLevel0(); |
2521 |
|
calo0_obj->Set(); |
2522 |
|
}; |
2523 |
|
l0_tree->SetBranchAddress("Calorimeter" ,calo0_obj->GetPointerToCalorimeterEvent()); |
2524 |
|
// cout << "PamLevel2::GetYodaTree() --- level0 calorimeter not implemented "<<endl; |
2525 |
|
} |
2526 |
|
//--------------------------------------------------- |
2527 |
|
// TOF: |
2528 |
|
if(TOF0){ |
2529 |
|
cout << "PamLevel2::GetYodaTree() --- level0 TOF not implemented "<<endl; |
2530 |
|
} |
2531 |
|
|
2532 |
|
}; |
2533 |
|
|
2534 |
|
if(!dbc || (dbc && !dbc->IsConnected())){ |
2535 |
|
cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<<endl; |
2536 |
|
} |
2537 |
|
|
2538 |
|
if ( TRK0 ) TrkParams::SetCalib(run_obj,dbc); |
2539 |
|
|
|
// if(tree_clone)return tree_clone; |
|
2540 |
|
|
2541 |
// TTree *Tout = 0; |
// cout << l0_tree << endl; |
2542 |
|
|
2543 |
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
return l0_tree; |
2544 |
// cout << "Create new PAMELA trees "<<endl; |
|
2545 |
|
} |
2546 |
|
|
2547 |
|
/** |
2548 |
|
* Method to retrieve the level0 tree (YODA tree) that contains the current event. |
2549 |
|
*/ |
2550 |
|
Int_t PamLevel2::GetYodaEntry(){ |
2551 |
|
|
2552 |
|
// cout << "Int_t PamLevel2::GetYodaEntry()"<<endl; |
2553 |
|
if(!GetYodaTree())return 0; |
2554 |
|
|
2555 |
|
// patch |
2556 |
|
if( (Int_t)irunentry < 0){ |
2557 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ATTENZIONE -- irunentry negativo?!?! "<<(Int_t)irunentry<<endl; |
2558 |
|
irunentry=0; |
2559 |
|
} |
2560 |
|
// --------------------------------- |
2561 |
|
// if file is NOT a preselected file |
2562 |
|
// --------------------------------- |
2563 |
|
UInt_t quellagiusta = irunentry + run_obj->EV_FROM; |
2564 |
|
|
|
// if(TRK1||TRK2||TRKh){ |
|
|
// TTree *T = new TTree("Tracker_clone","PAMELA tracker level2 data "); |
|
|
// if(TRK1) { |
|
|
// trk1_clone = new TrkLevel1(); |
|
|
// T->Branch("TrkLevel1","TrkLevel1", &trk1_clone); |
|
|
// T->BranchRef(); |
|
|
// cout << "Tracker : branch TrkLevel1"<<endl; |
|
|
// }; |
|
|
// if(TRK2) { |
|
|
// trk2_clone = new TrkLevel2(); |
|
|
// T->Branch("TrkLevel2", "TrkLevel2",&trk2_clone); |
|
|
// cout << "Tracker : branch TrkLevel2"<<endl; |
|
|
// }; |
|
|
// if(TRKh) { |
|
|
// trkh_clone = new TrkHough(); |
|
|
// T->Branch("TrkHough","TrkHough", &trkh_clone); |
|
|
// cout << "Tracker : branch TrkHough"<<endl; |
|
|
// }; |
|
|
// if(!Tout)Tout=T; |
|
|
// else Tout->AddFriend("Tracker_clone"); |
|
|
// } |
|
|
|
|
|
// // Calorimeter |
|
|
// if(CAL1||CAL2){ |
|
|
// TTree *C = new TTree("Calorimeter_clone","PAMELA calorimeter level2 data "); |
|
|
// if(CAL1) { |
|
|
// calo1_clone = new CaloLevel1(); |
|
|
// C->Branch("CaloLevel1", "CaloLevel1", &calo1_clone); |
|
|
// cout << "Calorimeter : branch CaloLevel1"<<endl; |
|
|
// }; |
|
|
// if(CAL2) { |
|
|
// calo2_clone = new CaloLevel2(); |
|
|
// C->Branch("CaloLevel2","CaloLevel2", &calo2_clone); |
|
|
// cout << "Calorimeter : branch CaloLevel2"<<endl; |
|
|
// }; |
|
|
// if(!Tout)Tout=C; |
|
|
// else Tout->AddFriend("Calorimeter_clone"); |
|
|
// } |
|
|
|
|
|
// // ToF |
|
|
// if(TOF) { |
|
|
// TTree *O = new TTree("ToF_clone","PAMELA ToF level2 data "); |
|
|
// tof_clone = new ToFLevel2(); |
|
|
// O->Branch("ToFLevel2","ToFLevel2", &tof_clone); |
|
|
// cout << "ToF : branch ToFLevel2"<<endl; |
|
|
// if(!Tout)Tout=O; |
|
|
// else Tout->AddFriend("ToF_clone"); |
|
|
// }; |
|
|
// // Trigger |
|
|
// if(TRG) { |
|
|
// TTree *R = new TTree("Trigger_clone","PAMELA trigger level2 data "); |
|
|
// trig_clone = new TrigLevel2(); |
|
|
// R->Branch("TrigLevel2","TrigLevel2", &trig_clone); |
|
|
// cout << "Trigger : branch TrigLevel2"<<endl; |
|
|
// if(!Tout)Tout=R; |
|
|
// else Tout->AddFriend("Trigger_clone"); |
|
|
// }; |
|
|
// // S4 |
|
|
// if(S4) { |
|
|
// TTree *S = new TTree("S4_clone","PAMELA S4 level2 data "); |
|
|
// s4_clone = new S4Level2(); |
|
|
// S->Branch("S4Level2","S4Level2", &s4_clone); |
|
|
// cout << "S4 : branch S4Level2"<<endl; |
|
|
// if(!Tout)Tout=S; |
|
|
// else Tout->AddFriend("S4_clone"); |
|
|
// }; |
|
|
// // Neutron Detector |
|
|
// if(ND) { |
|
|
// TTree *N = new TTree("NeutronD_clone","PAMELA neutron detector level2 data "); |
|
|
// nd_clone = new NDLevel2(); |
|
|
// N->Branch("NDLevel2","NDLevel2", &nd_clone); |
|
|
// cout << "NeutronD : branch NDLevel2"<<endl; |
|
|
// if(!Tout)Tout=N; |
|
|
// else Tout->AddFriend("NeutronD_clone"); |
|
|
// }; |
|
|
// // Anticounters |
|
|
// if(AC) { |
|
|
// TTree *A = new TTree("Anticounter_clone","PAMELA anticounter detector level2 data "); |
|
|
// ac_clone = new AcLevel2(); |
|
|
// A->Branch("AcLevel2","AcLevel2", &ac_clone); |
|
|
// cout << "Anticounter : branch AcLevel2"<<endl; |
|
|
// if(!Tout)Tout=A; |
|
|
// else Tout->AddFriend("Anticounter_clone"); |
|
|
// }; |
|
|
// // OrbitalInfo |
|
|
// if(ORB) { |
|
|
// TTree *B = new TTree("OrbitalInfo_clone","PAMELA oribital info "); |
|
|
// orb_clone = new OrbitalInfo(); |
|
|
// B->Branch("OrbitalInfo","OrbitalInfo", &orb_clone); |
|
|
// cout << "OrbitalInfo : branch OrbitalInfo"<<endl; |
|
|
// if(!Tout)Tout=B; |
|
|
// else Tout->AddFriend("OrbitalInfo_clone"); |
|
|
// }; |
|
|
// cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl; |
|
2565 |
|
|
2566 |
// tree_clone = Tout; |
// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl; |
2567 |
// tree_clone->SetDirectory(0); |
// cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl; |
2568 |
|
// cout << " time "<< GetOrbitalInfo()->absTime << endl; |
2569 |
|
// cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl; |
2570 |
|
|
2571 |
|
if( !GetOrbitalInfo() ){ |
2572 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl; |
2573 |
|
return 0; |
2574 |
|
} |
2575 |
|
|
2576 |
// return Tout; |
// --------------------------------------------------------------------- |
2577 |
// } |
// ATTENTION!!! |
2578 |
// /** |
// If data are not pre-processed with cleaner, the level0 tree may contain |
2579 |
// * Fill a tree (created with GetNewPamTree) |
// spurious nested physics packets. |
2580 |
// * |
// The GL_RUN variables EV_FROM, EV_TO and NEVENTS counts also these entries |
2581 |
// */ |
// while level2 tree DOES NOT!! |
2582 |
// //void PamLevel2::FillNewPamTree(TTree *T){ |
// This means that "quellagiusta" in these cases is not correct. |
2583 |
// void PamLevel2::FillNewPamTree(){ |
// In order to retrieve the correct level0 event, I implemented a check |
2584 |
|
// of the OBT and pkt-number. In case of mismatch, the level0 entry number |
2585 |
|
// is shift forward until when the packets match. |
2586 |
|
// --------------------------------------------------------------------- |
2587 |
|
Int_t answer = 0; |
2588 |
|
Int_t shift =0; |
2589 |
|
// printf(" siamo qui %i %i \n",shift,prevshift); |
2590 |
|
do{ |
2591 |
|
if(shift>0){ |
2592 |
|
cout << " level0 <--> level2 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" )"<<endl; |
2593 |
|
} |
2594 |
|
answer = l0_tree->GetEntry(quellagiusta+shift+prevshift); |
2595 |
|
shift++; |
2596 |
|
if( !GetEventHeader() ){ |
2597 |
|
cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl; |
2598 |
|
return 0; |
2599 |
|
} |
2600 |
|
// if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl; |
2601 |
|
// cout << " GetOrbitalInfo()->OBT "<< GetOrbitalInfo()->OBT << endl; |
2602 |
|
// cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; |
2603 |
|
// cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl; |
2604 |
|
// cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; |
2605 |
|
// printf(" IDRUN %u \n",GetRunInfo()->ID); |
2606 |
|
// |
2607 |
|
if ( prevshift != 0 && (quellagiusta+shift) == GetYodaTree()->GetEntries() ){ |
2608 |
|
prevshift = 0; |
2609 |
|
shift = -1; |
2610 |
|
}; |
2611 |
|
|
2612 |
|
}while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+shift) < GetYodaTree()->GetEntries() ); |
2613 |
|
|
2614 |
|
if ( (quellagiusta+shift) == GetYodaTree()->GetEntries() ) cout << " Big trouble here, no such event in Level0 data! " <<endl; |
2615 |
|
|
2616 |
|
// cout << "LA ENTRY GIUSTA E`: "<<quellagiusta<<" (spero...)"<<endl; |
2617 |
|
// return GetYodaTree()->GetEntry(quellagiusta); |
2618 |
|
if ( shift > 1 ) prevshift += (shift-1); |
2619 |
|
|
2620 |
|
return answer; |
2621 |
|
|
2622 |
|
} |
2623 |
|
|
|
// if(trk1_clone) *trk1_clone = *trk1_obj; |
|
|
// if(trk2_clone){ |
|
|
// trk2_clone->Clear(); |
|
|
// trk2_obj->Copy(*trk2_clone); |
|
|
// // *trk2_clone = *trk2_obj; |
|
|
// } |
|
|
// if(trkh_clone) *trkh_clone = *trkh_obj; |
|
|
// if(calo1_clone){ |
|
|
// // *calo1_clone = *calo1_obj; |
|
|
// calo1_clone->Clear(); |
|
|
// calo1_obj->Copy(*calo1_clone); |
|
|
// } |
|
|
// if(calo2_clone){ |
|
|
// // *calo2_clone = *calo2_obj; |
|
|
// calo2_clone->Clear(); |
|
|
// calo2_obj->Copy(*calo2_clone); |
|
|
// } |
|
|
// if(tof_clone) *tof_clone = *tof_obj; |
|
|
// if(trig_clone) *trig_clone = *trig_obj; |
|
|
// if(s4_clone) *s4_clone = *s4_obj; |
|
|
// if(nd_clone) *nd_clone = *nd_obj; |
|
|
// if(ac_clone) *ac_clone = *ac_obj; |
|
|
// if(orb_clone) *orb_clone = *orb_obj; |
|
|
|
|
|
// TTree *T = tree_clone; |
|
|
|
|
|
// T->Fill(); //fill main tree |
|
|
// // cout<<T->IsA()->GetName()<<" "<<T->GetName()<<endl; |
|
|
// TList *li = T->GetListOfFriends(); |
|
|
// TIter next(li); |
|
|
// TFriendElement* T_friend=0; |
|
|
// while( (T_friend = (TFriendElement*)next()) ){ |
|
|
// // cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl; |
|
|
// T_friend->GetTree()->Fill();//fill friends |
|
|
// } |
|
2624 |
|
|
|
// } |
|