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

  ViewVC Help
Powered by ViewVC 1.1.23