/[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.7 - (hide annotations) (download)
Wed Mar 22 15:04:11 2006 UTC (18 years, 8 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r06, v1r07
Changes since 1.6: +3 -1 lines
Added -O flag

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

  ViewVC Help
Powered by ViewVC 1.1.23