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