/[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.2 - (hide annotations) (download)
Mon Mar 13 09:01:22 2006 UTC (18 years, 8 months ago) by mocchiut
Branch: MAIN
Changes since 1.1: +8 -2 lines
First calorimeter flight quick look release

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

  ViewVC Help
Powered by ViewVC 1.1.23