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