1 |
/** |
2 |
* FTrkCalibQLookExpert.cxx |
3 |
* |
4 |
* autor: D.Fedele |
5 |
* version v1r13 |
6 |
* Parameters: |
7 |
* file - the data file to analyze |
8 |
* step - select =1 in order to analyze one event at time |
9 |
* fromevent - first event to analyze |
10 |
* toevent - last event to analyze |
11 |
* outdir - total path of output file |
12 |
* outfile - extension of output file (pdf,ps,gif,jpg) |
13 |
* |
14 |
*/ |
15 |
// |
16 |
#include <iostream> |
17 |
// |
18 |
#include <TPaveText.h> |
19 |
#include <TLatex.h> |
20 |
#include <TCanvas.h> |
21 |
#include <TFile.h> |
22 |
#include <TTree.h> |
23 |
#include <TGraph.h> |
24 |
#include <TStyle.h> |
25 |
#include <TString.h> |
26 |
// |
27 |
#include <PscuHeader.h> |
28 |
#include <EventHeader.h> |
29 |
#include <CalibTrk1Event.h> |
30 |
#include <CalibTrk2Event.h> |
31 |
// |
32 |
|
33 |
typedef struct caltrk_def{ |
34 |
Int_t good0[2]; |
35 |
Int_t daqmode[12]; |
36 |
Int_t dspnum[12]; |
37 |
Int_t calibnum[12]; |
38 |
Int_t ncalev[12]; |
39 |
Int_t calfl[12]; |
40 |
Int_t ped1[12]; |
41 |
Int_t ped2[12]; |
42 |
Int_t ped3[12]; |
43 |
Int_t sig1[12]; |
44 |
Int_t sig2[12]; |
45 |
Int_t sig3[12]; |
46 |
Int_t nbad1[12]; |
47 |
Int_t nbad2[12]; |
48 |
Int_t nbad3[12]; |
49 |
Float_t dspped[12][3702]; |
50 |
Float_t dspsig[12][3702]; |
51 |
Float_t dspbad[12][3702]; |
52 |
Int_t crc_c[12][3]; |
53 |
Int_t crc_hc[12]; |
54 |
}; |
55 |
|
56 |
|
57 |
void FTrkCalibQLook_EXPERT(TString file,Int_t step,Int_t fromevent, Int_t toevent,TString outdir,TString outfile) |
58 |
{ |
59 |
// |
60 |
// obtain information about the data file and select the output dir |
61 |
Int_t dwpos = file.Last('/'); |
62 |
Int_t dwpos1 = file.Last('.'); |
63 |
TString base,ffile ; |
64 |
ffile=file(dwpos+1,dwpos1-(dwpos+1)); |
65 |
if(dwpos>0) base=file(0,dwpos); |
66 |
|
67 |
TString out; |
68 |
if(outdir.Length()==0){ |
69 |
out = base; |
70 |
}else{ |
71 |
out = outdir; |
72 |
} |
73 |
if(out.Last('/')+1<out.Length()) out+="/"; |
74 |
|
75 |
// |
76 |
// inizialise the variables and open the file |
77 |
Int_t nevents=0; |
78 |
Int_t minevent = 0; |
79 |
Int_t maxevent = 0; |
80 |
ULong64_t FOBT[2]; |
81 |
|
82 |
FOBT[0]=0; |
83 |
FOBT[1]=0; |
84 |
|
85 |
struct caltrk_def ctrk; |
86 |
ctrk.good0[0]=0; |
87 |
ctrk.good0[1]=0; |
88 |
for(Int_t i=0;i<12;i++){ |
89 |
ctrk.daqmode[i]=0; |
90 |
ctrk.dspnum[i]=0; |
91 |
ctrk.calibnum[i]=0; |
92 |
ctrk.ncalev[i]=0; |
93 |
ctrk.calfl[i]=0; |
94 |
ctrk.ped1[i]=0; |
95 |
ctrk.ped2[i]=0; |
96 |
ctrk.ped3[i]=0; |
97 |
ctrk.sig1[i]=0; |
98 |
ctrk.sig2[i]=0; |
99 |
ctrk.sig3[i]=0; |
100 |
ctrk.nbad1[i]=0; |
101 |
ctrk.nbad2[i]=0; |
102 |
ctrk.nbad3[i]=0; |
103 |
ctrk.crc_c[i][0]=0; |
104 |
ctrk.crc_c[i][1]=0; |
105 |
ctrk.crc_c[i][2]=0; |
106 |
ctrk.crc_hc[i]=0; |
107 |
for(Int_t iii=0;iii<3072;iii++){ |
108 |
ctrk.dspped[i][iii]=0; |
109 |
ctrk.dspsig[i][iii]=0; |
110 |
ctrk.dspbad[i][iii]=0; |
111 |
}; |
112 |
|
113 |
}; |
114 |
|
115 |
TFile *calibFile = new TFile(file); |
116 |
if ( !calibFile ){ |
117 |
printf("No data file, exiting...\n"); |
118 |
return; |
119 |
}; |
120 |
TTree *otr1,*otr2,*hotr,*totr; |
121 |
pamela::EventHeader *eh1=0,*eh2=0,*eh4=0,*eh3=0; |
122 |
pamela::PscuHeader *ph=0; |
123 |
pamela::CalibTrk1Event *trk1 = 0; |
124 |
pamela::CalibTrk2Event *trk2 = 0; |
125 |
pamela::EventCounter *cod=0; |
126 |
|
127 |
pamela::PacketType *pctp=0; |
128 |
|
129 |
hotr = (TTree*)calibFile->Get("CalibHeader"); |
130 |
hotr->SetBranchAddress("Header", &eh4); |
131 |
|
132 |
totr = (TTree*)calibFile->Get("CalibTrailer"); |
133 |
totr->SetBranchAddress("Header", &eh3); |
134 |
|
135 |
otr1 = (TTree*)calibFile->Get("CalibTrk1"); |
136 |
otr1->SetBranchAddress("CalibTrk1", &trk1); |
137 |
otr1->SetBranchAddress("Header",&eh1); |
138 |
otr2 = (TTree*)calibFile->Get("CalibTrk2"); |
139 |
otr2->SetBranchAddress("CalibTrk2", &trk2); |
140 |
otr2->SetBranchAddress("Header",&eh2); |
141 |
|
142 |
if(otr1->GetEntries()==otr2->GetEntries()) |
143 |
nevents = otr1->GetEntries(); |
144 |
else{ |
145 |
printf("WARNING: CalibTrk1 entries is different from CalibTrk2 entries"); |
146 |
return;} |
147 |
if (nevents<=0) { |
148 |
calibFile->Close(); |
149 |
printf("No calibration packets found, exiting...\n"); |
150 |
return; |
151 |
}; |
152 |
|
153 |
printf("Number of calibration packets: %i\n",nevents); |
154 |
|
155 |
if ( fromevent > toevent && toevent ){ |
156 |
printf("It must be fromevent < toevent \n"); |
157 |
return; |
158 |
}; |
159 |
|
160 |
if ( fromevent > nevents || fromevent < 0 ) { |
161 |
printf("You can choose fromevent between 0 (all) and %i \n",nevents); |
162 |
return; |
163 |
}; |
164 |
|
165 |
if ( toevent > nevents || toevent < 0 ) { |
166 |
printf("You can choose toevent between 0 (all) and %i \n",nevents); |
167 |
return; |
168 |
}; |
169 |
if ( fromevent == 0 ) { |
170 |
minevent = 0; |
171 |
maxevent = nevents; |
172 |
} else { |
173 |
minevent = fromevent - 1; |
174 |
if ( toevent > 0 ){ |
175 |
maxevent = toevent; |
176 |
} else if (toevent > nevents) { |
177 |
maxevent = nevents; |
178 |
} else { |
179 |
maxevent = nevents; |
180 |
}; |
181 |
}; |
182 |
|
183 |
//********************************************************************** |
184 |
// |
185 |
// LOOP OVER EVENTS |
186 |
// |
187 |
//********************************************************************** |
188 |
|
189 |
Int_t hcevent=hotr->GetEntries(); |
190 |
Int_t tcevent=totr->GetEntries(); |
191 |
ULong64_t HOBT[hcevent], TOBT[tcevent]; |
192 |
for (Int_t i = 0; i < hcevent; i++){ |
193 |
hotr->GetEntry(i); |
194 |
ph = eh4->GetPscuHeader(); |
195 |
HOBT[i]= ph->GetOrbitalTime(); |
196 |
} |
197 |
for (Int_t i = 0; i < tcevent; i++){ |
198 |
totr->GetEntry(i); |
199 |
ph = eh3->GetPscuHeader(); |
200 |
TOBT[i]= ph->GetOrbitalTime(); |
201 |
} |
202 |
|
203 |
printf("\n Scan of calibration packets from %i to %i ... \n\n",minevent+1,maxevent); |
204 |
for (Int_t i = minevent; i < maxevent; i++){ |
205 |
|
206 |
otr1->GetEntry(i); |
207 |
otr2->GetEntry(i); |
208 |
|
209 |
ctrk.good0[0]=trk1->good0; |
210 |
ctrk.good0[1]=trk2->good0; |
211 |
for (Int_t m = 0; m < 6; m++){ |
212 |
ph = eh1->GetPscuHeader(); |
213 |
cod = eh1->GetCounter(); |
214 |
FOBT[0]= ph->GetOrbitalTime(); |
215 |
if(trk1->DSPnumber[m]>0){ |
216 |
if(trk1->DSPnumber[m]<13){ |
217 |
ctrk.daqmode[trk1->DSPnumber[m]-1]=trk1->DAQmode[m]; |
218 |
ctrk.dspnum[trk1->DSPnumber[m]-1]=trk1->DSPnumber[m]; |
219 |
ctrk.calibnum[trk1->DSPnumber[m]-1]=trk1->calibnumber[m]; |
220 |
ctrk.ncalev[trk1->DSPnumber[m]-1]=trk1->ncalib_event[m]; |
221 |
ctrk.ped1[trk1->DSPnumber[m]-1]=trk1->ped_l1[m]; |
222 |
ctrk.ped2[trk1->DSPnumber[m]-1]=trk1->ped_l2[m]; |
223 |
ctrk.ped3[trk1->DSPnumber[m]-1]=trk1->ped_l3[m]; |
224 |
ctrk.sig1[trk1->DSPnumber[m]-1]=trk1->sig_l1[m]; |
225 |
ctrk.sig2[trk1->DSPnumber[m]-1]=trk1->sig_l2[m]; |
226 |
ctrk.sig3[trk1->DSPnumber[m]-1]=trk1->sig_l3[m]; |
227 |
ctrk.nbad1[trk1->DSPnumber[m]-1]=trk1->nbad_l1[m]; |
228 |
ctrk.nbad2[trk1->DSPnumber[m]-1]=trk1->nbad_l2[m]; |
229 |
ctrk.nbad3[trk1->DSPnumber[m]-1]=trk1->nbad_l3[m]; |
230 |
ctrk.calfl[trk1->DSPnumber[m]-1]=trk1->cal_flag[m]; |
231 |
ctrk.crc_c[trk1->DSPnumber[m]-1][0]=trk1->crc_cal[m][0]; |
232 |
ctrk.crc_c[trk1->DSPnumber[m]-1][1]=trk1->crc_cal[m][1]; |
233 |
ctrk.crc_c[trk1->DSPnumber[m]-1][2]=trk1->crc_cal[m][2]; |
234 |
ctrk.crc_hc[trk1->DSPnumber[m]-1]=trk1->crc_hcal[m]; |
235 |
for (Int_t j = 0; j < 3072; j++){ |
236 |
ctrk.dspped[trk1->DSPnumber[m]-1][j]=trk1->DSPped_par[m][j]; |
237 |
ctrk.dspsig[trk1->DSPnumber[m]-1][j]=trk1->DSPsig_par[m][j]; |
238 |
ctrk.dspbad[trk1->DSPnumber[m]-1][j]=trk1->DSPbad_par[m][j]; |
239 |
}; |
240 |
} |
241 |
} |
242 |
ph = eh2->GetPscuHeader(); |
243 |
FOBT[1]= ph->GetOrbitalTime(); |
244 |
if(trk2->DSPnumber[m]>0){ |
245 |
if(trk2->DSPnumber[m]<13){ |
246 |
ctrk.daqmode[trk2->DSPnumber[m]-1]=trk2->DAQmode[m]; |
247 |
ctrk.dspnum[trk2->DSPnumber[m]-1]=trk2->DSPnumber[m]; |
248 |
ctrk.calibnum[trk2->DSPnumber[m]-1]=trk2->calibnumber[m]; |
249 |
ctrk.ncalev[trk2->DSPnumber[m]-1]=trk2->ncalib_event[m]; |
250 |
ctrk.ped1[trk2->DSPnumber[m]-1]=trk2->ped_l1[m]; |
251 |
ctrk.ped2[trk2->DSPnumber[m]-1]=trk2->ped_l2[m]; |
252 |
ctrk.ped3[trk2->DSPnumber[m]-1]=trk2->ped_l3[m]; |
253 |
ctrk.sig1[trk2->DSPnumber[m]-1]=trk2->sig_l1[m]; |
254 |
ctrk.sig2[trk2->DSPnumber[m]-1]=trk2->sig_l2[m]; |
255 |
ctrk.sig3[trk2->DSPnumber[m]-1]=trk2->sig_l3[m]; |
256 |
ctrk.nbad1[trk2->DSPnumber[m]-1]=trk2->nbad_l1[m]; |
257 |
ctrk.nbad2[trk2->DSPnumber[m]-1]=trk2->nbad_l2[m]; |
258 |
ctrk.nbad3[trk2->DSPnumber[m]-1]=trk2->nbad_l3[m]; |
259 |
ctrk.calfl[trk2->DSPnumber[m]-1]=trk2->cal_flag[m]; |
260 |
ctrk.crc_c[trk1->DSPnumber[m]-1][0]=trk2->crc_cal[m][0]; |
261 |
ctrk.crc_c[trk1->DSPnumber[m]-1][1]=trk2->crc_cal[m][1]; |
262 |
ctrk.crc_c[trk1->DSPnumber[m]-1][2]=trk2->crc_cal[m][2]; |
263 |
ctrk.crc_hc[trk1->DSPnumber[m]-1]=trk2->crc_hcal[m]; |
264 |
for (Int_t j = 0; j < 3072; j++){ |
265 |
ctrk.dspped[trk2->DSPnumber[m]-1][j]=trk2->DSPped_par[m][j]; |
266 |
ctrk.dspsig[trk2->DSPnumber[m]-1][j]=trk2->DSPsig_par[m][j]; |
267 |
ctrk.dspbad[trk2->DSPnumber[m]-1][j]=trk2->DSPbad_par[m][j]; |
268 |
} |
269 |
} |
270 |
} |
271 |
} |
272 |
|
273 |
|
274 |
// |
275 |
// other variables definitions |
276 |
Int_t risposta=0; |
277 |
stringstream fromfile; |
278 |
|
279 |
fromfile<<"FTrkCalibQLook_EXPERT File: "<<ffile<<" -- CalibHeader OBT= "<<HOBT[(cod->Get(pctp->CalibHeader))-1]<<" -- Calib pkt OBT= "<<FOBT[0]<<" -- CalibTrailer OBT= "<<TOBT[(cod->Get(pctp->CalibTrailer))]<<" --"; |
280 |
|
281 |
gStyle->SetLabelSize(0.07,"x"); |
282 |
gStyle->SetLabelSize(0.07,"y"); |
283 |
gStyle->SetTitleFillColor(10); |
284 |
gStyle->SetTitleFontSize(0.08); |
285 |
gStyle->SetTitleOffset(0.8,"y"); |
286 |
gStyle->SetTitleOffset(0.9,"x"); |
287 |
gStyle->SetTitleSize(0.06,"y"); |
288 |
gStyle->SetTitleSize(0.06,"x"); |
289 |
gStyle->SetOptStat(101110); |
290 |
gStyle->SetStatX(0.9); |
291 |
gStyle->SetStatW(0.4); |
292 |
gStyle->SetStatColor(10); |
293 |
gStyle->SetStatFontSize(0.1); |
294 |
|
295 |
// |
296 |
// draw display area |
297 |
|
298 |
TLatex *tzz=new TLatex(); |
299 |
tzz->SetTextFont(32); |
300 |
tzz->SetTextColor(1); |
301 |
tzz->SetTextAlign(12); |
302 |
tzz->SetTextSize(0.019); |
303 |
Int_t canvasx=1200; |
304 |
Int_t canvasy=900; |
305 |
TCanvas *c1 = new TCanvas("c1","FTrkCalibQLook_EXPERT_ped",canvasx,canvasy); |
306 |
c1->SetFillColor(10); |
307 |
tzz->DrawLatex(.01,0.98,fromfile.str().c_str()); |
308 |
tzz->DrawLatex(.90,0.98,"PEDESTAL"); |
309 |
TCanvas *c2 = new TCanvas("c2","FTrkCalibQLook_EXPERT_sig",canvasx,canvasy); |
310 |
c2->SetFillColor(10); |
311 |
tzz->DrawLatex(.01,0.98,fromfile.str().c_str()); |
312 |
tzz->DrawLatex(.90,0.98,"SIGMA"); |
313 |
|
314 |
|
315 |
TCanvas *sig=new TCanvas("sig","FTrkCalibQLook_EXPERT_histosig",canvasx,canvasy); |
316 |
sig->SetFillColor(10); |
317 |
tzz->DrawLatex(.01,0.98,fromfile.str().c_str()); |
318 |
tzz->DrawLatex(.85,0.97,"Histograms of the sigmas"); |
319 |
|
320 |
|
321 |
|
322 |
// draw pads |
323 |
TPad *trkpad1[12],*trkpad2[12],*trkpad3[36]; //pad for histos |
324 |
TPaveText *trkpadtext[12]; //pad for header |
325 |
TH1F *histosig[12]; //histos of sigma |
326 |
TH1F *histoped[12]; //histos of pedestals |
327 |
TH1F *histoasig[12]; //histos of sigma |
328 |
TH1F *histoaped[12]; //histos of pedestals |
329 |
|
330 |
TH1F *histosiglad[12][3]; //histos of sigma |
331 |
stringstream title; |
332 |
stringstream hid; |
333 |
|
334 |
Float_t posy = 0.95; // up y-coord - top pads |
335 |
Float_t hpad = 0.15; // pad height |
336 |
Float_t posx1=0; // left x-coord - pad column |
337 |
Float_t posx2=0; // right x-coord - pad olumn |
338 |
Float_t posx0=0; // x-coord - column division |
339 |
Float_t wrel = 0.6; // relative x size of first sub-column |
340 |
Float_t marg = 0.004; // margin among pads |
341 |
|
342 |
|
343 |
for(Int_t n = 0; n<12; n++){ |
344 |
if ( (n+1)%2 ) { |
345 |
if(n>1)posy = posy-(marg*2+hpad); |
346 |
posx1 = marg; |
347 |
posx2 = 0.5 - marg; |
348 |
posx0 = 0.5*wrel; |
349 |
|
350 |
} else { |
351 |
posx1 = posx1 + 0.5; |
352 |
posx2 = posx2 + 0.5; |
353 |
posx0 = posx0 + 0.5; |
354 |
|
355 |
}; |
356 |
/* -----------> pad for histograms */ |
357 |
trkpad1[n] = new TPad("pad1"," ",posx1,posy-hpad,posx0-marg,posy,18,0,0); |
358 |
trkpad2[n] = new TPad("pad2"," ",posx1,posy-hpad,posx0-marg,posy,18,0,0); |
359 |
/* -----------> pad for header dump */ |
360 |
trkpadtext[n] = new TPaveText((posx0+marg),(posy-hpad),posx2,posy); |
361 |
/* -----------> HISTOGRAMS */ |
362 |
/* calibration parameters */ |
363 |
title<<"DSP "<<n+1; |
364 |
hid<<"h"<<n<<"i"<<i; |
365 |
histosig[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3072,0.5,3072.5); |
366 |
hid.str(""); |
367 |
hid<<"hh"<<n<<"i"<<i; |
368 |
histoped[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3072,0.5,3072.5); |
369 |
hid.str(""); |
370 |
hid<<"hhh"<<n<<"i"<<i; |
371 |
hid.str(""); |
372 |
/* AVERAGE calibration parameters */ |
373 |
hid<<"ah"<<n<<"i"<<i; |
374 |
histoasig[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3,0.5,3072.5); |
375 |
hid.str(""); |
376 |
hid<<"ahh"<<n<<"i"<<i; |
377 |
histoaped[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3,0.5,3072.5); |
378 |
hid.str(""); |
379 |
for(int ii=0;ii<3;ii++){ |
380 |
title.str(""); |
381 |
title<<"DSP "<<n+1<<" / Lad "<<ii+1; |
382 |
hid<<"hhhh"<<n<<"i"<<i<<"ii"<<ii; |
383 |
histosiglad[n][ii] = new TH1F(hid.str().c_str(),title.str().c_str(),32,-0.5,30.5); |
384 |
hid.str(""); |
385 |
} |
386 |
title.str(""); |
387 |
}; //end loop on views |
388 |
|
389 |
Float_t tposy = 0.95; // up y-coord - top pads |
390 |
Float_t thpad = 0.; // pad height |
391 |
Float_t tposx1=0; // left x-coord - pad column |
392 |
Float_t tposx0=0; // x-coord - column division |
393 |
Float_t twrel = 0.; // relative x size of first sub-column |
394 |
Float_t tmarg = 0.002; // margin among pads |
395 |
thpad = (tposy-tmarg*11)/6; |
396 |
twrel = (1-tmarg*12)/6; |
397 |
|
398 |
for(Int_t n = 0; n<36; n++){ |
399 |
if ( (n+1)%6==1 ) { |
400 |
if(n>1) tposy = tposy-(tmarg*2+thpad); |
401 |
tposx1 = tmarg; |
402 |
tposx0 = tposx1 + twrel; |
403 |
} else { |
404 |
tposx1 = tposx0 + 2*tmarg; |
405 |
tposx0 = tposx1 + twrel; |
406 |
} |
407 |
trkpad3[n]= new TPad("pad3"," ",tposx1,tposy-thpad,tposx0,tposy,18,0,0); |
408 |
} |
409 |
|
410 |
|
411 |
stringstream message; |
412 |
|
413 |
//-------------------------------- |
414 |
//CHECK CALIBRATION procedure |
415 |
//-------------------------------- |
416 |
Int_t nn=0; |
417 |
Int_t calok = 0;//BAD |
418 |
for(Int_t n = 0; n<12; n++){ |
419 |
if(ctrk.ncalev[n]==0 && ctrk.calfl[n]==0)calok = 1;//GOOD |
420 |
|
421 |
|
422 |
nn=ctrk.dspnum[n]-1; |
423 |
/*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.* |
424 |
* |
425 |
* Write event LEVEL0 report |
426 |
* |
427 |
*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*/ |
428 |
trkpadtext[nn]->SetTextFont(40); |
429 |
trkpadtext[nn]->SetFillColor(33); |
430 |
if(calok==0)trkpadtext[nn]->SetFillColor(2); |
431 |
trkpadtext[nn]->SetTextSize(0.013); |
432 |
trkpadtext[nn]->SetTextAlign(13); |
433 |
trkpadtext[nn]->SetTextColor(1); |
434 |
|
435 |
trkpadtext[nn]->AddText(" "); |
436 |
message<<"DSP num --------> "<<ctrk.dspnum[n]; |
437 |
trkpadtext[nn]->AddText(message.str().c_str()); |
438 |
message.str(""); |
439 |
message<<"DAQ mode -------> "<<ctrk.daqmode[n]; |
440 |
trkpadtext[nn]->AddText(message.str().c_str()); |
441 |
message.str(""); |
442 |
message<<"Calibnumber ----> "<<ctrk.calibnum[n]; |
443 |
trkpadtext[nn]->AddText(message.str().c_str()); |
444 |
message.str(""); |
445 |
message<<"ncalib_event ---> "<<ctrk.ncalev[n]; |
446 |
trkpadtext[nn]->AddText(message.str().c_str()); |
447 |
message.str(""); |
448 |
message<<"Cal_flag -------> "<<ctrk.calfl[n]; |
449 |
trkpadtext[nn]->AddText(message.str().c_str()); |
450 |
message.str(""); |
451 |
message<<"crc_hcal -------> "<<ctrk.crc_hc[n]; |
452 |
trkpadtext[nn]->AddText(message.str().c_str()); |
453 |
message.str(""); |
454 |
message<<"crc_cal: l1- ";message.width(5);message<< ctrk.crc_c[n][0]; |
455 |
message<<" l2- ";message.width(5);message<< ctrk.crc_c[n][1]; |
456 |
message<<" l3- ";message.width(5);message<< ctrk.crc_c[n][2]; |
457 |
trkpadtext[nn]->AddText(message.str().c_str()); |
458 |
message.str(""); |
459 |
message<<"<PED>: l1- "; message.width(5);message<< ctrk.ped1[n]; |
460 |
message<<" l2-"; message.width(5);message<< ctrk.ped2[n]; |
461 |
message<<" l3-"; message.width(5);message<< ctrk.ped3[n]; |
462 |
trkpadtext[nn]->AddText(message.str().c_str()); |
463 |
message.str(""); |
464 |
message<<"<SIG>: l1- "; message.width(5);message<< ctrk.sig1[n]; |
465 |
message<<" l2-"; message.width(5);message<< ctrk.sig2[n]; |
466 |
message<<" l3-"; message.width(5);message<< ctrk.sig3[n]; |
467 |
trkpadtext[nn]->AddText(message.str().c_str()); |
468 |
message.str(""); |
469 |
message<<"n.BAD: l1- "; message.width(5);message<<ctrk.nbad1[n]; |
470 |
message<<" l2-"; message.width(5);message<< ctrk.nbad2[n]; |
471 |
message<<" l3-"; message.width(5);message<< ctrk.nbad3[n]; |
472 |
trkpadtext[nn]->AddText(message.str().c_str()); |
473 |
message.str(""); |
474 |
|
475 |
if(calok==0){ |
476 |
|
477 |
message.str("*** FAILED ***"); |
478 |
TText *t=trkpadtext[nn]->AddText(message.str().c_str()); |
479 |
t->SetTextSize(0.02); |
480 |
t->SetTextAlign(23); |
481 |
t->SetTextColor(5); |
482 |
}; |
483 |
|
484 |
/*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.* |
485 |
* |
486 |
* Plot histo |
487 |
* |
488 |
*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*/ |
489 |
|
490 |
|
491 |
/******************************************************/ |
492 |
/* fill histos */ |
493 |
for(Int_t j = 0; j < 3072; j++){ |
494 |
histosig[nn]->Fill((Float_t)j,ctrk.dspsig[nn][j]); |
495 |
histoped[nn]->Fill((Float_t)j,ctrk.dspped[nn][j]); |
496 |
if(j<1024) histosiglad[nn][0]->Fill(ctrk.dspsig[nn][j]); |
497 |
if(j>=1024 && j<2048) histosiglad[nn][1]->Fill(ctrk.dspsig[nn][j]); |
498 |
if(j>=2048 && j<3072) histosiglad[nn][2]->Fill(ctrk.dspsig[nn][j]); |
499 |
}; |
500 |
histoasig[nn]->Fill(1,ctrk.sig1[nn]); |
501 |
histoasig[nn]->Fill(1025,ctrk.sig2[nn]); |
502 |
histoasig[nn]->Fill(2049,ctrk.sig3[nn]); |
503 |
histoaped[nn]->Fill(1,ctrk.ped1[nn]); |
504 |
histoaped[nn]->Fill(1025,ctrk.ped2[nn]); |
505 |
histoaped[nn]->Fill(2049,ctrk.ped3[nn]); |
506 |
/******************************************************/ |
507 |
|
508 |
TLine li; |
509 |
li.SetLineColor(38); |
510 |
li.SetLineStyle(3); |
511 |
li.SetLineWidth(2); |
512 |
|
513 |
Float_t maxhist=0; |
514 |
TBox b; |
515 |
/* plot PEDESTAL */ |
516 |
c1->cd(); |
517 |
trkpadtext[nn]->Draw(); |
518 |
trkpad1[nn]->Draw(); |
519 |
trkpad1[nn]->cd(); |
520 |
trkpad1[nn]->SetFillColor(10); |
521 |
trkpad1[nn]->SetFrameFillColor(10); |
522 |
histoped[nn]->SetStats(kFALSE); |
523 |
histoped[nn]->SetLineColor(1); |
524 |
histoped[nn]->SetFillColor(12); |
525 |
histoped[nn]->SetLineWidth(1); |
526 |
histoped[nn]->GetYaxis()->SetTitle("PED (ADC channels)"); |
527 |
histoped[nn]->GetYaxis()->CenterTitle(); |
528 |
if((nn+1)%2==1) histoped[nn]->GetYaxis()->SetRangeUser(2200,3200); |
529 |
if((nn+1)%2==0) histoped[nn]->GetYaxis()->SetRangeUser(700,1700); |
530 |
histoaped[nn]->SetLineColor(5); |
531 |
histoaped[nn]->SetLineWidth(1); |
532 |
if(ctrk.good0[0]==1 && ctrk.good0[1]==1){ |
533 |
histoped[nn]->Draw("b"); |
534 |
if(nn==1){ |
535 |
maxhist=histoped[nn]->GetMaximum(); |
536 |
b.SetFillColor(6); |
537 |
b.SetFillStyle(3945); |
538 |
b.DrawBox(2944.,700.,3060.,maxhist); |
539 |
|
540 |
b.SetFillColor(107); |
541 |
b.SetFillStyle(3954); |
542 |
b.DrawBox(2816.,700.,2944.,maxhist); |
543 |
b.DrawBox(2048.,700.,2176.,maxhist); |
544 |
} |
545 |
else if(nn==4){ |
546 |
maxhist=histoped[nn]->GetMaximum(); |
547 |
b.SetFillColor(107); |
548 |
b.SetFillStyle(3954); |
549 |
b.DrawBox(384.,2200.,512.,maxhist); |
550 |
} |
551 |
else if(nn==6){ |
552 |
maxhist=histoped[nn]->GetMaximum(); |
553 |
b.SetFillColor(6); |
554 |
b.SetFillStyle(3945); |
555 |
b.DrawBox(2560.,2200.,2816.,maxhist); |
556 |
b.DrawBox(1024.,2200.,1535.,maxhist); |
557 |
|
558 |
b.SetFillColor(107); |
559 |
b.SetFillStyle(3954); |
560 |
b.DrawBox(512.,2200.,768.,maxhist); |
561 |
b.DrawBox(1536.,2200.,1792.,maxhist); |
562 |
} |
563 |
else if(nn==7){ |
564 |
maxhist=histoped[nn]->GetMaximum(); |
565 |
b.SetFillColor(107); |
566 |
b.SetFillStyle(3954); |
567 |
b.DrawBox(512.,700.,768.,maxhist); |
568 |
} |
569 |
else if(nn==9){ |
570 |
maxhist=histoped[nn]->GetMaximum(); |
571 |
b.SetFillColor(107); |
572 |
b.SetFillStyle(3954); |
573 |
b.DrawBox(256.,700.,384.,maxhist); |
574 |
} |
575 |
else if(nn==11){ |
576 |
maxhist=histoped[nn]->GetMaximum(); |
577 |
b.SetFillColor(6); |
578 |
b.SetFillStyle(3945); |
579 |
b.DrawBox(768.,700.,1024.,maxhist); |
580 |
|
581 |
b.SetFillColor(107); |
582 |
b.SetFillStyle(3954); |
583 |
b.DrawBox(0.,700.,512.,maxhist); |
584 |
b.DrawBox(1920.,700.,2048.,maxhist); |
585 |
b.DrawBox(2176.,700.,2304.,maxhist); |
586 |
} |
587 |
} |
588 |
else histoped[nn]->Draw("axis"); |
589 |
histoaped[nn]->Draw("same"); |
590 |
if((nn+1)%2==1) { |
591 |
li.DrawLine(1024.5,2200,1024.5,3200); |
592 |
li.DrawLine(2048.5,2200,2048.5,3200); |
593 |
} |
594 |
if((nn+1)%2==0) { |
595 |
li.DrawLine(1024.5,700,1024.5,1700); |
596 |
li.DrawLine(2048.5,700,2048.5,1700); |
597 |
} |
598 |
|
599 |
|
600 |
|
601 |
/* plot SIGMA */ |
602 |
Float_t max=500.; |
603 |
c2->cd(); |
604 |
trkpadtext[nn]->Draw(); |
605 |
trkpad2[nn]->SetLogy(); |
606 |
trkpad2[nn]->Draw(); |
607 |
trkpad2[nn]->cd(); |
608 |
trkpad2[nn]->SetFillColor(10); |
609 |
trkpad2[nn]->SetFrameFillColor(10); |
610 |
histosig[nn]->SetStats(kFALSE); |
611 |
histosig[nn]->SetLineColor(1); |
612 |
histosig[nn]->SetFillColor(12); |
613 |
histosig[nn]->SetLineWidth(1); |
614 |
histosig[nn]->SetMaximum(max); |
615 |
histosig[nn]->SetMinimum(0.5); |
616 |
histosig[nn]->GetYaxis()->SetTitle("SIG (ADC channels)"); |
617 |
histosig[nn]->GetYaxis()->CenterTitle(); |
618 |
histoasig[nn]->SetLineColor(5); |
619 |
histoasig[nn]->SetLineWidth(1); |
620 |
if(ctrk.good0[0]==1 && ctrk.good0[1]==1){ |
621 |
histosig[nn]->Draw("b"); |
622 |
if(nn==1){ |
623 |
maxhist=histosig[nn]->GetMaximum(); |
624 |
b.SetFillColor(6); |
625 |
b.SetFillStyle(3945); |
626 |
b.DrawBox(2944.,0.,3060.,maxhist); |
627 |
|
628 |
b.SetFillColor(107); |
629 |
b.SetFillStyle(3954); |
630 |
b.DrawBox(2816.,0.,2944.,maxhist); |
631 |
b.DrawBox(2048.,0.,2176.,maxhist); |
632 |
} |
633 |
else if(nn==4){ |
634 |
maxhist=histosig[nn]->GetMaximum(); |
635 |
b.SetFillColor(107); |
636 |
b.SetFillStyle(3954); |
637 |
b.DrawBox(384.,0.,512.,maxhist); |
638 |
} |
639 |
else if(nn==6){ |
640 |
maxhist=histosig[nn]->GetMaximum(); |
641 |
b.SetFillColor(6); |
642 |
b.SetFillStyle(3945); |
643 |
b.DrawBox(2560.,0.,2816.,maxhist); |
644 |
b.DrawBox(1024.,0.,1535.,maxhist); |
645 |
|
646 |
b.SetFillColor(107); |
647 |
b.SetFillStyle(3954); |
648 |
b.DrawBox(512.,0.,768.,maxhist); |
649 |
b.DrawBox(1536.,0.,1792.,maxhist); |
650 |
} |
651 |
else if(nn==7){ |
652 |
maxhist=histosig[nn]->GetMaximum(); |
653 |
b.SetFillColor(107); |
654 |
b.SetFillStyle(3954); |
655 |
b.DrawBox(512.,0.,768.,maxhist); |
656 |
} |
657 |
else if(nn==9){ |
658 |
maxhist=histosig[nn]->GetMaximum(); |
659 |
b.SetFillColor(107); |
660 |
b.SetFillStyle(3954); |
661 |
b.DrawBox(256.,0.,384.,maxhist); |
662 |
} |
663 |
else if(nn==11){ |
664 |
maxhist=histosig[nn]->GetMaximum(); |
665 |
b.SetFillColor(6); |
666 |
b.SetFillStyle(3945); |
667 |
b.DrawBox(768.,0.,1024.,maxhist); |
668 |
|
669 |
b.SetFillColor(107); |
670 |
b.SetFillStyle(3954); |
671 |
b.DrawBox(0.,0.,512.,maxhist); |
672 |
b.DrawBox(1920.,0.,2048.,maxhist); |
673 |
b.DrawBox(2176.,0.,2304.,maxhist); |
674 |
} |
675 |
} |
676 |
else histosig[nn]->Draw("axis"); |
677 |
histoasig[nn]->Draw("same"); |
678 |
li.DrawLine(1024.5,0,1024.5,max); |
679 |
li.DrawLine(2048.5,0,2048.5,max); |
680 |
|
681 |
for(int ii=0;ii<3;ii++){ |
682 |
sig->cd(); |
683 |
trkpad3[nn*3+ii]->Draw(); |
684 |
trkpad3[nn*3+ii]->cd(); |
685 |
trkpad3[nn*3+ii]->SetFillColor(10); |
686 |
trkpad3[nn*3+ii]->SetFrameFillColor(10); |
687 |
trkpad3[nn*3+ii]->SetLogy(); |
688 |
histosiglad[nn][ii]->SetLineColor(1); |
689 |
histosiglad[nn][ii]->SetFillColor(1); |
690 |
histosiglad[nn][ii]->SetLineWidth(1); |
691 |
histosiglad[nn][ii]->GetXaxis()->SetTitle("SIG (ADC channels)"); |
692 |
histosiglad[nn][ii]->GetXaxis()->CenterTitle(); |
693 |
histosiglad[nn][ii]->Draw(""); |
694 |
} |
695 |
|
696 |
};//end loop on views |
697 |
c1->Update();//draw pads in canvas |
698 |
c2->Update();//draw pads in canvas |
699 |
sig->Update();//draw pads in canvas |
700 |
|
701 |
stringstream nom1,nom2,nom3; |
702 |
|
703 |
if(!strcmp(outfile.Data(),"ps")||!strcmp(outfile.Data(),"pdf")){ |
704 |
nom1.str(""); |
705 |
nom2.str(""); |
706 |
nom3.str(""); |
707 |
nom1<<out<<ffile<<"_FTrkCalibQLook_EXPERT-pkt"<<i+1<<".ps("; |
708 |
nom2<<out<<ffile<<"_FTrkCalibQLook_EXPERT-pkt"<<i+1<<".ps"; |
709 |
nom3<<out<<ffile<<"_FTrkCalibQLook_EXPERT-pkt"<<i+1<<".ps)"; |
710 |
c1->Print(nom1.str().c_str(),"Landscape"); |
711 |
c2->Print(nom2.str().c_str(),"Landscape"); |
712 |
sig->Print(nom3.str().c_str(),"Landscape"); |
713 |
|
714 |
if(!strcmp(outfile.Data(),"pdf")){ |
715 |
stringstream com; |
716 |
com<<"ps2pdf13 "<<out<<ffile<<"_FTrkCalibQLook_EXPERT-pkt"<<i+1<<".ps "<<out<<ffile<<"_FTrkCalibQlook_EXPERT-pkt"<<i+1<<".pdf"; |
717 |
system(com.str().c_str()); |
718 |
printf("\n---> ps file converted in pdf format!\n"); |
719 |
com.str(""); |
720 |
com<<"rm -f "<<out<<ffile<<"_FTrkCalibQLook_EXPERT-pkt"<<i+1<<".ps"; |
721 |
system(com.str().c_str()); |
722 |
printf("---> ps file removed!\n\n"); |
723 |
com.str(""); |
724 |
} |
725 |
} |
726 |
else{ |
727 |
nom1.str(""); |
728 |
nom2.str(""); |
729 |
nom3.str(""); |
730 |
nom1<<out<<ffile<<"_FTrkCalibQLook_EXPERT-ped-pkt"<<i+1<<"."<<outfile.Data(); |
731 |
nom2<<out<<ffile<<"_FTrkCalibQLook_EXPERT-sig-pkt"<<i+1<<"."<<outfile.Data(); |
732 |
nom3<<out<<ffile<<"_FTrkCalibQLook_EXPERT-histosig-pkt"<<i+1<<"."<<outfile.Data(); |
733 |
c1->Print(nom1.str().c_str()); |
734 |
c2->Print(nom2.str().c_str()); |
735 |
sig->Print(nom3.str().c_str()); |
736 |
} |
737 |
|
738 |
if(step==1 && i!=maxevent-1 ){ |
739 |
printf("\n Press 1<enter> to continue, 2<enter> to quit.\n"); |
740 |
cin>>risposta; |
741 |
if ( i != maxevent-1 ) { |
742 |
if ( risposta == 2 ) { |
743 |
gROOT->Reset(); |
744 |
printf("Exiting...\n"); |
745 |
return; |
746 |
} |
747 |
} |
748 |
} |
749 |
};//end loop on events |
750 |
|
751 |
gROOT->Reset(); |
752 |
printf("... end of packets. \n"); |
753 |
return; |
754 |
} |
755 |
|
756 |
|