/[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.5 - (hide annotations) (download)
Mon Mar 20 13:40:43 2006 UTC (18 years, 8 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r04
Changes since 1.4: +3 -1 lines
Updated the operation manual

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

  ViewVC Help
Powered by ViewVC 1.1.23