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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Fri Aug 4 15:24:01 2006 UTC (18 years, 4 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r13
Changes since 1.9: +972 -957 lines
Bug fixed in CHKCALIB + new features added

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

  ViewVC Help
Powered by ViewVC 1.1.23