1 |
/** |
/** |
2 |
* Header Scan |
* Header_Scan |
3 |
* Author Nagni |
* Author Nagni |
4 |
* version 1.0 |
* version 1.0 |
5 |
* |
* |
49 |
* Date 16 June 2006 - Malvezzi |
* Date 16 June 2006 - Malvezzi |
50 |
* |
* |
51 |
* Description of changes: |
* Description of changes: |
52 |
* Implementation of case: numebr of events are <= 0. |
* Implementation of the case: numebr of events <= 0. |
53 |
* Remove of the graph "grPcktId1"; see PacketScan for the same information. |
* Remove graph "grPcktId1"; see PacketScan for the same information. |
54 |
* Fixed bugs: for a large namber of events is not possible to have vectors, so all graphs have been converted in histograms |
* Fixed bugs: for a large namber of events is not possible to have vectors, so I have subsituted graphs with histograms |
55 |
|
* or divided the graphs in more than one canvas. |
56 |
* |
* |
57 |
*/ |
*/ |
58 |
|
|
84 |
{ |
{ |
85 |
|
|
86 |
//------------------- Variables initilization -------------------------// |
//------------------- Variables initilization -------------------------// |
87 |
|
Long64_t nevents=0; |
88 |
TList *list = new TList; |
ULong_t lastime, firstime,obt;// offset, lastoffset, firstoffset; |
|
Int_t numkey; |
|
|
TObject *key = new TObject; |
|
|
const char *name; |
|
|
//TTree* tr = new TTree; |
|
|
//TTree* tr1 = new TTree; |
|
|
Long64_t nevents=0; // ev=0, events=0; |
|
|
ULong_t lastime, firstime; |
|
89 |
double obmin=0.; |
double obmin=0.; |
90 |
double obmax=0.; |
double obmax=0.; |
|
double obt; |
|
|
ULong_t maxoffset, minoffset; |
|
|
Float_t pcktLenght =0., pcktCounter=0., offset=0., allCounter=0.; |
|
91 |
stringstream oss, oss1, oss2, oss3, noentries; |
stringstream oss, oss1, oss2, oss3, noentries; |
92 |
//------- load root file -------------- |
//------- load root file -------------- |
93 |
TFile *file = new TFile(base.Data()); |
TFile *file = new TFile(base.Data()); |
95 |
printf("No such file in the directory has been found"); |
printf("No such file in the directory has been found"); |
96 |
return; |
return; |
97 |
} |
} |
|
if (outDir == "" ) outDir = "."; |
|
|
list = file->GetListOfKeys(); //get list of trees in the file |
|
|
numkey = file->GetNkeys(); //get number of trees in the file |
|
98 |
|
|
99 |
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
100 |
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
105 |
PhysicsTr->SetBranchAddress("Header", &eh); |
PhysicsTr->SetBranchAddress("Header", &eh); |
106 |
|
|
107 |
nevents = headBr->GetEntries(); |
nevents = headBr->GetEntries(); |
|
const Int_t sizetot = nevents; |
|
108 |
|
|
109 |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
110 |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
143 |
return; |
return; |
144 |
} |
} |
145 |
|
|
146 |
|
//-------------- to know the max and min OBT ----------------------------// |
147 |
///-------------- to know the max and min File Offset ----------------------------// |
for (Int_t i = 0; i < nevents; i++){ |
148 |
/*for (Int_t i=0; i<numkey; i++){ |
headBr->GetEntry(i); |
149 |
key = list->At(i); |
ph = eh->GetPscuHeader(); |
150 |
name=(key->GetName()); |
obt = ph->GetOrbitalTime(); |
151 |
tr = (TTree*)file->Get(name); |
//if(obt <= firstime) firstime=obt; |
152 |
if (tr->IsZombie()) continue; |
if(obt >= lastime) lastime=obt; |
153 |
events = tr->GetEntries(); |
} |
154 |
tr->SetBranchAddress("Header", &eh); |
|
|
for (Int_t j = 0; j < events; j++){ |
|
|
tr->GetEntry(j); |
|
|
ph = eh->GetPscuHeader(); |
|
|
ph->GetFileOffset(); |
|
|
if(ph->GetFileOffset() <= minoffset) minoffset=ph->GetFileOffset(); |
|
|
if(ph->GetFileOffset() >= maxoffset) maxoffset=ph->GetFileOffset(); |
|
|
} |
|
|
}*/ |
|
|
//*************************** Histograms ************************************************************// |
|
155 |
//------------------------ First histogram -----------------------------------// |
//------------------------ First histogram -----------------------------------// |
156 |
headBr->GetEntry(0); |
headBr->GetEntry(0); |
157 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
158 |
firstime = ph->GetOrbitalTime(); |
firstime = ph->GetOrbitalTime(); |
159 |
headBr->GetEntry(nevents-1); |
obmin=firstime; |
160 |
ph = eh->GetPscuHeader(); |
obmax=lastime; |
161 |
lastime = ph->GetOrbitalTime(); |
|
|
obmin=firstime; |
|
|
obmax=lastime; |
|
162 |
oss1.str(""); |
oss1.str(""); |
163 |
oss1 << filename.Data() << ": Physics Packet per minute;" <<" start @ " << firstime << ", end @ "<< lastime <<"ms"; |
oss1 <<"File name= "<< filename.Data() <<". Start time= " << obmin << ", end time= "<< obmax <<" ms"<<". Physics Packet per minute"; |
164 |
Int_t nbin = (lastime-firstime)/60000; |
Int_t nbin = (lastime-firstime)/60000; |
165 |
TH1F *h1 = new TH1F ("histo1", oss1.str().c_str(), nbin, obmin, obmax); |
TH1F *h1 = new TH1F ("histo1", oss1.str().c_str(), nbin, obmin, obmax); |
166 |
|
|
167 |
//------------------------ Second histogram -----------------------------------// |
//------------- Graph PscuCounter vs FileOffset --------------------------------- |
168 |
oss2.str(""); |
const Int_t size = 10000; |
169 |
oss2 << filename.Data() << ": Lenght of Physic packets;"; |
Int_t ev=0; |
170 |
Int_t nint = (lastime-firstime); |
Double_t PscuCounter[size], FileOffset[size], tempo[size], PcktLenght[size]; |
171 |
TH1F *PcktLenght = new TH1F ("histo2", oss2.str().c_str(), nint, obmin, obmax); |
Int_t m=0; |
172 |
|
Int_t pag= (nevents/10000)+1; |
173 |
|
|
174 |
//------------------------ Third histogram -----------------------------------// |
TMultiGraph *mg1 = new TMultiGraph(); |
175 |
oss3.str(""); |
oss1.str(""); |
176 |
oss3 << filename.Data() << ": Physics Counter"; |
oss1 << filename.Data() <<": PscuCounter vs FileOffset."; |
177 |
TH1F *PcktCounter = new TH1F ("histo3", oss3.str().c_str(), nint, obmin, obmax); |
mg1->SetTitle(oss1.str().c_str()); |
178 |
|
|
179 |
//------------------------ Fourth histogram -----------------------------------// |
TMultiGraph *mg2 = new TMultiGraph(); |
180 |
/*oss3.str(""); |
oss1.str(""); |
181 |
oss3 << filename.Data() << ": Packet Counter"; |
oss1 << filename.Data() <<": OBT vs FileOffset."; |
182 |
Int_t nintoffset = (maxoffset-minoffset)/10; |
mg2->SetTitle(oss1.str().c_str()); |
|
TH1F *FileOffset = new TH1F ("histo4", oss3.str().c_str(), nintoffset, minoffset, maxoffset); |
|
|
*/ |
|
|
//**************************************************************************************************// |
|
|
//------- fill histograms ---------// |
|
183 |
|
|
184 |
for (Int_t i = 0; i < nevents; i++){ |
TMultiGraph *mg3 = new TMultiGraph(); |
185 |
headBr->GetEntry(i); |
oss2.str(""); |
186 |
ph = eh->GetPscuHeader(); |
oss2 << filename.Data() <<": Lenght of Physic packets"; |
187 |
obt = ph->GetOrbitalTime(); |
mg3->SetTitle(oss2.str().c_str()); |
188 |
pcktLenght=ph->GetPacketLenght(); |
|
189 |
pcktCounter=ph->GetCounter(); |
TMultiGraph *mg4 = new TMultiGraph(); |
190 |
h1->Fill(obt); |
oss3.str(""); |
191 |
PcktLenght->Fill(obt,pcktLenght); |
oss3 << filename.Data() <<": Physics Counter"; |
192 |
PcktCounter->Fill(obt,pcktCounter); |
mg4->SetTitle(oss3.str().c_str()); |
|
} |
|
193 |
|
|
|
/*for (Int_t i=0; i<numkey; i++){ |
|
|
key = list->At(i); |
|
|
name=(char *)(key->GetName()); |
|
|
tr1 = (TTree*)file->Get(name); |
|
|
if (tr1->IsZombie()) continue; |
|
|
tr1->SetBranchAddress("Header", &eh); |
|
|
ev = tr1->GetEntries(); |
|
|
for (Int_t j = 0; j < ev; j++){ |
|
|
tr1->GetEntry(j); |
|
|
ph = eh->GetPscuHeader(); |
|
|
offset=ph->GetFileOffset(); |
|
|
allCounter= ph->GetCounter(); |
|
|
FileOffset->Fill(offset,allCounter); |
|
|
} |
|
|
}*/ |
|
|
|
|
|
//****************************** Canvases *******************************// |
|
|
//TGaxis::SetMaxDigits(4); |
|
|
//------------------- First Canvas --------------------------------// |
|
194 |
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1024); |
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1024); |
195 |
finalCanv1->Divide(1,3); |
finalCanv1->Divide(1,3); |
196 |
finalCanv1->SetFillColor(10); |
finalCanv1->SetFillColor(10); |
197 |
|
|
198 |
|
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
199 |
|
finalCanv2->Divide(1,2); |
200 |
|
finalCanv2->SetFillColor(10); |
201 |
|
|
202 |
|
/////ciclo sulle pagine//////////////////// |
203 |
|
for (Int_t interval=0; interval<pag; interval++){ |
204 |
|
|
205 |
|
for (Int_t l = 0; l < size; l++){ //ciclo su un sottogruppo |
206 |
|
headBr->GetEntry(ev+l); |
207 |
|
ph = eh->GetPscuHeader(); |
208 |
|
PscuCounter[l]= ph->GetCounter(); // = PcktCounter[l] |
209 |
|
FileOffset[l]=ph->GetFileOffset(); |
210 |
|
tempo[l]=ph->GetOrbitalTime(); |
211 |
|
PcktLenght[l]=ph->GetPacketLenght(); |
212 |
|
h1->Fill(ph->GetOrbitalTime()); |
213 |
|
m=l; |
214 |
|
} |
215 |
|
|
216 |
|
TGraph *graph1= new TGraph(m, tempo, PcktLenght); |
217 |
|
graph1->SetMarkerColor(2); |
218 |
|
graph1->SetMarkerSize(.5); |
219 |
|
graph1->SetMarkerStyle(21); |
220 |
|
mg3->Add(graph1); |
221 |
|
|
222 |
|
TGraph *graph2= new TGraph(m, tempo, PscuCounter); |
223 |
|
graph2->SetMarkerColor(4); |
224 |
|
graph2->SetMarkerSize(.5); |
225 |
|
graph2->SetMarkerStyle(21); |
226 |
|
mg4->Add(graph2); |
227 |
|
|
228 |
|
TGraph *graph3= new TGraph(m, FileOffset, PscuCounter); |
229 |
|
graph3->SetMarkerColor(3); |
230 |
|
graph3->SetMarkerSize(.5); |
231 |
|
graph3->SetMarkerStyle(21); |
232 |
|
mg1->Add(graph3); |
233 |
|
|
234 |
|
TGraph *graph4= new TGraph(m, FileOffset, tempo); |
235 |
|
graph4->SetMarkerColor(kBlue); |
236 |
|
graph4->SetMarkerSize(.5); |
237 |
|
graph4->SetMarkerStyle(21); |
238 |
|
mg2->Add(graph4); |
239 |
|
|
240 |
|
ev=ev+10000; |
241 |
|
} |
242 |
|
//------------ First Canvas ---------------------// |
243 |
|
|
244 |
finalCanv1->cd(1); |
finalCanv1->cd(1); |
245 |
h1->SetStats(kFALSE); |
h1->SetStats(kFALSE); |
246 |
h1->GetXaxis()->SetTitle("OBT (ms)"); |
h1->GetXaxis()->SetTitle("OBT (ms)"); |
253 |
h1->Draw(); |
h1->Draw(); |
254 |
|
|
255 |
finalCanv1->cd(2); |
finalCanv1->cd(2); |
256 |
PcktLenght->SetStats(kFALSE); |
mg3->Draw("AP"); |
257 |
PcktLenght->GetXaxis()->SetTitle("OBT (ms)"); |
mg3->GetXaxis()->SetTitle("OBT (ms)"); |
258 |
PcktLenght->GetXaxis()->CenterTitle(); |
mg3->GetXaxis()->CenterTitle(); |
259 |
PcktLenght->GetXaxis()->SetLabelSize(0.04); |
mg3->GetXaxis()->SetLabelSize(0.04); |
260 |
PcktLenght->GetYaxis()->SetTitle("Lenght (byte)"); |
mg3->GetYaxis()->SetTitle("Lenght (byte)"); |
261 |
PcktLenght->GetYaxis()->CenterTitle(); |
mg3->GetYaxis()->CenterTitle(); |
262 |
PcktLenght->GetYaxis()->SetLabelSize(0.04); |
mg3->GetYaxis()->SetLabelSize(0.04); |
263 |
PcktLenght->GetYaxis()->SetTitleSize(0.06); |
mg3->GetYaxis()->SetTitleSize(0.06); |
264 |
PcktLenght->GetYaxis()->SetTitleOffset(0.8); |
mg3->GetYaxis()->SetTitleOffset(0.8); |
265 |
PcktLenght->SetMarkerColor(2); |
|
|
PcktLenght->SetMarkerSize(.5); |
|
|
PcktLenght->SetMarkerStyle(21); |
|
|
PcktLenght->Draw("9p"); |
|
266 |
|
|
267 |
finalCanv1->cd(3); |
finalCanv1->cd(3); |
268 |
PcktCounter->SetStats(kFALSE); |
mg4->Draw("AP"); |
269 |
PcktCounter->GetXaxis()->SetTitle("OBT (ms)"); |
mg4->GetXaxis()->SetTitle("OBT (ms)"); |
270 |
PcktCounter->GetXaxis()->SetTitleSize(0.05); |
mg4->GetXaxis()->SetTitleSize(0.05); |
271 |
PcktCounter->GetXaxis()->CenterTitle(); |
mg4->GetXaxis()->CenterTitle(); |
272 |
PcktCounter->GetXaxis()->SetLabelSize(0.04); |
mg4->GetXaxis()->SetLabelSize(0.04); |
273 |
PcktCounter->GetYaxis()->SetTitle("Counter"); |
mg4->GetYaxis()->SetTitle("Counter"); |
274 |
PcktCounter->GetYaxis()->SetTitleSize(0.05); |
mg4->GetYaxis()->SetTitleSize(0.05); |
275 |
PcktCounter->GetYaxis()->CenterTitle(); |
mg4->GetYaxis()->CenterTitle(); |
276 |
PcktCounter->GetYaxis()->SetLabelSize(0.04); |
mg4->GetYaxis()->SetLabelSize(0.04); |
277 |
PcktCounter->GetYaxis()->SetTitleSize(0.06); |
mg4->GetYaxis()->SetTitleSize(0.06); |
278 |
PcktCounter->GetYaxis()->SetTitleOffset(0.8); |
mg4->GetYaxis()->SetTitleOffset(0.8); |
|
PcktCounter->SetMarkerColor(4); |
|
|
PcktCounter->SetMarkerSize(.5); |
|
|
PcktCounter->SetMarkerStyle(21); |
|
|
PcktCounter->Draw("9p"); |
|
|
//--------- Second Canvas -----------------------------// |
|
|
/*TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
|
|
finalCanv2->Divide(1,2); |
|
|
finalCanv2->SetFillColor(10); |
|
279 |
|
|
280 |
finalCanv2->cd(1); |
finalCanv1->Update(); |
|
PcktCounter->SetStats(kFALSE); |
|
|
PcktCounter->GetXaxis()->SetTitle("OBT (ms)"); |
|
|
PcktCounter->GetXaxis()->SetTitleSize(0.05); |
|
|
PcktCounter->GetXaxis()->CenterTitle(); |
|
|
PcktCounter->GetXaxis()->SetLabelSize(0.04); |
|
|
PcktCounter->GetYaxis()->SetTitle("Counter"); |
|
|
PcktCounter->GetYaxis()->SetTitleSize(0.05); |
|
|
PcktCounter->GetYaxis()->CenterTitle(); |
|
|
PcktCounter->GetYaxis()->SetLabelSize(0.04); |
|
|
PcktCounter->SetMarkerColor(4); |
|
|
PcktCounter->SetMarkerSize(.5); |
|
|
PcktCounter->SetMarkerStyle(21); |
|
|
PcktCounter->Draw("9p"); |
|
|
|
|
|
finalCanv2->cd(2); |
|
|
FileOffset->SetStats(kFALSE); |
|
|
FileOffset->GetXaxis()->SetTitle("File Offset"); |
|
|
FileOffset->GetXaxis()->CenterTitle(); |
|
|
FileOffset->GetXaxis()->SetTitleSize(0.05); |
|
|
FileOffset->GetXaxis()->SetLabelSize(0.04); |
|
|
FileOffset->GetYaxis()->SetTitle("Counter"); |
|
|
FileOffset->GetYaxis()->CenterTitle(); |
|
|
FileOffset->GetYaxis()->SetTitleSize(0.05); |
|
|
FileOffset->GetYaxis()->SetLabelSize(0.04); |
|
|
FileOffset->SetMarkerColor(3); |
|
|
FileOffset->SetMarkerSize(.5); |
|
|
FileOffset->SetMarkerStyle(21); |
|
|
FileOffset->Draw("9p");*/ |
|
281 |
|
|
|
//-------to save---------------------------/// |
|
282 |
oss.str(""); |
oss.str(""); |
|
oss1.str(""); |
|
|
|
|
283 |
oss << outDir.Data() << filename.Data(); |
oss << outDir.Data() << filename.Data(); |
|
oss1 << outDir.Data() << filename.Data(); |
|
|
|
|
284 |
oss << "_HeaderScan_1." << format.Data(); |
oss << "_HeaderScan_1." << format.Data(); |
|
oss1 << "_HeaderScan_2." << format.Data(); |
|
|
|
|
285 |
finalCanv1->SaveAs(oss.str().c_str()); |
finalCanv1->SaveAs(oss.str().c_str()); |
|
//finalCanv2->SaveAs(oss1.str().c_str()); |
|
286 |
|
|
|
file->Close(); |
|
|
|
|
|
} |
|
287 |
|
|
288 |
|
|
289 |
|
//------------ Second Canvas ---------------------// |
290 |
|
finalCanv2->cd(1); |
291 |
|
mg1->Draw("AP"); |
292 |
|
mg1->GetXaxis()->SetTitle("File Offset"); |
293 |
|
mg1->GetXaxis()->CenterTitle(); |
294 |
|
mg1->GetXaxis()->SetTitleSize(0.05); |
295 |
|
mg1->GetXaxis()->SetLabelSize(0.04); |
296 |
|
mg1->GetYaxis()->SetTitle("Counter"); |
297 |
|
mg1->GetYaxis()->CenterTitle(); |
298 |
|
mg1->GetYaxis()->SetTitleSize(0.05); |
299 |
|
mg1->GetYaxis()->SetLabelSize(0.04); |
300 |
|
|
301 |
|
finalCanv2->cd(2); |
302 |
|
mg2->Draw("AP"); |
303 |
|
mg2->GetXaxis()->SetTitle("File Offset"); |
304 |
|
mg2->GetXaxis()->CenterTitle(); |
305 |
|
mg2->GetXaxis()->SetTitleSize(0.05); |
306 |
|
mg2->GetXaxis()->SetLabelSize(0.04); |
307 |
|
mg2->GetYaxis()->SetTitle("OBT"); |
308 |
|
mg2->GetYaxis()->CenterTitle(); |
309 |
|
mg2->GetYaxis()->SetTitleSize(0.05); |
310 |
|
mg2->GetYaxis()->SetLabelSize(0.04); |
311 |
|
|
312 |
|
finalCanv2->Update(); |
313 |
|
|
314 |
|
oss1.str(""); |
315 |
|
oss1 << outDir.Data() << filename.Data(); |
316 |
|
oss1 << "_HeaderScan_2"<<"." << format.Data(); |
317 |
|
|
318 |
|
finalCanv2->SaveAs(oss1.str().c_str()); |
319 |
|
|
320 |
|
file->Close(); |
321 |
|
|
322 |
|
} |
323 |
|
|
324 |
int main(int argc, char* argv[]){ |
int main(int argc, char* argv[]){ |
325 |
TString path; |
TString path; |