1 |
// |
2 |
// Check the calorimter calibrations - Emiliano Mocchiutti |
3 |
// |
4 |
// FCaloCHKCALIB.c version 1.13 (2006-09-22) |
5 |
// |
6 |
// The only input needed is the path to the directory created by YODA for the data file you want to analyze. |
7 |
// |
8 |
// Changelog: |
9 |
// |
10 |
// 1.12 - 1.13 (2006-09-22): Set upper limit in calvar plot. |
11 |
// |
12 |
// 1.07 - 1.12 (2006-08-04): bugs fixed. |
13 |
// |
14 |
// 1.07 - 1.11 (2006-07-17): Adapted to flight conditions. |
15 |
// |
16 |
// 1.06 - 1.07 (2006-05-29): Fixed bug in output filename when input is not in the form DW_YYMMDD_NNN. Changed threshold for bad strip warning (from 0.005 to 0.03). |
17 |
// |
18 |
// 1.05 - 1.06 (2006-03-22): Add optimize flag in compiling the script! |
19 |
// |
20 |
// 1.04 - 1.05 (2006-03-22): Corrected wrong .C files. |
21 |
// |
22 |
// 1.03 - 1.04 (2006-03-20): Documentation updated. |
23 |
// |
24 |
// 1.02 - 1.03 (2006-03-20): Changed name of shared libraries (for example from FCaloQLOOK_cxx.so to libFCaloQLOOK.so). |
25 |
// |
26 |
// 1.01 - 1.02 (2006-03-13): Include files from YODA without "event" directory. |
27 |
// |
28 |
// 1.00 - 1.01 (2006-03-02): Works on YODA v6 output (single file), does not require anymore calocommon package. |
29 |
// |
30 |
// 0.00 - 1.00 (2006-03-02): Clone of CaloCHKCALIB.c |
31 |
// |
32 |
#include <iostream> |
33 |
#include <fstream> |
34 |
// |
35 |
#include <TTree.h> |
36 |
#include <TObject.h> |
37 |
#include <TString.h> |
38 |
#include <TFile.h> |
39 |
#include <TCanvas.h> |
40 |
#include <TH1.h> |
41 |
#include <TPolyLine.h> |
42 |
#include <TH1F.h> |
43 |
#include <TH2D.h> |
44 |
#include <TLatex.h> |
45 |
#include <TPad.h> |
46 |
#include <TPaveLabel.h> |
47 |
#include <TStyle.h> |
48 |
#include <TSystem.h> |
49 |
#include <TApplication.h> |
50 |
// |
51 |
#include <CalibCalPedEvent.h> |
52 |
#include <PamelaRun.h> |
53 |
// |
54 |
using namespace std; |
55 |
// |
56 |
void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){ |
57 |
if ( to == 0 ){ |
58 |
Int_t t2length = s2.Length(); |
59 |
s1 = ""; |
60 |
to = t2length; |
61 |
}; |
62 |
for (Int_t i = from; i<to; i++){ |
63 |
s1.Append(s2[i],1); |
64 |
}; |
65 |
} |
66 |
void stringappend(TString& s1, const TString& s2){ |
67 |
Int_t t2length = s2.Length(); |
68 |
for (Int_t i = 0; i<t2length; i++){ |
69 |
s1.Append(s2[i],1); |
70 |
}; |
71 |
} |
72 |
|
73 |
TString getFilename(const TString filename){ |
74 |
// |
75 |
const string fil = gSystem->BaseName(filename.Data()); |
76 |
Int_t posiz = fil.find(".root"); |
77 |
// |
78 |
TString file2; |
79 |
if ( posiz == -1 ){ |
80 |
file2 = gSystem->BaseName(filename.Data()); |
81 |
} else { |
82 |
Int_t posiz2 = 0; |
83 |
stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz); |
84 |
TString pdat(".dat"); |
85 |
stringappend(file2,pdat); |
86 |
}; |
87 |
return file2; |
88 |
} |
89 |
|
90 |
typedef struct Calib { |
91 |
Int_t iev; |
92 |
Int_t cstwerr[4];//per l'header contenente lo stato del calorimetro |
93 |
Float_t cperror[4]; |
94 |
Float_t mip[2][22][96];//(xy,piano,strip) |
95 |
Float_t calped[2][22][96]; |
96 |
Float_t calgood[2][22][96]; |
97 |
Float_t calthr[2][22][6]; |
98 |
Float_t calrms[2][22][96]; |
99 |
Float_t calbase[2][22][6]; |
100 |
Float_t calvar[2][22][6]; |
101 |
Float_t calpuls[2][22][96]; |
102 |
} calib; |
103 |
|
104 |
|
105 |
|
106 |
//main |
107 |
void FCaloCHKCALIB(TString filename, Long64_t calibnumber = 0, TString outDir = "", Int_t figmatra = 0, TString saveas = "png", Bool_t iactive =false, Bool_t w4i=false){ |
108 |
|
109 |
gStyle->SetPaperSize(19.,25.); |
110 |
// |
111 |
TApplication *app = 0; //crea un ambiente root (app) |
112 |
if ( iactive ) app = new TApplication("app",0,0);//verifica se deve essere interattivo |
113 |
// |
114 |
//definizione delle soglie per valutare problemi nell calibrazione |
115 |
Float_t ccalrmsthr=0.95;// numero di strip con rms entro i limiti (99%) |
116 |
Float_t ccalpedthr=0.95;// numero di strip con piedistallo entro i limiti(99%) |
117 |
Float_t ccalbadthr=0.03;// 0.005 numero massimo di strip non utilizzate (3%) per calibrare |
118 |
Float_t ccalthrthr=0.95; |
119 |
Float_t ccalvarthr=0.95; |
120 |
Float_t ccalbasthr=0.95; |
121 |
// |
122 |
Float_t ccalrms = 0.; |
123 |
Float_t ccalped = 0.; |
124 |
Float_t ccalbad = 0.; |
125 |
Float_t ccalthr = 0.; |
126 |
Float_t ccalvar = 0.; |
127 |
Float_t ccalbas = 0.; |
128 |
// |
129 |
struct Calib calib; |
130 |
stringstream titolo, sottotitolo; |
131 |
stringstream xviewev; |
132 |
stringstream yviewev; |
133 |
|
134 |
//directory di lavoro |
135 |
const char* startingdir = gSystem->WorkingDirectory(); |
136 |
if ( !strcmp(outDir.Data(),"") ) outDir = startingdir; |
137 |
|
138 |
//nome del file |
139 |
TString fififile = getFilename(filename); |
140 |
const char *file; |
141 |
file = fififile; |
142 |
|
143 |
//verifica se esiste il file |
144 |
ifstream myfile; |
145 |
myfile.open(filename.Data()); |
146 |
if ( !myfile ){ |
147 |
printf(" %s :no such file, exiting...\n\n",filename.Data()); |
148 |
return; |
149 |
}; |
150 |
myfile.close(); |
151 |
// |
152 |
|
153 |
//apre il file in 'File' |
154 |
TFile *File = new TFile(filename.Data()); |
155 |
|
156 |
//crea struttura tree (tr) con il tree "CalibCalPed" in File |
157 |
TTree *tr = (TTree*)File->Get("CalibCalPed"); |
158 |
//definisco struttura tree per caricare gli header cpu |
159 |
TTree *cpuhe = (TTree*)File->Get("CalibHeader"); |
160 |
|
161 |
if ( !tr ) { |
162 |
printf(" CalibCalPed : no such tree in %s \n",filename.Data()); |
163 |
printf(" Exiting, are you sure this is a LEVEL0 not corrupted file? \n\n"); |
164 |
return; |
165 |
}; |
166 |
|
167 |
pamela::CalibCalPedEvent *ce = 0; |
168 |
pamela::EventHeader *eh = 0;//definisco variabili di tipo header |
169 |
pamela::EventHeader *ch =0;//definisco la variabile per header cpu |
170 |
// pamela::PscuHeader *ph = 0; //definisco variabile di tipo pscu |
171 |
|
172 |
// |
173 |
//UInt_t found; |
174 |
UInt_t cpuobt=0, obt=0, obt0=0, obt1=0, obt2=0, obt3=0; |
175 |
|
176 |
// tr->SetBranchStatus("*",0,&found); //disable all branches |
177 |
// |
178 |
// found = 0; |
179 |
// tr->SetBranchStatus("iev*",1,&found); |
180 |
// found = 0; |
181 |
// tr->SetBranchStatus("cstwerr*",1,&found); |
182 |
// // printf("enabled %i branches \n",found); |
183 |
// found = 0; |
184 |
// tr->SetBranchStatus("cperror*",1,&found); |
185 |
// //printf("enabled %i branches \n",found); |
186 |
// found = 0; |
187 |
// tr->SetBranchStatus("cal*",1,&found); |
188 |
// //printf("enabled %i branches \n",found); |
189 |
// found = 0; |
190 |
// tr->SetBranchStatus("CalibCalPed*",1,&found); |
191 |
//printf("enabled %i branches \n",found); |
192 |
// |
193 |
tr->SetBranchAddress("CalibCalPed", &ce);//dichiaro in che ramo trovare quello che voglio puntare con ce |
194 |
tr->SetBranchAddress("Header", &eh);//dichiaro dove trovare quello che voglio in he |
195 |
// |
196 |
cpuhe->SetBranchAddress("Header",&ch); |
197 |
// |
198 |
Long64_t ncalibs = tr->GetEntries();//cerca il ramo Entries (calibrazioni) |
199 |
if ( ncalibs == 0 ){ |
200 |
printf(" No calibrations in this files! \n Exiting... \n"); |
201 |
return; |
202 |
}; |
203 |
printf("\n This file contains %i entries which corrispond to %i calibrations \n\n",(int)ncalibs,(int)ncalibs/4); |
204 |
Long64_t minev = 0; |
205 |
Long64_t maxev = ncalibs; |
206 |
if ( calibnumber ){//calibnumber e' in ingresso nel main |
207 |
minev = (calibnumber - 1)* 4; |
208 |
maxev = minev + 4; |
209 |
}; |
210 |
TCanvas *figura1;//finestra grafica che posso suddividere in piu' aree (pads) |
211 |
TCanvas *figura2 = 0; |
212 |
TCanvas *figura3; |
213 |
TCanvas *rapporto = 0; |
214 |
Int_t cmask = 127 ;//maschera per selezionare i Byte di errore dall'header |
215 |
Int_t cestw = 0; //variabile per contenere i Byte di errore del calorimetro estratti dall'header |
216 |
Int_t ver[4][23]; //variabile per riportare gli errori(22) su ogni sezione (4) |
217 |
|
218 |
//azzera ver |
219 |
for (Int_t k = 0; k < 4; k++ ){ |
220 |
for (Int_t m = 0; m < 23 ; m++ ){ |
221 |
ver[k][m] = 0 ; |
222 |
}; |
223 |
}; |
224 |
// |
225 |
// |
226 |
const string fil = gSystem->BaseName(filename.Data()); |
227 |
Int_t posiz = fil.find(".root"); |
228 |
// |
229 |
TString file2; |
230 |
if ( posiz == -1 ){ |
231 |
file2 = gSystem->BaseName(filename.Data()); |
232 |
} else { |
233 |
Int_t posiz2 = 0; |
234 |
stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz); |
235 |
}; |
236 |
const char *figrec = file2; |
237 |
// |
238 |
const char *outdir = outDir; |
239 |
const char *format = saveas; |
240 |
stringstream figsave; //definisco stringhe i/o |
241 |
stringstream figsave1; |
242 |
stringstream figsave2; |
243 |
// |
244 |
|
245 |
//-----------------inizio CHECK per ricerca errori dal calorimetro------------------- |
246 |
// to check or not to check? this is the problem... |
247 |
|
248 |
Bool_t check = false;//azzera flag presenza errori |
249 |
|
250 |
// |
251 |
//inizio loop su tutti gli header degli eventi di calibrazione |
252 |
for (Int_t ci = minev; ci < maxev ; ci+=4){ |
253 |
//scorre i pacchetti di 4 in 4 (cioe scorre le calibrazioni) |
254 |
Int_t incalrms = 0; |
255 |
Int_t outcalrms = 0; |
256 |
Int_t totcalbad = 0; |
257 |
Int_t incalped = 0; |
258 |
Int_t outcalped = 0; |
259 |
Int_t incalthr = 0; |
260 |
Int_t outcalthr = 0; |
261 |
Int_t incalvar = 0; |
262 |
Int_t outcalvar = 0; |
263 |
Int_t incalbas = 0; |
264 |
Int_t outcalbas = 0; |
265 |
//dall'albero calibheader, cerco obt dell cpu |
266 |
cpuhe->GetEntry(ci/4); |
267 |
cpuobt=ch->GetPscuHeader()->GetOrbitalTime(); |
268 |
obt0=0; |
269 |
obt1=0; |
270 |
obt2=0; |
271 |
obt3=0; |
272 |
|
273 |
//inizio loop su i 4 pacchetti per ogni calibrazione (scorre 4 successivi) |
274 |
for ( Int_t s=0 ; s<4 ;s++ ){ |
275 |
|
276 |
tr->GetEntry(ci+s);//sceglie la entry (calibrazione)del tree in cui ho tutte le sottostrutture |
277 |
|
278 |
|
279 |
//trovo l'OBT della entry (pacchetto) |
280 |
obt=eh->GetPscuHeader()->GetOrbitalTime();//cerca orbitaltime all'interno di Pscu |
281 |
/// |
282 |
|
283 |
|
284 |
calib.iev = ce->iev; |
285 |
cestw = 0; |
286 |
//cstwerr e' tutto l'header della sezione, mi interessano gli ultimi 2 Byte(errori del calorimetro) |
287 |
if ( ce->cstwerr[s] ){ |
288 |
cestw = ce->cstwerr[s] & cmask ; //confronto con la maschera per tenere solo gli |
289 |
ver[s][16]++;// ultimi 2 Byte (assegnati a cestw) |
290 |
}; |
291 |
if ( cestw ){//errori dal calorimetro |
292 |
if ( cestw & (1 << 0) ) ver[s][6]++ ;//spostati di uno e confronto se diverso 0 |
293 |
if ( cestw & (1 << 1) ) ver[s][5]++ ; |
294 |
if ( cestw & (1 << 2) ) ver[s][4]++ ; |
295 |
if ( cestw & (1 << 3) ) ver[s][3]++ ; |
296 |
if ( cestw & (1 << 4) ) ver[s][2]++ ; |
297 |
if ( cestw & (1 << 5) ) ver[s][1]++ ; |
298 |
if ( cestw & (1 << 6) ) ver[s][0]++ ; |
299 |
}; |
300 |
if ( ce->cperror[s] != 0. ){//errori dallo spacchettamento |
301 |
if (ce->cperror[s] == 128) ver[s][7]++ ; |
302 |
if (ce->cperror[s] == 129) ver[s][8]++ ; |
303 |
if (ce->cperror[s] == 130) { |
304 |
ver[s][9]++ ; |
305 |
ver[s][16]--; |
306 |
}; |
307 |
if (ce->cperror[s] == 132) ver[s][11]++ ; |
308 |
if (ce->cperror[s] == 140) ver[s][19]++ ; |
309 |
if (ce->cperror[s] == 141) ver[s][20]++ ; |
310 |
if (ce->cperror[s] == 142) ver[s][22]++ ; |
311 |
}; |
312 |
//lato oscuro :p |
313 |
for ( Int_t d=0 ; d<11 ;d++ ){ |
314 |
Int_t pre = -1; |
315 |
for ( Int_t j=0; j<96 ;j++){ |
316 |
if ( j%16 == 0 ) pre++; |
317 |
if ( s == 2 ){ |
318 |
//aggiungo obt del pacchetto che sta leggendo(obt) |
319 |
obt2=obt; |
320 |
calib.calped[0][2*d+1][j] = ce->calped[3][d][j]; |
321 |
calib.cstwerr[3] = ce->cstwerr[3]; |
322 |
calib.cperror[3] = ce->cperror[3]; |
323 |
calib.calgood[0][2*d+1][j] = ce->calgood[3][d][j]; |
324 |
calib.calthr[0][2*d+1][pre] = ce->calthr[3][d][pre]; |
325 |
calib.calrms[0][2*d+1][j] = ce->calrms[3][d][j]; |
326 |
calib.calbase[0][2*d+1][pre] = ce->calbase[3][d][pre]; |
327 |
calib.calvar[0][2*d+1][pre] = ce->calvar[3][d][pre]; |
328 |
}; |
329 |
if ( s == 3 ){ |
330 |
obt3=obt; |
331 |
calib.calped[0][2*d][j] = ce->calped[1][d][j]; |
332 |
calib.cstwerr[1] = ce->cstwerr[1]; |
333 |
calib.cperror[1] = ce->cperror[1]; |
334 |
calib.calgood[0][2*d][j] = ce->calgood[1][d][j]; |
335 |
calib.calthr[0][2*d][pre] = ce->calthr[1][d][pre]; |
336 |
calib.calrms[0][2*d][j] = ce->calrms[1][d][j]; |
337 |
calib.calbase[0][2*d][pre] = ce->calbase[1][d][pre]; |
338 |
calib.calvar[0][2*d][pre] = ce->calvar[1][d][pre]; |
339 |
}; |
340 |
if ( s == 0 ){ |
341 |
obt0=obt; |
342 |
calib.calped[1][2*d][j] = ce->calped[0][d][j]; |
343 |
calib.cstwerr[0] = ce->cstwerr[0]; |
344 |
calib.cperror[0] = ce->cperror[0]; |
345 |
calib.calgood[1][2*d][j] = ce->calgood[0][d][j]; |
346 |
calib.calthr[1][2*d][pre] = ce->calthr[0][d][pre]; |
347 |
calib.calrms[1][2*d][j] = ce->calrms[0][d][j]; |
348 |
calib.calbase[1][2*d][pre] = ce->calbase[0][d][pre]; |
349 |
calib.calvar[1][2*d][pre] = ce->calvar[0][d][pre]; |
350 |
}; |
351 |
if ( s == 1 ){ |
352 |
obt1=obt; |
353 |
calib.calped[1][2*d+1][j] = ce->calped[2][d][j]; |
354 |
calib.cstwerr[2] = ce->cstwerr[2]; |
355 |
calib.cperror[2] = ce->cperror[2]; |
356 |
calib.calgood[1][2*d+1][j] = ce->calgood[2][d][j]; |
357 |
calib.calthr[1][2*d+1][pre] = ce->calthr[2][d][pre]; |
358 |
calib.calrms[1][2*d+1][j] = ce->calrms[2][d][j]; |
359 |
calib.calbase[1][2*d+1][pre] = ce->calbase[2][d][pre]; |
360 |
calib.calvar[1][2*d+1][pre] = ce->calvar[2][d][pre]; |
361 |
}; |
362 |
}; |
363 |
};//chiuso for su si(sezioni) |
364 |
};//chiuso for su ci(eventi) |
365 |
// |
366 |
//fine CHECK |
367 |
|
368 |
// |
369 |
// Book the histograms: |
370 |
Int_t i = (ci-minev)/4; |
371 |
xviewev.str(""); |
372 |
xviewev << "x-view event " << (i+1); |
373 |
yviewev.str(""); |
374 |
yviewev << "y-view event " << (i+1); |
375 |
TH2F *Xview = new TH2F(xviewev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5); |
376 |
TH2F *Yview = new TH2F(yviewev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5); |
377 |
|
378 |
|
379 |
|
380 |
//prepara gli istogrammi figures: |
381 |
gDirectory->Delete("C14"); |
382 |
gDirectory->Delete("C15"); |
383 |
gDirectory->Delete("C16"); |
384 |
//TH1F *calped = new TH1F("C14","calped",4230,-3.5,4227.5); |
385 |
// TH1F *calrms = new TH1F("C15","calrms",4230,-3.5,4228.5); |
386 |
TH1F *calped = new TH1F("C14","C14 calped",2112,-3.5,4227.5); //istogramma unidimensionale con valori float |
387 |
// TH1F *calrms = new TH1F("C15","calrms",264,-2.,4226.); |
388 |
TH1F *calrms = new TH1F("C15","C15 calrms",2112,-3.5,4228.5); |
389 |
TH1F *calbad = new TH1F("C16","C16 calgood",4230,-3.5,4228.5); |
390 |
// |
391 |
gDirectory->Delete("C17"); |
392 |
gDirectory->Delete("C18"); |
393 |
gDirectory->Delete("C19"); |
394 |
TH1F *calthr = new TH1F("C17","C17 calthr",271,-4.5,268.5); |
395 |
TH1F *calvar = new TH1F("C18","C18 calvar",271,-4.5,268.5); |
396 |
TH1F *calbase = new TH1F("C19","C19 calbase",271,-4.5,268.5); |
397 |
// |
398 |
Int_t bgcolor = 10; |
399 |
TPad *pd1 = 0; |
400 |
TPad *pd2 = 0; |
401 |
TPad *palette = 0; |
402 |
TLatex *t=new TLatex(); |
403 |
|
404 |
// |
405 |
//pagina visualizzata solo se ci sono problemi |
406 |
if ( figmatra ){//figmatra e' variabile in ingresso in main |
407 |
figura2 = new TCanvas("Calorimeter:_strip_RMS", "Calorimeter:_strip_RMS", 750, 650); |
408 |
figura2->SetFillColor(10); |
409 |
figura2->Range(0,0,100,100); |
410 |
bgcolor = 10; |
411 |
pd1 = new TPad("pd1","This is pad1",0.02,0.05,0.88,0.49,bgcolor); |
412 |
pd2 = new TPad("pd2","This is pad2",0.02,0.51,0.88,0.95,bgcolor); |
413 |
palette = new TPad("palette","This is palette",0.90,0.05,0.98,0.90,bgcolor); |
414 |
figura2->cd(); |
415 |
gStyle->SetOptStat(""); |
416 |
t=new TLatex(); |
417 |
t->SetTextFont(32); |
418 |
t->SetTextColor(1); |
419 |
t->SetTextSize(0.03); |
420 |
t->SetTextAlign(12); |
421 |
t->DrawLatex(90.,92.5,"ADC ch."); |
422 |
pd1->Range(0,0,100,100); |
423 |
pd2->Range(0,0,100,100); |
424 |
palette->Range(0,0,100,100); |
425 |
pd1->SetTicks(); |
426 |
pd2->SetTicks(); |
427 |
pd1->Draw(); |
428 |
pd2->Draw(); |
429 |
palette->Draw(); |
430 |
palette->cd(); |
431 |
// palette |
432 |
TPaveLabel *box1 = new TPaveLabel(2,2,98,14,"OFF",""); |
433 |
box1->SetTextFont(32); |
434 |
box1->SetTextColor(1); |
435 |
box1->SetTextSize(0.25); |
436 |
box1->SetFillColor(10); |
437 |
box1->Draw(); |
438 |
TPaveLabel *box2 = new TPaveLabel(2,16,98,28,"0-1.5",""); |
439 |
box2->SetTextFont(32); |
440 |
box2->SetTextColor(1); |
441 |
box2->SetTextSize(0.25); |
442 |
box2->SetFillColor(38); |
443 |
box2->Draw(); |
444 |
TPaveLabel *box3 = new TPaveLabel(2,30,98,42,"1.5-4",""); |
445 |
box3->SetTextFont(32); |
446 |
box3->SetTextColor(1); |
447 |
box3->SetTextSize(0.25); |
448 |
box3->SetFillColor(4); |
449 |
box3->Draw(); |
450 |
TPaveLabel *box4 = new TPaveLabel(2,44,98,56,"4-6.5",""); |
451 |
box4->SetTextFont(32); |
452 |
box4->SetTextColor(1); |
453 |
box4->SetTextSize(0.25); |
454 |
box4->SetFillColor(3); |
455 |
box4->Draw(); |
456 |
TPaveLabel *box5 = new TPaveLabel(2,58,98,70,"6.5-11.5",""); |
457 |
box5->SetTextFont(32); |
458 |
box5->SetTextColor(1); |
459 |
box5->SetTextSize(0.25); |
460 |
box5->SetFillColor(2); |
461 |
box5->Draw(); |
462 |
TPaveLabel *box6 = new TPaveLabel(2,72,98,84,">11.5",""); |
463 |
box6->SetTextFont(32); |
464 |
box6->SetTextColor(1); |
465 |
box6->SetTextSize(0.25); |
466 |
box6->SetFillColor(6); |
467 |
box6->Draw(); |
468 |
TPaveLabel *box7 = new TPaveLabel(2,86,98,98,"BAD",""); |
469 |
box7->SetTextFont(32); |
470 |
box7->SetTextColor(10); |
471 |
box7->SetTextSize(0.25); |
472 |
box7->SetFillColor(1); |
473 |
box7->Draw(); |
474 |
// |
475 |
pd1->cd(); |
476 |
gStyle->SetOptStat(""); |
477 |
Xview->SetXTitle("strip"); |
478 |
Xview->SetYTitle("X - plane"); |
479 |
Xview->GetYaxis()->SetTitleOffset(0.5); |
480 |
Xview->SetFillColor(bgcolor); |
481 |
Xview->Fill(1.,1.,1.); |
482 |
Xview->Draw("box"); |
483 |
pd1->Update(); |
484 |
pd2->cd(); |
485 |
gStyle->SetOptStat(""); |
486 |
Yview->SetXTitle("strip"); |
487 |
Yview->SetYTitle("Y - plane"); |
488 |
Yview->GetYaxis()->SetTitleOffset(0.5); |
489 |
Yview->SetFillColor(bgcolor); |
490 |
Yview->Fill(1.,1.,1.); |
491 |
Yview->Draw("box"); |
492 |
pd2->Update(); |
493 |
}; |
494 |
// |
495 |
// run over views and planes |
496 |
//verifica quali strip sono state utilizzate per la calibrazione |
497 |
Int_t j = 0; |
498 |
Int_t g = 0; |
499 |
gStyle->SetOptStat(""); |
500 |
for (Int_t m = 0; m < 22; m++){//loop sui piani |
501 |
for (Int_t l = 0; l < 2; l++){//loop x y |
502 |
for (Int_t n = 0; n < 96; n++){ //loop sulle strip |
503 |
//controlla quante strip hanno piedistallo fuori dai limiti (escludendo quelle difettose) |
504 |
calped->Fill((float)j,calib.calped[l][m][n]); |
505 |
if ( (calib.calped[l][m][n] > 700. || calib.calped[l][m][n] < -700.) && (j < 4032 || j > 4048) ){ |
506 |
outcalped++; |
507 |
} else { |
508 |
incalped++; |
509 |
}; |
510 |
//controlla quali strip hanno rms fuori dai limiti (ponendo un limite diverso(piu' alto) per quelle difettose |
511 |
calrms->Fill((float)j,(calib.calrms[l][m][n]/4.)); |
512 |
if ( (((calib.calrms[l][m][n]/4.) > 10. || (calib.calrms[l][m][n]/4.) < 1.) && (j < 3440 || j > 3550)) || ( (j > 3439 && j < 3551) && ((calib.calrms[l][m][n]/4.) > 150. || (calib.calrms[l][m][n]/4.) < 1.)) ){ |
513 |
outcalrms++; |
514 |
} else { |
515 |
incalrms++; |
516 |
};//controlla (conta) quali strip sono state escluse dalla calibrazione |
517 |
calbad->Fill((float)j,(float)calib.calgood[l][m][n]); |
518 |
if ( calib.calgood[l][m][n] ) totcalbad++;//strip(orientazione(l),piano(m),numero(n))e' nulla, aumenta il |
519 |
// |
520 |
//preamplificatori(soglia max di calvar portata a 9, prima era 8) |
521 |
if ( n < 6 ){ |
522 |
calthr->Fill((float)g,(float)calib.calthr[l][m][n]);//controlla quali strip hanno soglia al difuori del limite(esclude) |
523 |
//(quelle difettose) |
524 |
if ( (calib.calthr[l][m][n] > 25. || calib.calthr[l][m][n] < 12.) && (g < 215 || g > 221) ){ |
525 |
outcalthr++; |
526 |
} else { |
527 |
incalthr++; |
528 |
}; |
529 |
calvar->Fill((float)g,(float)calib.calvar[l][m][n]);//controlla la varianza (esclude le difettose) |
530 |
if ( (calib.calvar[l][m][n] > 9. || calib.calvar[l][m][n] < 1. ) && (g < 215 || g > 221) ){ |
531 |
outcalvar++; |
532 |
} else { |
533 |
incalvar++; |
534 |
}; |
535 |
calbase->Fill((float)g,(float)calib.calbase[l][m][n]);//controlla baseline |
536 |
if ( calib.calbase[l][m][n] > 4500. || calib.calbase[l][m][n] < 2000. ){ |
537 |
outcalbas++; |
538 |
} else { |
539 |
incalbas++; |
540 |
}; |
541 |
g++;//contatore preamplificatoripassa alla strip successiva (0-286) |
542 |
}; |
543 |
// |
544 |
j++;//contatore strip |
545 |
|
546 |
//istogrammi (solo se ci sono stati problemi) |
547 |
if ( figmatra ){ |
548 |
figura2->cd(); |
549 |
xviewev.str(""); |
550 |
xviewev << "x-view " << i; |
551 |
xviewev << " event " << n; |
552 |
xviewev << " " << m; |
553 |
xviewev << " " << l; |
554 |
yviewev.str(""); |
555 |
yviewev << "y-view " << i; |
556 |
yviewev << " event " << n; |
557 |
yviewev << " " << m; |
558 |
yviewev << " " << l; |
559 |
TH2F *Xview = new TH2F(xviewev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);//istogramma 2d |
560 |
TH2F *Yview = new TH2F(yviewev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5); |
561 |
if ( calib.calrms[l][m][n] > 0 ){ |
562 |
Xview->SetFillColor(38); |
563 |
Yview->SetFillColor(38); |
564 |
}; |
565 |
if ( calib.calrms[l][m][n] > 6 ){ |
566 |
Xview->SetFillColor(4); |
567 |
Yview->SetFillColor(4); |
568 |
}; |
569 |
if ( calib.calrms[l][m][n] > 16 ){ |
570 |
Xview->SetFillColor(3); |
571 |
Yview->SetFillColor(3); |
572 |
}; |
573 |
if ( calib.calrms[l][m][n] > 26 ){ |
574 |
Xview->SetFillColor(2); |
575 |
Yview->SetFillColor(2); |
576 |
}; |
577 |
if ( calib.calrms[l][m][n] > 46 ){ |
578 |
Xview->SetFillColor(6); |
579 |
Yview->SetFillColor(6); |
580 |
}; |
581 |
if ( calib.calrms[l][m][n] <= 0 || calib.calrms[l][m][n] >30000 || calib.calped[l][m][n]>25000){ |
582 |
Xview->SetFillColor(10); |
583 |
Yview->SetFillColor(10); |
584 |
}; |
585 |
if ( calib.calgood[l][m][n] != 0 ){ |
586 |
Xview->SetFillColor(1); |
587 |
Yview->SetFillColor(1); |
588 |
}; |
589 |
if ( l == 0 ) { |
590 |
Xview->Fill(n,m,1.); |
591 |
pd1->cd(); |
592 |
Xview->Draw("box same"); |
593 |
}; |
594 |
if ( l == 1 ) { |
595 |
Yview->Fill(n,m,1.); |
596 |
pd2->cd(); |
597 |
Yview->Draw("box same"); |
598 |
}; |
599 |
};//fine istogrammi |
600 |
};//fine loop strip per piano |
601 |
};//fine loop x y |
602 |
};//fine loop piani |
603 |
|
604 |
//disega la figura |
605 |
if ( figmatra ){ |
606 |
figura2->cd(); |
607 |
gStyle->SetOptStat(""); |
608 |
gStyle->SetOptDate(0); |
609 |
t=new TLatex(); |
610 |
t->SetTextFont(32); |
611 |
t->SetTextColor(1); |
612 |
t->SetTextSize(0.03); |
613 |
t->SetTextAlign(12); |
614 |
titolo.str(""); |
615 |
titolo << "C13 - Calorimeter: strip RMS - file "; |
616 |
titolo << file; |
617 |
titolo << " - calibration number "; |
618 |
titolo << (i+1); |
619 |
t->DrawLatex(0.5,97.,titolo.str().c_str()); |
620 |
pd1->Update(); |
621 |
pd2->Update(); |
622 |
figura2->Update(); |
623 |
}; |
624 |
//fine pagina visualizzata solo se ci sono problemi |
625 |
// |
626 |
|
627 |
//Prepara le finestre |
628 |
//finestra con figure C14,C15,C16 |
629 |
figura1 = new TCanvas("Calorimeter_calped_calrms_calgood", "Calorimeter_calped_calrms_calgood", 750, 950);//nuova finestra |
630 |
figura1->SetFillColor(10); |
631 |
figura1->Range(0,0,100,100); |
632 |
// |
633 |
ccalped = (float)incalped/((float)outcalped + (float)incalped); |
634 |
Int_t f1pd1col = 10;//costante=10 |
635 |
if ( ccalped < ccalpedthr ) { //se % strip con piedistallo buono < numero minimo segna soglia |
636 |
check = true; //flag per segnalare errori |
637 |
f1pd1col = 45; // (se ci sono problemi, cambia colore) |
638 |
}; |
639 |
// |
640 |
ccalrms = (float)incalrms/((float)outcalrms + (float)incalrms); |
641 |
Int_t f1pd2col = 10; |
642 |
if ( ccalrms < ccalrmsthr ) { //se % strip con rms buono< numero minimo segna errore |
643 |
check = true; |
644 |
f1pd2col = 45; |
645 |
}; |
646 |
// |
647 |
ccalbad = (float)totcalbad/4224.; |
648 |
Int_t f1pd3col = 10; |
649 |
if ( ccalbad > ccalbadthr ) { //se il numero di strip escluse dalla calibrazione e' troppo alto segna errore |
650 |
check = true; |
651 |
f1pd3col = 45; |
652 |
}; |
653 |
// |
654 |
TPad *f1pd1 = new TPad("f1pd1","This is f1pad1",0.02,0.684,0.98,0.95,f1pd1col);//prepara le pad di figura1 |
655 |
TPad *f1pd2 = new TPad("f1pd2","This is f1pad2",0.02,0.367,0.98,0.634,f1pd2col); |
656 |
TPad *f1pd3 = new TPad("f1pd3","This is f1pad3",0.02,0.05,0.98,0.317,f1pd3col); |
657 |
figura1->Clear(); |
658 |
figura1->cd(); |
659 |
f1pd1->SetTicks(); |
660 |
f1pd2->SetTicks(); |
661 |
f1pd3->SetTicks(); |
662 |
f1pd1->Draw(); |
663 |
f1pd2->Draw(); |
664 |
f1pd3->Draw(); |
665 |
figura1->Draw(); |
666 |
|
667 |
//finestra con figure C17,C18,C19 |
668 |
figura3 = new TCanvas("Calorimeter_calthr_calvar_calbase", "Calorimeter_calthr_calvar_calbase", 750, 950); |
669 |
figura3->SetFillColor(10); |
670 |
figura3->Range(0,0,100,100); |
671 |
// |
672 |
ccalthr = (float)incalthr/((float)outcalthr + (float)incalthr); |
673 |
Int_t f3pd1col = 10; |
674 |
if ( ccalthr < ccalthrthr ) { //controlla % strip fuori soglia |
675 |
check = true; |
676 |
f3pd1col = 45; |
677 |
}; |
678 |
// |
679 |
ccalvar = (float)incalvar/((float)outcalvar + (float)incalvar); |
680 |
Int_t f3pd2col = 10; |
681 |
if ( ccalvar < ccalvarthr ) { //controlla strip con varianza fuori dai limiti |
682 |
check = true; |
683 |
f3pd2col = 45; |
684 |
}; |
685 |
// |
686 |
ccalbas = (float)incalbas/((float)outcalbas + (float)incalbas); |
687 |
Int_t f3pd3col = 10; |
688 |
if ( ccalbas < ccalbasthr ) { //controlla strip con baseline fuori dai limiti |
689 |
check = true; |
690 |
f3pd3col = 45; |
691 |
}; |
692 |
// |
693 |
TPad *f3pd1 = new TPad("f3pd1","This is f3pad1",0.02,0.684,0.98,0.95,f3pd1col);//prepara le pad di figura 3 |
694 |
TPad *f3pd2 = new TPad("f3pd2","This is f3pad2",0.02,0.367,0.98,0.634,f3pd2col); |
695 |
TPad *f3pd3 = new TPad("f3pd3","This is f3pad3",0.02,0.05,0.98,0.317,f3pd3col); |
696 |
figura3->Clear();//cancella tutto in figura 3 |
697 |
figura3->cd(); |
698 |
f3pd1->SetTicks(); |
699 |
f3pd2->SetTicks(); |
700 |
f3pd3->SetTicks(); |
701 |
f3pd1->Draw(); |
702 |
f3pd2->Draw(); |
703 |
f3pd3->Draw(); |
704 |
figura3->Draw(); |
705 |
|
706 |
|
707 |
//mette i titoli nella figura 1 |
708 |
gStyle->SetOptStat("N"); |
709 |
figura1->cd(); |
710 |
gStyle->SetNdivisions(322,"x"); |
711 |
t=new TLatex(); |
712 |
t->SetTextFont(32); |
713 |
t->SetTextColor(1); |
714 |
t->SetTextSize(0.025); |
715 |
t->SetTextAlign(12); |
716 |
titolo.str(""); |
717 |
titolo << "EXPERT - Calorimeter: calped/calrms/calgood - file "; |
718 |
titolo << file; |
719 |
titolo << " - calibration number "; |
720 |
titolo << (i+1); |
721 |
sottotitolo.str(""); |
722 |
sottotitolo << "CPU OBT:" <<cpuobt; |
723 |
sottotitolo << " | OBT pk1:" <<obt0; |
724 |
sottotitolo << " - OBT pk2:"<<obt1; |
725 |
sottotitolo << " - OBT pk3:"<<obt2; |
726 |
sottotitolo << " - OBT pk4:"<<obt3; |
727 |
t->DrawLatex(0.5,98.,titolo.str().c_str()); |
728 |
t->SetTextSize(0.02); |
729 |
t->DrawLatex(0.5,96.,sottotitolo.str().c_str()); |
730 |
t->SetTextSize(0.03); |
731 |
// |
732 |
f1pd1->cd(); |
733 |
//titoli al grafico calped |
734 |
calped->GetXaxis()->SetNdivisions(322); |
735 |
calped->SetXTitle("strip"); |
736 |
calped->SetYTitle("ADC channels"); |
737 |
calped->SetMaximum(3000.); |
738 |
calped->SetMinimum(-3000.); |
739 |
//disegna istogramma calped |
740 |
calped->Draw(); |
741 |
//disegna la banda di accettazione |
742 |
TPolyLine *banda1; |
743 |
Double_t xc[4] = {0.,4224.,4224.,0.}; |
744 |
Double_t yc[4] = {-700.,-700.,700.,700.}; |
745 |
banda1 = new TPolyLine(4,xc,yc); |
746 |
banda1->SetLineColor(5); |
747 |
banda1->SetFillColor(5); |
748 |
banda1->SetLineWidth(1); |
749 |
banda1->Draw("fSAME"); |
750 |
//banda per le strip difettose |
751 |
TPolyLine *banda2; |
752 |
Double_t xc2[4] = {4031.5,4047.5,4047.5,4031.5}; |
753 |
// Double_t yc2[4] = {-2500.,-2500.,28000.,28000.}; |
754 |
Double_t yc2[4] = {-3000.,-3000.,3000.,3000.}; |
755 |
banda2 = new TPolyLine(4,xc2,yc2); |
756 |
banda2->SetLineColor(5); |
757 |
banda2->SetFillColor(5); |
758 |
banda2->SetLineWidth(1); |
759 |
banda2->Draw("fSAME"); |
760 |
|
761 |
calped->Draw("SAME"); |
762 |
// |
763 |
f1pd2->cd(); |
764 |
//prepara grafico calrms |
765 |
f1pd2->SetLogy(); |
766 |
calrms->GetXaxis()->SetNdivisions(322); |
767 |
//disegna istogramma calrms |
768 |
calrms->Draw(); |
769 |
//banda di accettazione |
770 |
Double_t xd[4] = {0.,4224.,4224.,0.}; |
771 |
Double_t yd[4] = {1.,1.,10.,10.}; |
772 |
banda1 = new TPolyLine(4,xd,yd); |
773 |
banda1->SetLineColor(5); |
774 |
banda1->SetFillColor(5); |
775 |
banda1->SetLineWidth(1); |
776 |
banda1->Draw("fSAME"); |
777 |
|
778 |
Float_t minrm = calrms->GetMinimum(); |
779 |
Float_t maxrm = calrms->GetMaximum(); |
780 |
Double_t xrm2[4] = {3449.,3551.,3551.,3449.}; |
781 |
Double_t yrm2[4] = {minrm,minrm,maxrm,maxrm}; |
782 |
//banda per strip difettose |
783 |
banda2 = new TPolyLine(4,xrm2,yrm2); |
784 |
banda2->SetLineColor(5); |
785 |
banda2->SetFillColor(5); |
786 |
banda2->SetLineWidth(1); |
787 |
banda2->Draw("fSAME"); |
788 |
|
789 |
calrms->SetXTitle("strip"); |
790 |
calrms->SetYTitle("ADC channels"); |
791 |
|
792 |
calrms->Draw("SAME"); |
793 |
//prepara grafico calbad |
794 |
f1pd3->cd(); |
795 |
gStyle->SetNdivisions(344,"x"); |
796 |
calbad->GetXaxis()->SetNdivisions(322); |
797 |
//disegna calbad |
798 |
calbad->Draw(); |
799 |
calbad->SetXTitle("strip"); |
800 |
calbad->SetYTitle("0=good 255=bad"); |
801 |
// |
802 |
f1pd1->Update(); |
803 |
f1pd2->Update(); |
804 |
f1pd3->Update(); |
805 |
figura1->Update(); |
806 |
// |
807 |
|
808 |
|
809 |
//pagina con figure C17,C18,C19 |
810 |
figura3->cd(); |
811 |
gStyle->SetNdivisions(644,"x"); |
812 |
t=new TLatex(); |
813 |
t->SetTextFont(32); |
814 |
t->SetTextColor(1); |
815 |
t->SetTextSize(0.025); |
816 |
t->SetTextAlign(12); |
817 |
titolo.str(""); |
818 |
titolo << "EXPERT - Calorimeter: calthr/calvar/calbase - file "; |
819 |
titolo << file; |
820 |
titolo << " - calibration number "; |
821 |
titolo << (i+1); |
822 |
t->DrawLatex(0.5,98.,titolo.str().c_str()); |
823 |
t->SetTextSize(0.02); |
824 |
t->DrawLatex(0.5,96.,sottotitolo.str().c_str()); |
825 |
t->SetTextSize(0.03); |
826 |
// |
827 |
f3pd1->cd(); |
828 |
calthr->GetXaxis()->SetNdivisions(644); |
829 |
calthr->SetXTitle("pre-amplifier"); |
830 |
calthr->SetYTitle("ADC channels"); |
831 |
calthr->Draw(); |
832 |
Double_t xe[4] = {0.,264.,264.,0.}; |
833 |
Double_t ye[4] = {12.,12.,25.,25.}; |
834 |
banda1 = new TPolyLine(4,xe,ye); |
835 |
banda1->SetLineColor(5); |
836 |
banda1->SetFillColor(5); |
837 |
banda1->SetLineWidth(1); |
838 |
banda1->Draw("fSAME"); |
839 |
|
840 |
minrm = calthr->GetMinimum(); |
841 |
maxrm = 1.05*calthr->GetMaximum(); |
842 |
Double_t xth2[4] = {215.,221.,221.,215.}; |
843 |
Double_t yth2[4] = {minrm,minrm,maxrm,maxrm}; |
844 |
banda2 = new TPolyLine(4,xth2,yth2); |
845 |
banda2->SetLineColor(5); |
846 |
banda2->SetFillColor(5); |
847 |
banda2->SetLineWidth(1); |
848 |
banda2->Draw("fSAME"); |
849 |
// |
850 |
calthr->Draw("SAME"); |
851 |
|
852 |
|
853 |
f3pd2->cd(); |
854 |
// gPad->SetLogy(); |
855 |
//banda di soglia per calvar portata a 9, prima era a 8) |
856 |
calvar->SetMaximum(25.); |
857 |
calvar->GetXaxis()->SetNdivisions(644); |
858 |
calvar->SetXTitle("pre-amplifier"); |
859 |
calvar->SetYTitle("ADC channels"); |
860 |
calvar->Draw(); |
861 |
Double_t xt[4] = {0.,264.,264.,0.}; |
862 |
Double_t yt[4] = {1.,1.,9.,9.}; |
863 |
banda1 = new TPolyLine(4,xt,yt); |
864 |
banda1->SetLineColor(5); |
865 |
banda1->SetFillColor(5); |
866 |
banda1->SetLineWidth(1); |
867 |
banda1->Draw("fSAME"); |
868 |
|
869 |
minrm = calvar->GetMinimum(); |
870 |
maxrm = 1.05*calvar->GetMaximum(); |
871 |
Double_t xva2[4] = {215.,221.,221.,215.}; |
872 |
Double_t yva2[4] = {minrm,minrm,maxrm,maxrm}; |
873 |
banda2 = new TPolyLine(4,xva2,yva2); |
874 |
banda2->SetLineColor(5); |
875 |
banda2->SetFillColor(5); |
876 |
banda2->SetLineWidth(1); |
877 |
banda2->Draw("fSAME"); |
878 |
// |
879 |
calvar->Draw("SAME"); |
880 |
|
881 |
|
882 |
f3pd3->cd(); |
883 |
calbase->GetXaxis()->SetNdivisions(644); |
884 |
calbase->SetXTitle("pre-amplifier"); |
885 |
calbase->SetYTitle("ADC channels"); |
886 |
calbase->Draw(); |
887 |
Double_t xg[4] = {0.,264.,264.,0.}; |
888 |
Double_t yg[4] = {2000.,2000.,4500.,4500.}; |
889 |
banda1 = new TPolyLine(4,xg,yg); |
890 |
banda1->SetLineColor(5); |
891 |
banda1->SetFillColor(5); |
892 |
banda1->SetLineWidth(1); |
893 |
banda1->Draw("fSAME"); |
894 |
calbase->Draw("SAME"); |
895 |
// |
896 |
f3pd1->Update(); |
897 |
f3pd2->Update(); |
898 |
f3pd3->Update(); |
899 |
figura3->Update(); |
900 |
// |
901 |
//file output |
902 |
if ( !strcmp(format,"ps") ) { |
903 |
if ( ci == minev ) { |
904 |
figsave.str(""); |
905 |
figsave << outdir << "/" ; |
906 |
figsave << figrec << "_CaloCHKCALIB."; |
907 |
figsave << format; |
908 |
figsave << "("; |
909 |
}; |
910 |
if ( figmatra ) { |
911 |
figura2->Print(figsave.str().c_str(),"Portrait"); |
912 |
if ( ci == minev ) { |
913 |
figsave.str(""); |
914 |
figsave << outdir << "/" ; |
915 |
figsave << figrec << "_CaloCHKCALIB."; |
916 |
figsave << format; |
917 |
}; |
918 |
}; |
919 |
// |
920 |
figura1->Print(figsave.str().c_str(),"Portrait"); |
921 |
if ( ci == minev ) { |
922 |
figsave.str(""); |
923 |
figsave << outdir << "/" ; |
924 |
figsave << figrec << "_CaloCHKCALIB."; |
925 |
figsave << format; |
926 |
}; |
927 |
// |
928 |
figura3->Print(figsave.str().c_str(),"Portrait"); |
929 |
// |
930 |
} else { |
931 |
if ( figmatra ) { |
932 |
figsave.str(""); |
933 |
figsave << outdir << "/" ; |
934 |
figsave << figrec << "_CaloCHKCALIB1_"; |
935 |
figsave << (i+1) << "."; |
936 |
figsave << format; |
937 |
figura2->SaveAs(figsave.str().c_str()); |
938 |
}; |
939 |
// |
940 |
figsave1.str(""); |
941 |
figsave1 << outdir << "/" ; |
942 |
figsave1 << figrec << "_CaloCHKCALIB2_"; |
943 |
figsave1 << (i+1) << "."; |
944 |
figsave1 << format; |
945 |
figura1->SaveAs(figsave1.str().c_str()); |
946 |
// |
947 |
figsave2.str(""); |
948 |
figsave2 << outdir << "/" ; |
949 |
figsave2 << figrec << "_CaloCHKCALIB3_"; |
950 |
figsave2 << (i+1) << "."; |
951 |
figsave2 << format; |
952 |
figura3->SaveAs(figsave2.str().c_str()); |
953 |
// |
954 |
}; |
955 |
if ( iactive && w4i ){ |
956 |
while ( gROOT->GetListOfCanvases()->FindObject(figura2) || gROOT->GetListOfCanvases()->FindObject(figura1) || gROOT->GetListOfCanvases()->FindObject(figura3) ){ |
957 |
gSystem->ProcessEvents(); |
958 |
gSystem->Sleep(10); |
959 |
}; |
960 |
}; |
961 |
};//fine del loop sulle calibrazioni |
962 |
// |
963 |
// |
964 |
// |
965 |
// |
966 |
// report sheet: |
967 |
// |
968 |
stringstream errore; |
969 |
rapporto= new TCanvas("Calorimeter calibration report", "Calorimeter calibration report", 750, 950); |
970 |
rapporto->cd(); |
971 |
rapporto->SetFillColor(10); |
972 |
rapporto->Range(0,0,100,100); |
973 |
TLatex *t=new TLatex(); |
974 |
t->SetTextFont(32); |
975 |
t->SetTextColor(1); |
976 |
t->SetTextSize(0.035); |
977 |
t->SetTextAlign(12); |
978 |
errore.str(""); |
979 |
errore << "BASIC - C20 - Calibrations in file: " << file; |
980 |
errore << " "; |
981 |
t->SetTextSize(0.02); |
982 |
t->DrawLatex(2.,99.,errore.str().c_str()); |
983 |
// |
984 |
TPad *pad1; |
985 |
TPad *pad2; |
986 |
TPad *pad3; |
987 |
TPad *pad4; |
988 |
pad1 = new TPad("pad1","This is pad1",0.02,0.47,0.49,0.90,19); |
989 |
pad2 = new TPad("pad2","This is pad2",0.51,0.47,0.98,0.90,19); |
990 |
pad3 = new TPad("pad3","This is pad3",0.02,0.02,0.49,0.45,19); |
991 |
pad4 = new TPad("pad4","This is pad4",0.51,0.02,0.98,0.45,19); |
992 |
pad1->Range(0,0,100,100); |
993 |
pad2->Range(0,0,100,100); |
994 |
pad3->Range(0,0,100,100); |
995 |
pad4->Range(0,0,100,100); |
996 |
// |
997 |
pad1->Draw(); |
998 |
pad2->Draw(); |
999 |
pad3->Draw(); |
1000 |
pad4->Draw(); |
1001 |
// |
1002 |
char *sezione = 0; |
1003 |
for (Int_t si = 0; si < 4; si++){ |
1004 |
if (si == 2) |
1005 |
{ |
1006 |
pad1->cd() ; |
1007 |
sezione = "** Section YE (x even) **"; |
1008 |
} |
1009 |
if (si == 3) |
1010 |
{ |
1011 |
pad2->cd(); |
1012 |
sezione = "** Section YO (x odd) **"; |
1013 |
} |
1014 |
if (si == 0) |
1015 |
{ |
1016 |
pad3->cd(); |
1017 |
sezione = "** Section XE (y odd) **"; |
1018 |
} |
1019 |
if (si == 1) |
1020 |
{ |
1021 |
pad4->cd(); |
1022 |
sezione = "** Section XO (y even) **"; |
1023 |
} |
1024 |
t->SetTextFont(32); |
1025 |
t->SetTextColor(1); |
1026 |
t->SetTextSize(0.05); |
1027 |
t->SetTextAlign(12); |
1028 |
t->DrawLatex(33.,97.,sezione); |
1029 |
t->SetTextSize(0.05); |
1030 |
|
1031 |
//scorre ver cercando il j tipo di errore: 'si'=sezione |
1032 |
for (Int_t j = 0; j < 23; j++){ |
1033 |
if ( ver[si][j] ) {//controlla se le sezioni di ver[si][j] sonoe diverse da zero. |
1034 |
t->SetTextColor(50); //controlla quali sono !=0 e assegna il rispettivo errore |
1035 |
if (j == 0) {//del calorimetro |
1036 |
errore.str(""); |
1037 |
errore << "* DSP ack error: " << ver[si][j]; |
1038 |
errore << " time(s)"; |
1039 |
t->DrawLatex(2.,30.,errore.str().c_str()); |
1040 |
check = true; |
1041 |
} |
1042 |
if (j == 1) {//calorimetro |
1043 |
errore.str(""); |
1044 |
errore << "* Temperature alarm: " << ver[si][j]; |
1045 |
errore << " time(s)"; |
1046 |
t->DrawLatex(2.,74.,errore.str().c_str()); |
1047 |
check = true; |
1048 |
} |
1049 |
if (j == 2) {//calorimetro |
1050 |
errore.str(""); |
1051 |
errore << "* Latch up alarm: " << ver[si][j]; |
1052 |
errore << " time(s)."; |
1053 |
t->DrawLatex(2.,65.,errore.str().c_str()); |
1054 |
check = true; |
1055 |
} |
1056 |
if (j == 3) {//calorimetro |
1057 |
errore.str(""); |
1058 |
errore << "RAW mode: " << ver[si][j]; |
1059 |
errore << " time(s)"; |
1060 |
t->SetTextColor(38); |
1061 |
t->DrawLatex(2.,90.,errore.str().c_str()); |
1062 |
} |
1063 |
if (j == 4) {//calorimetro |
1064 |
errore.str(""); |
1065 |
errore << "* CMD length error: " << ver[si][j]; |
1066 |
errore << " time(s)"; |
1067 |
t->DrawLatex(2.,66.,errore.str().c_str()); |
1068 |
check = true; |
1069 |
} |
1070 |
if (j == 5) {//calorimetro |
1071 |
errore.str(""); |
1072 |
errore << "* Execution error: " << ver[si][j]; |
1073 |
errore << " time(s)"; |
1074 |
t->DrawLatex(2.,62.,errore.str().c_str()); |
1075 |
check = true; |
1076 |
} |
1077 |
if (j == 6) {//calorimetro |
1078 |
errore.str(""); |
1079 |
errore << "* CRC error (st. word): " << ver[si][j]; |
1080 |
errore << " time(s)"; |
1081 |
t->DrawLatex(2.,58.,errore.str().c_str()); |
1082 |
check = true; |
1083 |
} |
1084 |
if (j == 7) { |
1085 |
errore.str(""); |
1086 |
errore << "View or command not recognized: " << ver[si][j]; |
1087 |
errore << " time(s)"; |
1088 |
t->DrawLatex(2.,54.,errore.str().c_str()); |
1089 |
check = true; |
1090 |
} |
1091 |
// |
1092 |
if (j == 8) { |
1093 |
errore.str(""); |
1094 |
errore << "Missing section: " << ver[si][j]; |
1095 |
errore << " time(s)"; |
1096 |
t->DrawLatex(2.,50.,errore.str().c_str()); |
1097 |
check = true; |
1098 |
} |
1099 |
if (j == 9) { |
1100 |
errore.str(""); |
1101 |
errore << "RAW MODE COMMAND: " << ver[si][j]; |
1102 |
errore << " time(s)"; |
1103 |
t->DrawLatex(2.,42.,errore.str().c_str()); |
1104 |
} |
1105 |
if (j == 11) { |
1106 |
errore.str(""); |
1107 |
errore << "CRC error (data): " << ver[si][j]; |
1108 |
errore << " time(s)"; |
1109 |
t->DrawLatex(2.,38.,errore.str().c_str()); |
1110 |
check = true; |
1111 |
} |
1112 |
if (j == 16) { |
1113 |
errore.str(""); |
1114 |
errore << "Number of calibrations: " << ver[si][j]; |
1115 |
t->SetTextColor(38); |
1116 |
t->DrawLatex(2.,86.,errore.str().c_str()); |
1117 |
} |
1118 |
if (j == 19) { |
1119 |
errore.str(""); |
1120 |
errore << "Pedestal checksum wrong: " << ver[si][j]; |
1121 |
errore << " time(s)"; |
1122 |
t->DrawLatex(2.,14.,errore.str().c_str()); |
1123 |
check = true; |
1124 |
} |
1125 |
if (j == 20) { |
1126 |
errore.str(""); |
1127 |
errore << "Thresholds checksum wrong: " << ver[si][j]; |
1128 |
errore << " time(s)"; |
1129 |
t->DrawLatex(2.,10.,errore.str().c_str()); |
1130 |
check = true; |
1131 |
} |
1132 |
if (j == 22) { |
1133 |
errore.str(""); |
1134 |
errore << "Packet length is zero (YODA input error), skipped: " << ver[si][j]; |
1135 |
errore << " time(s)"; |
1136 |
t->DrawLatex(2.,3.,errore.str().c_str()); |
1137 |
check = true; |
1138 |
}; |
1139 |
}; |
1140 |
}; |
1141 |
}; |
1142 |
rapporto->cd(); |
1143 |
t->SetTextFont(32); |
1144 |
t->SetTextColor(1); |
1145 |
t->SetTextSize(0.035); |
1146 |
t->SetTextAlign(12); |
1147 |
t->DrawLatex(7.,95.,"Calorimeter CALIBRATION quick look: "); |
1148 |
printf(" ccalped %f ccalrms %f ccalbad %f ccalthr %f ccalvar %f ccalbas %f \n",ccalped,ccalrms,ccalbad,ccalthr,ccalvar,ccalbas); |
1149 |
|
1150 |
|
1151 |
if ( check ) { |
1152 |
t->SetTextColor(50); |
1153 |
t->DrawLatex(65.,95.,"WARNING, CHECK!"); |
1154 |
t->SetTextColor(1); |
1155 |
} else { |
1156 |
t->SetTextColor(38); |
1157 |
t->DrawLatex(65.,95.,"OK!"); |
1158 |
t->SetTextColor(1); |
1159 |
}; |
1160 |
rapporto->Update(); |
1161 |
// |
1162 |
if ( !strcmp(format,"ps") ) { |
1163 |
figsave.str(""); |
1164 |
figsave << outdir << "/" ; |
1165 |
figsave << figrec << "_CaloCHKCALIB."; |
1166 |
figsave << format; |
1167 |
figsave << ")"; |
1168 |
rapporto->Print(figsave.str().c_str(),"Portrait"); |
1169 |
} else { |
1170 |
figsave.str(""); |
1171 |
figsave << outdir << "/" ; |
1172 |
figsave << figrec << "_CaloCHKCALIB_report."; |
1173 |
figsave << format; |
1174 |
rapporto->SaveAs(figsave.str().c_str()); |
1175 |
}; |
1176 |
if ( iactive && w4i ){ |
1177 |
while ( gROOT->GetListOfCanvases()->FindObject(rapporto) ){ |
1178 |
gSystem->ProcessEvents(); |
1179 |
gSystem->Sleep(10); |
1180 |
}; |
1181 |
}; |
1182 |
printf("\n"); |
1183 |
return; |
1184 |
} |
1185 |
|