/[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.4 - (show annotations) (download)
Mon Mar 20 11:52:33 2006 UTC (18 years, 8 months ago) by mocchiut
Branch: MAIN
Changes since 1.3: +3 -1 lines
Changed name of shared libraries from FCaloXXX_cxx.so to libFCaloXXX.so

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

  ViewVC Help
Powered by ViewVC 1.1.23