1 |
|
2 |
/* |
3 |
* S4 Quick Look |
4 |
* Author Marcelli-Malvezzi |
5 |
* Version 1.00 - March 2006 |
6 |
* |
7 |
* Description - The aim of S4 QL software is to monitor the bahaviour of this detector. |
8 |
* It creates three canvases: the first one contains the histogram of S4 data, the second one |
9 |
* is relative to the time behaviour of collected data while the last shows S4 rate |
10 |
* (information from trigger Packet). |
11 |
* See documentation for a more detailed description of the output. |
12 |
* |
13 |
* |
14 |
* Parameters: |
15 |
* TSTring base - the path to the root directory for the specific Pamela unpack session |
16 |
* There is no default value, without this input the program will not run |
17 |
* TString outDir - the path where to save the output image (Default = ./) |
18 |
* TString format - the format which will be used fo rsave the produced images (Default = "jpg") |
19 |
* Float_t DeltaT - the time interval in minute for calculation of average S4 data for minute, |
20 |
* see S4_QL_2 plot (Default = 1 minute) |
21 |
* |
22 |
* |
23 |
* Version 1.1 - June 2006 |
24 |
* Fixed bugs: the vector "trcss" was inizilized to have dimension 10, but for files with large number of events this |
25 |
* is not true; now this vector is inizialized at 100. |
26 |
* |
27 |
* the threshold at which S4 is set and the trigger configuration can change in the file; all these changes are reported |
28 |
* in a pad |
29 |
* |
30 |
* for a large namber of events is not possible to have vectors, so all graphs have been converted in histograms |
31 |
* |
32 |
* Version 2.0 - September 2006 |
33 |
* Fixed bugs: changed the number of bin in the "rate" histograms and the size of the string vector trcss |
34 |
*******/ |
35 |
|
36 |
|
37 |
#include <iostream> |
38 |
#include <fstream> |
39 |
#include <sstream> |
40 |
#include <math.h> |
41 |
#include "TStyle.h" |
42 |
#include "TFile.h" |
43 |
#include "TList.h" |
44 |
#include "TTree.h" |
45 |
#include "TLatex.h" |
46 |
#include "TObjString.h" |
47 |
#include "TCanvas.h" |
48 |
#include "TGraph.h" |
49 |
#include "TH1F.h" |
50 |
#include "TF1.h" |
51 |
#include "TGaxis.h" |
52 |
#include "TString.h" |
53 |
#include "TPaveText.h" |
54 |
#include "EventHeader.h" |
55 |
#include "PscuHeader.h" |
56 |
#include "TMultiGraph.h" |
57 |
#include "physics/S4/S4Event.h" |
58 |
#include "varDump/VarDumpEvent.h" |
59 |
#include "varDump/VarDumpRecord.h" |
60 |
#include "physics/trigger/TriggerEvent.h" |
61 |
|
62 |
using namespace std; |
63 |
|
64 |
void S4_QL(TString base, TString outDir, TString format, ULong_t DeltaT){ //DeltaT in minute |
65 |
|
66 |
//------ Variables initialization ---------/ |
67 |
Int_t tmpSize; |
68 |
ULong_t mintime, maxtime; |
69 |
Int_t adcmax; |
70 |
Int_t j=0; |
71 |
Int_t S4_TRHadc; |
72 |
Int_t S4_TRHmip; |
73 |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
74 |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
75 |
char *trc; |
76 |
TString trcs; |
77 |
TString str; |
78 |
TString trcsstot[31]; |
79 |
TString trcsstot2; |
80 |
|
81 |
TString trgconf[31]={"TOF1","TOF2","TOF3","TOF4","TOF5","TOF6","TOF7","S4","CALO","CALO-S4","TOF1-S4","TOF2-S4","TOF3-S4","TOF4-S4","TOF5-S4","TOF6-S4","TOF7-S4","TOF1-CALO","TOF2-CALO","TOF3-CALO","TOF4-CALO","TOF5-CALO","TOF6-CALO","TOF7-CALO","TOF1-CALO-S4","TOF2-CALO-S4","TOF3-CALO-S4","TOF4-CALO-S4","TOF5-CALO-S4","TOF6-CALO-S4","TOF7-CALO-S4",}; |
82 |
stringstream oss, oss1, oss2, oss3, s4soglia, buffer, conftrig, noentries; |
83 |
ULong_t lastime, firstime; |
84 |
Int_t vardumpentries = 0; |
85 |
Int_t channels = 4096; |
86 |
char S4_TRH[10]; |
87 |
char S4_TRH2[10]; |
88 |
Int_t trigconf = 0; |
89 |
Long64_t nevents; |
90 |
string title; |
91 |
double obmin=0.; |
92 |
double obmax=0.; |
93 |
double obt; |
94 |
double s4rate; |
95 |
//------to open headerfile, s4file, Trigfile and vardumpfile---------------------------/ |
96 |
TFile *file =new TFile(base.Data()) ; |
97 |
if (!file){ |
98 |
printf("No such file in the directory has been found"); |
99 |
return; |
100 |
} |
101 |
|
102 |
TTree *VarDumpTr = (TTree*)file->Get("VarDump"); |
103 |
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
104 |
|
105 |
TBranch *S4Br = PhysicsTr->GetBranch("S4"); |
106 |
TBranch *TriggerBr = PhysicsTr->GetBranch("Trigger"); |
107 |
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
108 |
TBranch *VarDumpBr = VarDumpTr->GetBranch("VarDump"); |
109 |
TBranch *headVarDumpBr = VarDumpTr->GetBranch("Header"); |
110 |
|
111 |
pamela::S4::S4Event *s4e = 0; |
112 |
pamela::EventHeader *eh = 0; |
113 |
pamela::PscuHeader *ph = 0; |
114 |
pamela::trigger::TriggerEvent *trige = 0; |
115 |
pamela::VarDumpEvent *vde = 0; |
116 |
pamela::VarDumpRecord *vdr = 0; |
117 |
|
118 |
PhysicsTr->SetBranchAddress("S4", &s4e); |
119 |
PhysicsTr->SetBranchAddress("Header", &eh); |
120 |
PhysicsTr->SetBranchAddress("Trigger", &trige); |
121 |
VarDumpTr->SetBranchAddress("VarDump", &vde); |
122 |
|
123 |
nevents = S4Br->GetEntries(); |
124 |
|
125 |
//----------- If nevents < = 0 ---------------------------------/ |
126 |
if (nevents<=0) { |
127 |
printf("nevents = %i \n", nevents); |
128 |
printf(" \n"); |
129 |
|
130 |
TCanvas *canvas4 = new TCanvas("No entries", "No entries ", 400, 200); |
131 |
canvas4->SetFillColor(10); |
132 |
canvas4->cd(); |
133 |
|
134 |
TLatex *l = new TLatex(); |
135 |
l->SetTextAlign(12); |
136 |
l->SetTextSize(0.15); |
137 |
l->SetTextColor(2); |
138 |
noentries.str(""); |
139 |
noentries<< "S4_QL:"; |
140 |
l->DrawLatex(0.05, 0.7, noentries.str().c_str()); |
141 |
noentries.str(""); |
142 |
noentries<< "No entries for this files"; |
143 |
l->DrawLatex(0.05, 0.5, noentries.str().c_str()); |
144 |
|
145 |
if (outDir == "./") { |
146 |
oss.str(""); |
147 |
oss << filename.Data() << "_S4_QL." << format.Data(); |
148 |
} else { |
149 |
oss.str(""); |
150 |
oss << outDir.Data() << filename.Data() << "_S4_QL." << format.Data(); |
151 |
} |
152 |
|
153 |
canvas4->Update(); |
154 |
canvas4->SaveAs(oss.str().c_str()); |
155 |
|
156 |
return; |
157 |
} |
158 |
const Int_t ev = nevents; |
159 |
TString trcss[ev]; |
160 |
//-------to set trigger configuration---------------------------------// |
161 |
for (Int_t ll = 0; ll < nevents; ll++){ |
162 |
TriggerBr->GetEntry(ll); |
163 |
trigconf = trige->trigconf; |
164 |
trc = 0; |
165 |
if ( trigconf & (1<<0) ) trc = "TOF1"; |
166 |
if ( trigconf & (1<<1) ) { |
167 |
if (trc==0) trc= "TOF2"; |
168 |
else trc = Form("%s-TOF2",trc); |
169 |
} |
170 |
if ( trigconf & (1<<2) ) { |
171 |
if (trc==0) trc= "TOF3"; |
172 |
else trc = Form("%s-TOF3",trc); |
173 |
} |
174 |
if ( trigconf & (1<<3) ) { |
175 |
if (trc==0) trc= "TOF4"; |
176 |
else trc = Form("%s-TOF4",trc); |
177 |
} |
178 |
if ( trigconf & (1<<4) ) { |
179 |
if (trc==0) trc= "TOF5"; |
180 |
else trc = Form("%s-TOF5",trc); |
181 |
} |
182 |
if ( trigconf & (1<<5) ) { |
183 |
if (trc==0) trc= "TOF6"; |
184 |
else trc = Form("%s-TOF6",trc); |
185 |
} |
186 |
if ( trigconf & (1<<6) ) { |
187 |
if (trc==0) trc= "TOF7"; |
188 |
else trc = Form("%s-TOF7",trc); |
189 |
} |
190 |
if ( trigconf & (1<<7) ) { |
191 |
if (trc==0) trc= "S4"; |
192 |
else trc = Form("%s-S4",trc); |
193 |
} |
194 |
if ( trigconf & (1<<8) ) { |
195 |
if (trc==0) trc= "CALO"; |
196 |
else trc = Form("%s-CALO",trc); |
197 |
} |
198 |
if ( trigconf & (1<<9) ) { |
199 |
if (trc==0) trc= "CALIB_ON"; |
200 |
else trc = Form("%s-CALIB_ON",trc); |
201 |
} |
202 |
trcs = ""; |
203 |
trcs = trc; |
204 |
if (ll==0){ |
205 |
trcss[0]=trcs; |
206 |
j=j+1; |
207 |
} |
208 |
if (trcs!=trcss[j-1] && ll>0){ |
209 |
trcss[j]=trcs; |
210 |
j=j+1; |
211 |
} |
212 |
//cout<<i<<"\n"; |
213 |
//cout<<nevents<<"\n\n"; |
214 |
} |
215 |
/////////////////////////////////////////////////////////////////// |
216 |
for(Int_t k=0; k<31; k++){ |
217 |
for(Int_t p=0; p<j ; p++){ |
218 |
if(trgconf[k]==trcss[p]){ |
219 |
trcsstot[k]=trgconf[k]; |
220 |
} |
221 |
} |
222 |
} |
223 |
for(Int_t k=0; k<31; k++){ |
224 |
if(trcsstot[k]!= "") |
225 |
trcsstot2=trcsstot2+"/"+ trcsstot[k]; |
226 |
} |
227 |
|
228 |
//---------to search S4 threshold and convert it into char (hexadecimal value)--------// |
229 |
vardumpentries = VarDumpBr->GetEntries(); |
230 |
if(vardumpentries==0){ |
231 |
cout<<"TTree VarDump: Entries = 0"<<"\n"<<" S4 Threshold not defined"<<"\n"; |
232 |
str= " Not defined"; |
233 |
} |
234 |
else{ |
235 |
for(Int_t k=0; k< vardumpentries; k++){ |
236 |
VarDumpBr->GetEntry(k); |
237 |
vdr = (pamela::VarDumpRecord*)vde->Records->At(118); |
238 |
S4_TRHadc=((vdr->VAR_VALUE)/256); //trh (number of ADC channels) |
239 |
S4_TRHmip=S4_TRHadc*2; |
240 |
|
241 |
//-----to convert decimal value to TString of S4 threshold value-------// |
242 |
if(k==0){ |
243 |
sprintf(S4_TRH, "%d" , S4_TRHmip); |
244 |
str= S4_TRH; |
245 |
}else{ |
246 |
sprintf(S4_TRH2, "%d" , S4_TRHmip); |
247 |
if(!strcmp(S4_TRH, S4_TRH2)) continue; |
248 |
str= str+"/"+S4_TRH2; |
249 |
} |
250 |
sprintf(S4_TRH, "%d" , S4_TRHmip); |
251 |
} |
252 |
} |
253 |
|
254 |
//********************** First Histogram ************************************// |
255 |
TH1F *h1 = new TH1F("All events", "S4 distribution for file: "+filename, channels, 1, channels); |
256 |
TH1F *h2 = new TH1F("S4 Triggered events", "S4 distribution for file: "+filename, channels, 1, channels); |
257 |
|
258 |
//********************** Second Histogram ************************************// |
259 |
headBr->GetEntry(0); |
260 |
ph = eh->GetPscuHeader(); |
261 |
firstime = ph->GetOrbitalTime(); |
262 |
|
263 |
int iii =0; |
264 |
while(iii < nevents){ |
265 |
headBr->GetEntry(iii); |
266 |
ph = eh->GetPscuHeader(); |
267 |
if((ph->GetOrbitalTime()) <= firstime) firstime=ph->GetOrbitalTime(); |
268 |
if((ph->GetOrbitalTime()) >= lastime) lastime=ph->GetOrbitalTime(); |
269 |
iii++; |
270 |
} |
271 |
|
272 |
obmin=firstime; |
273 |
obmax=lastime; |
274 |
const ULong_t nint=(((lastime-firstime)/(DeltaT*60000))); |
275 |
const Int_t size = (Int_t)(nint+1); |
276 |
|
277 |
TH1F *Allev = new TH1F("Mean signal from S4-all events", filename+": Mean signal from S4 (all triggered events)", size, obmin, obmax); |
278 |
TH1F *Alltime = new TH1F("Mean signal from S4-all events", filename+": Mean signal from S4 (all triggered events)", size, obmin, obmax); |
279 |
TH1F *S4ev = new TH1F("Mean signal from S4-triggered events", filename+": Mean signal from S4 (only s4 triggered events)", size, obmin, obmax); |
280 |
TH1F *S4time = new TH1F("Mean signal from S4-triggered events", filename+": Mean signal from S4 (only s4 triggered events)", size, obmin, obmax); |
281 |
|
282 |
//********************** Third Histogram ************************************// |
283 |
title=""; |
284 |
title=filename+": S4 rate from Trigger Packet"; |
285 |
|
286 |
const ULong_t nint2=(lastime-firstime)/10000; |
287 |
const Int_t size2 = (Int_t)((nint2+1)); // one bin every 10 second |
288 |
const ULong_t nint3=(lastime-firstime)/1000; |
289 |
const Int_t size3 = (Int_t)((nint3+1)); // one bin every 1 second |
290 |
TH1F *rate= new TH1F(title.c_str(), title.c_str(), size2, obmin, obmax); |
291 |
TH1F *rateline= new TH1F(filename+". S4 rate from Trigger Packet: mean value over 100 events", filename+". S4 rate from Trigger Packet: mean value over 100 events", size3, obmin, obmax); |
292 |
|
293 |
//------------------------------------------------------------------------------------------------------------------ |
294 |
//------- fill histograms ---------// |
295 |
Int_t n=0, p=0; |
296 |
for (Int_t i = 0; i < nevents; i++){ |
297 |
TriggerBr->GetEntry(i); |
298 |
headBr->GetEntry(i); |
299 |
S4Br->GetEntry(i); |
300 |
ph = eh->GetPscuHeader(); |
301 |
if (s4e->unpackError == 1 && (s4e->S4_DATA)==0) continue; |
302 |
s4rate= trige->s4calcount[0]; |
303 |
rate->Fill(ph->GetOrbitalTime(), s4rate); |
304 |
h1->Fill(s4e->S4_DATA); |
305 |
Allev->Fill(ph->GetOrbitalTime(),s4e->S4_DATA); |
306 |
Alltime->Fill(ph->GetOrbitalTime()); |
307 |
if ((trige->patterntrig[0] == 0)&&(trige->patterntrig[1] != 0)&&(trige->patterntrig[2] == 0)&&(trige->patterntrig[3] == 0)&&(trige->patterntrig[4] == 0)&&(trige->patterntrig[5] == 0)){ |
308 |
h2->Fill(s4e->S4_DATA); |
309 |
S4ev->Fill(ph->GetOrbitalTime(),s4e->S4_DATA); |
310 |
S4time->Fill(ph->GetOrbitalTime()); |
311 |
p=p+1; |
312 |
} |
313 |
} |
314 |
Int_t kk=0; |
315 |
while (kk < nevents){ |
316 |
obt=0; |
317 |
s4rate=0; |
318 |
for(Int_t jj=kk; jj< (kk+100); jj++){ |
319 |
TriggerBr->GetEntry(jj); |
320 |
headBr->GetEntry(jj); |
321 |
obt = obt+(ph->GetOrbitalTime()); |
322 |
s4rate= s4rate+(trige->s4calcount[0]); |
323 |
} |
324 |
rateline->Fill((obt/100),(s4rate/100)); |
325 |
kk=kk+100; |
326 |
} |
327 |
|
328 |
//****************************** Canvases *******************************// |
329 |
//------------------- First Canvas --------------------------------// |
330 |
TCanvas *canvas1 = new TCanvas("S4_QL_1", "S4 HISTO ", 1280, 1024); |
331 |
canvas1->SetFillColor(10); |
332 |
canvas1->Divide(1,2); |
333 |
|
334 |
TPad *all= new TPad ("","", 0, 0, 1, 1); |
335 |
all->SetFillColor(10); |
336 |
TPad *s4 = new TPad ("s4","s4", 0, 1, 1, 0); |
337 |
s4->SetFillColor(10); |
338 |
TPad *pad = new TPad("pad","pad", .30,.80,.78,.90); |
339 |
pad->SetFillColor(10); |
340 |
TPad *pad2 = new TPad("pad2","pad2", .30,.80,.78,.90); |
341 |
pad2->SetFillColor(10); |
342 |
TLatex *l = new TLatex(); |
343 |
l->SetTextAlign(12); |
344 |
l->SetTextSize(0.35); |
345 |
l->SetTextColor(8); |
346 |
s4soglia.str(""); |
347 |
s4soglia << "S4_THRESHOLD: "<<str.Data()<<" MIP"; |
348 |
TLatex *ll = new TLatex(); |
349 |
ll->SetTextAlign(12); |
350 |
ll->SetTextSize(0.35); |
351 |
conftrig.str(""); |
352 |
conftrig<<"TRIGGER CONF: "<<trcsstot2.Data(); |
353 |
if(adcmax<=100) adcmax=120; |
354 |
|
355 |
canvas1->cd(1); |
356 |
all->Draw(); |
357 |
all->cd(); |
358 |
h1->SetLineColor(kBlack); |
359 |
h1->SetFillColor(kRed); |
360 |
h1->GetXaxis()->SetTitle("ADC"); |
361 |
h1->GetXaxis()->CenterTitle(); |
362 |
h1->GetYaxis()->SetTitle("Number of Events"); |
363 |
h1->GetYaxis()->CenterTitle(); |
364 |
h1->Draw(); |
365 |
pad->Draw(); |
366 |
pad->cd(); |
367 |
l->DrawLatex(0.05, 0.65, s4soglia.str().c_str()); |
368 |
ll->DrawLatex(0.05, 0.15, conftrig.str().c_str()); |
369 |
|
370 |
|
371 |
canvas1->cd(2); |
372 |
s4->Draw(); |
373 |
s4->cd(); |
374 |
h2->SetLineColor(kBlack); |
375 |
h2->SetFillColor(2); |
376 |
h2->GetXaxis()->SetTitle("ADC"); |
377 |
h2->GetXaxis()->CenterTitle(); |
378 |
h2->GetYaxis()->SetTitle("Number of Events"); |
379 |
h2->GetYaxis()->CenterTitle(); |
380 |
h2->Draw(); |
381 |
pad2->Draw(); |
382 |
pad2->cd(); |
383 |
l->DrawLatex(0.05, 0.65, s4soglia.str().c_str()); |
384 |
ll->DrawLatex(0.05, 0.15, conftrig.str().c_str()); |
385 |
|
386 |
if (h1->GetMaximum()>0){ |
387 |
all->SetLogy(); |
388 |
all->SetLogx(); |
389 |
} |
390 |
if (h2->GetMaximum()>0){ |
391 |
s4->SetLogy(); |
392 |
s4->SetLogx(); |
393 |
} |
394 |
canvas1->Update(); |
395 |
|
396 |
|
397 |
if (outDir == "./") { |
398 |
oss1.str(""); |
399 |
oss1 << filename.Data() << "_S4_QL_1." << format.Data(); |
400 |
} else { |
401 |
oss1.str(""); |
402 |
oss1 << outDir.Data() << filename.Data() << "_S4_QL_1." << format.Data(); |
403 |
} |
404 |
canvas1->SaveAs(oss1.str().c_str()); |
405 |
|
406 |
//------------------- Second Canvas --------------------------------// |
407 |
if (nint==0){ |
408 |
cout<<"Number of Time Interval = 0"<<"\n"<<" Set another value for input parameter DeltaTevtime "<<"\n"<<"RETURN"<<"\n"; |
409 |
|
410 |
TCanvas *canvas2 = new TCanvas("Number of time interval=0", "Number of time interval=0", 900, 300); |
411 |
canvas2->SetFillColor(10); |
412 |
canvas2->cd(); |
413 |
|
414 |
TLatex *l = new TLatex(); |
415 |
l->SetTextAlign(12); |
416 |
l->SetTextSize(0.10); |
417 |
l->SetTextColor(2); |
418 |
noentries.str(""); |
419 |
noentries<< "S4_QL: Time evolution"; |
420 |
l->DrawLatex(0.05, 0.7, noentries.str().c_str()); |
421 |
noentries.str(""); |
422 |
noentries<< "Number of Time Interval = 0"; |
423 |
l->SetTextColor(1); |
424 |
l->DrawLatex(0.05, 0.5, noentries.str().c_str()); |
425 |
noentries.str(" Set another value for input parameter DeltaTevtime"); |
426 |
noentries<< ""; |
427 |
l->DrawLatex(0.05, 0.3, noentries.str().c_str()); |
428 |
|
429 |
if (outDir == "./") { |
430 |
oss.str(""); |
431 |
oss << filename.Data() << "_S4_QL_2." << format.Data(); |
432 |
} else { |
433 |
oss.str(""); |
434 |
oss << outDir.Data() << filename.Data() << "_S4_QL_2." << format.Data(); |
435 |
} |
436 |
canvas2->Update(); |
437 |
canvas2->SaveAs(oss.str().c_str()); |
438 |
|
439 |
return; |
440 |
} |
441 |
TCanvas *canvas2 = new TCanvas("S4_QL_2", "S4 - Time evolution", 1280, 1024); |
442 |
canvas2->SetFillColor(10); |
443 |
canvas2->Divide(1,2); |
444 |
|
445 |
TPad *pad3 = new TPad("pad3","pad3", .7,.1,.88,.30); |
446 |
pad3->SetFillColor(10); |
447 |
TPad *pad4 = new TPad("pad4","pad4", .7,.1,.88,.30); |
448 |
pad4->SetFillColor(10); |
449 |
|
450 |
TLatex *l3 = new TLatex(); |
451 |
l3->SetTextAlign(12); |
452 |
l3->SetTextSize(.3); |
453 |
l3->SetTextColor(2); |
454 |
buffer.str(""); |
455 |
buffer<<"DT : "<<DeltaT<<" min"; |
456 |
|
457 |
canvas2->cd(1); |
458 |
Allev->SetStats(kFALSE); |
459 |
Allev->SetMarkerColor(2); |
460 |
Allev->SetMarkerSize(.5); |
461 |
Allev->SetMarkerStyle(21); |
462 |
Allev->GetXaxis()->SetTitle("Time ( OBT in ms )"); |
463 |
Allev->GetXaxis()->CenterTitle(); |
464 |
Allev->GetYaxis()->SetTitle("Mean signal ( ADC )"); |
465 |
Allev->GetYaxis()->CenterTitle(); |
466 |
//Allev->SetMinimum(20); |
467 |
Allev->Divide(Alltime); |
468 |
Allev->Draw("p"); |
469 |
pad3->Draw(); |
470 |
pad3->cd(); |
471 |
l3->DrawLatex(0.05, 0.65, buffer.str().c_str()); |
472 |
|
473 |
|
474 |
canvas2->cd(2); |
475 |
if(p != 0){ |
476 |
S4ev->SetStats(kFALSE); |
477 |
S4ev->SetMarkerColor(2); |
478 |
S4ev->SetMarkerSize(.5); |
479 |
S4ev->SetMarkerStyle(21); |
480 |
S4ev->GetXaxis()->SetTitle("Time ( OBT in ms )"); |
481 |
S4ev->GetXaxis()->CenterTitle(); |
482 |
S4ev->GetYaxis()->SetTitle("Mean signal ( ADC )"); |
483 |
S4ev->GetYaxis()->CenterTitle(); |
484 |
S4ev->SetMinimum(20); |
485 |
S4ev->Divide(S4time); |
486 |
S4ev->Draw("p"); |
487 |
pad4->Draw(); |
488 |
pad4->cd(); |
489 |
l3->DrawLatex(0.05, 0.65, buffer.str().c_str()); |
490 |
}else{ |
491 |
TLatex *l = new TLatex(); |
492 |
l->SetTextAlign(12); |
493 |
l->SetTextSize(0.07); |
494 |
l->SetTextColor(2); |
495 |
noentries.str(""); |
496 |
noentries<< "S4_QL: Time evolution"; |
497 |
l->DrawLatex(0.06, 0.6, noentries.str().c_str()); |
498 |
noentries.str(""); |
499 |
noentries<< "No S4 triggered events."; |
500 |
l->SetTextColor(1); |
501 |
l->DrawLatex(0.06, 0.5, noentries.str().c_str()); |
502 |
} |
503 |
|
504 |
if (outDir == "./") { |
505 |
oss2.str(""); |
506 |
oss2 << filename.Data() << "_S4_QL_2." << format.Data(); |
507 |
} else { |
508 |
oss2.str(""); |
509 |
oss2 << outDir.Data() << filename.Data() << "_S4_QL_2." << format.Data(); |
510 |
} |
511 |
canvas2->SaveAs(oss2.str().c_str()); |
512 |
|
513 |
//------------------- Third Canvas --------------------------------// |
514 |
TCanvas *canvas3 = new TCanvas("S4 - Rate", "S4 - Rate", 1280, 1024); |
515 |
canvas3->SetFillColor(10); |
516 |
canvas3->Divide(1,2); |
517 |
|
518 |
canvas3->cd(1); |
519 |
rate->SetStats(kFALSE); |
520 |
rate->SetMarkerColor(2); |
521 |
rate->SetMarkerSize(.5); |
522 |
rate->SetMarkerStyle(21); |
523 |
rate->GetXaxis()->SetTitle("Time ( OBT in ms )"); |
524 |
rate->GetXaxis()->CenterTitle(); |
525 |
rate->GetYaxis()->SetTitle("S4 rate (Hz)"); |
526 |
rate->GetYaxis()->CenterTitle(); |
527 |
if(rate->GetMaximum() > 1000) gPad->SetLogy(); |
528 |
rate->Draw("9p"); |
529 |
|
530 |
canvas3->cd(2); |
531 |
rateline->SetStats(kFALSE); |
532 |
rateline->SetMarkerColor(4); |
533 |
rateline->SetMarkerSize(.5); |
534 |
rateline->SetMarkerStyle(21); |
535 |
rateline->GetXaxis()->SetTitle("Time ( OBT in ms )"); |
536 |
rateline->GetXaxis()->CenterTitle(); |
537 |
rateline->GetYaxis()->SetTitle("S4 rate (Hz)"); |
538 |
rateline->GetYaxis()->CenterTitle(); |
539 |
rateline->SetMaximum(rate->GetMaximum()); |
540 |
if(rateline->GetMaximum() > 1000) gPad->SetLogy(); |
541 |
rateline->Draw("9p"); |
542 |
|
543 |
|
544 |
if (outDir == "./") { |
545 |
oss3.str(""); |
546 |
oss3 << filename.Data() << "_S4_QL_3." << format.Data(); |
547 |
} else { |
548 |
oss3.str(""); |
549 |
oss3 << outDir.Data() << filename.Data() << "_S4_QL_3." << format.Data(); |
550 |
} |
551 |
canvas3->SaveAs(oss3.str().c_str()); |
552 |
file->Close(); |
553 |
} |
554 |
|
555 |
|
556 |
int main(int argc, char* argv[]){ |
557 |
TString path; |
558 |
TString outDir ="./"; |
559 |
TString format ="jpg"; |
560 |
ULong_t DeltaT =1; |
561 |
|
562 |
|
563 |
if (argc < 2){ |
564 |
printf("You have to insert at least the file to analyze \n"); |
565 |
printf("Try '--help' for more information. \n"); |
566 |
exit(1); |
567 |
} |
568 |
|
569 |
if (!strcmp(argv[1], "--help")){ |
570 |
printf( "Usage: ND_QL FILE [OPTION] \n"); |
571 |
printf( "\t --help Print this help and exit \n"); |
572 |
printf( "\t -outDir[path] Path where to put the output [default ./] \n"); |
573 |
printf( "\t -format[jpg|gif|ps] Format for output files [default 'jpg'] \n"); |
574 |
printf( "\t -DeltaT Time interval to control time evolution of acquired data in minute [default = 1 min] \n"); |
575 |
exit(1); |
576 |
} |
577 |
|
578 |
path=argv[1]; |
579 |
|
580 |
for (int i = 2; i < argc; i++){ |
581 |
|
582 |
if (!strcmp(argv[i], "-outDir")){ |
583 |
if (++i >= argc){ |
584 |
printf( "-outDir needs arguments. \n"); |
585 |
printf( "Try '--help' for more information. \n"); |
586 |
exit(1); |
587 |
} |
588 |
else{ |
589 |
outDir = argv[i]; |
590 |
continue; |
591 |
} |
592 |
} |
593 |
|
594 |
if (!strcmp(argv[i], "-format")){ |
595 |
if (++i >= argc){ |
596 |
printf( "-format needs arguments. \n"); |
597 |
printf( "Try '--help' for more information. \n"); |
598 |
exit(1); |
599 |
} |
600 |
else{ |
601 |
format = argv[i]; |
602 |
continue; |
603 |
} |
604 |
} |
605 |
|
606 |
if (!strcmp(argv[i], "-DeltaT")){ |
607 |
if (++i >= argc){ |
608 |
printf( "-DeltaT needs arguments. \n"); |
609 |
printf( "Try '--help' for more information. \n"); |
610 |
exit(1); |
611 |
} |
612 |
else{ |
613 |
DeltaT = atol(argv[i]); |
614 |
continue; |
615 |
} |
616 |
} |
617 |
|
618 |
|
619 |
} |
620 |
|
621 |
S4_QL(argv[1], outDir, format, DeltaT); |
622 |
|
623 |
} |
624 |
|