54 |
* Fixed bugs: for a large namber of events is not possible to have vectors, so I have subsituted graphs with 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. |
* 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 |
|
|
70 |
#include "TMultiGraph.h" |
#include "TMultiGraph.h" |
71 |
#include <sstream> |
#include <sstream> |
72 |
#include <iostream> |
#include <iostream> |
73 |
|
#include <stdio.h> |
74 |
|
#include <string.h> |
75 |
#include "TString.h" |
#include "TString.h" |
76 |
#include "TStyle.h" |
#include "TStyle.h" |
77 |
#include "TFile.h" |
#include "TFile.h" |
84 |
#include "TGaxis.h" |
#include "TGaxis.h" |
85 |
#include "EventHeader.h" |
#include "EventHeader.h" |
86 |
#include "PscuHeader.h" |
#include "PscuHeader.h" |
87 |
|
#include "RunHeaderEvent.h" |
88 |
|
#include "TPaveText.h" |
89 |
|
|
90 |
using namespace std; |
using namespace std; |
91 |
|
|
92 |
void HeaderScan(TString base, TString outDir, TString format) |
void HeaderScan(TString base, TString outDir, TString format){ |
|
{ |
|
93 |
|
|
94 |
//------------------- Variables initilization -------------------------// |
//------------------- Variables initilization -------------------------// |
95 |
Long64_t nevents=0; |
Long64_t nevents=0, runnevents; |
96 |
ULong_t lastime, firstime,obt;// offset, lastoffset, firstoffset; |
ULong_t lastime, firstime, primotempo, ultimotempo, primoffset=500000000, ultimoffset; |
97 |
double obmin=0.; |
double obmin=0.; |
98 |
double obmax=0.; |
double obmax=0.; |
99 |
stringstream oss, oss1, oss2, oss3, noentries; |
stringstream oss, oss1, oss2, oss3, noentries, stringa; |
100 |
//------- load root file -------------- |
|
101 |
|
//-------------- Load root file, tree and branch -------------------// |
102 |
TFile *file = new TFile(base.Data()); |
TFile *file = new TFile(base.Data()); |
103 |
if (!file){ |
if (!file){ |
104 |
printf("No such file in the directory has been found"); |
printf("No such file in the directory has been found"); |
105 |
return; |
return; |
106 |
} |
} |
107 |
|
|
108 |
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
109 |
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
110 |
|
|
111 |
pamela::EventHeader *eh = 0; |
pamela::EventHeader *eh = new pamela::EventHeader; |
112 |
pamela::PscuHeader *ph = 0; |
pamela::PscuHeader *ph = new pamela::PscuHeader; |
113 |
|
|
114 |
PhysicsTr->SetBranchAddress("Header", &eh); |
PhysicsTr->SetBranchAddress("Header", &eh); |
115 |
|
nevents = PhysicsTr->GetEntries(); |
116 |
|
const Int_t size = nevents; |
117 |
|
|
118 |
nevents = headBr->GetEntries(); |
TTree *RunHeadTr = (TTree*)file->Get("RunHeader"); ///run header tree |
119 |
|
pamela::EventHeader *eH= new pamela::EventHeader; |
120 |
|
pamela::RunHeaderEvent *reh=new pamela::RunHeaderEvent; |
121 |
|
|
122 |
|
RunHeadTr->SetBranchAddress("Header",&eH); |
123 |
|
RunHeadTr->SetBranchAddress("RunHeader",&reh); |
124 |
|
runnevents = RunHeadTr->GetEntries(); |
125 |
|
|
126 |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
127 |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
130 |
if (nevents<=0) { |
if (nevents<=0) { |
131 |
printf("nevents = %i \n", nevents); |
printf("nevents = %i \n", nevents); |
132 |
printf(" \n"); |
printf(" \n"); |
|
|
|
133 |
TCanvas *canv = new TCanvas("No entries", "No entries ", 400, 200); |
TCanvas *canv = new TCanvas("No entries", "No entries ", 400, 200); |
134 |
canv->SetFillColor(10); |
canv->SetFillColor(10); |
135 |
canv->cd(); |
canv->cd(); |
|
|
|
136 |
TLatex *l = new TLatex(); |
TLatex *l = new TLatex(); |
137 |
l->SetTextAlign(12); |
l->SetTextAlign(12); |
138 |
l->SetTextSize(0.15); |
l->SetTextSize(0.15); |
143 |
noentries.str(""); |
noentries.str(""); |
144 |
noentries<< "No Physics entries for this files"; |
noentries<< "No Physics entries for this files"; |
145 |
l->DrawLatex(0.05, 0.5, noentries.str().c_str()); |
l->DrawLatex(0.05, 0.5, noentries.str().c_str()); |
|
|
|
146 |
if (outDir == "./") { |
if (outDir == "./") { |
147 |
oss.str(""); |
oss.str(""); |
148 |
oss << filename.Data() << "_HeaderScan_QL." << format.Data(); |
oss << filename.Data() << "_HeaderScan_QL." << format.Data(); |
149 |
} else { |
} else { |
150 |
oss.str(""); |
oss.str(""); |
151 |
oss << outDir.Data() << filename.Data() << "_HeaderScan_QL." << format.Data(); |
oss << outDir.Data() << filename.Data() << "_HeaderScan_QL." << format.Data(); |
152 |
} |
} |
|
|
|
153 |
canv->Update(); |
canv->Update(); |
154 |
canv->SaveAs(oss.str().c_str()); |
canv->SaveAs(oss.str().c_str()); |
|
|
|
155 |
return; |
return; |
156 |
} |
} |
|
|
|
157 |
//-------------- to know the max and min OBT ----------------------------// |
//-------------- to know the max and min OBT ----------------------------// |
|
for (Int_t i = 0; i < nevents; i++){ |
|
|
headBr->GetEntry(i); |
|
|
ph = eh->GetPscuHeader(); |
|
|
obt = ph->GetOrbitalTime(); |
|
|
//if(obt <= firstime) firstime=obt; |
|
|
if(obt >= lastime) lastime=obt; |
|
|
} |
|
|
|
|
|
//------------------------ First histogram -----------------------------------// |
|
158 |
headBr->GetEntry(0); |
headBr->GetEntry(0); |
159 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
160 |
firstime = ph->GetOrbitalTime(); |
firstime = ph->GetOrbitalTime(); |
161 |
obmin=firstime; |
headBr->GetEntry(nevents); |
162 |
obmax=lastime; |
ph = eh->GetPscuHeader(); |
163 |
|
lastime = ph->GetOrbitalTime(); |
164 |
|
int i =0; |
165 |
|
while(i < nevents){ |
166 |
|
headBr->GetEntry(i); |
167 |
|
ph = eh->GetPscuHeader(); |
168 |
|
if((ph->GetOrbitalTime()) <= firstime) firstime=ph->GetOrbitalTime(); |
169 |
|
if((ph->GetOrbitalTime()) >= lastime) lastime=ph->GetOrbitalTime(); |
170 |
|
i++; |
171 |
|
} |
172 |
|
|
173 |
oss1.str(""); |
//------------------------ First histogram -----------------------------------// |
174 |
oss1 <<"File name= "<< filename.Data() <<". Start time= " << obmin << ", end time= "<< obmax <<" ms"<<". Physics Packet per minute"; |
obmin=firstime; |
175 |
|
obmax=lastime; |
176 |
Int_t nbin = (lastime-firstime)/60000; |
Int_t nbin = (lastime-firstime)/60000; |
177 |
TH1F *h1 = new TH1F ("histo1", oss1.str().c_str(), nbin, obmin, obmax); |
TH1F *h1 = new TH1F ("histo1", "" , nbin, obmin, obmax); |
|
|
|
|
//------------- Graph PscuCounter vs FileOffset --------------------------------- |
|
|
const Int_t size = 10000; |
|
|
Int_t ev=0; |
|
|
Double_t PscuCounter[size], FileOffset[size], tempo[size], PcktLenght[size]; |
|
|
Int_t m=0; |
|
|
Int_t pag= (nevents/10000)+1; |
|
178 |
|
|
179 |
TMultiGraph *mg1 = new TMultiGraph(); |
//------------------- fill vectors and histogram -----------------------------// |
180 |
oss1.str(""); |
Double_t *PscuCounter = new Double_t[size]; |
181 |
oss1 << filename.Data() <<": PscuCounter vs FileOffset."; |
Double_t *PacketLenght = new Double_t[size]; |
182 |
mg1->SetTitle(oss1.str().c_str()); |
Double_t *OBTime = new Double_t[size]; |
183 |
|
Double_t *Eventsperminute= new Double_t[nbin]; |
184 |
|
Double_t *Minute= new Double_t[nbin]; |
185 |
|
Int_t max=0; |
186 |
|
for (Int_t k = 0; k < nevents; k++){ |
187 |
|
headBr->GetEntry(k); |
188 |
|
ph = eh->GetPscuHeader(); |
189 |
|
h1->Fill(ph->GetOrbitalTime()); |
190 |
|
PscuCounter[k]= ph->GetCounter(); |
191 |
|
PacketLenght[k]=ph->GetPacketLenght(); |
192 |
|
OBTime[k]=ph->GetOrbitalTime(); |
193 |
|
} |
194 |
|
int l=0; |
195 |
|
while(l<nbin){ |
196 |
|
Eventsperminute[l]=h1->GetBinContent(l); |
197 |
|
Minute[l]=firstime+l*60000; |
198 |
|
if(h1->GetBinContent(l) >= max)max =(Int_t)h1->GetBinContent(l); |
199 |
|
l++; |
200 |
|
} |
201 |
|
|
202 |
|
//----------- Graph and MultiGraph -----------------------------------------------// |
203 |
|
TMultiGraph *rate = new TMultiGraph(); |
204 |
|
TMultiGraph *packetLength = new TMultiGraph(); |
205 |
|
TMultiGraph *packeCounter = new TMultiGraph(); |
206 |
|
|
|
TMultiGraph *mg2 = new TMultiGraph(); |
|
207 |
oss1.str(""); |
oss1.str(""); |
208 |
oss1 << filename.Data() <<": OBT vs FileOffset."; |
oss1 << "Physics Packet per minute. Start time = " << obmin << ", End time = "<< obmax <<" ms"; |
209 |
mg2->SetTitle(oss1.str().c_str()); |
TGraph *rate1= new TGraph(nbin, (const Double_t*)Minute, (const Double_t*)Eventsperminute); |
210 |
|
rate1->SetMarkerColor(kBlack); |
211 |
|
rate1->SetMarkerSize(.1); |
212 |
|
rate1->SetMarkerStyle(21); |
213 |
|
rate->Add(rate1); |
214 |
|
|
215 |
TMultiGraph *mg3 = new TMultiGraph(); |
TGraph *packetLength1= new TGraph(nevents, (const Double_t*)OBTime, (const Double_t*)PacketLenght); |
216 |
oss2.str(""); |
oss2.str(""); |
217 |
oss2 << filename.Data() <<": Lenght of Physic packets"; |
oss2 <<"Lenght of Physic packets"; |
218 |
mg3->SetTitle(oss2.str().c_str()); |
packetLength1->SetMarkerColor(2); |
219 |
|
packetLength1->SetMarkerSize(.3); |
220 |
|
packetLength1->SetMarkerStyle(21); |
221 |
|
packetLength->Add(packetLength1); |
222 |
|
|
223 |
TMultiGraph *mg4 = new TMultiGraph(); |
TGraph *packeCounter1= new TGraph(nevents, (const Double_t*)OBTime, (const Double_t*)PscuCounter); |
224 |
oss3.str(""); |
oss3.str(""); |
225 |
oss3 << filename.Data() <<": Physics Counter"; |
oss3 <<"Physics Counter vs. OBT"; |
226 |
mg4->SetTitle(oss3.str().c_str()); |
packeCounter1->SetMarkerColor(4); |
227 |
|
packeCounter1->SetMarkerSize(.2); |
228 |
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1024); |
packeCounter1->SetMarkerStyle(21); |
229 |
finalCanv1->Divide(1,3); |
packeCounter->Add(packeCounter1); |
230 |
finalCanv1->SetFillColor(10); |
|
231 |
|
//------------ Create and Draw Canvas ---------------------// |
232 |
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
TCanvas *finalCanv = new TCanvas("Header", base, 1200, 1600); |
233 |
finalCanv2->Divide(1,2); |
finalCanv->Divide(1,6); |
234 |
finalCanv2->SetFillColor(10); |
finalCanv->SetFillColor(10); |
235 |
|
|
236 |
/////ciclo sulle pagine//////////////////// |
TPad *all2= new TPad ("","", 0, 0, 1, 1); |
237 |
for (Int_t interval=0; interval<pag; interval++){ |
all2->SetFillColor(10); |
238 |
|
TPad *all3= new TPad ("","", 0, 0, 1, 1); |
239 |
for (Int_t l = 0; l < size; l++){ //ciclo su un sottogruppo |
all3->SetFillColor(10); |
240 |
headBr->GetEntry(ev+l); |
TPad *all4= new TPad ("","", 0, 0, 1, 1); |
241 |
ph = eh->GetPscuHeader(); |
all4->SetFillColor(10); |
242 |
PscuCounter[l]= ph->GetCounter(); // = PcktCounter[l] |
TPad *all= new TPad ("","", 0, 0, 1, 1); |
243 |
FileOffset[l]=ph->GetFileOffset(); |
all->SetFillColor(10); |
244 |
tempo[l]=ph->GetOrbitalTime(); |
TPad *all1= new TPad ("","", 0, 0, 1, 1); |
245 |
PcktLenght[l]=ph->GetPacketLenght(); |
all1->SetFillColor(10); |
246 |
h1->Fill(ph->GetOrbitalTime()); |
|
247 |
m=l; |
TLine li; |
248 |
} |
li.SetLineStyle(4); |
249 |
|
li.SetLineWidth(2); |
250 |
TGraph *graph1= new TGraph(m, tempo, PcktLenght); |
|
251 |
graph1->SetMarkerColor(2); |
//----------- First PAD -------------------------------// |
252 |
graph1->SetMarkerSize(.5); |
finalCanv->cd(1); |
253 |
graph1->SetMarkerStyle(21); |
all2->Draw(); |
254 |
mg3->Add(graph1); |
all2->cd(); |
255 |
|
rate->Draw("ALP"); |
256 |
TGraph *graph2= new TGraph(m, tempo, PscuCounter); |
rate->GetXaxis()->SetTitle("OBT (ms)"); |
257 |
graph2->SetMarkerColor(4); |
rate->GetXaxis()->SetTitleSize(0.05); |
258 |
graph2->SetMarkerSize(.5); |
rate->GetXaxis()->CenterTitle(); |
259 |
graph2->SetMarkerStyle(21); |
rate->GetXaxis()->SetLabelSize(0.05); |
260 |
mg4->Add(graph2); |
rate->GetYaxis()->SetTitle("Number of events "); |
261 |
|
rate->GetYaxis()->CenterTitle(); |
262 |
TGraph *graph3= new TGraph(m, FileOffset, PscuCounter); |
rate->GetYaxis()->SetLabelSize(0.05); |
263 |
graph3->SetMarkerColor(3); |
rate->GetYaxis()->SetTitleSize(0.06); |
264 |
graph3->SetMarkerSize(.5); |
rate->GetYaxis()->SetTitleOffset(0.6); |
265 |
graph3->SetMarkerStyle(21); |
for (Int_t l = 0; l < runnevents; l++){ |
266 |
mg1->Add(graph3); |
RunHeadTr->GetEntry(l); |
267 |
|
ph = eH->GetPscuHeader(); |
268 |
TGraph *graph4= new TGraph(m, FileOffset, tempo); |
int ws= reh->RM_ACQ_SETTING_MODE; |
269 |
graph4->SetMarkerColor(kBlue); |
int id = ph->GetPacketId1(); |
270 |
graph4->SetMarkerSize(.5); |
Int_t obt = ph->GetOrbitalTime(); |
271 |
graph4->SetMarkerStyle(21); |
if (ws==1){ |
272 |
mg2->Add(graph4); |
li.SetLineColor(3); |
273 |
|
li.DrawLine(obt,0,obt,max); |
274 |
ev=ev+10000; |
} |
275 |
|
else if (ws==2){ |
276 |
|
li.SetLineColor(4); |
277 |
|
li.DrawLine(obt,0,obt,max); |
278 |
|
} |
279 |
} |
} |
|
//------------ First Canvas ---------------------// |
|
|
|
|
|
finalCanv1->cd(1); |
|
|
h1->SetStats(kFALSE); |
|
|
h1->GetXaxis()->SetTitle("OBT (ms)"); |
|
|
h1->GetXaxis()->CenterTitle(); |
|
|
h1->GetXaxis()->SetLabelSize(0.04); |
|
|
h1->GetYaxis()->SetTitle("Number of events "); |
|
|
h1->GetYaxis()->CenterTitle(); |
|
|
h1->GetYaxis()->SetTitleSize(0.06); |
|
|
h1->GetYaxis()->SetTitleOffset(0.8); |
|
|
h1->Draw(); |
|
280 |
|
|
281 |
finalCanv1->cd(2); |
RunHeadTr->GetEntry(0); |
282 |
mg3->Draw("AP"); |
ph = eH->GetPscuHeader(); |
283 |
mg3->GetXaxis()->SetTitle("OBT (ms)"); |
ULong_t TimeSync = reh->LAST_TIME_SYNC_INFO; |
284 |
mg3->GetXaxis()->CenterTitle(); |
ULong_t ObtSync = reh->OBT_TIME_SYNC; |
285 |
mg3->GetXaxis()->SetLabelSize(0.04); |
//cout<<"TimeSync "<<reh->LAST_TIME_SYNC_INFO<<"\n"; |
286 |
mg3->GetYaxis()->SetTitle("Lenght (byte)"); |
//cout<<"ObtSync "<<reh->OBT_TIME_SYNC<<"\n"; |
287 |
mg3->GetYaxis()->CenterTitle(); |
|
288 |
mg3->GetYaxis()->SetLabelSize(0.04); |
finalCanv->cd(1); |
289 |
mg3->GetYaxis()->SetTitleSize(0.06); |
stringstream ws1, ws2; |
290 |
mg3->GetYaxis()->SetTitleOffset(0.8); |
ws1.str(""); |
291 |
|
ws2.str(""); |
292 |
|
ws1<<"ACQ_SETTING_MODE = 1"; |
293 |
finalCanv1->cd(3); |
ws2<<"ACQ_SETTING_MODE = 2"; |
294 |
mg4->Draw("AP"); |
TPaveText *pt=0; |
295 |
mg4->GetXaxis()->SetTitle("OBT (ms)"); |
pt = new TPaveText (.60,.92,.76,.98); |
296 |
mg4->GetXaxis()->SetTitleSize(0.05); |
pt->AddText(ws1.str().c_str()); |
297 |
mg4->GetXaxis()->CenterTitle(); |
pt->SetTextColor(3); |
298 |
mg4->GetXaxis()->SetLabelSize(0.04); |
pt->SetFillColor(10); |
299 |
mg4->GetYaxis()->SetTitle("Counter"); |
pt->SetBorderSize(0); |
300 |
mg4->GetYaxis()->SetTitleSize(0.05); |
pt->Draw(); |
301 |
mg4->GetYaxis()->CenterTitle(); |
TPaveText *pt1=0; |
302 |
mg4->GetYaxis()->SetLabelSize(0.04); |
pt1 = new TPaveText (.76,.92,.92,.98); |
303 |
mg4->GetYaxis()->SetTitleSize(0.06); |
pt1->AddText(ws2.str().c_str()); |
304 |
mg4->GetYaxis()->SetTitleOffset(0.8); |
pt1->SetTextColor(4); |
305 |
|
pt1->SetFillColor(10); |
306 |
|
pt1->SetBorderSize(0); |
307 |
|
pt1->Draw(); |
308 |
|
pt1 = new TPaveText (.05,.91,.6,1); |
309 |
|
pt1->AddText(oss1.str().c_str()); |
310 |
|
pt1->SetTextColor(1); |
311 |
|
pt1->SetFillColor(10); |
312 |
|
pt1->SetBorderSize(0); |
313 |
|
pt1->Draw(); |
314 |
|
|
315 |
|
//----------- Second PAD -------------------------------// |
316 |
|
finalCanv->cd(2); |
317 |
|
all3->Draw(); |
318 |
|
all3->cd(); |
319 |
|
packetLength->Draw("AP"); |
320 |
|
packetLength->GetXaxis()->SetTitle("OBT (ms)"); |
321 |
|
packetLength->GetXaxis()->SetTitleSize(0.05); |
322 |
|
packetLength->GetXaxis()->CenterTitle(); |
323 |
|
packetLength->GetXaxis()->SetLabelSize(0.05); |
324 |
|
packetLength->GetYaxis()->SetTitle("Lenght (byte)"); |
325 |
|
packetLength->GetYaxis()->CenterTitle(); |
326 |
|
packetLength->GetYaxis()->SetLabelSize(0.05); |
327 |
|
packetLength->GetYaxis()->SetTitleSize(0.06); |
328 |
|
packetLength->GetYaxis()->SetTitleOffset(0.6); |
329 |
|
|
330 |
|
|
331 |
|
finalCanv->cd(2); |
332 |
|
pt = new TPaveText (.6,.91,.90,1); |
333 |
|
pt->AddText(oss2.str().c_str()); |
334 |
|
pt->SetTextColor(2); |
335 |
|
pt->SetFillColor(10); |
336 |
|
pt->SetBorderSize(0); |
337 |
|
pt->Draw(); |
338 |
|
|
339 |
|
//----------- Third PAD -------------------------------// |
340 |
|
finalCanv->cd(3); |
341 |
|
all4->Draw(); |
342 |
|
all4->cd(); |
343 |
|
packeCounter->Draw("AP"); |
344 |
|
packeCounter->GetXaxis()->SetTitle("OBT (ms)"); |
345 |
|
packeCounter->GetXaxis()->SetTitleSize(0.05); |
346 |
|
packeCounter->GetXaxis()->CenterTitle(); |
347 |
|
packeCounter->GetXaxis()->SetLabelSize(0.05); |
348 |
|
packeCounter->GetYaxis()->SetTitle("Counter"); |
349 |
|
packeCounter->GetYaxis()->SetTitleSize(0.05); |
350 |
|
packeCounter->GetYaxis()->CenterTitle(); |
351 |
|
packeCounter->GetYaxis()->SetLabelSize(0.05); |
352 |
|
packeCounter->GetYaxis()->SetTitleSize(0.06); |
353 |
|
packeCounter->GetYaxis()->SetTitleOffset(0.6); |
354 |
|
|
355 |
|
|
356 |
|
finalCanv->cd(3); |
357 |
|
TPaveText *pt2=0; |
358 |
|
pt2 = new TPaveText (.6,.91,.90,1); |
359 |
|
pt2->AddText(oss3.str().c_str()); |
360 |
|
pt2->SetTextColor(4); |
361 |
|
pt2->SetFillColor(10); |
362 |
|
pt2->SetBorderSize(0); |
363 |
|
pt2->Draw(); |
364 |
|
|
365 |
|
/**********************************************************************************************/ |
366 |
|
|
367 |
finalCanv1->Update(); |
TMultiGraph *mg1 = new TMultiGraph(); |
368 |
|
TMultiGraph *mg2 = new TMultiGraph(); |
369 |
oss.str(""); |
//---------------------- fill vectors and histogram --------------------------------------------------// |
370 |
oss << outDir.Data() << filename.Data(); |
TList *list = new TList; |
371 |
oss << "_HeaderScan_1." << format.Data(); |
Int_t numkey; |
372 |
finalCanv1->SaveAs(oss.str().c_str()); |
TObject *key = new TObject; |
373 |
|
const char *name; |
374 |
|
char *SoftInfo="SoftInfo"; |
375 |
|
TTree* tr = new TTree; |
376 |
|
Long64_t nevntskey=0; |
377 |
|
list = file->GetListOfKeys(); |
378 |
|
numkey = file->GetNkeys(); |
379 |
|
ULong_t salto; |
380 |
|
for (Int_t m=0; m<numkey; m++){ |
381 |
|
if(m==numkey)continue; |
382 |
|
key = list->At(m); |
383 |
|
name=(char *)(key->GetName()); |
384 |
|
if(strcmp(name,SoftInfo)==0)continue; |
385 |
|
tr = (TTree*)file->Get(name); |
386 |
|
if (tr->IsZombie()) continue; |
387 |
|
|
388 |
|
tr->SetBranchAddress("Header", &eh); |
389 |
|
TBranch *Br = tr->GetBranch("Header"); |
390 |
|
nevntskey = tr->GetEntries(); |
391 |
|
if(nevntskey !=0){ |
392 |
|
Int_t size1=nevntskey; |
393 |
|
Double_t *PscuCounter1 = new Double_t[size1]; |
394 |
|
Double_t *FileOffset1 = new Double_t[size1]; |
395 |
|
Double_t *tempo1 = new Double_t[size1]; |
396 |
|
|
397 |
|
int n=0; |
398 |
|
while(n<nevntskey){ |
399 |
|
Br->GetEntry(n); |
400 |
|
ph = eh->GetPscuHeader(); |
401 |
|
PscuCounter1[n]= ph->GetCounter(); |
402 |
|
FileOffset1[n]=ph->GetFileOffset(); |
403 |
|
tempo1[n]=ph->GetOrbitalTime(); |
404 |
|
if((m==0) && (n==0)){ |
405 |
|
primotempo=ph->GetOrbitalTime(); |
406 |
|
salto=ph->GetOrbitalTime(); |
407 |
|
} |
408 |
|
if(salto > ph->GetOrbitalTime())salto=ph->GetOrbitalTime(); |
409 |
|
if(ph->GetFileOffset()<= primoffset){ |
410 |
|
primoffset=ph->GetFileOffset(); |
411 |
|
primotempo=ph->GetOrbitalTime(); |
412 |
|
} |
413 |
|
if(ph->GetFileOffset()>=ultimoffset){ |
414 |
|
ultimotempo=ph->GetOrbitalTime(); |
415 |
|
ultimoffset=ph->GetFileOffset(); |
416 |
|
} |
417 |
|
n++; |
418 |
|
} |
419 |
|
|
420 |
|
TGraph *graph3= new TGraph(nevntskey, (const Double_t*)FileOffset1, (const Double_t*)PscuCounter1); |
421 |
|
graph3->SetMarkerColor(3); |
422 |
|
graph3->SetMarkerSize(.2); |
423 |
|
graph3->SetMarkerStyle(21); |
424 |
|
mg1->Add(graph3); |
425 |
|
|
426 |
|
TGraph *graph4= new TGraph(nevntskey, (const Double_t*)FileOffset1, (const Double_t*)tempo1); |
427 |
|
graph4->SetMarkerColor(kBlue); |
428 |
|
graph4->SetMarkerSize(.2); |
429 |
|
graph4->SetMarkerStyle(21); |
430 |
|
mg2->Add(graph4); |
431 |
|
} |
432 |
|
} |
433 |
|
|
434 |
|
TLatex *lat = new TLatex(); |
435 |
|
lat->SetTextAlign(12); |
436 |
|
lat->SetTextSize(0.15); |
437 |
|
lat->SetTextColor(kBlue); |
438 |
|
|
439 |
|
//------------ Fourth PAD ---------------------// |
440 |
|
finalCanv->cd(4); |
441 |
|
all1->Draw(); |
442 |
|
all1->cd(); |
443 |
|
|
444 |
//------------ Second Canvas ---------------------// |
oss1.str(""); |
445 |
finalCanv2->cd(1); |
oss1 <<"PscuCounter vs FileOffset."; |
446 |
mg1->Draw("AP"); |
mg1->Draw("AP"); |
447 |
mg1->GetXaxis()->SetTitle("File Offset"); |
mg1->GetXaxis()->SetTitle("File Offset"); |
448 |
mg1->GetXaxis()->CenterTitle(); |
mg1->GetXaxis()->CenterTitle(); |
449 |
|
mg1->GetXaxis()->SetTitleOffset(0.8); |
450 |
mg1->GetXaxis()->SetTitleSize(0.05); |
mg1->GetXaxis()->SetTitleSize(0.05); |
451 |
mg1->GetXaxis()->SetLabelSize(0.04); |
mg1->GetXaxis()->SetLabelSize(0.05); |
452 |
mg1->GetYaxis()->SetTitle("Counter"); |
mg1->GetYaxis()->SetTitle("Counter"); |
453 |
mg1->GetYaxis()->CenterTitle(); |
mg1->GetYaxis()->CenterTitle(); |
454 |
mg1->GetYaxis()->SetTitleSize(0.05); |
mg1->GetYaxis()->SetTitleSize(0.06); |
455 |
mg1->GetYaxis()->SetLabelSize(0.04); |
mg1->GetYaxis()->SetLabelSize(0.06); |
456 |
|
mg1->GetYaxis()->SetTitleOffset(0.6); |
457 |
finalCanv2->cd(2); |
finalCanv->cd(4); |
458 |
|
TPaveText *pt3=0; |
459 |
|
pt3 = new TPaveText (.60,.91,.90,1); |
460 |
|
pt3->AddText(oss1.str().c_str()); |
461 |
|
pt3->SetTextColor(3); |
462 |
|
pt3->SetFillColor(10); |
463 |
|
pt3->SetBorderSize(0); |
464 |
|
pt3->Draw(); |
465 |
|
|
466 |
|
//------------ Fifth PAD ---------------------// |
467 |
|
finalCanv->cd(5); |
468 |
|
all->Draw(); |
469 |
|
all->cd(); |
470 |
|
oss3.str(""); |
471 |
|
oss3 << "OBT vs FileOffset"; |
472 |
mg2->Draw("AP"); |
mg2->Draw("AP"); |
473 |
mg2->GetXaxis()->SetTitle("File Offset"); |
mg2->GetXaxis()->SetTitle("File Offset"); |
474 |
mg2->GetXaxis()->CenterTitle(); |
mg2->GetXaxis()->CenterTitle(); |
475 |
mg2->GetXaxis()->SetTitleSize(0.05); |
mg2->GetXaxis()->SetTitleSize(0.05); |
476 |
mg2->GetXaxis()->SetLabelSize(0.04); |
mg2->GetXaxis()->SetLabelSize(0.05); |
477 |
mg2->GetYaxis()->SetTitle("OBT"); |
mg2->GetYaxis()->SetTitle("OBT"); |
478 |
mg2->GetYaxis()->CenterTitle(); |
mg2->GetYaxis()->CenterTitle(); |
479 |
mg2->GetYaxis()->SetTitleSize(0.05); |
mg2->GetYaxis()->SetTitleSize(0.06); |
480 |
mg2->GetYaxis()->SetLabelSize(0.04); |
mg2->GetYaxis()->SetLabelSize(0.05); |
481 |
|
mg2->GetYaxis()->SetTitleOffset(0.6); |
482 |
|
|
483 |
|
finalCanv->cd(5); |
484 |
|
TPaveText *pt4=0; |
485 |
|
pt4 = new TPaveText (.70,.91,.90,1); |
486 |
|
pt4->AddText(oss3.str().c_str()); |
487 |
|
pt4->SetTextColor(kBlue); |
488 |
|
pt4->SetFillColor(10); |
489 |
|
pt4->SetBorderSize(0); |
490 |
|
pt4->Draw(); |
491 |
|
|
492 |
|
finalCanv->cd(6); |
493 |
|
ULong_t primotempoABS=TimeSync+((primotempo/1000)-ObtSync); |
494 |
|
ULong_t obmaxABS=TimeSync+((lastime/1000)-ObtSync); |
495 |
|
ULong_t saltoABS=TimeSync+((salto/1000)-ObtSync); |
496 |
|
ULong_t ultimotempoABS=TimeSync+((ultimotempo/1000)-ObtSync); |
497 |
|
|
498 |
|
TPaveText *pt5=0; |
499 |
|
pt5 = new TPaveText (0,0,1,1); |
500 |
|
stringa.str(""); |
501 |
|
stringa << " Filename: "<<filename.Data()<<"\n"; |
502 |
|
TText *t1=pt5->AddText(0.25,0.95,stringa.str().c_str()); |
503 |
|
t1->SetTextSize(0.1); |
504 |
|
stringa.str(""); |
505 |
|
stringa << " OBT (ms) ABS TIME (s)"; |
506 |
|
TText *t2=pt5->AddText(0.32,0.75,stringa.str().c_str()); |
507 |
|
t2->SetTextSize(0.07); |
508 |
|
stringa.str(""); |
509 |
|
stringa << "New data start at: "<<primotempo<<" "<<primotempoABS; |
510 |
|
TText *t3=pt5->AddText(0.25,0.60,stringa.str().c_str()); |
511 |
|
t3->SetTextSize(0.08); |
512 |
|
stringa.str(""); |
513 |
|
stringa << "New data end at: "<<lastime<<" "<<obmaxABS; |
514 |
|
TText *t4=pt5->AddText(0.25,0.50,stringa.str().c_str()); |
515 |
|
t4->SetTextSize(0.08); |
516 |
|
if(primotempo!=salto || lastime!=ultimotempo){ |
517 |
|
stringa.str(""); |
518 |
|
stringa << "Old data start at: "<<salto<<" "<<saltoABS; |
519 |
|
TText *t5=pt5->AddText(0.65,0.60,stringa.str().c_str()); |
520 |
|
t5->SetTextSize(0.08); |
521 |
|
stringa.str(""); |
522 |
|
stringa << "Old data end at: "<<ultimotempo<<" "<<ultimotempoABS; |
523 |
|
TText *t6=pt5->AddText(0.65,0.50,stringa.str().c_str()); |
524 |
|
t6->SetTextSize(0.08); |
525 |
|
stringa.str(""); |
526 |
|
stringa << " OBT (ms) ABS TIME (s)"; |
527 |
|
TText *t2=pt5->AddText(0.72,0.75,stringa.str().c_str()); |
528 |
|
t2->SetTextSize(0.07); |
529 |
|
} |
530 |
|
pt5->SetTextColor(kBlack); |
531 |
|
pt5->SetFillColor(10); |
532 |
|
pt5->SetBorderSize(0); |
533 |
|
pt5->Draw(); |
534 |
|
|
535 |
finalCanv2->Update(); |
finalCanv->Update(); |
536 |
|
|
537 |
oss1.str(""); |
oss1.str(""); |
538 |
oss1 << outDir.Data() << filename.Data(); |
oss1 << outDir.Data() << filename.Data(); |
539 |
oss1 << "_HeaderScan_2"<<"." << format.Data(); |
oss1 << "_HeaderScan"<<"." << format.Data(); |
540 |
|
|
541 |
|
finalCanv->SaveAs(oss1.str().c_str()); |
542 |
|
|
|
finalCanv2->SaveAs(oss1.str().c_str()); |
|
|
|
|
543 |
file->Close(); |
file->Close(); |
544 |
|
|
545 |
} |
} |
587 |
} |
} |
588 |
HeaderScan(argv[1], outDir, format); |
HeaderScan(argv[1], outDir, format); |
589 |
} |
} |
590 |
|
|