/[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.9 - (hide annotations) (download)
Mon Jul 17 08:51:11 2006 UTC (18 years, 5 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r11, v1r12
Changes since 1.8: +47 -28 lines
Adapted to flight conditions

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

  ViewVC Help
Powered by ViewVC 1.1.23