/[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.1 - (show annotations) (download)
Thu Mar 9 16:14:32 2006 UTC (18 years, 9 months ago) by mocchiut
Branch: MAIN
Branch point for: FQLOOK
Initial revision

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

  ViewVC Help
Powered by ViewVC 1.1.23