1 |
/** |
/** |
2 |
* Header Scan |
* Header_Scan |
3 |
* Author Nagni |
* Author Nagni |
4 |
* version 1.0 |
* version 1.0 |
5 |
* |
* |
43 |
* There is no default value, without this input the program will not run |
* There is no default value, without this input the program will not run |
44 |
* TString outDir - the path where to save the output image (Default = ./) |
* TString outDir - the path where to save the output image (Default = ./) |
45 |
* TString format - the format which will be used fo rsave the produced images (Default = "jpg") |
* TString format - the format which will be used fo rsave the produced images (Default = "jpg") |
46 |
|
* |
47 |
|
* |
48 |
|
* Version 1.7 |
49 |
|
* Date 16 June 2006 - Malvezzi |
50 |
|
* |
51 |
|
* Description of changes: |
52 |
|
* Implementation of the case: numebr of events <= 0. |
53 |
|
* 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 I have subsituted graphs with histograms |
55 |
|
* or divided the graphs in more than one canvas. |
56 |
|
* |
57 |
|
* Version 1.8 |
58 |
|
* Date 8 August 2006 - Malvezzi |
59 |
|
* |
60 |
|
* Description: changed the scale in the second and third graph of the first canvas; added a pad of text in the second canvas |
61 |
|
* |
62 |
*/ |
*/ |
63 |
|
|
64 |
|
|
65 |
|
#include <fstream> |
66 |
|
#include <math.h> |
67 |
|
#include "TLatex.h" |
68 |
|
#include "TF1.h" |
69 |
|
#include "TPaveText.h" |
70 |
|
#include "TMultiGraph.h" |
71 |
#include <sstream> |
#include <sstream> |
72 |
#include <iostream> |
#include <iostream> |
73 |
#include "TString.h" |
#include "TString.h" |
82 |
#include "TGaxis.h" |
#include "TGaxis.h" |
83 |
#include "EventHeader.h" |
#include "EventHeader.h" |
84 |
#include "PscuHeader.h" |
#include "PscuHeader.h" |
85 |
|
#include "RunHeaderEvent.h" |
86 |
|
#include "TPaveText.h" |
87 |
|
|
88 |
using namespace std; |
using namespace std; |
89 |
|
|
90 |
void HeaderScan(TString base, TString outDir, TString format) |
void HeaderScan(TString base, TString outDir, TString format){ |
|
{ |
|
91 |
|
|
92 |
TList *list = new TList; |
//------------------- Variables initilization -------------------------// |
93 |
Int_t numkey; |
Long64_t nevents=0, runnevents; |
94 |
TObject *key = new TObject; |
ULong_t lastime, firstime, primotempo, ultimotempo, primoffset=500000000, ultimoffset; |
95 |
const char *name; |
double obmin=0.; |
96 |
TTree* tr = new TTree; |
double obmax=0.; |
97 |
Long64_t totevents=0, totphysevents=0; |
stringstream oss, oss1, oss2, oss3, noentries, stringa; |
|
Float_t id; |
|
|
Long64_t nevents=0; |
|
|
|
|
|
//------- load root file -------------- |
|
98 |
|
|
99 |
|
//-------------- Load root file, tree and branch -------------------// |
100 |
TFile *file = new TFile(base.Data()); |
TFile *file = new TFile(base.Data()); |
|
|
|
101 |
if (!file){ |
if (!file){ |
102 |
printf("No such file in the directory has been found"); |
printf("No such file in the directory has been found"); |
103 |
return; |
return; |
104 |
} |
} |
105 |
if (outDir == "" ) outDir = "."; |
|
106 |
|
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
107 |
list = file->GetListOfKeys(); |
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
108 |
|
|
109 |
numkey = file->GetNkeys(); |
pamela::EventHeader *eh = 0; |
110 |
|
pamela::PscuHeader *ph = 0; |
111 |
pamela::EventHeader *eh=0; |
|
112 |
pamela::PscuHeader *ph=0; |
PhysicsTr->SetBranchAddress("Header", &eh); |
113 |
|
nevents = PhysicsTr->GetEntries(); |
114 |
///-----to know the total number f events end of physics events----////// |
const Int_t size = nevents; |
115 |
|
|
116 |
for (Int_t i=0; i<numkey; i++){ |
TTree *RunHeadTr = (TTree*)file->Get("RunHeader"); ///run header tree |
117 |
key = list->At(i); |
pamela::EventHeader *eH=0; |
118 |
name=(key->GetName()); |
pamela::RunHeaderEvent *reh=0; |
119 |
//cout<<name<<"\n"; |
|
120 |
tr = (TTree*)file->Get(name); |
RunHeadTr->SetBranchAddress("Header",&eH); |
121 |
if (tr->IsZombie()) continue; |
RunHeadTr->SetBranchAddress("RunHeader",&reh); |
122 |
nevents = tr->GetEntries(); |
runnevents = RunHeadTr->GetEntries(); |
123 |
totevents+=nevents; |
|
|
tr->SetBranchAddress("Header", &eh); |
|
|
for (Int_t j = 0; j < nevents; j++){ |
|
|
tr->GetEntry(j); |
|
|
ph = eh->GetPscuHeader(); |
|
|
if(ph->GetPacketId1() == 0x10) ++totphysevents; |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
const Long64_t totalevents=totevents; |
|
|
const Long64_t totalphysevents=totphysevents; |
|
|
|
|
|
///////////////////////////////////////////////// |
|
|
|
|
124 |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
125 |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
|
stringstream oss; |
|
|
oss.str(""); |
|
|
oss << filename.Data(); |
|
|
|
|
|
Float_t obt[totalevents], pcktId[totalevents], pcktLenght[totalphysevents], pcktCounter[totalphysevents], offset[totalevents], allCounter[totalevents]; |
|
|
Float_t obtphysevents=0; |
|
|
|
|
126 |
|
|
127 |
totphysevents=0; |
//----------- If nevents < = 0 ---------------------------------/ |
128 |
totevents=0; |
if (nevents<=0) { |
129 |
for (Int_t i=0; i<numkey; i++){ |
printf("nevents = %i \n", nevents); |
130 |
key = list->At(i); |
printf(" \n"); |
131 |
name=(char *)(key->GetName()); |
TCanvas *canv = new TCanvas("No entries", "No entries ", 400, 200); |
132 |
tr = (TTree*)file->Get(name); |
canv->SetFillColor(10); |
133 |
if (tr->IsZombie()) continue; |
canv->cd(); |
134 |
tr->SetBranchAddress("Header", &eh); |
TLatex *l = new TLatex(); |
135 |
nevents = tr->GetEntries(); |
l->SetTextAlign(12); |
136 |
for (Int_t j = 0; j < nevents; j++){ |
l->SetTextSize(0.15); |
137 |
tr->GetEntry(j); |
l->SetTextColor(2); |
138 |
ph = eh->GetPscuHeader(); |
noentries.str(""); |
139 |
obt[j+totevents]=ph->GetOrbitalTime() ; |
noentries<< "HeaderScan_QL:"; |
140 |
pcktId[j+totevents]=ph->GetPacketId1(); |
l->DrawLatex(0.05, 0.7, noentries.str().c_str()); |
141 |
offset[j+totevents]=ph->GetFileOffset(); |
noentries.str(""); |
142 |
if(pcktId[j+totevents]==16){ |
noentries<< "No Physics entries for this files"; |
143 |
pcktLenght[totphysevents]=ph->GetPacketLenght(); |
l->DrawLatex(0.05, 0.5, noentries.str().c_str()); |
144 |
pcktCounter[totphysevents]=ph->GetCounter(); |
if (outDir == "./") { |
145 |
totphysevents=totphysevents+1; |
oss.str(""); |
146 |
} |
oss << filename.Data() << "_HeaderScan_QL." << format.Data(); |
147 |
offset[j+totevents]=ph->GetFileOffset(); |
} else { |
148 |
allCounter[j+totevents]= ph->GetCounter(); |
oss.str(""); |
149 |
} |
oss << outDir.Data() << filename.Data() << "_HeaderScan_QL." << format.Data(); |
150 |
totevents=totevents+nevents; |
} |
151 |
|
canv->Update(); |
152 |
|
canv->SaveAs(oss.str().c_str()); |
153 |
|
return; |
154 |
} |
} |
155 |
|
//-------------- to know the max and min OBT ----------------------------// |
156 |
|
headBr->GetEntry(0); |
157 |
Float_t mintime=obt[0], maxtime=obt[0], minlen=pcktLenght[0], maxlen=pcktLenght[0], mincount=pcktCounter[0], maxcount=pcktCounter[0]; |
ph = eh->GetPscuHeader(); |
158 |
|
firstime = ph->GetOrbitalTime(); |
159 |
|
headBr->GetEntry(nevents); |
160 |
for (Int_t t=0; t<totalevents; t++){ |
ph = eh->GetPscuHeader(); |
161 |
if(obt[t]<mintime) mintime=obt[t]; |
lastime = ph->GetOrbitalTime(); |
162 |
if(obt[t]>maxtime) maxtime=obt[t]; |
int i =0; |
163 |
} |
while(i < nevents){ |
164 |
for (Int_t t=0; t<totalphysevents; t++){ |
headBr->GetEntry(i); |
165 |
if(pcktLenght[t]<=minlen) minlen=pcktLenght[t]; |
ph = eh->GetPscuHeader(); |
166 |
if(pcktLenght[t]>=maxlen) maxlen=pcktLenght[t]; |
if((ph->GetOrbitalTime()) <= firstime) firstime=ph->GetOrbitalTime(); |
167 |
if(pcktCounter[t]<=mincount) mincount=pcktCounter[t]; |
if((ph->GetOrbitalTime()) >= lastime) lastime=ph->GetOrbitalTime(); |
168 |
if(pcktCounter[t]>=maxcount) maxcount=pcktCounter[t]; |
i++; |
169 |
|
} |
170 |
|
|
171 |
|
//------------------------ First histogram -----------------------------------// |
172 |
|
obmin=firstime; |
173 |
|
obmax=lastime; |
174 |
|
Int_t nbin = (lastime-firstime)/60000; |
175 |
|
TH1F *h1 = new TH1F ("histo1", "" , nbin, obmin, obmax); |
176 |
|
|
177 |
|
//------------------- fill vectors and histogram -----------------------------// |
178 |
|
Double_t *PscuCounter = new Double_t[size]; |
179 |
|
Double_t *PacketLenght = new Double_t[size]; |
180 |
|
Double_t *OBTime = new Double_t[size]; |
181 |
|
Double_t *Eventsperminute= new Double_t[nbin]; |
182 |
|
Double_t *Minute= new Double_t[nbin]; |
183 |
|
Int_t max=0; |
184 |
|
for (Int_t k = 0; k < nevents; k++){ |
185 |
|
headBr->GetEntry(k); |
186 |
|
ph = eh->GetPscuHeader(); |
187 |
|
h1->Fill(ph->GetOrbitalTime()); |
188 |
|
PscuCounter[k]= ph->GetCounter(); |
189 |
|
PacketLenght[k]=ph->GetPacketLenght(); |
190 |
|
OBTime[k]=ph->GetOrbitalTime(); |
191 |
|
} |
192 |
|
int l=0; |
193 |
|
while(l<nbin){ |
194 |
|
Eventsperminute[l]=h1->GetBinContent(l); |
195 |
|
Minute[l]=firstime+l*60000; |
196 |
|
if(h1->GetBinContent(l) >= max)max =(Int_t)h1->GetBinContent(l); |
197 |
|
l++; |
198 |
} |
} |
|
|
|
|
|
|
|
Float_t nbintime = (maxtime-mintime)/1000; |
|
|
Float_t nbinlen = (maxlen-minlen)/100; |
|
|
Float_t nbincount = (maxcount-mincount)/100; |
|
|
|
|
|
|
|
|
///---------------------------TO GRAPH---------------------------------------------/// |
|
|
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1024); |
|
|
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
|
|
finalCanv1->Divide(3); |
|
|
finalCanv1->SetFillColor(10); |
|
|
finalCanv2->Divide(2); |
|
|
finalCanv2->SetFillColor(10); |
|
199 |
|
|
200 |
|
//----------- Graph and MultiGraph -----------------------------------------------// |
201 |
TGraph *grPcktId1 = new TGraph(totalevents, obt, pcktId); |
TMultiGraph *rate = new TMultiGraph(); |
202 |
TGraph *grPcktLenght = new TGraph(totalevents, obt, pcktLenght); |
TMultiGraph *packetLength = new TMultiGraph(); |
203 |
TGraph *grPcktCounter = new TGraph(totalevents, obt, pcktCounter); |
TMultiGraph *packeCounter = new TMultiGraph(); |
|
TGraph *grFileOffset = new TGraph(totalevents, offset, allCounter); |
|
|
|
|
|
TGaxis::SetMaxDigits(3); |
|
204 |
|
|
|
//-----canvas 1-------------------------------/// |
|
|
finalCanv1->cd(1); |
|
|
|
|
|
stringstream oss1; |
|
|
oss1.str(""); |
|
|
oss1 << "OBT (ms) with t0 = " << mintime << "ms"; |
|
|
|
|
|
gStyle->SetTitleH(0.06); |
|
|
grPcktId1->SetTitle(oss.str().c_str()); |
|
|
grPcktId1->GetXaxis()->SetTitle(oss1.str().c_str()); |
|
|
grPcktId1->GetXaxis()->CenterTitle(); |
|
|
grPcktId1->GetXaxis()->SetLabelSize(0.03); |
|
|
grPcktId1->GetYaxis()->SetTitle("Packet ID"); |
|
|
grPcktId1->GetYaxis()->CenterTitle(); |
|
|
grPcktId1->SetMarkerSize(4); |
|
|
grPcktId1->Draw("AP"); |
|
|
|
|
|
|
|
|
finalCanv1->cd(2); |
|
205 |
oss1.str(""); |
oss1.str(""); |
206 |
oss1 << "OBT (min) with t0 = " << mintime << "ms"; |
oss1 << "Physics Packet per minute. Start time = " << obmin << ", End time = "<< obmax <<" ms"; |
207 |
|
TGraph *rate1= new TGraph(nbin, (const Double_t*)Minute, (const Double_t*)Eventsperminute); |
208 |
TH1F *h1 = new TH1F ("h1", oss.str().c_str(), (int)(nbintime/60), mintime, maxtime); |
rate1->SetMarkerColor(kBlack); |
209 |
|
rate1->SetMarkerSize(.1); |
210 |
|
rate1->SetMarkerStyle(21); |
211 |
|
rate->Add(rate1); |
212 |
|
|
213 |
|
TGraph *packetLength1= new TGraph(nevents, (const Double_t*)OBTime, (const Double_t*)PacketLenght); |
214 |
|
oss2.str(""); |
215 |
|
oss2 <<"Lenght of Physic packets"; |
216 |
|
packetLength1->SetMarkerColor(2); |
217 |
|
packetLength1->SetMarkerSize(.3); |
218 |
|
packetLength1->SetMarkerStyle(21); |
219 |
|
packetLength->Add(packetLength1); |
220 |
|
|
221 |
|
TGraph *packeCounter1= new TGraph(nevents, (const Double_t*)OBTime, (const Double_t*)PscuCounter); |
222 |
|
oss3.str(""); |
223 |
|
oss3 <<"Physics Counter vs. OBT"; |
224 |
|
packeCounter1->SetMarkerColor(4); |
225 |
|
packeCounter1->SetMarkerSize(.2); |
226 |
|
packeCounter1->SetMarkerStyle(21); |
227 |
|
packeCounter->Add(packeCounter1); |
228 |
|
|
229 |
|
//------------ Create and Draw Canvas ---------------------// |
230 |
|
TCanvas *finalCanv = new TCanvas("Header", base, 1200, 1600); |
231 |
|
finalCanv->Divide(1,6); |
232 |
|
finalCanv->SetFillColor(10); |
233 |
|
|
234 |
|
TPad *all2= new TPad ("","", 0, 0, 1, 1); |
235 |
|
all2->SetFillColor(10); |
236 |
|
TPad *all3= new TPad ("","", 0, 0, 1, 1); |
237 |
|
all3->SetFillColor(10); |
238 |
|
TPad *all4= new TPad ("","", 0, 0, 1, 1); |
239 |
|
all4->SetFillColor(10); |
240 |
|
TPad *all= new TPad ("","", 0, 0, 1, 1); |
241 |
|
all->SetFillColor(10); |
242 |
|
TPad *all1= new TPad ("","", 0, 0, 1, 1); |
243 |
|
all1->SetFillColor(10); |
244 |
|
|
245 |
|
TLine li; |
246 |
|
li.SetLineStyle(4); |
247 |
|
li.SetLineWidth(2); |
248 |
|
|
249 |
|
//----------- First PAD -------------------------------// |
250 |
|
finalCanv->cd(1); |
251 |
|
all2->Draw(); |
252 |
|
all2->cd(); |
253 |
|
rate->Draw("ALP"); |
254 |
|
rate->GetXaxis()->SetTitle("OBT (ms)"); |
255 |
|
rate->GetXaxis()->SetTitleSize(0.05); |
256 |
|
rate->GetXaxis()->CenterTitle(); |
257 |
|
rate->GetXaxis()->SetLabelSize(0.05); |
258 |
|
rate->GetYaxis()->SetTitle("Number of events "); |
259 |
|
rate->GetYaxis()->CenterTitle(); |
260 |
|
rate->GetYaxis()->SetLabelSize(0.05); |
261 |
|
rate->GetYaxis()->SetTitleSize(0.06); |
262 |
|
rate->GetYaxis()->SetTitleOffset(0.6); |
263 |
|
for (Int_t l = 0; l < runnevents; l++){ |
264 |
|
RunHeadTr->GetEntry(l); |
265 |
|
ph = eH->GetPscuHeader(); |
266 |
|
int ws= reh->RM_ACQ_SETTING_MODE; |
267 |
|
int id = ph->GetPacketId1(); |
268 |
|
Int_t obt = ph->GetOrbitalTime(); |
269 |
|
if (ws==1){ |
270 |
|
li.SetLineColor(3); |
271 |
|
li.DrawLine(obt,0,obt,max); |
272 |
|
} |
273 |
|
else if (ws==2){ |
274 |
|
li.SetLineColor(4); |
275 |
|
li.DrawLine(obt,0,obt,max); |
276 |
|
} |
277 |
|
} |
278 |
|
|
279 |
for (Int_t i=0; i<numkey; i++){ |
RunHeadTr->GetEntry(0); |
280 |
key = list->At(i); |
ph = eH->GetPscuHeader(); |
281 |
|
ULong_t TimeSync = reh->LAST_TIME_SYNC_INFO; |
282 |
|
ULong_t ObtSync = reh->OBT_TIME_SYNC; |
283 |
|
//cout<<"TimeSync "<<reh->LAST_TIME_SYNC_INFO<<"\n"; |
284 |
|
//cout<<"ObtSync "<<reh->OBT_TIME_SYNC<<"\n"; |
285 |
|
|
286 |
|
finalCanv->cd(1); |
287 |
|
stringstream ws1, ws2; |
288 |
|
ws1.str(""); |
289 |
|
ws2.str(""); |
290 |
|
ws1<<"ACQ_SETTING_MODE = 1"; |
291 |
|
ws2<<"ACQ_SETTING_MODE = 2"; |
292 |
|
TPaveText *pt=0; |
293 |
|
pt = new TPaveText (.60,.92,.76,.98); |
294 |
|
pt->AddText(ws1.str().c_str()); |
295 |
|
pt->SetTextColor(3); |
296 |
|
pt->SetFillColor(10); |
297 |
|
pt->SetBorderSize(0); |
298 |
|
pt->Draw(); |
299 |
|
TPaveText *pt1=0; |
300 |
|
pt1 = new TPaveText (.76,.92,.92,.98); |
301 |
|
pt1->AddText(ws2.str().c_str()); |
302 |
|
pt1->SetTextColor(4); |
303 |
|
pt1->SetFillColor(10); |
304 |
|
pt1->SetBorderSize(0); |
305 |
|
pt1->Draw(); |
306 |
|
pt1 = new TPaveText (.05,.91,.6,1); |
307 |
|
pt1->AddText(oss1.str().c_str()); |
308 |
|
pt1->SetTextColor(1); |
309 |
|
pt1->SetFillColor(10); |
310 |
|
pt1->SetBorderSize(0); |
311 |
|
pt1->Draw(); |
312 |
|
|
313 |
|
//----------- Second PAD -------------------------------// |
314 |
|
finalCanv->cd(2); |
315 |
|
all3->Draw(); |
316 |
|
all3->cd(); |
317 |
|
packetLength->Draw("AP"); |
318 |
|
packetLength->GetXaxis()->SetTitle("OBT (ms)"); |
319 |
|
packetLength->GetXaxis()->SetTitleSize(0.05); |
320 |
|
packetLength->GetXaxis()->CenterTitle(); |
321 |
|
packetLength->GetXaxis()->SetLabelSize(0.05); |
322 |
|
packetLength->GetYaxis()->SetTitle("Lenght (byte)"); |
323 |
|
packetLength->GetYaxis()->CenterTitle(); |
324 |
|
packetLength->GetYaxis()->SetLabelSize(0.05); |
325 |
|
packetLength->GetYaxis()->SetTitleSize(0.06); |
326 |
|
packetLength->GetYaxis()->SetTitleOffset(0.6); |
327 |
|
|
328 |
|
|
329 |
|
finalCanv->cd(2); |
330 |
|
pt = new TPaveText (.6,.91,.90,1); |
331 |
|
pt->AddText(oss2.str().c_str()); |
332 |
|
pt->SetTextColor(2); |
333 |
|
pt->SetFillColor(10); |
334 |
|
pt->SetBorderSize(0); |
335 |
|
pt->Draw(); |
336 |
|
|
337 |
|
//----------- Third PAD -------------------------------// |
338 |
|
finalCanv->cd(3); |
339 |
|
all4->Draw(); |
340 |
|
all4->cd(); |
341 |
|
packeCounter->Draw("AP"); |
342 |
|
packeCounter->GetXaxis()->SetTitle("OBT (ms)"); |
343 |
|
packeCounter->GetXaxis()->SetTitleSize(0.05); |
344 |
|
packeCounter->GetXaxis()->CenterTitle(); |
345 |
|
packeCounter->GetXaxis()->SetLabelSize(0.05); |
346 |
|
packeCounter->GetYaxis()->SetTitle("Counter"); |
347 |
|
packeCounter->GetYaxis()->SetTitleSize(0.05); |
348 |
|
packeCounter->GetYaxis()->CenterTitle(); |
349 |
|
packeCounter->GetYaxis()->SetLabelSize(0.05); |
350 |
|
packeCounter->GetYaxis()->SetTitleSize(0.06); |
351 |
|
packeCounter->GetYaxis()->SetTitleOffset(0.6); |
352 |
|
|
353 |
|
|
354 |
|
finalCanv->cd(3); |
355 |
|
TPaveText *pt2=0; |
356 |
|
pt2 = new TPaveText (.6,.91,.90,1); |
357 |
|
pt2->AddText(oss3.str().c_str()); |
358 |
|
pt2->SetTextColor(4); |
359 |
|
pt2->SetFillColor(10); |
360 |
|
pt2->SetBorderSize(0); |
361 |
|
pt2->Draw(); |
362 |
|
|
363 |
|
/**********************************************************************************************/ |
364 |
|
|
365 |
|
TMultiGraph *mg1 = new TMultiGraph(); |
366 |
|
TMultiGraph *mg2 = new TMultiGraph(); |
367 |
|
//---------------------- fill vectors and histogram --------------------------------------------------// |
368 |
|
TList *list = new TList; |
369 |
|
Int_t numkey; |
370 |
|
TObject *key = new TObject; |
371 |
|
const char *name; |
372 |
|
TTree* tr = new TTree; |
373 |
|
Long64_t nevntskey=0; |
374 |
|
list = file->GetListOfKeys(); |
375 |
|
numkey = file->GetNkeys(); |
376 |
|
ULong_t salto; |
377 |
|
for (Int_t m=0; m<numkey; m++){ |
378 |
|
key = list->At(m); |
379 |
name=(char *)(key->GetName()); |
name=(char *)(key->GetName()); |
380 |
tr = (TTree*)file->Get(name); |
tr = (TTree*)file->Get(name); |
381 |
if (tr->IsZombie()) continue; |
if (tr->IsZombie()) continue; |
382 |
tr->SetBranchAddress("Header", &eh); |
tr->SetBranchAddress("Header", &eh); |
383 |
nevents = tr->GetEntries(); |
TBranch *Br = tr->GetBranch("Header"); |
384 |
for (Int_t j = 0; j < nevents; j++){ |
nevntskey = tr->GetEntries(); |
385 |
tr->GetEntry(j); |
|
386 |
ph = eh->GetPscuHeader(); |
if(nevntskey !=0){ |
387 |
if((ph->GetPacketId1()) == 16){ |
Int_t size1=nevntskey; |
388 |
obtphysevents=ph->GetOrbitalTime(); |
Double_t *PscuCounter1 = new Double_t[size1]; |
389 |
h1->Fill(obtphysevents); |
Double_t *FileOffset1 = new Double_t[size1]; |
390 |
} |
Double_t *tempo1 = new Double_t[size1]; |
391 |
} |
|
392 |
|
int n=0; |
393 |
|
while(n<nevntskey){ |
394 |
|
Br->GetEntry(n); |
395 |
|
ph = eh->GetPscuHeader(); |
396 |
|
PscuCounter1[n]= ph->GetCounter(); |
397 |
|
FileOffset1[n]=ph->GetFileOffset(); |
398 |
|
tempo1[n]=ph->GetOrbitalTime(); |
399 |
|
if((m==0) && (n==0)){ |
400 |
|
primotempo=ph->GetOrbitalTime(); |
401 |
|
salto=ph->GetOrbitalTime(); |
402 |
|
} |
403 |
|
if(salto > ph->GetOrbitalTime())salto=ph->GetOrbitalTime(); |
404 |
|
if(ph->GetFileOffset()<= primoffset){ |
405 |
|
primoffset=ph->GetFileOffset(); |
406 |
|
primotempo=ph->GetOrbitalTime(); |
407 |
|
} |
408 |
|
if(ph->GetFileOffset()>=ultimoffset){ |
409 |
|
ultimotempo=ph->GetOrbitalTime(); |
410 |
|
ultimoffset=ph->GetFileOffset(); |
411 |
|
} |
412 |
|
n++; |
413 |
|
} |
414 |
|
TGraph *graph3= new TGraph(nevntskey, (const Double_t*)FileOffset1, (const Double_t*)PscuCounter1); |
415 |
|
graph3->SetMarkerColor(3); |
416 |
|
graph3->SetMarkerSize(.2); |
417 |
|
graph3->SetMarkerStyle(21); |
418 |
|
mg1->Add(graph3); |
419 |
|
|
420 |
|
TGraph *graph4= new TGraph(nevntskey, (const Double_t*)FileOffset1, (const Double_t*)tempo1); |
421 |
|
graph4->SetMarkerColor(kBlue); |
422 |
|
graph4->SetMarkerSize(.2); |
423 |
|
graph4->SetMarkerStyle(21); |
424 |
|
mg2->Add(graph4); |
425 |
|
} |
426 |
} |
} |
|
|
|
|
h1->SetMarkerStyle(6); |
|
|
h1->GetXaxis()->SetTitle(oss1.str().c_str()); |
|
|
h1->GetXaxis()->CenterTitle(); |
|
|
h1->GetXaxis()->SetLabelSize(0.03); |
|
|
h1->GetYaxis()->SetTitle("number of Physic packets"); |
|
|
h1->GetYaxis()->CenterTitle(); |
|
|
h1->Draw(); |
|
|
|
|
|
|
|
|
finalCanv1->cd(3); |
|
|
oss1.str(""); |
|
|
oss1 << "OBT (ms) with t0 = " << mintime << "ms"; |
|
|
|
|
|
grPcktLenght->SetTitle(oss.str().c_str()); |
|
|
grPcktLenght->GetXaxis()->SetTitle(oss1.str().c_str()); |
|
|
grPcktLenght->GetXaxis()->CenterTitle(); |
|
|
grPcktLenght->GetXaxis()->SetLabelSize(0.03); |
|
|
grPcktLenght->GetYaxis()->SetTitle("Lenght of Physic packets (byte)"); |
|
|
grPcktLenght->GetYaxis()->CenterTitle(); |
|
|
grPcktLenght->GetYaxis()->SetLabelSize(0.03); |
|
|
grPcktLenght->SetMarkerSize(4); |
|
|
grPcktLenght->Draw("AP"); |
|
|
|
|
|
|
|
|
finalCanv1->cd(2); |
|
|
h1->Draw(); |
|
|
|
|
|
finalCanv1->Update(); |
|
|
|
|
|
|
|
|
///---------canvas 2-----------------------------// |
|
|
finalCanv2->cd(1); |
|
|
|
|
|
grPcktCounter->SetTitle(oss.str().c_str()); |
|
|
grPcktCounter->GetXaxis()->SetTitle(oss1.str().c_str()); |
|
|
grPcktCounter->GetXaxis()->SetTitleSize(0.04); |
|
|
grPcktCounter->GetXaxis()->CenterTitle(); |
|
|
grPcktCounter->GetXaxis()->SetLabelSize(0.03); |
|
|
grPcktCounter->GetYaxis()->SetTitle("PacketCounter of Physic packets"); |
|
|
grPcktCounter->GetYaxis()->SetTitleSize(0.04); |
|
|
grPcktCounter->GetYaxis()->CenterTitle(); |
|
|
grPcktCounter->GetYaxis()->SetLabelSize(0.03); |
|
|
grPcktCounter->SetMarkerSize(4); |
|
|
grPcktCounter->SetMinimum(mincount); |
|
|
grPcktCounter->SetMaximum(maxcount); |
|
|
grPcktCounter->Draw("AP"); |
|
|
|
|
|
finalCanv2->cd(2); |
|
|
|
|
|
grFileOffset->SetTitle(oss.str().c_str()); |
|
|
grFileOffset->GetXaxis()->SetTitle("File Offset"); |
|
|
grFileOffset->GetXaxis()->CenterTitle(); |
|
|
grFileOffset->GetXaxis()->SetTitleSize(0.04); |
|
|
grFileOffset->GetXaxis()->SetLabelSize(0.03); |
|
|
grFileOffset->GetYaxis()->SetTitle("Packet counter"); |
|
|
grFileOffset->GetYaxis()->CenterTitle(); |
|
|
grFileOffset->GetYaxis()->SetTitleSize(0.04); |
|
|
grFileOffset->GetYaxis()->SetLabelSize(0.03); |
|
|
grFileOffset->SetMarkerSize(4); |
|
|
grFileOffset->Draw("AP"); |
|
|
|
|
|
finalCanv1->Update(); |
|
|
|
|
|
|
|
|
//-------to save---------------------------/// |
|
|
oss.str(""); |
|
|
oss1.str(""); |
|
|
|
|
|
oss << outDir.Data() << filename.Data(); |
|
|
oss1 << outDir.Data() << filename.Data(); |
|
427 |
|
|
428 |
oss << "_HeaderScan_1." << format.Data(); |
TLatex *lat = new TLatex(); |
429 |
oss1 << "_HeaderScan_2." << format.Data(); |
lat->SetTextAlign(12); |
430 |
|
lat->SetTextSize(0.15); |
431 |
finalCanv1->SaveAs(oss.str().c_str()); |
lat->SetTextColor(kBlue); |
432 |
finalCanv2->SaveAs(oss1.str().c_str()); |
|
433 |
|
//------------ Fourth PAD ---------------------// |
434 |
|
finalCanv->cd(4); |
435 |
file->Close(); |
all1->Draw(); |
436 |
|
all1->cd(); |
437 |
} |
|
438 |
|
oss1.str(""); |
439 |
|
oss1 <<"PscuCounter vs FileOffset."; |
440 |
|
mg1->Draw("AP"); |
441 |
|
mg1->GetXaxis()->SetTitle("File Offset"); |
442 |
|
mg1->GetXaxis()->CenterTitle(); |
443 |
|
mg1->GetXaxis()->SetTitleOffset(0.8); |
444 |
|
mg1->GetXaxis()->SetTitleSize(0.05); |
445 |
|
mg1->GetXaxis()->SetLabelSize(0.05); |
446 |
|
mg1->GetYaxis()->SetTitle("Counter"); |
447 |
|
mg1->GetYaxis()->CenterTitle(); |
448 |
|
mg1->GetYaxis()->SetTitleSize(0.06); |
449 |
|
mg1->GetYaxis()->SetLabelSize(0.06); |
450 |
|
mg1->GetYaxis()->SetTitleOffset(0.6); |
451 |
|
finalCanv->cd(4); |
452 |
|
TPaveText *pt3=0; |
453 |
|
pt3 = new TPaveText (.60,.91,.90,1); |
454 |
|
pt3->AddText(oss1.str().c_str()); |
455 |
|
pt3->SetTextColor(3); |
456 |
|
pt3->SetFillColor(10); |
457 |
|
pt3->SetBorderSize(0); |
458 |
|
pt3->Draw(); |
459 |
|
|
460 |
|
//------------ Fifth PAD ---------------------// |
461 |
|
finalCanv->cd(5); |
462 |
|
all->Draw(); |
463 |
|
all->cd(); |
464 |
|
oss3.str(""); |
465 |
|
oss3 << "OBT vs FileOffset"; |
466 |
|
mg2->Draw("AP"); |
467 |
|
mg2->GetXaxis()->SetTitle("File Offset"); |
468 |
|
mg2->GetXaxis()->CenterTitle(); |
469 |
|
mg2->GetXaxis()->SetTitleSize(0.05); |
470 |
|
mg2->GetXaxis()->SetLabelSize(0.05); |
471 |
|
mg2->GetYaxis()->SetTitle("OBT"); |
472 |
|
mg2->GetYaxis()->CenterTitle(); |
473 |
|
mg2->GetYaxis()->SetTitleSize(0.06); |
474 |
|
mg2->GetYaxis()->SetLabelSize(0.05); |
475 |
|
mg2->GetYaxis()->SetTitleOffset(0.6); |
476 |
|
|
477 |
|
finalCanv->cd(5); |
478 |
|
TPaveText *pt4=0; |
479 |
|
pt4 = new TPaveText (.70,.91,.90,1); |
480 |
|
pt4->AddText(oss3.str().c_str()); |
481 |
|
pt4->SetTextColor(kBlue); |
482 |
|
pt4->SetFillColor(10); |
483 |
|
pt4->SetBorderSize(0); |
484 |
|
pt4->Draw(); |
485 |
|
|
486 |
|
finalCanv->cd(6); |
487 |
|
ULong_t primotempoABS=TimeSync+((primotempo/1000)-ObtSync); |
488 |
|
ULong_t obmaxABS=TimeSync+((lastime/1000)-ObtSync); |
489 |
|
ULong_t saltoABS=TimeSync+((salto/1000)-ObtSync); |
490 |
|
ULong_t ultimotempoABS=TimeSync+((ultimotempo/1000)-ObtSync); |
491 |
|
|
492 |
|
TPaveText *pt5=0; |
493 |
|
pt5 = new TPaveText (0,0,1,1); |
494 |
|
stringa.str(""); |
495 |
|
stringa << " Filename: "<<filename.Data()<<"\n"; |
496 |
|
TText *t1=pt5->AddText(0.25,0.95,stringa.str().c_str()); |
497 |
|
t1->SetTextSize(0.1); |
498 |
|
stringa.str(""); |
499 |
|
stringa << " OBT (ms) ABS TIME (s)"; |
500 |
|
TText *t2=pt5->AddText(0.32,0.75,stringa.str().c_str()); |
501 |
|
t2->SetTextSize(0.07); |
502 |
|
stringa.str(""); |
503 |
|
stringa << "New data start at: "<<primotempo<<" "<<primotempoABS; |
504 |
|
TText *t3=pt5->AddText(0.25,0.60,stringa.str().c_str()); |
505 |
|
t3->SetTextSize(0.08); |
506 |
|
stringa.str(""); |
507 |
|
stringa << "New data end at: "<<lastime<<" "<<obmaxABS; |
508 |
|
TText *t4=pt5->AddText(0.25,0.50,stringa.str().c_str()); |
509 |
|
t4->SetTextSize(0.08); |
510 |
|
if(primotempo!=salto || lastime!=ultimotempo){ |
511 |
|
stringa.str(""); |
512 |
|
stringa << "Old data start at: "<<salto<<" "<<saltoABS; |
513 |
|
TText *t5=pt5->AddText(0.65,0.60,stringa.str().c_str()); |
514 |
|
t5->SetTextSize(0.08); |
515 |
|
stringa.str(""); |
516 |
|
stringa << "Old data end at: "<<ultimotempo<<" "<<ultimotempoABS; |
517 |
|
TText *t6=pt5->AddText(0.65,0.50,stringa.str().c_str()); |
518 |
|
t6->SetTextSize(0.08); |
519 |
|
stringa.str(""); |
520 |
|
stringa << " OBT (ms) ABS TIME (s)"; |
521 |
|
TText *t2=pt5->AddText(0.72,0.75,stringa.str().c_str()); |
522 |
|
t2->SetTextSize(0.07); |
523 |
|
} |
524 |
|
pt5->SetTextColor(kBlack); |
525 |
|
pt5->SetFillColor(10); |
526 |
|
pt5->SetBorderSize(0); |
527 |
|
pt5->Draw(); |
528 |
|
|
529 |
|
finalCanv->Update(); |
530 |
|
|
531 |
|
oss1.str(""); |
532 |
|
oss1 << outDir.Data() << filename.Data(); |
533 |
|
oss1 << "_HeaderScan"<<"." << format.Data(); |
534 |
|
|
535 |
|
finalCanv->SaveAs(oss1.str().c_str()); |
536 |
|
|
537 |
|
file->Close(); |
538 |
|
|
539 |
|
} |
540 |
|
|
541 |
int main(int argc, char* argv[]){ |
int main(int argc, char* argv[]){ |
542 |
TString path; |
TString path; |
543 |
TString outDir = "./"; |
TString outDir = "./"; |
544 |
TString format = "jpg"; |
TString format = "jpg"; |
|
|
|
545 |
if (argc < 2){ |
if (argc < 2){ |
546 |
printf("You have to insert at least the file to analyze \n"); |
printf("You have to insert at least the file to analyze \n"); |
547 |
printf("Try '--help' for more information. \n"); |
printf("Try '--help' for more information. \n"); |
548 |
exit(1); |
exit(1); |
549 |
} |
} |
|
|
|
550 |
if (!strcmp(argv[1], "--help")){ |
if (!strcmp(argv[1], "--help")){ |
551 |
printf( "Usage: HeaderScan FILE [OPTION] \n"); |
printf( "Usage: HeaderScan FILE [OPTION] \n"); |
552 |
printf( "\t --help Print this help and exit \n"); |
printf( "\t --help Print this help and exit \n"); |
554 |
printf( "\t -format[jpg|ps|gif] Format for output files [default 'jpg'] \n"); |
printf( "\t -format[jpg|ps|gif] Format for output files [default 'jpg'] \n"); |
555 |
exit(1); |
exit(1); |
556 |
} |
} |
|
|
|
|
|
|
557 |
path=argv[1]; |
path=argv[1]; |
558 |
|
for (int i = 2; i < argc; i++){ |
|
for (int i = 2; i < argc; i++){ |
|
|
|
|
559 |
if (!strcmp(argv[i], "-outDir")){ |
if (!strcmp(argv[i], "-outDir")){ |
560 |
if (++i >= argc){ |
if (++i >= argc){ |
561 |
printf( "-outDir needs arguments. \n"); |
printf( "-outDir needs arguments. \n"); |
566 |
outDir = argv[i]; |
outDir = argv[i]; |
567 |
continue; |
continue; |
568 |
} |
} |
569 |
} |
} |
|
|
|
570 |
if (!strcmp(argv[i], "-format")){ |
if (!strcmp(argv[i], "-format")){ |
571 |
if (++i >= argc){ |
if (++i >= argc){ |
572 |
printf( "-format needs arguments. \n"); |
printf( "-format needs arguments. \n"); |
578 |
continue; |
continue; |
579 |
} |
} |
580 |
} |
} |
|
|
|
|
|
|
581 |
} |
} |
|
|
|
582 |
HeaderScan(argv[1], outDir, format); |
HeaderScan(argv[1], outDir, format); |
|
|
|
583 |
} |
} |
584 |
|
|