/[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.3 - (hide annotations) (download)
Mon Mar 13 14:49:31 2006 UTC (18 years, 8 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r02
Changes since 1.2: +4 -2 lines
Bug: include files from YODA from the wrong directory, fixed.

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

  ViewVC Help
Powered by ViewVC 1.1.23