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 |
* 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, primotempo, ultimotempo, primoffset=500000000, ultimoffset=100000000; |
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, stringa; |
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 << filename.Data() <<": Physics Packet per minute. Start time = " << obmin << ", End time = "<< obmax <<" ms"; |
|
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); |
183 |
|
|
184 |
|
//------------------- fill vectors and histogram -----------------------------// |
185 |
|
Double_t *PscuCounter = new Double_t[size]; |
186 |
|
Double_t *PacketLenght = new Double_t[size]; |
187 |
|
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 |
|
Int_t max=0; |
192 |
|
for (Int_t k = 0; k < nevents; k++){ |
193 |
|
headBr->GetEntry(k); |
194 |
|
ph = eh->GetPscuHeader(); |
195 |
|
h1->Fill(ph->GetOrbitalTime()); |
196 |
|
PscuCounter[k]= ph->GetCounter(); |
197 |
|
PacketLenght[k]=ph->GetPacketLenght(); |
198 |
|
utile= ph->GetOrbitalTime(); |
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 =(Int_t)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 |
|
|
214 |
|
oss1.str(""); |
215 |
|
oss1 << "Physics Packet per minute. Start time = " << obmin << ", End time = "<< obmax <<" ms"; |
216 |
|
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 |
|
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 |
Int_t nbin2 =(lastime-firstime); |
packetLength1->SetMarkerColor(2); |
226 |
TH1F *packetLength = new TH1F ("packetLength", oss2.str().c_str(), nbin2, obmin, obmax); |
packetLength1->SetMarkerSize(.3); |
227 |
|
packetLength1->SetMarkerStyle(21); |
228 |
|
packetLength->Add(packetLength1); |
229 |
|
|
230 |
|
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 |
TH1F *packeCounter = new TH1F ("packeCounter", oss3.str().c_str(), nbin2, obmin, obmax); |
packeCounter1->SetMarkerColor(4); |
234 |
//---------------------------------------------------- |
packeCounter1->SetMarkerSize(.2); |
235 |
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1150); |
packeCounter1->SetMarkerStyle(21); |
236 |
finalCanv1->Divide(1,3); |
packeCounter->Add(packeCounter1); |
237 |
finalCanv1->SetFillColor(10); |
|
238 |
|
//------------ Create and Draw Canvas ---------------------// |
239 |
|
TCanvas *finalCanv = new TCanvas("Header", base, 1200, 1600); |
240 |
|
finalCanv->Divide(1,6); |
241 |
|
finalCanv->SetFillColor(10); |
242 |
|
|
243 |
TPad *all2= new TPad ("","", 0, 0, 1, 1); |
TPad *all2= new TPad ("","", 0, 0, 1, 1); |
244 |
all2->SetFillColor(10); |
all2->SetFillColor(10); |
245 |
TPad *all3= new TPad ("","", 0, 0, 1, 1); |
TPad *all3= new TPad ("","", 0, 0, 1, 1); |
246 |
all3->SetFillColor(10); |
all3->SetFillColor(10); |
247 |
TPad *all4= new TPad ("","", 0, 0, 1, 1); |
TPad *all4= new TPad ("","", 0, 0, 1, 1); |
248 |
all4->SetFillColor(10); |
all4->SetFillColor(10); |
|
//---------------------------------------------------- |
|
|
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1150); |
|
|
finalCanv2->Divide(1,2); |
|
|
finalCanv2->SetFillColor(10); |
|
|
|
|
|
TMultiGraph *mg1 = new TMultiGraph(); |
|
|
oss1.str(""); |
|
|
oss1 << filename.Data() <<": PscuCounter vs FileOffset."; |
|
|
mg1->SetTitle(oss1.str().c_str()); |
|
|
|
|
|
TMultiGraph *mg2 = new TMultiGraph(); |
|
|
|
|
249 |
TPad *all= new TPad ("","", 0, 0, 1, 1); |
TPad *all= new TPad ("","", 0, 0, 1, 1); |
250 |
all->SetFillColor(10); |
all->SetFillColor(10); |
251 |
TPad *all1= new TPad ("","", 0, 0, 1, 1); |
TPad *all1= new TPad ("","", 0, 0, 1, 1); |
252 |
all1->SetFillColor(10); |
all1->SetFillColor(10); |
|
TPad *pad = new TPad("pad","pad", .80,.50,.90,.80); |
|
|
pad->SetFillColor(10); |
|
|
//-------------------------------------------------------------------------- |
|
|
for (Int_t l = 0; l < nevents; l++){ |
|
|
headBr->GetEntry(l); |
|
|
ph = eh->GetPscuHeader(); |
|
|
h1->Fill(ph->GetOrbitalTime()); |
|
|
packetLength->Fill(ph->GetOrbitalTime(),ph->GetPacketLenght()); |
|
|
packeCounter->Fill(ph->GetOrbitalTime(),ph->GetCounter()); |
|
|
} |
|
253 |
|
|
254 |
//------------ First Canvas ---------------------// |
TLine li; |
255 |
|
li.SetLineStyle(4); |
256 |
|
li.SetLineWidth(2); |
257 |
|
|
258 |
finalCanv1->cd(1); |
//----------- First PAD -------------------------------// |
259 |
|
finalCanv->cd(1); |
260 |
all2->Draw(); |
all2->Draw(); |
261 |
all2->cd(); |
all2->cd(); |
262 |
h1->SetStats(kFALSE); |
rate->Draw("ALP"); |
263 |
h1->GetXaxis()->SetTitle("OBT (ms)"); |
rate->GetXaxis()->SetTitle("OBT (ms)"); |
264 |
h1->GetXaxis()->CenterTitle(); |
rate->GetXaxis()->SetTitleSize(0.05); |
265 |
h1->GetXaxis()->SetLabelSize(0.04); |
rate->GetXaxis()->CenterTitle(); |
266 |
h1->GetYaxis()->SetTitle("Number of events "); |
rate->GetXaxis()->SetLabelSize(0.05); |
267 |
h1->GetYaxis()->CenterTitle(); |
rate->GetYaxis()->SetTitle("Number of events "); |
268 |
h1->GetYaxis()->SetTitleSize(0.06); |
rate->GetYaxis()->CenterTitle(); |
269 |
h1->GetYaxis()->SetTitleOffset(0.8); |
rate->GetYaxis()->SetLabelSize(0.05); |
270 |
h1->Draw(); |
rate->GetYaxis()->SetTitleSize(0.06); |
271 |
|
rate->GetYaxis()->SetTitleOffset(0.6); |
272 |
|
for (Int_t l = 0; l < runnevents; l++){ |
273 |
|
RunHeadTr->GetEntry(l); |
274 |
|
ph = eH->GetPscuHeader(); |
275 |
|
int ws= reh->RM_ACQ_SETTING_MODE; |
276 |
|
int id = ph->GetPacketId1(); |
277 |
|
Int_t obt = ph->GetOrbitalTime(); |
278 |
|
if (ws==1){ |
279 |
|
li.SetLineColor(3); |
280 |
|
li.DrawLine(obt,0,obt,max); |
281 |
|
} |
282 |
|
else if (ws==2){ |
283 |
|
li.SetLineColor(4); |
284 |
|
li.DrawLine(obt,0,obt,max); |
285 |
|
} |
286 |
|
} |
287 |
|
|
288 |
|
RunHeadTr->GetEntry(0); |
289 |
|
ph = eH->GetPscuHeader(); |
290 |
|
ULong_t TimeSync = reh->LAST_TIME_SYNC_INFO; |
291 |
|
ULong_t ObtSync = reh->OBT_TIME_SYNC; |
292 |
|
//cout<<"TimeSync "<<reh->LAST_TIME_SYNC_INFO<<"\n"; |
293 |
|
//cout<<"ObtSync "<<reh->OBT_TIME_SYNC<<"\n"; |
294 |
|
|
295 |
|
finalCanv->cd(1); |
296 |
|
stringstream ws1, ws2; |
297 |
|
ws1.str(""); |
298 |
|
ws2.str(""); |
299 |
|
ws1<<"ACQ_SETTING_MODE = 1"; |
300 |
|
ws2<<"ACQ_SETTING_MODE = 2"; |
301 |
|
TPaveText *pt=0; |
302 |
|
pt = new TPaveText (.60,.92,.76,.98); |
303 |
|
pt->AddText(ws1.str().c_str()); |
304 |
|
pt->SetTextColor(3); |
305 |
|
pt->SetFillColor(10); |
306 |
|
pt->SetBorderSize(0); |
307 |
|
pt->Draw(); |
308 |
|
TPaveText *pt1=0; |
309 |
|
pt1 = new TPaveText (.76,.92,.92,.98); |
310 |
|
pt1->AddText(ws2.str().c_str()); |
311 |
|
pt1->SetTextColor(4); |
312 |
|
pt1->SetFillColor(10); |
313 |
|
pt1->SetBorderSize(0); |
314 |
|
pt1->Draw(); |
315 |
|
pt1 = new TPaveText (.05,.91,.6,1); |
316 |
|
pt1->AddText(oss1.str().c_str()); |
317 |
|
pt1->SetTextColor(1); |
318 |
|
pt1->SetFillColor(10); |
319 |
|
pt1->SetBorderSize(0); |
320 |
|
pt1->Draw(); |
321 |
|
|
322 |
finalCanv1->cd(2); |
//----------- Second PAD -------------------------------// |
323 |
|
finalCanv->cd(2); |
324 |
all3->Draw(); |
all3->Draw(); |
325 |
all3->cd(); |
all3->cd(); |
326 |
packetLength->SetStats(kFALSE); |
packetLength->Draw("AP"); |
|
packetLength->SetMarkerColor(2); |
|
|
packetLength->SetMarkerSize(.5); |
|
|
packetLength->SetMarkerStyle(21); |
|
327 |
packetLength->GetXaxis()->SetTitle("OBT (ms)"); |
packetLength->GetXaxis()->SetTitle("OBT (ms)"); |
328 |
|
packetLength->GetXaxis()->SetTitleSize(0.05); |
329 |
packetLength->GetXaxis()->CenterTitle(); |
packetLength->GetXaxis()->CenterTitle(); |
330 |
packetLength->GetXaxis()->SetLabelSize(0.04); |
packetLength->GetXaxis()->SetLabelSize(0.05); |
331 |
packetLength->GetYaxis()->SetTitle("Lenght (byte)"); |
packetLength->GetYaxis()->SetTitle("Lenght (byte)"); |
332 |
packetLength->GetYaxis()->CenterTitle(); |
packetLength->GetYaxis()->CenterTitle(); |
333 |
packetLength->GetYaxis()->SetLabelSize(0.04); |
packetLength->GetYaxis()->SetLabelSize(0.05); |
334 |
packetLength->GetYaxis()->SetTitleSize(0.06); |
packetLength->GetYaxis()->SetTitleSize(0.06); |
335 |
packetLength->GetYaxis()->SetTitleOffset(0.8); |
packetLength->GetYaxis()->SetTitleOffset(0.6); |
336 |
packetLength->Draw("9p"); |
|
337 |
|
|
338 |
|
finalCanv->cd(2); |
339 |
|
pt = new TPaveText (.6,.91,.90,1); |
340 |
|
pt->AddText(oss2.str().c_str()); |
341 |
|
pt->SetTextColor(2); |
342 |
|
pt->SetFillColor(10); |
343 |
|
pt->SetBorderSize(0); |
344 |
|
pt->Draw(); |
345 |
|
|
346 |
finalCanv1->cd(3); |
//----------- Third PAD -------------------------------// |
347 |
|
finalCanv->cd(3); |
348 |
all4->Draw(); |
all4->Draw(); |
349 |
all4->cd(); |
all4->cd(); |
350 |
packeCounter->SetStats(kFALSE); |
packeCounter->Draw("AP"); |
|
packeCounter->SetMarkerColor(4); |
|
|
packeCounter->SetMarkerSize(.5); |
|
|
packeCounter->SetMarkerStyle(21); |
|
351 |
packeCounter->GetXaxis()->SetTitle("OBT (ms)"); |
packeCounter->GetXaxis()->SetTitle("OBT (ms)"); |
352 |
packeCounter->GetXaxis()->SetTitleSize(0.05); |
packeCounter->GetXaxis()->SetTitleSize(0.05); |
353 |
packeCounter->GetXaxis()->CenterTitle(); |
packeCounter->GetXaxis()->CenterTitle(); |
354 |
packeCounter->GetXaxis()->SetLabelSize(0.04); |
packeCounter->GetXaxis()->SetLabelSize(0.05); |
355 |
packeCounter->GetYaxis()->SetTitle("Counter"); |
packeCounter->GetYaxis()->SetTitle("Counter"); |
356 |
packeCounter->GetYaxis()->SetTitleSize(0.05); |
packeCounter->GetYaxis()->SetTitleSize(0.05); |
357 |
packeCounter->GetYaxis()->CenterTitle(); |
packeCounter->GetYaxis()->CenterTitle(); |
358 |
packeCounter->GetYaxis()->SetLabelSize(0.04); |
packeCounter->GetYaxis()->SetLabelSize(0.05); |
359 |
packeCounter->GetYaxis()->SetTitleSize(0.06); |
packeCounter->GetYaxis()->SetTitleSize(0.06); |
360 |
packeCounter->GetYaxis()->SetTitleOffset(0.8); |
packeCounter->GetYaxis()->SetTitleOffset(0.6); |
361 |
Double_t min = 500000000.; |
|
362 |
for (Int_t l = 0; l < nevents; l++){ |
|
363 |
if((packeCounter->GetBinContent(l))<= min && (packeCounter->GetBinContent(l))!= 0) min = packeCounter->GetBinContent(l); |
finalCanv->cd(3); |
364 |
} |
TPaveText *pt2=0; |
365 |
packeCounter->SetMinimum(min); |
pt2 = new TPaveText (.6,.91,.90,1); |
366 |
packeCounter->Draw("9p"); |
pt2->AddText(oss3.str().c_str()); |
367 |
|
pt2->SetTextColor(4); |
368 |
oss.str(""); |
pt2->SetFillColor(10); |
369 |
oss << outDir.Data() << filename.Data(); |
pt2->SetBorderSize(0); |
370 |
oss << "_HeaderScan_1." << format.Data(); |
pt2->Draw(); |
371 |
finalCanv1->SaveAs(oss.str().c_str()); |
|
372 |
|
/**********************************************************************************************/ |
373 |
//------------------------------------------------- |
|
374 |
|
TMultiGraph *mg1 = new TMultiGraph(); |
375 |
|
TMultiGraph *mg2 = new TMultiGraph(); |
376 |
|
//---------------------- fill vectors and histogram --------------------------------------------------// |
377 |
TList *list = new TList; |
TList *list = new TList; |
378 |
Int_t numkey; |
Int_t numkey; |
379 |
TObject *key = new TObject; |
TObject *key = new TObject; |
380 |
const char *name; |
const char *name; |
381 |
|
char *SoftInfo="SoftInfo"; |
382 |
TTree* tr = new TTree; |
TTree* tr = new TTree; |
383 |
Long64_t nevntskey=0; |
Long64_t nevntskey=0; |
384 |
list = file->GetListOfKeys(); |
list = file->GetListOfKeys(); |
385 |
numkey = file->GetNkeys(); |
numkey = file->GetNkeys(); |
386 |
|
ULong_t salto; |
387 |
const Int_t size1 = 10000; |
for (Int_t m=0; m<numkey; m++){ |
388 |
Int_t ev1=0; |
key = list->At(m); |
|
Double_t PscuCounter1[size1], FileOffset1[size1], tempo1[size1], salto[size1]; |
|
|
Int_t pag1=0; |
|
|
Int_t m1=0; |
|
|
Int_t ll=0; |
|
|
|
|
|
for (Int_t i=0; i<numkey; i++){ |
|
|
key = list->At(i); |
|
389 |
name=(char *)(key->GetName()); |
name=(char *)(key->GetName()); |
390 |
|
if(strcmp(name,SoftInfo)==0)continue; |
391 |
tr = (TTree*)file->Get(name); |
tr = (TTree*)file->Get(name); |
392 |
if (tr->IsZombie()) continue; |
if (tr->IsZombie()) continue; |
393 |
|
|
394 |
tr->SetBranchAddress("Header", &eh); |
tr->SetBranchAddress("Header", &eh); |
395 |
TBranch *Br = tr->GetBranch("Header"); |
TBranch *Br = tr->GetBranch("Header"); |
396 |
nevntskey = tr->GetEntries(); |
nevntskey = tr->GetEntries(); |
397 |
m1=0; |
if(nevntskey !=0){ |
398 |
pag1= (nevntskey/10000)+1; |
Int_t size1=nevntskey; |
399 |
/////ciclo sulle pagine//////////////////// |
Double_t *PscuCounter1 = new Double_t[size1]; |
400 |
for (Int_t interval1=0; interval1<pag1; interval1++){ |
Double_t *FileOffset1 = new Double_t[size1]; |
401 |
|
Double_t *tempo1 = new Double_t[size1]; |
402 |
|
|
403 |
|
int n=0; |
404 |
|
while(n<nevntskey){ |
405 |
|
Br->GetEntry(n); |
406 |
|
ph = eh->GetPscuHeader(); |
407 |
|
PscuCounter1[n]= ph->GetCounter(); |
408 |
|
FileOffset1[n]=ph->GetFileOffset(); |
409 |
|
utile=ph->GetOrbitalTime(); |
410 |
|
tempo1[n]=utile; |
411 |
|
if((m==0) && (n==0)){ |
412 |
|
primotempo=ph->GetOrbitalTime(); |
413 |
|
salto=ph->GetOrbitalTime(); |
414 |
|
} |
415 |
|
if(salto > ph->GetOrbitalTime())salto=ph->GetOrbitalTime(); |
416 |
|
if(ph->GetFileOffset()<= primoffset){ |
417 |
|
primoffset=ph->GetFileOffset(); |
418 |
|
primotempo=ph->GetOrbitalTime(); |
419 |
|
} |
420 |
|
if(ph->GetFileOffset()>=ultimoffset){ |
421 |
|
ultimotempo=ph->GetOrbitalTime(); |
422 |
|
ultimoffset=ph->GetFileOffset(); |
423 |
|
} |
424 |
|
n++; |
425 |
|
} |
426 |
|
|
427 |
for (Int_t l = 0; l < size1; l++){ //ciclo su un sottogruppo |
TGraph *graph3= new TGraph(nevntskey, (const Double_t*)FileOffset1, (const Double_t*)PscuCounter1); |
428 |
Br->GetEntry(ev1+l); |
graph3->SetMarkerColor(3); |
429 |
ph = eh->GetPscuHeader(); |
graph3->SetMarkerSize(.2); |
430 |
PscuCounter1[l]= ph->GetCounter(); // = PcktCounter[l] |
graph3->SetMarkerStyle(21); |
431 |
FileOffset1[l]=ph->GetFileOffset(); |
mg1->Add(graph3); |
432 |
tempo1[l]=ph->GetOrbitalTime(); |
|
433 |
if(ph->GetFileOffset()<= primoffset){ |
TGraph *graph4= new TGraph(nevntskey, (const Double_t*)FileOffset1, (const Double_t*)tempo1); |
434 |
primoffset =ph->GetFileOffset(); |
graph4->SetMarkerColor(kBlue); |
435 |
primotempo=ph->GetOrbitalTime(); |
graph4->SetMarkerSize(.2); |
436 |
|
graph4->SetMarkerStyle(21); |
437 |
|
mg2->Add(graph4); |
438 |
} |
} |
|
if(ph->GetFileOffset()>= ultimoffset){ |
|
|
ultimoffset = ph->GetFileOffset(); |
|
|
ultimotempo = ph->GetOrbitalTime(); |
|
|
} |
|
|
if(l>0){ |
|
|
if(tempo1[l] < tempo1[l-1]){ |
|
|
salto[ll]= ph->GetOrbitalTime(); |
|
|
ll=ll+1; |
|
|
} |
|
|
} |
|
|
|
|
|
m1=l; |
|
|
} |
|
|
|
|
|
TGraph *graph3= new TGraph(m1, FileOffset1, PscuCounter1); |
|
|
graph3->SetMarkerColor(3); |
|
|
graph3->SetMarkerSize(.5); |
|
|
graph3->SetMarkerStyle(21); |
|
|
mg1->Add(graph3); |
|
|
|
|
|
TGraph *graph4= new TGraph(m1, FileOffset1, tempo1); |
|
|
graph4->SetMarkerColor(kBlue); |
|
|
graph4->SetMarkerSize(.5); |
|
|
graph4->SetMarkerStyle(21); |
|
|
mg2->Add(graph4); |
|
|
|
|
|
ev1=ev1+10000; |
|
|
} |
|
439 |
} |
} |
440 |
|
|
441 |
|
TLatex *lat = new TLatex(); |
442 |
TLatex *lat = new TLatex(); |
lat->SetTextAlign(12); |
443 |
lat->SetTextAlign(12); |
lat->SetTextSize(0.15); |
444 |
lat->SetTextSize(0.15); |
lat->SetTextColor(kBlue); |
|
lat->SetTextColor(kBlue); |
|
|
|
|
445 |
|
|
446 |
//------------ Second Canvas ---------------------// |
//------------ Fourth PAD ---------------------// |
447 |
finalCanv2->cd(1); |
finalCanv->cd(4); |
448 |
all1->Draw(); |
all1->Draw(); |
449 |
all1->cd(); |
all1->cd(); |
450 |
|
|
451 |
|
oss1.str(""); |
452 |
|
oss1 <<"PscuCounter vs FileOffset."; |
453 |
mg1->Draw("AP"); |
mg1->Draw("AP"); |
454 |
mg1->GetXaxis()->SetTitle("File Offset"); |
mg1->GetXaxis()->SetTitle("File Offset"); |
455 |
mg1->GetXaxis()->CenterTitle(); |
mg1->GetXaxis()->CenterTitle(); |
456 |
|
mg1->GetXaxis()->SetTitleOffset(0.8); |
457 |
mg1->GetXaxis()->SetTitleSize(0.05); |
mg1->GetXaxis()->SetTitleSize(0.05); |
458 |
mg1->GetXaxis()->SetLabelSize(0.04); |
mg1->GetXaxis()->SetLabelSize(0.05); |
459 |
mg1->GetYaxis()->SetTitle("Counter"); |
mg1->GetYaxis()->SetTitle("Counter"); |
460 |
mg1->GetYaxis()->CenterTitle(); |
mg1->GetYaxis()->CenterTitle(); |
461 |
mg1->GetYaxis()->SetTitleSize(0.05); |
mg1->GetYaxis()->SetTitleSize(0.06); |
462 |
mg1->GetYaxis()->SetLabelSize(0.03); |
mg1->GetYaxis()->SetLabelSize(0.06); |
463 |
|
mg1->GetYaxis()->SetTitleOffset(0.6); |
464 |
|
finalCanv->cd(4); |
465 |
|
TPaveText *pt3=0; |
466 |
|
pt3 = new TPaveText (.60,.91,.90,1); |
467 |
|
pt3->AddText(oss1.str().c_str()); |
468 |
|
pt3->SetTextColor(3); |
469 |
|
pt3->SetFillColor(10); |
470 |
|
pt3->SetBorderSize(0); |
471 |
|
pt3->Draw(); |
472 |
|
|
473 |
finalCanv2->cd(2); |
//------------ Fifth PAD ---------------------// |
474 |
|
finalCanv->cd(5); |
475 |
all->Draw(); |
all->Draw(); |
476 |
all->cd(); |
all->cd(); |
|
|
|
477 |
oss3.str(""); |
oss3.str(""); |
478 |
oss3 << filename.Data() <<" OBT vs FileOffset. First packet = "<<primotempo <<" ms, Last packet = "<<ultimotempo<<" ms."; |
oss3 << "OBT vs FileOffset"; |
|
mg2->SetTitle(oss3.str().c_str()); |
|
479 |
mg2->Draw("AP"); |
mg2->Draw("AP"); |
480 |
mg2->GetXaxis()->SetTitle("File Offset"); |
mg2->GetXaxis()->SetTitle("File Offset"); |
481 |
mg2->GetXaxis()->CenterTitle(); |
mg2->GetXaxis()->CenterTitle(); |
482 |
mg2->GetXaxis()->SetTitleSize(0.05); |
mg2->GetXaxis()->SetTitleSize(0.05); |
483 |
mg2->GetXaxis()->SetLabelSize(0.04); |
mg2->GetXaxis()->SetLabelSize(0.05); |
484 |
mg2->GetYaxis()->SetTitle("OBT"); |
mg2->GetYaxis()->SetTitle("OBT"); |
485 |
mg2->GetYaxis()->CenterTitle(); |
mg2->GetYaxis()->CenterTitle(); |
486 |
mg2->GetYaxis()->SetTitleSize(0.05); |
mg2->GetYaxis()->SetTitleSize(0.06); |
487 |
mg2->GetYaxis()->SetLabelSize(0.03); |
mg2->GetYaxis()->SetLabelSize(0.05); |
488 |
double min2 = 0.8; |
mg2->GetYaxis()->SetTitleOffset(0.6); |
489 |
if(ll-1 > 0){ |
|
490 |
pad->Draw(); |
finalCanv->cd(5); |
491 |
pad->cd(); |
TPaveText *pt4=0; |
492 |
stringa.str(""); |
pt4 = new TPaveText (.70,.91,.90,1); |
493 |
stringa << "jump back at:"; |
pt4->AddText(oss3.str().c_str()); |
494 |
lat->DrawLatex(0.08, min2, stringa.str().c_str()); |
pt4->SetTextColor(kBlue); |
495 |
for(Int_t kk=0; kk <(ll-1); kk++){ |
pt4->SetFillColor(10); |
496 |
stringa.str(""); |
pt4->SetBorderSize(0); |
497 |
stringa << salto[kk]; |
pt4->Draw(); |
498 |
min2=min2-0.1; |
|
499 |
lat->DrawLatex(0.08, min2,stringa.str().c_str()); |
finalCanv->cd(6); |
500 |
//cout<<salto[kk]<<";\n"; |
ULong_t primotempoABS=TimeSync+((primotempo/1000)-ObtSync); |
501 |
} |
ULong_t obmaxABS=TimeSync+((lastime/1000)-ObtSync); |
502 |
} |
ULong_t saltoABS=TimeSync+((salto/1000)-ObtSync); |
503 |
|
ULong_t ultimotempoABS=TimeSync+((ultimotempo/1000)-ObtSync); |
504 |
finalCanv2->Update(); |
|
505 |
|
TPaveText *pt5=0; |
506 |
|
pt5 = new TPaveText (0,0,1,1); |
507 |
|
stringa.str(""); |
508 |
|
stringa << " Filename: "<<filename.Data()<<"\n"; |
509 |
|
TText *t1=pt5->AddText(0.25,0.95,stringa.str().c_str()); |
510 |
|
t1->SetTextSize(0.1); |
511 |
|
stringa.str(""); |
512 |
|
stringa << " OBT (ms) ABS TIME (s)"; |
513 |
|
TText *t2=pt5->AddText(0.32,0.75,stringa.str().c_str()); |
514 |
|
t2->SetTextSize(0.07); |
515 |
|
stringa.str(""); |
516 |
|
stringa << "New data start at: "<<primotempo<<" "<<primotempoABS; |
517 |
|
TText *t3=pt5->AddText(0.25,0.60,stringa.str().c_str()); |
518 |
|
t3->SetTextSize(0.08); |
519 |
|
stringa.str(""); |
520 |
|
stringa << "New data end at: "<<lastime<<" "<<obmaxABS; |
521 |
|
TText *t4=pt5->AddText(0.25,0.50,stringa.str().c_str()); |
522 |
|
t4->SetTextSize(0.08); |
523 |
|
if(primotempo!=salto || lastime!=ultimotempo){ |
524 |
|
stringa.str(""); |
525 |
|
stringa << "Old data start at: "<<salto<<" "<<saltoABS; |
526 |
|
TText *t5=pt5->AddText(0.65,0.60,stringa.str().c_str()); |
527 |
|
t5->SetTextSize(0.08); |
528 |
|
stringa.str(""); |
529 |
|
stringa << "Old data end at: "<<ultimotempo<<" "<<ultimotempoABS; |
530 |
|
TText *t6=pt5->AddText(0.65,0.50,stringa.str().c_str()); |
531 |
|
t6->SetTextSize(0.08); |
532 |
|
stringa.str(""); |
533 |
|
stringa << " OBT (ms) ABS TIME (s)"; |
534 |
|
TText *t2=pt5->AddText(0.72,0.75,stringa.str().c_str()); |
535 |
|
t2->SetTextSize(0.07); |
536 |
|
} |
537 |
|
pt5->SetTextColor(kBlack); |
538 |
|
pt5->SetFillColor(10); |
539 |
|
pt5->SetBorderSize(0); |
540 |
|
pt5->Draw(); |
541 |
|
|
542 |
|
finalCanv->Update(); |
543 |
|
|
544 |
oss1.str(""); |
oss1.str(""); |
545 |
oss1 << outDir.Data() << filename.Data(); |
oss1 << outDir.Data() << filename.Data(); |
546 |
oss1 << "_HeaderScan_2"<<"." << format.Data(); |
oss1 << "_HeaderScan"<<"." << format.Data(); |
547 |
|
|
548 |
|
finalCanv->SaveAs(oss1.str().c_str()); |
549 |
|
|
|
finalCanv2->SaveAs(oss1.str().c_str()); |
|
|
|
|
550 |
file->Close(); |
file->Close(); |
551 |
|
|
552 |
} |
} |
594 |
} |
} |
595 |
HeaderScan(argv[1], outDir, format); |
HeaderScan(argv[1], outDir, format); |
596 |
} |
} |
597 |
|
|