/[PAMELA software]/quicklook/calo/FQLOOK/macros/FCaloCHKCALIB.cxx
ViewVC logotype

Contents of /quicklook/calo/FQLOOK/macros/FCaloCHKCALIB.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download)
Wed Mar 22 14:01:56 2006 UTC (18 years, 8 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r05
Changes since 1.5: +3 -1 lines
Documentation updated, small changes in lib names

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

  ViewVC Help
Powered by ViewVC 1.1.23