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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations) (download)
Mon May 29 09:38:26 2006 UTC (18 years, 6 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r10, v1r08, v1r09
Changes since 1.7: +56 -25 lines
Fixed bug in output filename and changed threshold for bad strip warning

1 mocchiut 1.1 //
2     // Check the calorimter calibrations - Emiliano Mocchiutti
3     //
4 mocchiut 1.8 // FCaloCHKCALIB.c version 1.07 (2006-05-29)
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.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).
11     //
12 mocchiut 1.7 // 1.05 - 1.06 (2006-03-22): Add optimize flag in compiling the script!
13 mocchiut 1.6 //
14     // 1.04 - 1.05 (2006-03-22): Corrected wrong .C files.
15 mocchiut 1.5 //
16     // 1.03 - 1.04 (2006-03-20): Documentation updated.
17 mocchiut 1.4 //
18     // 1.02 - 1.03 (2006-03-20): Changed name of shared libraries (for example from FCaloQLOOK_cxx.so to libFCaloQLOOK.so).
19 mocchiut 1.1 //
20 mocchiut 1.3 // 1.01 - 1.02 (2006-03-13): Include files from YODA without "event" directory.
21     //
22 mocchiut 1.1 // 1.00 - 1.01 (2006-03-02): Works on YODA v6 output (single file), does not require anymore calocommon package.
23     //
24     // 0.00 - 1.00 (2006-03-02): Clone of CaloCHKCALIB.c
25     //
26     #include <iostream>
27     #include <fstream>
28     //
29     #include <TTree.h>
30     #include <TObject.h>
31     #include <TString.h>
32     #include <TFile.h>
33     #include <TCanvas.h>
34     #include <TH1.h>
35     #include <TPolyLine.h>
36     #include <TH1F.h>
37     #include <TH2D.h>
38     #include <TLatex.h>
39     #include <TPad.h>
40     #include <TPaveLabel.h>
41     #include <TStyle.h>
42 mocchiut 1.2 #include <TSystem.h>
43 mocchiut 1.1 //
44 mocchiut 1.3 #include <CalibCalPedEvent.h>
45 mocchiut 1.1 //
46     using namespace std;
47     //
48     void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){
49     if ( to == 0 ){
50     Int_t t2length = s2.Length();
51     s1 = "";
52     to = t2length;
53     };
54     for (Int_t i = from; i<to; i++){
55     s1.Append(s2[i],1);
56     };
57     }
58     void stringappend(TString& s1, const TString& s2){
59     Int_t t2length = s2.Length();
60     for (Int_t i = 0; i<t2length; i++){
61     s1.Append(s2[i],1);
62     };
63     }
64    
65 mocchiut 1.8 // TString getFilename(const TString filename){
66     // const string fil = (const char*)filename;
67     // Int_t posiz = fil.find("dw_");
68     // if ( posiz == -1 ) posiz = fil.find("DW_");
69     // if ( posiz == -1 ) return 0;
70     // Int_t posiz2 = posiz+13;
71     // TString file2;
72     // stringcopy(file2,filename,posiz,posiz2);
73     // TString pdat(".dat");
74     // stringappend(file2,pdat);
75     // return file2;
76     // }
77 mocchiut 1.1 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     Int_t iev;
96     Int_t cstwerr[4];
97     Float_t cperror[4];
98     Float_t mip[2][22][96];
99     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     } calib;
107    
108     void FCaloCHKCALIB(TString filename, Long64_t calibnumber = 0, TString outDir = "", Int_t figmatra = 0, TString saveas = "ps"){
109     gStyle->SetPaperSize(19.,25.);
110     //
111     Float_t ccalrmsthr=0.99;
112     Float_t ccalpedthr=0.99;
113 mocchiut 1.8 Float_t ccalbadthr=0.03;// 0.005
114 mocchiut 1.1 Float_t ccalthrthr=0.98;
115     Float_t ccalvarthr=0.99;
116     Float_t ccalbasthr=0.99;
117     //
118     Float_t ccalrms;
119     Float_t ccalped;
120     Float_t ccalbad;
121     Float_t ccalthr;
122     Float_t ccalvar;
123     Float_t ccalbas;
124     //
125     struct Calib calib;
126     stringstream titolo;
127     stringstream xviewev;
128     stringstream yviewev;
129     const char* startingdir = gSystem->WorkingDirectory();
130     if ( !strcmp(outDir.Data(),"") ) outDir = startingdir;
131     TString fififile = getFilename(filename);
132     const char *file;
133     file = fififile;
134     //
135     ifstream myfile;
136     myfile.open(filename.Data());
137     if ( !myfile ){
138 mocchiut 1.2 printf(" %s :no such file, exiting...\n\n",filename.Data());
139     return;
140 mocchiut 1.1 };
141     myfile.close();
142     //
143     TFile *File = new TFile(filename.Data());
144     //
145     TTree *tr = (TTree*)File->Get("CalibCalPed");
146 mocchiut 1.2 if ( !tr ) {
147     printf(" CalibCalPed : no such tree in %s \n",filename.Data());
148     printf(" Exiting, are you sure this is a LEVEL0 not corrupted file? \n\n");
149     return;
150     };
151 mocchiut 1.1 pamela::CalibCalPedEvent *ce = 0;
152     //
153     UInt_t found;
154     tr->SetBranchStatus("*",0,&found); //disable all branches
155     //
156     found = 0;
157     tr->SetBranchStatus("iev*",1,&found);
158     found = 0;
159     tr->SetBranchStatus("cstwerr*",1,&found);
160     // printf("enabled %i branches \n",found);
161     found = 0;
162     tr->SetBranchStatus("cperror*",1,&found);
163     //printf("enabled %i branches \n",found);
164     found = 0;
165     tr->SetBranchStatus("cal*",1,&found);
166     //printf("enabled %i branches \n",found);
167     found = 0;
168     tr->SetBranchStatus("CalibCalPed*",1,&found);
169     //printf("enabled %i branches \n",found);
170     //
171     tr->SetBranchAddress("CalibCalPed", &ce);
172     //
173     Long64_t ncalibs = tr->GetEntries();
174     if ( ncalibs == 0 ){
175     printf(" No calibrations in this files! \n Exiting... \n");
176     return;
177     };
178     printf("\n This file contains %i entries which corrispond to %i calibrations \n\n",(int)ncalibs,(int)ncalibs/4);
179     Long64_t minev = 0;
180     Long64_t maxev = ncalibs;
181     if ( calibnumber ){
182     minev = (calibnumber - 1)* 4;
183     maxev = minev + 4;
184     };
185     TCanvas *figura1;
186     TCanvas *figura2 = 0;
187     TCanvas *figura3;
188     TCanvas *rapporto = 0;
189     Int_t cmask = 127 ;
190     Int_t cestw = 0;
191     Int_t ver[4][23];
192     //
193     for (Int_t k = 0; k < 4; k++ ){
194     for (Int_t m = 0; m < 23 ; m++ ){
195     ver[k][m] = 0 ;
196     };
197     };
198     //
199 mocchiut 1.8 // //
200     // const string fil = (const char*)filename;
201     // Int_t posiz = fil.find("dw_");
202     // if ( posiz == -1 ) posiz = fil.find("DW_");
203     // Int_t posiz2 = posiz+13;
204     // TString file2;
205     // stringcopy(file2,filename,posiz,posiz2);
206     // //
207     // const char *figrec = file2;
208     //
209     const string fil = gSystem->BaseName(filename.Data());
210     Int_t posiz = fil.find(".root");
211 mocchiut 1.1 //
212     TString file2;
213 mocchiut 1.8 if ( posiz == -1 ){
214     file2 = gSystem->BaseName(filename.Data());
215     } else {
216     Int_t posiz2 = 0;
217     stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz);
218     };
219     const char *figrec = file2;
220 mocchiut 1.1 //
221     const char *outdir = outDir;
222     const char *format = saveas;
223     stringstream figsave;
224     stringstream figsave1;
225     stringstream figsave2;
226     //
227     // to check or not to check? this is the problem...
228     //
229     Bool_t check = false;
230     //
231     for (Int_t ci = minev; ci < maxev ; ci+=4){
232     //
233     Int_t incalrms = 0;
234     Int_t outcalrms = 0;
235     Int_t totcalbad = 0;
236     Int_t incalped = 0;
237     Int_t outcalped = 0;
238     Int_t incalthr = 0;
239     Int_t outcalthr = 0;
240     Int_t incalvar = 0;
241     Int_t outcalvar = 0;
242     Int_t incalbas = 0;
243     Int_t outcalbas = 0;
244     //
245     for ( Int_t s=0 ; s<4 ;s++ ){
246     tr->GetEntry(ci+s);
247     calib.iev = ce->iev;
248     //
249     //
250     //
251     cestw = 0;
252     if ( ce->cstwerr[s] ){
253     cestw = ce->cstwerr[s] & cmask ;
254     ver[s][16]++;
255     };
256     if ( cestw ){
257     if ( cestw & (1 << 0) ) ver[s][6]++ ;
258     if ( cestw & (1 << 1) ) ver[s][5]++ ;
259     if ( cestw & (1 << 2) ) ver[s][4]++ ;
260     if ( cestw & (1 << 3) ) ver[s][3]++ ;
261     if ( cestw & (1 << 4) ) ver[s][2]++ ;
262     if ( cestw & (1 << 5) ) ver[s][1]++ ;
263     if ( cestw & (1 << 6) ) ver[s][0]++ ;
264     };
265     if ( ce->cperror[s] != 0. ){
266     if (ce->cperror[s] == 128) ver[s][7]++ ;
267     if (ce->cperror[s] == 129) ver[s][8]++ ;
268     if (ce->cperror[s] == 130) {
269     ver[s][9]++ ;
270     ver[s][16]--;
271     };
272     if (ce->cperror[s] == 132) ver[s][11]++ ;
273     if (ce->cperror[s] == 140) ver[s][19]++ ;
274     if (ce->cperror[s] == 141) ver[s][20]++ ;
275     if (ce->cperror[s] == 142) ver[s][22]++ ;
276     };
277     //
278     for ( Int_t d=0 ; d<11 ;d++ ){
279     Int_t pre = -1;
280     for ( Int_t j=0; j<96 ;j++){
281     if ( j%16 == 0 ) pre++;
282     if ( s == 2 ){
283     calib.calped[0][2*d+1][j] = ce->calped[3][d][j];
284     calib.cstwerr[3] = ce->cstwerr[3];
285     calib.cperror[3] = ce->cperror[3];
286     calib.calgood[0][2*d+1][j] = ce->calgood[3][d][j];
287     calib.calthr[0][2*d+1][pre] = ce->calthr[3][d][pre];
288     calib.calrms[0][2*d+1][j] = ce->calrms[3][d][j];
289     calib.calbase[0][2*d+1][pre] = ce->calbase[3][d][pre];
290     calib.calvar[0][2*d+1][pre] = ce->calvar[3][d][pre];
291     };
292     if ( s == 3 ){
293     calib.calped[0][2*d][j] = ce->calped[1][d][j];
294     calib.cstwerr[1] = ce->cstwerr[1];
295     calib.cperror[1] = ce->cperror[1];
296     calib.calgood[0][2*d][j] = ce->calgood[1][d][j];
297     calib.calthr[0][2*d][pre] = ce->calthr[1][d][pre];
298     calib.calrms[0][2*d][j] = ce->calrms[1][d][j];
299     calib.calbase[0][2*d][pre] = ce->calbase[1][d][pre];
300     calib.calvar[0][2*d][pre] = ce->calvar[1][d][pre];
301     };
302     if ( s == 0 ){
303     calib.calped[1][2*d][j] = ce->calped[0][d][j];
304     calib.cstwerr[0] = ce->cstwerr[0];
305     calib.cperror[0] = ce->cperror[0];
306     calib.calgood[1][2*d][j] = ce->calgood[0][d][j];
307     calib.calthr[1][2*d][pre] = ce->calthr[0][d][pre];
308     calib.calrms[1][2*d][j] = ce->calrms[0][d][j];
309     calib.calbase[1][2*d][pre] = ce->calbase[0][d][pre];
310     calib.calvar[1][2*d][pre] = ce->calvar[0][d][pre];
311     };
312     if ( s == 1 ){
313     calib.calped[1][2*d+1][j] = ce->calped[2][d][j];
314     calib.cstwerr[2] = ce->cstwerr[2];
315     calib.cperror[2] = ce->cperror[2];
316     calib.calgood[1][2*d+1][j] = ce->calgood[2][d][j];
317     calib.calthr[1][2*d+1][pre] = ce->calthr[2][d][pre];
318     calib.calrms[1][2*d+1][j] = ce->calrms[2][d][j];
319     calib.calbase[1][2*d+1][pre] = ce->calbase[2][d][pre];
320     calib.calvar[1][2*d+1][pre] = ce->calvar[2][d][pre];
321     };
322     };
323     };
324     };
325     //
326     // Book the histograms:
327     //
328     //
329     Int_t i = (ci-minev)/4;
330     xviewev.str("");
331     xviewev << "x-view event " << (i+1);
332     yviewev.str("");
333     yviewev << "y-view event " << (i+1);
334     TH2F *Xview = new TH2F(xviewev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
335     TH2F *Yview = new TH2F(yviewev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
336     //
337     // figures:
338     //
339     gDirectory->Delete("C14");
340     gDirectory->Delete("C15");
341     gDirectory->Delete("C16");
342     TH1F *calped = new TH1F("C14","calped",4230,-3.5,4227.5);
343     TH1F *calrms = new TH1F("C15","calrms",4230,-3.5,4228.5);
344     TH1F *calbad = new TH1F("C16","calgood",4230,-3.5,4228.5);
345     //
346     gDirectory->Delete("C17");
347     gDirectory->Delete("C18");
348     gDirectory->Delete("C19");
349     TH1F *calthr = new TH1F("C17","calthr",271,-4.5,268.5);
350     TH1F *calvar = new TH1F("C18","calvar",271,-4.5,268.5);
351     TH1F *calbase = new TH1F("C19","calbase",271,-4.5,268.5);
352     //
353     Int_t bgcolor = 10;
354     TPad *pd1 = 0;
355     TPad *pd2 = 0;
356     TPad *palette = 0;
357     TLatex *t=new TLatex();
358     if ( figmatra ){
359     figura2 = new TCanvas("Calorimeter:_strip_RMS", "Calorimeter:_strip_RMS", 750, 650);
360     figura2->SetFillColor(10);
361     figura2->Range(0,0,100,100);
362     bgcolor = 10;
363     pd1 = new TPad("pd1","This is pad1",0.02,0.05,0.88,0.49,bgcolor);
364     pd2 = new TPad("pd2","This is pad2",0.02,0.51,0.88,0.95,bgcolor);
365     palette = new TPad("palette","This is palette",0.90,0.05,0.98,0.90,bgcolor);
366     figura2->cd();
367     gStyle->SetOptStat("");
368     t=new TLatex();
369     t->SetTextFont(32);
370     t->SetTextColor(1);
371     t->SetTextSize(0.03);
372     t->SetTextAlign(12);
373     t->DrawLatex(90.,92.5,"ADC ch.");
374     pd1->Range(0,0,100,100);
375     pd2->Range(0,0,100,100);
376     palette->Range(0,0,100,100);
377     pd1->SetTicks();
378     pd2->SetTicks();
379     pd1->Draw();
380     pd2->Draw();
381     palette->Draw();
382     palette->cd();
383     // palette
384     TPaveLabel *box1 = new TPaveLabel(2,2,98,14,"OFF","");
385     box1->SetTextFont(32);
386     box1->SetTextColor(1);
387     box1->SetTextSize(0.25);
388     box1->SetFillColor(10);
389     box1->Draw();
390     TPaveLabel *box2 = new TPaveLabel(2,16,98,28,"0-1.5","");
391     box2->SetTextFont(32);
392     box2->SetTextColor(1);
393     box2->SetTextSize(0.25);
394     box2->SetFillColor(38);
395     box2->Draw();
396     TPaveLabel *box3 = new TPaveLabel(2,30,98,42,"1.5-4","");
397     box3->SetTextFont(32);
398     box3->SetTextColor(1);
399     box3->SetTextSize(0.25);
400     box3->SetFillColor(4);
401     box3->Draw();
402     TPaveLabel *box4 = new TPaveLabel(2,44,98,56,"4-6.5","");
403     box4->SetTextFont(32);
404     box4->SetTextColor(1);
405     box4->SetTextSize(0.25);
406     box4->SetFillColor(3);
407     box4->Draw();
408     TPaveLabel *box5 = new TPaveLabel(2,58,98,70,"6.5-11.5","");
409     box5->SetTextFont(32);
410     box5->SetTextColor(1);
411     box5->SetTextSize(0.25);
412     box5->SetFillColor(2);
413     box5->Draw();
414     TPaveLabel *box6 = new TPaveLabel(2,72,98,84,">11.5","");
415     box6->SetTextFont(32);
416     box6->SetTextColor(1);
417     box6->SetTextSize(0.25);
418     box6->SetFillColor(6);
419     box6->Draw();
420     TPaveLabel *box7 = new TPaveLabel(2,86,98,98,"BAD","");
421     box7->SetTextFont(32);
422     box7->SetTextColor(10);
423     box7->SetTextSize(0.25);
424     box7->SetFillColor(1);
425     box7->Draw();
426     //
427     pd1->cd();
428     gStyle->SetOptStat("");
429     Xview->SetXTitle("strip");
430     Xview->SetYTitle("X - plane");
431     Xview->GetYaxis()->SetTitleOffset(0.5);
432     Xview->SetFillColor(bgcolor);
433     Xview->Fill(1.,1.,1.);
434     Xview->Draw("box");
435     pd1->Update();
436     pd2->cd();
437     gStyle->SetOptStat("");
438     Yview->SetXTitle("strip");
439     Yview->SetYTitle("Y - plane");
440     Yview->GetYaxis()->SetTitleOffset(0.5);
441     Yview->SetFillColor(bgcolor);
442     Yview->Fill(1.,1.,1.);
443     Yview->Draw("box");
444     pd2->Update();
445     };
446     //
447     // run over views and planes
448     //
449     Int_t j = 0;
450     Int_t g = 0;
451     gStyle->SetOptStat("");
452     for (Int_t m = 0; m < 22; m++){
453     for (Int_t l = 0; l < 2; l++){
454     for (Int_t n = 0; n < 96; n++){
455     //
456     calped->Fill((float)j,calib.calped[l][m][n]);
457     if ( (calib.calped[l][m][n] > 700. || calib.calped[l][m][n] < -700.) && (j < 4032 || j > 4048) ){
458     outcalped++;
459     } else {
460     incalped++;
461     };
462     calrms->Fill((float)j,(calib.calrms[l][m][n]/4.));
463     if ( (calib.calrms[l][m][n]/4.) > 7. || (calib.calrms[l][m][n]/4.) < 1. ){
464     outcalrms++;
465     } else {
466     incalrms++;
467     };
468     calbad->Fill((float)j,(float)calib.calgood[l][m][n]);
469     if ( calib.calgood[l][m][n] ) totcalbad++;
470     //
471     if ( n < 6 ){
472     calthr->Fill((float)g,(float)calib.calthr[l][m][n]);
473     if ( calib.calthr[l][m][n] > 21. || calib.calthr[l][m][n] < 12. ){
474     outcalthr++;
475     } else {
476     incalthr++;
477     };
478     calvar->Fill((float)g,(float)calib.calvar[l][m][n]);
479     if ( calib.calvar[l][m][n] > 8. || calib.calvar[l][m][n] < 1. ){
480     outcalvar++;
481     } else {
482     incalvar++;
483     };
484     calbase->Fill((float)g,(float)calib.calbase[l][m][n]);
485     if ( calib.calbase[l][m][n] > 4500. || calib.calbase[l][m][n] < 2000. ){
486     outcalbas++;
487     } else {
488     incalbas++;
489     };
490     g++;
491     };
492     //
493     j++;
494     //
495     if ( figmatra ){
496     figura2->cd();
497     xviewev.str("");
498     xviewev << "x-view " << i;
499     xviewev << " event " << n;
500     xviewev << " " << m;
501     xviewev << " " << l;
502     yviewev.str("");
503     yviewev << "y-view " << i;
504     yviewev << " event " << n;
505     yviewev << " " << m;
506     yviewev << " " << l;
507     TH2F *Xview = new TH2F(xviewev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
508     TH2F *Yview = new TH2F(yviewev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
509     if ( calib.calrms[l][m][n] > 0 ){
510     Xview->SetFillColor(38);
511     Yview->SetFillColor(38);
512     };
513     if ( calib.calrms[l][m][n] > 6 ){
514     Xview->SetFillColor(4);
515     Yview->SetFillColor(4);
516     };
517     if ( calib.calrms[l][m][n] > 16 ){
518     Xview->SetFillColor(3);
519     Yview->SetFillColor(3);
520     };
521     if ( calib.calrms[l][m][n] > 26 ){
522     Xview->SetFillColor(2);
523     Yview->SetFillColor(2);
524     };
525     if ( calib.calrms[l][m][n] > 46 ){
526     Xview->SetFillColor(6);
527     Yview->SetFillColor(6);
528     };
529     if ( calib.calrms[l][m][n] <= 0 || calib.calrms[l][m][n] >30000 || calib.calped[l][m][n]>25000){
530     Xview->SetFillColor(10);
531     Yview->SetFillColor(10);
532     };
533     if ( calib.calgood[l][m][n] != 0 ){
534     Xview->SetFillColor(1);
535     Yview->SetFillColor(1);
536     };
537     if ( l == 0 ) {
538     Xview->Fill(n,m,1.);
539     pd1->cd();
540     Xview->Draw("box same");
541     };
542     if ( l == 1 ) {
543     Yview->Fill(n,m,1.);
544     pd2->cd();
545     Yview->Draw("box same");
546     };
547     };
548     };
549     };
550     };
551     if ( figmatra ){
552     figura2->cd();
553     gStyle->SetOptStat("");
554     gStyle->SetOptDate(0);
555     t=new TLatex();
556     t->SetTextFont(32);
557     t->SetTextColor(1);
558     t->SetTextSize(0.03);
559     t->SetTextAlign(12);
560     titolo.str("");
561     titolo << "C13 - Calorimeter: strip RMS - file ";
562     titolo << file;
563     titolo << " - calibration number ";
564     titolo << (i+1);
565     t->DrawLatex(0.5,97.,titolo.str().c_str());
566     pd1->Update();
567     pd2->Update();
568     figura2->Update();
569     };
570     //
571     figura1 = new TCanvas("Calorimeter_calped_calrms_calgood", "Calorimeter_calped_calrms_calgood", 750, 950);
572     figura1->SetFillColor(10);
573     figura1->Range(0,0,100,100);
574     //
575     ccalped = (float)incalped/((float)outcalped + (float)incalped);
576     Int_t f1pd1col = 10;
577     if ( ccalped < ccalpedthr ) {
578     check = true;
579     f1pd1col = 45;
580     };
581     //
582     ccalrms = (float)incalrms/((float)outcalrms + (float)incalrms);
583     Int_t f1pd2col = 10;
584     if ( ccalrms < ccalrmsthr ) {
585     check = true;
586     f1pd2col = 45;
587     };
588     //
589     ccalbad = (float)totcalbad/4224.;
590     Int_t f1pd3col = 10;
591     if ( ccalbad > ccalbadthr ) {
592     check = true;
593     f1pd3col = 45;
594     };
595     //
596     TPad *f1pd1 = new TPad("f1pd1","This is f1pad1",0.02,0.684,0.98,0.95,f1pd1col);
597     TPad *f1pd2 = new TPad("f1pd2","This is f1pad2",0.02,0.367,0.98,0.634,f1pd2col);
598     TPad *f1pd3 = new TPad("f1pd3","This is f1pad3",0.02,0.05,0.98,0.317,f1pd3col);
599     figura1->Clear();
600     figura1->cd();
601     f1pd1->SetTicks();
602     f1pd2->SetTicks();
603     f1pd3->SetTicks();
604     f1pd1->Draw();
605     f1pd2->Draw();
606     f1pd3->Draw();
607     figura1->Draw();
608     figura3 = new TCanvas("Calorimeter_calthr_calvar_calbase", "Calorimeter_calthr_calvar_calbase", 750, 950);
609     figura3->SetFillColor(10);
610     figura3->Range(0,0,100,100);
611     //
612     ccalthr = (float)incalthr/((float)outcalthr + (float)incalthr);
613     Int_t f3pd1col = 10;
614     if ( ccalthr < ccalthrthr ) {
615     check = true;
616     f3pd1col = 45;
617     };
618     //
619     ccalvar = (float)incalvar/((float)outcalvar + (float)incalvar);
620     Int_t f3pd2col = 10;
621     if ( ccalvar < ccalvarthr ) {
622     check = true;
623     f3pd2col = 45;
624     };
625     //
626     ccalbas = (float)incalbas/((float)outcalbas + (float)incalbas);
627     Int_t f3pd3col = 10;
628     if ( ccalbas < ccalbasthr ) {
629     check = true;
630     f3pd3col = 45;
631     };
632     //
633     TPad *f3pd1 = new TPad("f3pd1","This is f3pad1",0.02,0.684,0.98,0.95,f3pd1col);
634     TPad *f3pd2 = new TPad("f3pd2","This is f3pad2",0.02,0.367,0.98,0.634,f3pd2col);
635     TPad *f3pd3 = new TPad("f3pd3","This is f3pad3",0.02,0.05,0.98,0.317,f3pd3col);
636     figura3->Clear();
637     figura3->cd();
638     f3pd1->SetTicks();
639     f3pd2->SetTicks();
640     f3pd3->SetTicks();
641     f3pd1->Draw();
642     f3pd2->Draw();
643     f3pd3->Draw();
644     figura3->Draw();
645     //
646     gStyle->SetOptStat("N");
647     figura1->cd();
648     gStyle->SetNdivisions(322,"x");
649     t=new TLatex();
650     t->SetTextFont(32);
651     t->SetTextColor(1);
652     t->SetTextSize(0.025);
653     t->SetTextAlign(12);
654     titolo.str("");
655     titolo << "EXPERT - Calorimeter: calped/calrms/calgood - file ";
656     titolo << file;
657     titolo << " - calibration number ";
658     titolo << (i+1);
659     t->DrawLatex(0.5,97.,titolo.str().c_str());
660     t->SetTextSize(0.03);
661     f1pd1->cd();
662     //
663     calped->GetXaxis()->SetNdivisions(322);
664     calped->SetXTitle("strip");
665     calped->SetYTitle("ADC channels");
666     calped->Draw();
667     TPolyLine *banda1;
668     Double_t xc[4] = {0.,4224.,4224.,0.};
669     Double_t yc[4] = {-700.,-700.,700.,700.};
670     banda1 = new TPolyLine(4,xc,yc);
671     banda1->SetLineColor(5);
672     banda1->SetFillColor(5);
673     banda1->SetLineWidth(1);
674     banda1->Draw("fSAME");
675     TPolyLine *banda2;
676     Double_t xc2[4] = {4031.5,4047.5,4047.5,4031.5};
677     Double_t yc2[4] = {-2500.,-2500.,28000.,28000.};
678     banda2 = new TPolyLine(4,xc2,yc2);
679     banda2->SetLineColor(5);
680     banda2->SetFillColor(5);
681     banda2->SetLineWidth(1);
682     banda2->Draw("fSAME");
683     calped->Draw("SAME");
684     f1pd2->cd();
685     f1pd2->SetLogy();
686     calrms->GetXaxis()->SetNdivisions(322);
687     calrms->Draw();
688     Double_t xd[4] = {0.,4224.,4224.,0.};
689     Double_t yd[4] = {1.,1.,7.,7.};
690     banda1 = new TPolyLine(4,xd,yd);
691     banda1->SetLineColor(5);
692     banda1->SetFillColor(5);
693     banda1->SetLineWidth(1);
694     banda1->Draw("fSAME");
695     calrms->SetXTitle("strip");
696     calrms->SetYTitle("ADC channels");
697     calrms->Draw("SAME");
698     f1pd3->cd();
699     gStyle->SetNdivisions(344,"x");
700     calbad->GetXaxis()->SetNdivisions(322);
701     calbad->Draw();
702     calbad->SetXTitle("strip");
703     calbad->SetYTitle("0=good 255=bad");
704     f1pd1->Update();
705     f1pd2->Update();
706     f1pd3->Update();
707     figura1->Update();
708     //
709     figura3->cd();
710     gStyle->SetNdivisions(644,"x");
711     t=new TLatex();
712     t->SetTextFont(32);
713     t->SetTextColor(1);
714     t->SetTextSize(0.025);
715     t->SetTextAlign(12);
716     titolo.str("");
717     titolo << "EXPERT - Calorimeter: calthr/calvar/calbase - file ";
718     titolo << file;
719     titolo << " - calibration number ";
720     titolo << (i+1);
721     t->DrawLatex(0.5,97.,titolo.str().c_str());
722     t->SetTextSize(0.03);
723     //
724     f3pd1->cd();
725     calthr->GetXaxis()->SetNdivisions(644);
726     calthr->SetXTitle("pre-amplifier");
727     calthr->SetYTitle("ADC channels");
728     calthr->Draw();
729     Double_t xe[4] = {0.,264.,264.,0.};
730     Double_t ye[4] = {12.,12.,21.,21.};
731     banda1 = new TPolyLine(4,xe,ye);
732     banda1->SetLineColor(5);
733     banda1->SetFillColor(5);
734     banda1->SetLineWidth(1);
735     banda1->Draw("fSAME");
736     calthr->Draw("SAME");
737     f3pd2->cd();
738     calvar->GetXaxis()->SetNdivisions(644);
739     calvar->SetXTitle("pre-amplifier");
740     calvar->SetYTitle("ADC channels");
741     calvar->Draw();
742     Double_t xt[4] = {0.,264.,264.,0.};
743     Double_t yt[4] = {1.,1.,8.,8.};
744     banda1 = new TPolyLine(4,xt,yt);
745     banda1->SetLineColor(5);
746     banda1->SetFillColor(5);
747     banda1->SetLineWidth(1);
748     banda1->Draw("fSAME");
749     calvar->Draw("SAME");
750     f3pd3->cd();
751     calbase->GetXaxis()->SetNdivisions(644);
752     calbase->SetXTitle("pre-amplifier");
753     calbase->SetYTitle("ADC channels");
754     calbase->Draw();
755     Double_t xg[4] = {0.,264.,264.,0.};
756     Double_t yg[4] = {2000.,2000.,4500.,4500.};
757     banda1 = new TPolyLine(4,xg,yg);
758     banda1->SetLineColor(5);
759     banda1->SetFillColor(5);
760     banda1->SetLineWidth(1);
761     banda1->Draw("fSAME");
762     calbase->Draw("SAME");
763     f3pd1->Update();
764     f3pd2->Update();
765     f3pd3->Update();
766     figura3->Update();
767     //
768     //
769     //
770     if ( ci == maxev-4 ) {
771     //
772     // report sheet:
773     //
774     stringstream errore;
775     rapporto= new TCanvas("Calorimeter calibration report", "Calorimeter calibration report", 750, 950);
776     rapporto->cd();
777     rapporto->SetFillColor(10);
778     rapporto->Range(0,0,100,100);
779     t=new TLatex();
780     t->SetTextFont(32);
781     t->SetTextColor(1);
782     t->SetTextSize(0.035);
783     t->SetTextAlign(12);
784     errore.str("");
785     errore << "BASIC - C20 - Calibrations in file: " << file;
786     errore << " ";
787     t->SetTextSize(0.02);
788     t->DrawLatex(2.,99.,errore.str().c_str());
789     //
790     TPad *pad1;
791     TPad *pad2;
792     TPad *pad3;
793     TPad *pad4;
794     pad1 = new TPad("pad1","This is pad1",0.02,0.47,0.49,0.90,19);
795     pad2 = new TPad("pad2","This is pad2",0.51,0.47,0.98,0.90,19);
796     pad3 = new TPad("pad3","This is pad3",0.02,0.02,0.49,0.45,19);
797     pad4 = new TPad("pad4","This is pad4",0.51,0.02,0.98,0.45,19);
798     pad1->Range(0,0,100,100);
799     pad2->Range(0,0,100,100);
800     pad3->Range(0,0,100,100);
801     pad4->Range(0,0,100,100);
802     //
803     pad1->Draw();
804     pad2->Draw();
805     pad3->Draw();
806     pad4->Draw();
807     //
808     char *sezione = 0;
809     for (Int_t si = 0; si < 4; si++){
810     if (si == 2)
811     {
812     pad1->cd() ;
813     sezione = "** Section YE (x even) **";
814     }
815     if (si == 3)
816     {
817     pad2->cd();
818     sezione = "** Section YO (x odd) **";
819     }
820     if (si == 0)
821     {
822     pad3->cd();
823     sezione = "** Section XE (y odd) **";
824     }
825     if (si == 1)
826     {
827     pad4->cd();
828     sezione = "** Section XO (y even) **";
829     }
830     t->SetTextFont(32);
831     t->SetTextColor(1);
832     t->SetTextSize(0.05);
833     t->SetTextAlign(12);
834     t->DrawLatex(33.,97.,sezione);
835     t->SetTextSize(0.05);
836     for (Int_t j = 0; j < 23; j++){
837     if ( ver[si][j] ) {
838     t->SetTextColor(50);
839     if (j == 0) {
840     errore.str("");
841     errore << "* DSP ack error: " << ver[si][j];
842     errore << " time(s)";
843     t->DrawLatex(2.,30.,errore.str().c_str());
844     check = true;
845     }
846     if (j == 1) {
847     errore.str("");
848     errore << "* Temperature alarm: " << ver[si][j];
849     errore << " time(s)";
850     t->DrawLatex(2.,74.,errore.str().c_str());
851     check = true;
852     }
853     if (j == 2) {
854     errore.str("");
855     errore << "* Latch up alarm: " << ver[si][j];
856     errore << " time(s).";
857     t->DrawLatex(2.,65.,errore.str().c_str());
858     check = true;
859     }
860     if (j == 3) {
861     errore.str("");
862     errore << "RAW mode: " << ver[si][j];
863     errore << " time(s)";
864     t->SetTextColor(38);
865     t->DrawLatex(2.,90.,errore.str().c_str());
866     }
867     if (j == 4) {
868     errore.str("");
869     errore << "* CMD length error: " << ver[si][j];
870     errore << " time(s)";
871     t->DrawLatex(2.,66.,errore.str().c_str());
872     check = true;
873     }
874     if (j == 5) {
875     errore.str("");
876     errore << "* Execution error: " << ver[si][j];
877     errore << " time(s)";
878     t->DrawLatex(2.,62.,errore.str().c_str());
879     check = true;
880     }
881     if (j == 6) {
882     errore.str("");
883     errore << "* CRC error (st. word): " << ver[si][j];
884     errore << " time(s)";
885     t->DrawLatex(2.,58.,errore.str().c_str());
886     check = true;
887     }
888     if (j == 7) {
889     errore.str("");
890     errore << "View or command not recognized: " << ver[si][j];
891     errore << " time(s)";
892     t->DrawLatex(2.,54.,errore.str().c_str());
893     check = true;
894     }
895     //
896     if (j == 8) {
897     errore.str("");
898     errore << "Missing section: " << ver[si][j];
899     errore << " time(s)";
900     t->DrawLatex(2.,50.,errore.str().c_str());
901     check = true;
902     }
903     if (j == 9) {
904     errore.str("");
905     errore << "RAW MODE COMMAND: " << ver[si][j];
906     errore << " time(s)";
907     t->DrawLatex(2.,42.,errore.str().c_str());
908     }
909     if (j == 11) {
910     errore.str("");
911     errore << "CRC error (data): " << ver[si][j];
912     errore << " time(s)";
913     t->DrawLatex(2.,38.,errore.str().c_str());
914     check = true;
915     }
916     if (j == 16) {
917     errore.str("");
918     errore << "Number of calibrations: " << ver[si][j];
919     t->SetTextColor(38);
920     t->DrawLatex(2.,86.,errore.str().c_str());
921     }
922     if (j == 19) {
923     errore.str("");
924     errore << "Pedestal checksum wrong: " << ver[si][j];
925     errore << " time(s)";
926     t->DrawLatex(2.,14.,errore.str().c_str());
927     check = true;
928     }
929     if (j == 20) {
930     errore.str("");
931     errore << "Thresholds checksum wrong: " << ver[si][j];
932     errore << " time(s)";
933     t->DrawLatex(2.,10.,errore.str().c_str());
934     check = true;
935     }
936     if (j == 22) {
937     errore.str("");
938     errore << "Packet length is zero (YODA input error), skipped: " << ver[si][j];
939     errore << " time(s)";
940     t->DrawLatex(2.,3.,errore.str().c_str());
941     check = true;
942     };
943     };
944     };
945     };
946     rapporto->cd();
947     t->SetTextFont(32);
948     t->SetTextColor(1);
949     t->SetTextSize(0.035);
950     t->SetTextAlign(12);
951     t->DrawLatex(7.,95.,"Calorimeter CALIBRATION quick look: ");
952     //printf("vediamo: ccalped %f ccalrms %f ccalbad %f ccalthr %f ccalvar %f ccalbas %f \n",ccalped,ccalrms,ccalbad,ccalthr,ccalvar,ccalbas);
953     if ( check ) {
954     t->SetTextColor(50);
955     t->DrawLatex(65.,95.,"WARNING, CHECK!");
956     t->SetTextColor(1);
957     } else {
958     t->SetTextColor(38);
959     t->DrawLatex(65.,95.,"OK!");
960     t->SetTextColor(1);
961     };
962     rapporto->Update();
963     };
964     //
965     if ( !strcmp(format,"ps") ) {
966     if ( ci == minev ) {
967     figsave.str("");
968     figsave << outdir << "/" ;
969 mocchiut 1.8 figsave << figrec << "_CaloCHKCALIB.";
970 mocchiut 1.1 figsave << format;
971     figsave << "(";
972     };
973     if ( figmatra ) {
974     figura2->Print(figsave.str().c_str(),"Portrait");
975     if ( ci == minev ) {
976     figsave.str("");
977     figsave << outdir << "/" ;
978 mocchiut 1.8 figsave << figrec << "_CaloCHKCALIB.";
979 mocchiut 1.1 figsave << format;
980     };
981     };
982     //
983     figura1->Print(figsave.str().c_str(),"Portrait");
984     if ( ci == minev ) {
985     figsave.str("");
986     figsave << outdir << "/" ;
987 mocchiut 1.8 figsave << figrec << "_CaloCHKCALIB.";
988 mocchiut 1.1 figsave << format;
989     };
990     //
991     figura3->Print(figsave.str().c_str(),"Portrait");
992     //
993     if ( ci == maxev-4 ) {
994     figsave.str("");
995     figsave << outdir << "/" ;
996 mocchiut 1.8 figsave << figrec << "_CaloCHKCALIB.";
997 mocchiut 1.1 figsave << format;
998     figsave << ")";
999     rapporto->Print(figsave.str().c_str(),"Portrait");
1000     };
1001     } else {
1002     if ( figmatra ) {
1003     figsave.str("");
1004     figsave << outdir << "/" ;
1005 mocchiut 1.8 figsave << figrec << "_CaloCHKCALIB1_";
1006 mocchiut 1.1 figsave << (i+1) << ".";
1007     figsave << format;
1008     figura2->SaveAs(figsave.str().c_str());
1009     };
1010     //
1011     figsave1.str("");
1012     figsave1 << outdir << "/" ;
1013 mocchiut 1.8 figsave1 << figrec << "_CaloCHKCALIB2_";
1014 mocchiut 1.1 figsave1 << (i+1) << ".";
1015     figsave1 << format;
1016     figura1->SaveAs(figsave1.str().c_str());
1017     //
1018     figsave2.str("");
1019     figsave2 << outdir << "/" ;
1020 mocchiut 1.8 figsave2 << figrec << "_CaloCHKCALIB3_";
1021 mocchiut 1.1 figsave2 << (i+1) << ".";
1022     figsave2 << format;
1023     figura3->SaveAs(figsave2.str().c_str());
1024     //
1025     if ( ci == maxev-4 ) {
1026     figsave.str("");
1027     figsave << outdir << "/" ;
1028 mocchiut 1.8 figsave << figrec << "_CaloCHKCALIB_report.";
1029 mocchiut 1.1 figsave << format;
1030     rapporto->SaveAs(figsave.str().c_str());
1031     };
1032     };
1033     };
1034     printf("\n");
1035     return;
1036     }

  ViewVC Help
Powered by ViewVC 1.1.23