/[PAMELA software]/quicklook/calo/FQLOOK/macros/FCaloCHKCALIB.cxx
ViewVC logotype

Annotation of /quicklook/calo/FQLOOK/macros/FCaloCHKCALIB.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (hide annotations) (download)
Wed Jul 18 07:57:12 2007 UTC (17 years, 4 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r22, v1r23
Changes since 1.14: +2 -2 lines
05953 bug (infinite loop) fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23