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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (show annotations) (download)
Thu Sep 28 19:39:00 2006 UTC (18 years, 2 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r17
Changes since 1.16: +20 -18 lines
Bug fixed in number of event determination

1 //
2 // Check for possible errors and shows raw distribution of variables coming from the DSP (no calibrations needed) - Emiliano Mocchiutti
3 //
4 // FCaloQLOOK.c version 1.13 (2006-09-28)
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.12 - 1.13 (2006-09-28): Give wrong number of events in compress mode, fixed.
11 //
12 // 1.11 - 1.12 (2006-09-22): Check for different number of events, put output in a file and write down errors for each event. Fixed jumpev bug.
13 //
14 // 1.09 - 1.11 (2006-07-17): Adapted to flight conditions.
15 //
16 // 1.07 - 1.09 (2006-05-29): Fixed bug in output filename when input is not in the form DW_YYMMDD_NNN. Bug in latchup alarm not coming from the status word, fixed.
17 //
18 // 1.06 - 1.07 (2006-05-23): Don't print warning in case of latchup not recognized from the status word, fixed. Added "expert" figures from 21 to 28 which appears only in the
19 // case of latchup alarm.
20 //
21 // 1.05 - 1.06 (2006-03-22): Add optimize flag in compiling the script!
22 //
23 // 1.04 - 1.05 (2006-03-22): Corrected wrong .C files.
24 //
25 // 1.03 - 1.04 (2006-03-20): Documentation updated.
26 //
27 // 1.02 - 1.03 (2006-03-20): Changed name of shared libraries (from FCaloQLOOK_cxx.so to libFCaloQLOOK.so).
28 //
29 // 1.01 - 1.02 (2006-03-13): Include files from YODA without "event" directory.
30 //
31 // 1.00 - 1.01 (2006-02-28): Works on YODA v6 output (single file), does not require anymore calocommon package.
32 //
33 // 0.00 - 1.00 (2006-02-28): Clone of CaloQLOOK.c (ground software).
34 //
35 #include <iostream>
36 #include <fstream>
37 //
38 #include <TObject.h>
39 #include <TString.h>
40 #include <TFile.h>
41 #include <TCanvas.h>
42 #include <TH1.h>
43 #include <TH1F.h>
44 #include <TH2D.h>
45 #include <TLatex.h>
46 #include <TPad.h>
47 #include <TPolyLine.h>
48 #include <TStyle.h>
49 #include <TSystem.h>
50 #include <TApplication.h>
51 //
52 #include <PamelaRun.h>
53 #include <physics/calorimeter/CalorimeterEvent.h>
54 //
55 #include <FCaloQLOOKfun.h>
56 //
57 using namespace std;
58 //
59 void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){
60 if ( to == 0 ){
61 Int_t t2length = s2.Length();
62 s1 = "";
63 to = t2length;
64 };
65 for (Int_t i = from; i<to; i++){
66 s1.Append(s2[i],1);
67 };
68 }
69 void stringappend(TString& s1, const TString& s2){
70 Int_t t2length = s2.Length();
71 for (Int_t i = 0; i<t2length; i++){
72 s1.Append(s2[i],1);
73 };
74 }
75
76 TString getFilename(const TString filename){
77 //
78 const string fil = gSystem->BaseName(filename.Data());
79 Int_t posiz = fil.find(".root");
80 //
81 TString file2;
82 if ( posiz == -1 ){
83 file2 = gSystem->BaseName(filename.Data());
84 } else {
85 Int_t posiz2 = 0;
86 stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz);
87 TString pdat(".dat");
88 stringappend(file2,pdat);
89 };
90 return file2;
91 }
92
93 void sighandler(UInt_t pkt_num, UInt_t obt, UInt_t entry, UInt_t section, UInt_t totev, Bool_t &evdone){
94 if ( !evdone ){
95 printf("\n\n=================================================\n");
96 printf("PSCU-Pkt N. %u - OBT %u ms\n",pkt_num,obt);
97 printf("Total events %u\n",totev);
98 printf("(ROOT-tree entry %u )\n",entry);
99 printf("=================================================\n");
100 evdone = true;
101 };
102 TString sec = "UNKNOWN";
103 if ( section == 0 ) sec = "XE";
104 if ( section == 1 ) sec = "XO";
105 if ( section == 2 ) sec = "YE";
106 if ( section == 3 ) sec = "YO";
107 printf(" Section %s (DSP n. %i) message: ",sec.Data(),section);
108 };
109
110 void FCaloQLOOK(TString filename, Int_t fromevent=0, Int_t toevent=0, TString outDir="", TString saveas = "png", Bool_t iactive =false, Bool_t w4i=false){
111 gStyle->SetPaperSize(19.,25.);
112 const char* startingdir = gSystem->WorkingDirectory();
113 // printf(" basename is %s \n",gSystem->BaseName(filename.Data()));
114 // printf(" getfilename is %s \n",getFilename(filename).Data());
115 if ( !strcmp(outDir.Data(),"") ) outDir = startingdir;
116 //
117 TApplication *app = 0;
118 if ( iactive ) app = new TApplication("app",0,0);
119 //
120 ifstream myfile;
121 myfile.open(filename.Data());
122 if ( !myfile ){
123 printf(" %s :no such file, exiting...\n\n",filename.Data());
124 return;
125 };
126 myfile.close();
127 //
128 TFile *File = new TFile(filename.Data());
129 TTree *tr = (TTree*)File->Get("Physics");
130 if ( !tr ) {
131 printf(" Physics : no such tree in %s \n",filename.Data());
132 printf(" Exiting, are you sure this is a LEVEL0 not corrupted file? \n\n");
133 return;
134 };
135 //
136 // Define variables
137 //
138 Float_t ctshitthr = 0.65;
139 Float_t cbasethr = 0.95;
140 Float_t cdexythr = 0.995;
141 //Float_t cdexythr = 0.90;
142 Float_t cdexycthr = 0.95;
143 Float_t h1rth = 0.90;
144 Int_t calevnth = 13;
145 //
146 pamela::calorimeter::CalorimeterEvent *ce = 0;
147 pamela::EventHeader *eh = 0;
148 pamela::PscuHeader *ph = 0;
149 //
150 UInt_t found;
151 tr->SetBranchStatus("*",0,&found); //disable all branches
152 //
153 found = 0;
154 tr->SetBranchStatus("iev*",1,&found);
155 // printf("enabled %i branches \n",found);
156 found = 0;
157 tr->SetBranchStatus("dexy*",1,&found);
158 // printf("enabled %i branches \n",found);
159 found = 0;
160 tr->SetBranchStatus("stwerr*",1,&found);
161 // printf("enabled %i branches \n",found);
162 found = 0;
163 tr->SetBranchStatus("perror*",1,&found);
164 // printf("enabled %i branches \n",found);
165 found = 0;
166 tr->SetBranchStatus("cal*",1,&found);
167 // printf("enabled %i branches \n",found);
168 found = 0;
169 tr->SetBranchStatus("base*",1,&found);
170 //printf("enabled %i branches \n",found);
171 found = 0;
172 tr->SetBranchStatus("Pscu*",1,&found);
173 //printf("enabled %i branches \n",found);
174 found = 0;
175 tr->SetBranchStatus("Calorimeter*",1,&found);
176 //printf("calo enabled %i branches \n",found);
177 found = 0;
178 tr->SetBranchStatus("Header*",1,&found);
179 //printf("head enabled %i branches \n",found);
180 //
181 tr->SetBranchAddress("Calorimeter", &ce);
182 tr->SetBranchAddress("Header", &eh);
183 //
184 Long64_t nevents = tr->GetEntries();
185 if ( nevents < 1 ) {
186 printf("The file is empty!\n");
187 return;
188 };
189 Int_t const size = nevents;
190 Double_t iev2[size+1];
191 Int_t ver[4][23], lver[4][23],shit[4][11], rshit[4][11], se,bl, pl, fulldiff[4],cshit, cpre[4],nullsh[4][11], lalarm[4];
192 se = 0;
193 pl = 0;
194 Float_t allbase = 0.;
195 Int_t tshit, trshit, compdata,rawdata, errorfull, calevn1, calevn2, calevn3, calevn4, pshit[4][11];
196 tshit = 0;
197 trshit = 0;
198 char *sezione;
199 Bool_t check = false;
200 sezione = "";
201 stringstream errore;
202 errore.str("");
203 //
204 TString fififile = getFilename(filename);
205 const char *file = fififile;
206 //
207 // book histograms
208 //
209 TH1F *h1;
210 TH1F *h1r;
211 TH1F *hdiff;
212 TH1F *Baseline;
213 TH1F *Dexy;
214 TH1F *Dexyc;
215 TH1F *Calstriphit;
216 TH1F *calev01;
217 TH1F *calev23;
218 TH1F *calev03;
219 TH1F *lupstw[4];
220 TH1F *lup[4];
221 TH2D *calev2;
222
223 h1 = new TH1F("C7","Strips hit, compress mode",100,0.,200.);
224 h1r = new TH1F("C8","Strips hit, raw mode",100,-1,1);
225 h1r->SetBit(TH1F::kCanRebin);
226 hdiff = new TH1F("C6","Differences in full mode",100,-3,3);
227 hdiff->SetBit(TH1F::kCanRebin);
228 Baseline = new TH1F("C9","baselines",100,0,3);
229 Baseline->SetBit(TH1F::kCanRebin);
230 Dexy = new TH1F("C12","dexy",100,0.,10000.);
231 Dexy->SetBit(TH1F::kCanRebin);
232 Dexyc = new TH1F("C10","dexyc",100,-100.,37000.);
233 // Dexyc->SetBit(TH1F::kCanRebin);
234 Calstriphit = new TH1F("C11","calstriphit[1:4]",100,0.,200.);
235
236 calev01 = new TH1F("C3","|calevnum(1)-calevnum(2)|",100,0,1);
237 calev01->SetBit(TH1F::kCanRebin);
238 calev23 = new TH1F("C4","|calevnum(3)-calevnum(4)|",100,0,1);
239 calev23->SetBit(TH1F::kCanRebin);
240 calev03 = new TH1F("C5","|calevnum(1)-calevnum(4)|",100,0,1);
241 calev03->SetBit(TH1F::kCanRebin);
242 calev2 = new TH2D("C2","calevnum(2)%iev",3000,0.,2.,100,0.,2.);
243 calev2->SetBit(TH2D::kCanRebin);
244
245 stringstream oss;
246 stringstream noss;
247 for ( Int_t i=0; i<4; i++){
248 oss.str("");
249 oss << "OBT stw latch up section " << i;
250 noss.str("");
251 noss << "C" << 21+i;
252 lupstw[i] = new TH1F(noss.str().c_str(),oss.str().c_str(),100,-1,1);
253 lupstw[i]->SetBit(TH1F::kCanRebin);
254 oss.str("");
255 oss << "OBT no stw latch up section " << i;
256 noss.str("");
257 noss << "C" << 25+i;
258 lup[i] = new TH1F(noss.str().c_str(),oss.str().c_str(),100,-1,1);
259 lup[i]->SetBit(TH1F::kCanRebin);
260 };
261
262 //
263 // run over each event and take out some variables
264 //
265 if ( fromevent > toevent && toevent ){
266 printf("It must be fromevent < toevent \n");
267 return;
268 };
269
270
271 if ( fromevent > nevents+1 || fromevent < 0 ) {
272 printf("You can choose fromevent between 0 (all) and %i \n",(int)nevents+1);
273 return;
274 };
275
276 if ( toevent > nevents+1 || toevent < 0 ) {
277 printf("You can choose toevent between 0 (all) and %i \n",(int)nevents+1);
278 return;
279 };
280 Int_t minevent = 0;
281 Int_t maxevent = 0;
282 if ( fromevent == 0 ) {
283 minevent = 0;
284 maxevent = nevents -1;
285 } else {
286 minevent = fromevent - 1;
287 if ( toevent > 0 ){
288 maxevent = toevent - 1;
289 } else {
290 maxevent = fromevent - 1;
291 };
292 };
293
294 for (Int_t k = 0; k < 4; k++ ){
295 for (Int_t m = 0; m < 23 ; m++ ){
296 ver[k][m] = 0 ;
297 lver[k][m] = 0 ;
298 cpre[k]=0;
299 if ( m < 11 ) {
300 pshit[k][m] = 0;
301 nullsh[k][m] = 0;
302 };
303 lalarm[k] = 0;
304 };
305 };
306 Int_t pdone, bdone;
307 pdone = 0;
308 bdone = 0;
309 bool isCOMP = false;
310 bool isFULL = false;
311 bool isRAW = false;
312 Int_t alldexy=0;
313 Int_t alldexy2=0;
314 Int_t planebases=0;
315 // Int_t stri=0;
316 Int_t fcheck = 0;
317 Int_t cestw=0;
318 Int_t cmask = 127 ;
319 compdata = 0;
320 rawdata = 0;
321 errorfull = 0;
322 calevn1 = 0;
323 calevn2 = 0;
324 calevn3 = 0;
325 calevn4 = 0;
326 fulldiff[0] = 0;
327 fulldiff[1] = 0;
328 fulldiff[2] = 0;
329 fulldiff[3] = 0;
330 // printf("\n Processed events: \n\n");
331 printf("\n Start processing: \n\n");
332 unsigned short int calev0=0;
333 unsigned short int oldcalev0;
334 unsigned short int calev1=0;
335 unsigned short int oldcalev1;
336 unsigned short int calevv2=0;
337 unsigned short int oldcalev2;
338 unsigned short int calev3=0;
339 unsigned short int oldcalev3;
340 Int_t i = minevent;
341 UInt_t headc = 0;
342 UInt_t headco = 0;
343 Bool_t h1rcheck = false;
344 Int_t h1rin = 0;
345 Int_t h1rout = 0;
346 Int_t intshit = 0;
347 Int_t outtshit = 0;
348 Int_t incshit = 0;
349 Int_t outcshit = 0;
350 Int_t inbase = 0;
351 Int_t outbase = 0;
352 Int_t indexy = 0;
353 Int_t outdexy = 0;
354 Int_t indexyc = 0;
355 Int_t outdexyc = 0;
356 UInt_t obt = 0;
357 UInt_t minobt[4];
358 UInt_t maxobt[4];
359 UInt_t swminobt[4];
360 UInt_t swmaxobt[4];
361 Bool_t firstobt[4];
362 Bool_t swfirstobt[4];
363 for ( Int_t i = 0; i<4; i++){
364 minobt[i] = 0;
365 maxobt[i] = 0;
366 swminobt[i] = 0;
367 swmaxobt[i] = 0;
368 firstobt[i] = true;
369 swfirstobt[i] = true;
370 };
371 Bool_t evdone = false;
372 //
373 while ( i < maxevent+1){
374 evdone = false;
375 tshit = 0;
376 trshit = 0;
377 tr->GetEntry(i);
378 iev2[i] = ce->iev;
379 //
380 ph = eh->GetPscuHeader();
381 headco = headc;
382 headc = ph->GetCounter();
383 obt = ph->GetOrbitalTime();
384 if ( (int)abs((int)(ce->calevnum[0]-ce->calevnum[1])) ) calevn1++;
385 if ( (int)abs((int)(ce->calevnum[2]-ce->calevnum[3])) ) calevn2++;
386 if ( (int)abs((int)(ce->calevnum[0]-ce->calevnum[3])) ) calevn3++;
387 calev01->Fill(abs((int)(ce->calevnum[0]-ce->calevnum[1])));
388 calev23->Fill(abs((int)(ce->calevnum[2]-ce->calevnum[3])));
389 calev03->Fill(abs((int)(ce->calevnum[0]-ce->calevnum[3])));
390 unsigned short calvnm2 = (unsigned short)ce->calevnum[2];
391 calev2->Fill(ce->iev,calvnm2);
392 calevn4 += (int)ce->calevnum[2];
393 oldcalev0 = calev0;
394 calev0 = (int)ce->calevnum[0];
395 oldcalev1 = calev1;
396 calev1 = (int)ce->calevnum[1];
397 oldcalev2 = calevv2;
398 calevv2 = (int)ce->calevnum[2];
399 oldcalev3 = calev3;
400 calev3 = (int)ce->calevnum[3];
401 // goto jumpprintout;
402 if ( (headc - headco -1) == 0. && ((calev0 - oldcalev0 - 1) > 0 || (calev1 - oldcalev1 - 1) > 0 || (calevv2 - oldcalev2 - 1) > 0 || (calev3 - oldcalev3 - 1) > 0) ){
403 if ( i != minevent ) {
404 // printf(" %f 0 Event %i: %i\n",headco,i,oldcalev0);
405 // printf(" %f 0 Event %i: %i\n",headc,i+1,calev0);
406 // printf(" %f 1 Event %i: %i\n",headco,i,oldcalev1);
407 // printf(" %f 1 Event %i: %i\n",headc,i+1,calev1);
408 // printf(" %f 2 Event %i: %i\n",headco,i,oldcalev2);
409 // printf(" %f 2 Event %i: %i\n",headc,i+1,calevv2);
410 // printf(" %f 3 Event %i: %i\n",headco,i,oldcalev3);
411 // printf(" %f 3 Event %i: %i\n",headc,i+1,calev3);
412 isRAW = 0;
413 if ( ce->stwerr[0] & (1 << 3)) isRAW = 1;
414 if ( (calev0 - oldcalev0 - 1) > 0 && !isRAW && ce->perror[0] != 129 && oldcalev0 != 0) {
415 ver[0][10]++;
416 sighandler(headc,obt,i,0,nevents,evdone);
417 printf(" jump in the counter calev is %i oldcalev was %i \n",calev0,oldcalev0);
418 };
419 isRAW = 0;
420 if ( ce->stwerr[0] & (1 << 3)) isRAW = 1;
421 if ( (calev1 - oldcalev1 - 1) > 0 && !isRAW && ce->perror[1] != 129 && oldcalev1 != 0 ){
422 ver[1][10]++;
423 sighandler(headc,obt,i,1,nevents,evdone);
424 printf(" jump in the counter calev is %i oldcalev was %i \n",calev1,oldcalev1);
425 };
426 isRAW = 0;
427 if ( ce->stwerr[0] & (1 << 3)) isRAW = 1;
428 if ( (calevv2 - oldcalev2 - 1) > 0 && !isRAW && ce->perror[2] != 129 && oldcalev2 != 0 ){
429 ver[2][10]++;
430 sighandler(headc,obt,i,2,nevents,evdone);
431 printf(" jump in the counter calev is %i oldcalev was %i \n",calevv2,oldcalev2);
432 };
433 isRAW = 0;
434 if ( ce->stwerr[0] & (1 << 3)) isRAW = 1;
435 if ( (calev3 - oldcalev3 - 1) > 0 && !isRAW && ce->perror[3] != 129 && oldcalev3 != 0 ){
436 ver[3][10]++;
437 sighandler(headc,obt,i,3,nevents,evdone);
438 printf(" jump in the counter calev is %i oldcalev was %i \n",calev3,oldcalev3);
439 };
440 }
441 };
442 // jumpprintout:
443 memcpy(shit, nullsh, sizeof(nullsh));
444 memcpy(rshit, nullsh, sizeof(nullsh));
445 for (Int_t l = 0; l < 2; l++ ){
446 for (Int_t ii = 0; ii < 22; ii++){
447 if (l == 0 && ii%2 == 0){
448 se = 3;
449 pl = ii/2;
450 pdone = 0;
451 };
452 if (l == 0 && ii%2 != 0){
453 se = 2;
454 pl = (ii-1)/2;
455 pdone = 0;
456 };
457 if (l == 1 && ii%2 == 0){
458 se = 0;
459 pl = ii/2;
460 pdone = 0;
461 };
462 if (l == 1 && ii%2 != 0){
463 se = 1;
464 pl = (ii-1)/2;
465 pdone = 0;
466 };
467 isCOMP = false;
468 isFULL = false;
469 isRAW = false;
470 if ( ce->stwerr[se] & (1 << 16) ) isCOMP = true;
471 if ( ce->stwerr[se] & (1 << 17) ) isFULL = true;
472 if ( ce->stwerr[se] & (1 << 3) ) isRAW = true;
473 bl = -1;
474 for (Int_t kk = 0; kk < 96 ; kk++ ){
475 if ( kk%16 == 0 ){
476 bdone = 0;
477 bl++;
478 allbase = ce->base[l][ii][bl];
479 // alldexy=0;
480 // alldexy2=0;
481 // stri=0;
482 // for (Int_t e = 0; e < 16 ; e++ ){
483 // stri = e + 16 * bl;
484 // alldexy += (int)ce->dexyc[l][ii][stri];
485 // alldexy2 += (int)ce->dexy[l][ii][stri];
486 // };
487 };
488 //
489 if ( kk == 0 ){
490 planebases = 0;
491 alldexy=0;
492 alldexy2=0;
493 for (Int_t e = 0; e < 96 ; e++ ){
494 if ( e < 6 ) planebases += (int)ce->base[l][ii][e];
495 alldexy += (int)ce->dexyc[l][ii][e];
496 alldexy2 += (int)ce->dexy[l][ii][e];
497 };
498 };
499 //
500 if ( !isRAW ) {
501 //
502 if ( !pdone ){
503 // if ( (ce->base[l][ii][bl]>32000 || ce->base[l][ii][bl] == 0 ) && ( alldexy > 512000 || alldexy == 0) && ce->perror[se] == 0 ) {
504 if ( (planebases>192000 || planebases == 0 ) && ( alldexy > 3072000 || alldexy == 0) && ce->perror[se] == 0 ) {
505 pdone = 1;
506 pshit[se][pl]++ ;
507 if ( (ce->stwerr[se] & (1 << 4)) == 0 ) {
508 lalarm[se]++;
509 lup[se]->Fill(obt);
510 if ( firstobt[se] ) minobt[se] = obt;
511 if ( obt > maxobt[se] ) maxobt[se] = obt;
512 };
513 lver[se][2]++ ;
514 sighandler(headc,obt,i,se,nevents,evdone);
515 printf(" latch up (data) in DSP mode alldexy %i planebases %i \n",alldexy,planebases);
516 };
517 }
518 //
519 if ( !bdone ){
520 Baseline->Fill(ce->base[l][ii][bl]);
521 if ( ce->base[l][ii][bl] > 2000. && ce->base[l][ii][bl] < 4500. ){
522 inbase++;
523 } else {
524 outbase++;
525 };
526 bdone = 1;
527 };
528 //
529 if (ce->dexyc[l][ii][kk] > 0 ) {
530 shit[se][pl]++ ;
531 compdata = 1;
532 };
533 //
534 if ( isFULL ) {
535 if ( ce->dexy[l][ii][kk] > 0 && ce->dexy[l][ii][kk] < 32000 ) {
536 rshit[se][pl]++ ;
537 rawdata = 1;
538 };
539 Dexy->Fill(ce->dexy[l][ii][kk]);
540 if ( ce->dexy[l][ii][kk] < 2000. || ce->dexy[l][ii][kk] > 5000. ) {
541 outdexy++;
542 } else {
543 indexy++;
544 };
545 if ( ce->dexyc[l][ii][kk]>0 && (ce->dexy[l][ii][kk]-ce->dexyc[l][ii][kk]) != 0 && ce->perror[se] != 132 && (ce->base[l][ii][bl] == 0 || ce->base[l][ii][bl] >32000) ){
546 hdiff->Fill(ce->dexyc[l][ii][kk]-ce->dexy[l][ii][kk]);
547 fulldiff[se]++;
548 errorfull = 1;
549 };
550 };
551 //
552 Dexyc->Fill(ce->dexyc[l][ii][kk]);
553 if ( ce->dexyc[l][ii][kk] != 0. && ( ce->dexyc[l][ii][kk] < 2000. || ce->dexyc[l][ii][kk] > 5000. ) ) {
554 outdexyc++;
555 } else {
556 indexyc++;
557 };
558 //
559 if (ce->dexyc[l][ii][kk] < 0 ){
560 ver[se][21]++ ;
561 sighandler(headc,obt,i,se,nevents,evdone);
562 printf(" negative ADC values!! ce->dexyc[%i][%i][%i] = %f \n",l,ii,kk,ce->dexyc[l][ii][kk]);
563 };
564 //
565 if ( allbase == 0. || allbase > 32000.) {
566 fcheck = 0;
567 for (Int_t nn = bl*16; nn < (bl+1)*16 ; nn++){
568 if ( ce->dexyc[l][ii][nn] > 0. && ce->dexyc[l][ii][nn] < 32000. ) fcheck++;
569 };
570 if ( fcheck ) {
571 cpre[se]++;
572 allbase = 1.;
573 };
574 };
575 //
576 } else {
577 if ( !pdone ){
578 if ( ( alldexy2 > 3072000 || alldexy2 == 0) && ce->perror[se] == 0 ) {
579 // if ( (alldexy2>512000 || alldexy2 == 0) && ce->perror[se] == 0 ) {
580 pdone = 1;
581 pshit[se][pl]++ ;
582 if ( (ce->stwerr[se] & (1 << 4)) == 0 ){
583 lalarm[se]++;
584 lup[se]->Fill(obt);
585 if ( firstobt[se] ) minobt[se] = obt;
586 if ( obt > maxobt[se] ) maxobt[se] = obt;
587 };
588 lver[se][2]++ ;
589 sighandler(headc,obt,i,se,nevents,evdone);
590 printf(" latch up (data) in RAW mode alldexy2 %i \n",alldexy2);
591 };
592 };
593 if ( ce->dexy[l][ii][kk] > 0 && ce->dexy[l][ii][kk] < 32000 ) {
594 rshit[se][pl]++ ;
595 rawdata = 1;
596 };
597 Dexy->Fill(ce->dexy[l][ii][kk]);
598 if ( ce->dexy[l][ii][kk] < 2000. || ce->dexy[l][ii][kk] > 5000. ) {
599 outdexy++;
600 } else {
601 indexy++;
602 };
603 };
604 };
605 };
606 };
607 cshit = 0;
608 for (Int_t k = 0; k < 4 ; k++ ){
609 isCOMP = false;
610 isFULL = false;
611 cestw=0;
612 if ( ce->stwerr[k] ) cestw = ce->stwerr[k] & cmask ;
613 if ( ce->stwerr[k] & (1 << 16) && !(cestw & (1 << 3)) ) isCOMP = true;
614 if ( ce->stwerr[k] & (1 << 17) && !(cestw & (1 << 3)) ) isFULL = true;
615 //
616 if ( isCOMP ) ver[k][16]++;
617 if ( isFULL ) ver[k][17]++;
618 cshit += (int)ce->calstriphit[k];
619 if ( cestw ){
620 if ( cestw & (1 << 0) ){
621 ver[k][6]++ ;
622 sighandler(headc,obt,i,k,nevents,evdone);
623 printf(" CRC error (st. word) \n");
624 };
625 if ( cestw & (1 << 1) ){
626 ver[k][5]++ ;
627 sighandler(headc,obt,i,k,nevents,evdone);
628 printf(" execution error \n");
629 };
630 if ( cestw & (1 << 2) ){
631 ver[k][4]++ ;
632 sighandler(headc,obt,i,k,nevents,evdone);
633 printf(" CMD length error \n");
634 };
635 if ( cestw & (1 << 3) ) ver[k][3]++ ; // raw mode
636 if ( cestw & (1 << 4) ){
637 ver[k][2]++ ;
638 sighandler(headc,obt,i,k,nevents,evdone);
639 printf(" latch up alarm (st. word)\n");
640 lupstw[k]->Fill(obt);
641 if ( swfirstobt[k] ) swminobt[k] = obt;
642 if ( obt > swmaxobt[k] ) swmaxobt[k] = obt;
643 };
644 if ( cestw & (1 << 5) ){
645 ver[k][1]++ ;
646 sighandler(headc,obt,i,k,nevents,evdone);
647 printf(" temperature alarm \n");
648 };
649 if ( cestw & (1 << 6) ){
650 ver[k][0]++ ;
651 sighandler(headc,obt,i,k,nevents,evdone);
652 printf(" DSP ack error \n");
653 };
654 };
655 if ( ce->stwerr[k] == 0 && ce->perror[k] == 0 ) ver[k][8]++ ;
656 if ( ce->perror[k] != 0. ){
657 if (ce->perror[k] == 128){
658 ver[k][7]++ ;
659 sighandler(headc,obt,i,k,nevents,evdone);
660 printf(" view or command not recognized \n");
661 };
662 if (ce->perror[k] == 129){
663 ver[k][8]++ ;
664 sighandler(headc,obt,i,k,nevents,evdone);
665 printf(" missing section \n");
666 };
667 if (ce->perror[k] == 132){
668 ver[k][11]++ ;
669 if ( ver[k][11] < 30 ){
670 sighandler(headc,obt,i,k,nevents,evdone);
671 printf(" CRC error (data) \n");
672 };
673 if ( ver[k][11] == 30 ){
674 sighandler(headc,obt,i,k,nevents,evdone);
675 printf(" CRC error (data) \n");
676 printf(" WARNING TOO MANY CRC ERRORS ON DATA FOR THIS SECTION \n");
677 printf(" THEY WILL NOT BE DISPLAYED HERE ANYMORE FOR THIS FILE! \n");
678 };
679 };
680 if (ce->perror[k] == 133){
681 ver[k][12]++ ;
682 sighandler(headc,obt,i,k,nevents,evdone);
683 printf(" length problems in RAW mode \n");
684 };
685 if (ce->perror[k] == 134){
686 ver[k][13]++ ;
687 sighandler(headc,obt,i,k,nevents,evdone);
688 printf(" length problems in COMPRESS mode \n");
689 };
690 if (ce->perror[k] == 135){
691 ver[k][14]++ ;
692 sighandler(headc,obt,i,k,nevents,evdone);
693 printf(" length problems in FULL mode \n");
694 };
695 if (ce->perror[k] == 136){
696 ver[k][15]++ ;
697 sighandler(headc,obt,i,k,nevents,evdone);
698 printf(" acquisition mode problems \n");
699 };
700 if (ce->perror[k] == 139){
701 ver[k][18]++ ;
702 sighandler(headc,obt,i,k,nevents,evdone);
703 printf(" problems with coding\n");
704 };
705 if (ce->perror[k] == 140){
706 ver[k][19]++ ;
707 sighandler(headc,obt,i,k,nevents,evdone);
708 printf(" pedestal checksum wrong\n");
709 };
710 if (ce->perror[k] == 141){
711 ver[k][20]++ ;
712 sighandler(headc,obt,i,k,nevents,evdone);
713 printf(" thresholds checksum wrong\n");
714 };
715 if (ce->perror[k] == 142){
716 ver[k][22]++ ;
717 sighandler(headc,obt,i,k,nevents,evdone);
718 printf(" packet length is zero (YODA input error), skipped\n");
719 };
720 };
721 for (Int_t kk = 0; kk < 11 ; kk++ ){
722 tshit += shit[k][kk];
723 trshit += rshit[k][kk];
724 };
725 };
726 if (isCOMP || isFULL){
727 Calstriphit->Fill(cshit);
728 // if ( (cshit > 0 && cshit < 25) || (cshit > 40 && cshit < 80) ){
729 if ( (cshit > 10 && cshit < 100) ){
730 incshit++;
731 } else {
732 outcshit++;
733 };
734 //
735 if ( tshit>0 ) h1->Fill(tshit);
736 // if ( (tshit > 0 && tshit < 25) || (tshit > 40 && tshit < 80) ){
737 if ( (tshit > 10 && tshit < 100) ){
738 intshit++;
739 } else {
740 outtshit++;
741 };
742 };
743 if ( trshit>0 ) {
744 h1r->Fill(trshit);
745 if ( trshit < 4210 ){
746 h1rout++;
747 // printf("ma come... trshit %i \n",trshit);
748 } else {
749 h1rin++;
750 };
751 };
752 // if ( i%1000 == 0 && i > 0 ) printf("%iK\n",i/1000);
753 i++;
754 };
755 printf("\n");
756 printf("\n end processing. \n\n");
757 if ( (float)h1rout/((float)h1rin+(float)h1rout) > h1rth ){
758 h1rcheck = true;
759 };
760 //
761 // output figures, first sheet:
762 //
763 gStyle->SetOptDate(0);
764 gStyle->SetOptStat(1111);
765 TCanvas *figura = new TCanvas("Calorimeter_Detector_Report_1/3", "Calorimeter_Detector_Report_1/3", 1100, 900);
766 figura->SetFillColor(10);
767 figura->Range(0,0,100,100);
768 errore.str("");
769 errore << "EXPERT -- File: " << file;
770 errore << " ";
771 TLatex *t=new TLatex();
772 t->SetTextFont(32);
773 t->SetTextColor(1);
774 t->SetTextAlign(12);
775 t->SetTextSize(0.015);
776 t->DrawLatex(2.,99.,errore.str().c_str());
777 TPad *pd5;
778 TPad *pd6;
779 TPad *pd7;
780 TPad *pd8;
781 TPad *pad1;
782 TPad *pad2;
783 TPad *pad3;
784 TPad *pad4;
785 TPad *pd1;
786 TPad *pd2;
787 TPad *pd3;
788 TPad *pd4;
789 //
790 Double_t h1max;
791 TPolyLine *banda1;
792 TPolyLine *banda2;
793 Float_t ctshit = 0;
794 Float_t ccshit = 0;
795 Float_t cbase = 0;
796 Float_t cdexy = 0;
797 Float_t cdexyc = 0;
798 //
799 if ( compdata && rawdata ){
800 ctshit = (float)intshit/((float)outtshit + (float)intshit);
801 Int_t pd5col = 10;
802 Int_t pd6col = 10;
803 if ( ctshit < ctshitthr ) {
804 check = true;
805 pd5col = 45;
806 };
807 if ( h1rcheck ) {
808 check = true;
809 pd6col = 45;
810 };
811 pd5 = new TPad("pd5","This is pad5",0.51,0.51,0.98,0.98,pd5col);
812 pd6 = new TPad("pd6","This is pad6",0.51,0.02,0.98,0.49,pd6col);
813 pd5->SetTicks();
814 pd6->SetTicks();
815 pd5->Range(0,0,100,100);
816 pd6->Range(0,0,100,100);
817 figura->cd();
818 pd5->Draw();
819 pd5->cd();
820 h1->SetXTitle("Number of hit (dexyc>0)");
821 h1->SetYTitle("Number of events");
822 h1->Draw();
823 //
824 h1max = h1->GetMaximum()*1.05;
825 Double_t xc[4] = {10.,100.,100.,10.};
826 Double_t yc[4] = {0.,0.,h1max,h1max};
827 banda1 = new TPolyLine(4,xc,yc);
828 banda1->SetLineColor(5);
829 banda1->SetFillColor(5);
830 banda1->SetLineWidth(1);
831 banda1->Draw("fSAME");
832 // Double_t xd[4] = {40.,80.,80.,40.};
833 // Double_t yd[4] = {0.,0.,h1max,h1max};
834 // banda2 = new TPolyLine(4,xd,yd);
835 // banda2->SetLineColor(5);
836 // banda2->SetFillColor(5);
837 // banda2->SetLineWidth(1);
838 //banda2->Draw("fSAME");
839 h1->Draw("SAME");
840 //
841 figura->cd();
842 pd6->Draw();
843 pd6->cd();
844 gPad->SetLogy();
845 h1r->SetXTitle("Number of hit (dexy>0)");
846 h1r->SetYTitle("Number of events");
847 h1r->Draw();
848 h1max = h1r->GetMaximum()*2.05;
849 Double_t xg[4] = {4220.,4230.,4230.,4220.};
850 Double_t yg[4] = {0.,0.,h1max,h1max};
851 banda1 = new TPolyLine(4,xg,yg);
852 banda1->SetLineColor(5);
853 banda1->SetFillColor(5);
854 banda1->SetLineWidth(1);
855 banda1->Draw("fSAME");
856 h1r->Draw("SAME");
857 };
858 if ( (compdata && !rawdata) || (!compdata && rawdata) ){
859 if ( tshit !=0 ) {
860 ctshit = (float)intshit/((float)outtshit + (float)intshit);
861 Int_t pd5col = 10;
862 if ( ctshit < ctshitthr ) {
863 check = true;
864 pd5col = 45;
865 };
866 pd5 = new TPad("pd5","This is pad5",0.51,0.02,0.98,0.98,pd5col);
867 pd5->Range(0,0,100,100);
868 pd5->SetTicks();
869 pd5->Draw();
870 pd5->cd();
871 h1->SetXTitle("Number of hit (dexyc>0)");
872 h1->SetYTitle("Number of events");
873 h1->Draw();
874 h1max = h1->GetMaximum()*1.05;
875 Double_t xe[4] = {10.,100.,100.,10.};
876 Double_t ye[4] = {0.,0.,h1max,h1max};
877 banda1 = new TPolyLine(4,xe,ye);
878 banda1->SetLineColor(5);
879 banda1->SetFillColor(5);
880 banda1->SetLineWidth(1);
881 banda1->Draw("fSAME");
882 // Double_t xf[4] = {40.,80.,80.,40.};
883 // Double_t yf[4] = {0.,0.,h1max,h1max};
884 // banda2 = new TPolyLine(4,xf,yf);
885 // banda2->SetLineColor(5);
886 // banda2->SetFillColor(5);
887 // banda2->SetLineWidth(1);
888 // banda2->Draw("fSAME");
889 h1->Draw("SAME");
890 };
891 if ( trshit !=0 ) {
892 Int_t pd5col = 10;
893 if ( h1rcheck ) {
894 check = true;
895 pd5col = 45;
896 };
897 pd5 = new TPad("pd5","This is pad5",0.51,0.02,0.98,0.98,pd5col);
898 pd5->Range(0,0,100,100);
899 pd5->SetTicks();
900 pd5->Draw();
901 pd5->cd();
902 gPad->SetLogy();
903 h1r->SetXTitle("Number of hit (dexyc>0 or dexy>0)");
904 h1r->SetYTitle("Number of events");
905 h1r->Draw();
906 h1max = h1r->GetMaximum()*2.05;
907 Double_t xh[4] = {4220.,4230.,4230.,4220.};
908 Double_t yh[4] = {0.,0.,h1max,h1max};
909 banda1 = new TPolyLine(4,xh,yh);
910 banda1->SetLineColor(5);
911 banda1->SetFillColor(5);
912 banda1->SetLineWidth(1);
913 banda1->Draw("fSAME");
914 h1r->Draw("SAME");
915 };
916 };
917 if ( !errorfull ) {
918 if ( calevn1 > calevnth || calevn2 > calevnth || calevn3 > calevnth ) {
919 pd1 = new TPad("pd1","This is pad1",0.02,0.51,0.24,0.98,45);
920 pd2 = new TPad("pd2","This is pad2",0.26,0.51,0.49,0.98,45);
921 pd3 = new TPad("pd3","This is pad3",0.02,0.02,0.24,0.49,45);
922 pd4 = new TPad("pd4","This is pad4",0.26,0.02,0.49,0.49,45);
923 figura->cd();
924 // printf("ou2! \n");
925 check = true;
926 pd1->Range(0,0,100,100);
927 pd2->Range(0,0,100,100);
928 pd3->Range(0,0,100,100);
929 pd4->Range(0,0,100,100);
930 pd1->Draw();
931 pd2->Draw();
932 pd3->Draw();
933 pd4->Draw();
934
935 pd1->cd();
936 gPad->SetLogy();
937 calev01->SetXTitle("delta calevnum 1-2");
938 calev01->SetYTitle("Number of events");
939 calev01->Draw();
940
941 pd2->cd();
942 gPad->SetLogy();
943 calev23->SetXTitle("delta calevnum 3-4");
944 calev23->SetYTitle("Number of events");
945 calev23->Draw();
946
947 pd3->cd();
948 gPad->SetLogy();
949 calev03->SetXTitle("delta calevnum 1-4");
950 calev03->SetYTitle("Number of events");
951 calev03->Draw();
952
953 pd4->cd();
954 calev2->SetYTitle("calevnum 2");
955 calev2->SetXTitle("iev");
956 calev2->Draw();
957 } else {
958 if ( calevn4 ) {
959 pd3 = new TPad("pd3","This is pad3",0.02,0.02,0.49,0.98,10);
960 figura->cd();
961 pd3->Range(0,0,100,100);
962 pd3->Draw();
963 pd3->cd();
964 calev2->SetYTitle("calevnum 2");
965 calev2->SetXTitle("iev");
966 calev2->Draw();
967 } else {
968 figura->cd();
969 t=new TLatex();
970 t->SetTextFont(32);
971 t->SetTextColor(1);
972 t->SetTextSize(0.04);
973 t->SetTextAlign(12);
974 t->DrawLatex(10.,49.,"No calevnum infos from DSP");
975 };
976 };
977 } else {
978 figura->cd();
979 check = true;
980 // printf("nou! \n");
981 pd1 = new TPad("pd1","This is pad1",0.02,0.02,0.49,0.98,45);
982 pd1->Range(0,0,100,100);
983 pd1->Draw();
984 pd1->cd();
985 gPad->SetLogy();
986 hdiff->SetXTitle("Differences in FULL mode");
987 hdiff->SetYTitle("Number of events");
988 hdiff->Draw();
989 };
990
991 //
992 // output figures, second sheet:
993 //
994 TCanvas *figura2 = new TCanvas("Calorimeter_Detector_Report_2/3","Calorimeter_Detector_Report_2/3", 1100, 900);
995 if ( compdata ){
996 Int_t pd1col = 10;
997 Int_t pd2col = 10;
998 Int_t pd3col = 10;
999 Int_t pd4col = 10;
1000 if ( (outdexy+indexy) ) {
1001 cdexy = (float)indexy/((float)outdexy + (float)indexy);
1002 if ( cdexy < cdexythr ) {
1003 check = true;
1004 pd4col = 45;
1005 };
1006 };
1007 if ( (outcshit+incshit) ) {
1008 ccshit = (float)incshit/((float)outcshit + (float)incshit);
1009 if ( ccshit < ctshitthr ) {
1010 check = true;
1011 pd3col = 45;
1012 };
1013 };
1014 if ( (outdexyc+indexyc) ) {
1015 cdexyc = (float)indexyc/((float)outdexyc + (float)indexyc);
1016 if ( cdexyc < cdexycthr ) {
1017 check = true;
1018 pd2col = 45;
1019 };
1020 };
1021 if ( (outbase+inbase) ) {
1022 cbase = (float)inbase/((float)outbase + (float)inbase);
1023 if ( cbase < cbasethr ) {
1024 check = true;
1025 pd1col = 45;
1026 };
1027 };
1028 figura2->SetFillColor(10);
1029 figura2->Range(0,0,100,100);
1030 errore.str("");
1031 errore << "EXPERT -- File: " << file;
1032 errore << " ";
1033 t=new TLatex();
1034 t->SetTextFont(32);
1035 t->SetTextColor(1);
1036 t->SetTextAlign(12);
1037 t->SetTextSize(0.015);
1038 t->DrawLatex(2.,99.,errore.str().c_str());
1039 pd1 = new TPad("pd1","This is pad1",0.02,0.51,0.49,0.98,pd1col);
1040 pd2 = new TPad("pd2","This is pad2",0.51,0.51,0.98,0.98,pd2col);
1041 pd3 = new TPad("pd3","This is pad3",0.02,0.02,0.49,0.49,pd3col);
1042 pd4 = new TPad("pd4","This is pad4",0.51,0.02,0.98,0.49,pd4col);
1043 figura2->cd();
1044 pd1->Range(0,0,100,100);
1045 pd2->Range(0,0,100,100);
1046 pd3->Range(0,0,100,100);
1047 pd4->Range(0,0,100,100);
1048 pd1->SetTicks();
1049 pd2->SetTicks();
1050 pd3->SetTicks();
1051 pd4->SetTicks();
1052 pd1->Draw();
1053 pd2->Draw();
1054 pd3->Draw();
1055 pd4->Draw();
1056 pd1->cd();
1057 Baseline->SetXTitle("ADC channels");
1058 Baseline->SetYTitle("Number of events");
1059 Baseline->Draw();
1060 h1max = Baseline->GetMaximum()*1.05;
1061 Double_t xc[4] = {2000.,4500.,4500.,2000.};
1062 Double_t yc[4] = {0.,0.,h1max,h1max};
1063 banda1 = new TPolyLine(4,xc,yc);
1064 banda1->SetLineColor(5);
1065 banda1->SetFillColor(5);
1066 banda1->SetLineWidth(1);
1067 banda1->Draw("fSAME");
1068 Baseline->Draw("SAME");
1069 //
1070 pd2->cd();
1071 gPad->SetLogy();
1072 Dexyc->SetXTitle("ADC channels");
1073 Dexyc->SetYTitle("Number of events");
1074 Dexyc->Draw();
1075 h1max = Dexyc->GetMaximum()*2.05;
1076 Double_t xe[4] = {2000.,5000.,5000.,2000.};
1077 Double_t ye[4] = {0.,0.,h1max,h1max};
1078 banda1 = new TPolyLine(4,xe,ye);
1079 banda1->SetLineColor(5);
1080 banda1->SetFillColor(5);
1081 banda1->SetLineWidth(1);
1082 banda1->Draw("fSAME");
1083 Double_t xj[4] = {0.,40.,40.,0.};
1084 Double_t yj[4] = {0.,0.,h1max,h1max};
1085 banda2 = new TPolyLine(4,xj,yj);
1086 banda2->SetLineColor(5);
1087 banda2->SetFillColor(5);
1088 banda2->SetLineWidth(1);
1089 banda2->Draw("fSAME");
1090 Dexyc->Draw("SAME");
1091 //
1092 pd3->cd();
1093 // gPad->SetLogy();
1094 Calstriphit->SetXTitle("Number of hit");
1095 Calstriphit->SetYTitle("Number of events");
1096 Calstriphit->Draw();
1097 h1max = Calstriphit->GetMaximum()*1.05;
1098 Double_t xg[4] = {10.,100.,100.,10.};
1099 Double_t yg[4] = {0.,0.,h1max,h1max};
1100 banda1 = new TPolyLine(4,xg,yg);
1101 banda1->SetLineColor(5);
1102 banda1->SetFillColor(5);
1103 banda1->SetLineWidth(1);
1104 banda1->Draw("fSAME");
1105 // Double_t xh[4] = {40.,80.,80.,40.};
1106 // Double_t yh[4] = {0.,0.,h1max,h1max};
1107 // banda2 = new TPolyLine(4,xh,yh);
1108 // banda2->SetLineColor(5);
1109 // banda2->SetFillColor(5);
1110 // banda2->SetLineWidth(1);
1111 // banda2->Draw("fSAME");
1112 Calstriphit->Draw("SAME");
1113 //
1114 pd4->cd();
1115 gPad->SetLogy();
1116 Dexy->SetXTitle("ADC channels");
1117 Dexy->SetYTitle("Number of events");
1118 Dexy->Draw();
1119 // h1max = Dexy->GetMaximum()*1.05;
1120 h1max = Dexy->GetMaximum()*2.05;
1121 Double_t xd[4] = {2000.,5000.,5000.,2000.};
1122 Double_t yd[4] = {0.,0.,h1max,h1max};
1123 banda1 = new TPolyLine(4,xd,yd);
1124 banda1->SetLineColor(5);
1125 banda1->SetFillColor(5);
1126 banda1->SetLineWidth(1);
1127 banda1->Draw("fSAME");
1128 Dexy->Draw("SAME");
1129 } else {
1130 Int_t pd4col = 10;
1131 if ( (outdexy+indexy) ) {
1132 cdexy = (float)indexy/((float)outdexy + (float)indexy);
1133 if ( cdexy < cdexythr ) {
1134 check = true;
1135 pd4col = 45;
1136 };
1137 };
1138 figura2->SetFillColor(10);
1139 figura2->Range(0,0,100,100);
1140 errore.str("");
1141 errore << "EXPERT -- File: " << file;
1142 errore << " ";
1143 t=new TLatex();
1144 t->SetTextFont(32);
1145 t->SetTextColor(1);
1146 t->SetTextAlign(12);
1147 t->SetTextSize(0.015);
1148 t->DrawLatex(2.,99.,errore.str().c_str());
1149 pd4 = new TPad("pd4","This is pad4",0.02,0.02,0.98,0.98,pd4col);
1150 figura2->cd();
1151 pd4->Range(0,0,100,100);
1152 pd4->SetTicks();
1153 pd4->Draw();
1154 //
1155 pd4->cd();
1156 gPad->SetLogy();
1157 Dexy->SetXTitle("ADC channels");
1158 Dexy->SetYTitle("Number of events");
1159 Dexy->Draw();
1160 // h1max = Dexy->GetMaximum()*1.05;
1161 h1max = Dexy->GetMaximum()*2.05;
1162 Double_t xd[4] = {2000.,5000.,5000.,2000.};
1163 Double_t yd[4] = {0.,0.,h1max,h1max};
1164 banda1 = new TPolyLine(4,xd,yd);
1165 banda1->SetLineColor(5);
1166 banda1->SetFillColor(5);
1167 banda1->SetLineWidth(1);
1168 banda1->Draw("fSAME");
1169 Dexy->Draw("SAME");
1170 };
1171 //
1172 TCanvas *figura3 = 0;
1173 Bool_t printfigure3 = false;
1174 for (Int_t i = 0; i<4; i++){
1175 if ( ver[i][2] || lver[i][2] ){
1176 printfigure3 = true;
1177 break;
1178 };
1179 };
1180 if ( printfigure3 ){
1181 figura3 = new TCanvas("Calorimeter_Detector_Report_2bis/3","Calorimeter_Detector_Report_2bis/3", 1100, 900);
1182 figura3->SetFillColor(10);
1183 figura3->Range(0,0,100,100);
1184 errore.str("");
1185 errore << "EXPERT -- File: " << file;
1186 errore << " ";
1187 t=new TLatex();
1188 t->SetTextFont(32);
1189 t->SetTextColor(1);
1190 t->SetTextAlign(12);
1191 t->SetTextSize(0.015);
1192 t->DrawLatex(2.,99.,errore.str().c_str());
1193 pd1 = new TPad("pd1","This is pad1",0.02,0.51,0.49,0.73,45);
1194 pd5 = new TPad("pd5","This is pad5",0.02,0.76,0.49,0.98,45);
1195 pd2 = new TPad("pd2","This is pad2",0.51,0.51,0.98,0.73,45);
1196 pd6 = new TPad("pd6","This is pad6",0.51,0.76,0.98,0.98,45);
1197 pd3 = new TPad("pd3","This is pad3",0.02,0.02,0.49,0.23,45);
1198 pd7 = new TPad("pd7","This is pad7",0.02,0.26,0.49,0.49,45);
1199 pd4 = new TPad("pd4","This is pad4",0.51,0.02,0.98,0.23,45);
1200 pd8 = new TPad("pd8","This is pad8",0.51,0.26,0.98,0.49,45);
1201 figura3->cd();
1202 pd1->Range(0,0,100,100);
1203 pd2->Range(0,0,100,100);
1204 pd3->Range(0,0,100,100);
1205 pd4->Range(0,0,100,100);
1206 pd1->SetTicks();
1207 pd2->SetTicks();
1208 pd3->SetTicks();
1209 pd4->SetTicks();
1210 pd1->Draw();
1211 pd2->Draw();
1212 pd3->Draw();
1213 pd4->Draw();
1214 pd5->Range(0,0,100,100);
1215 pd6->Range(0,0,100,100);
1216 pd7->Range(0,0,100,100);
1217 pd8->Range(0,0,100,100);
1218 pd5->SetTicks();
1219 pd6->SetTicks();
1220 pd7->SetTicks();
1221 pd8->SetTicks();
1222 pd5->Draw();
1223 pd6->Draw();
1224 pd7->Draw();
1225 pd8->Draw();
1226 pd1->cd();
1227 lup[0]->SetAxisRange((Double_t)min(minobt[0],swminobt[0])*0.9,(Double_t)max(maxobt[0],swmaxobt[0])*1.1,"X");
1228 lup[0]->SetXTitle("OBT");
1229 lup[0]->SetYTitle("Number of events");
1230 lup[0]->Draw();
1231 pd5->cd();
1232 lupstw[0]->SetAxisRange((Double_t)min(minobt[0],swminobt[0])*0.9,(Double_t)max(maxobt[0],swmaxobt[0])*1.1,"X");
1233 // lupstw[0]->SetAxisRange((Double_t)swminobt[0]*0.9,(Double_t)swmaxobt[0]*1.1,"X");
1234 lupstw[0]->SetXTitle("OBT");
1235 lupstw[0]->SetYTitle("Number of events");
1236 lupstw[0]->Draw();
1237 pd2->cd();
1238 lup[1]->SetAxisRange((Double_t)min(minobt[1],swminobt[1])*0.9,(Double_t)max(maxobt[1],swmaxobt[1])*1.1,"X");
1239 // lup[1]->SetAxisRange((Double_t)minobt[1]*0.9,(Double_t)maxobt[1]*1.1,"X");
1240 lup[1]->SetXTitle("OBT");
1241 lup[1]->SetYTitle("Number of events");
1242 lup[1]->Draw();
1243 pd6->cd();
1244 lupstw[1]->SetAxisRange((Double_t)min(minobt[1],swminobt[1])*0.9,(Double_t)max(maxobt[1],swmaxobt[1])*1.1,"X");
1245 // lupstw[1]->SetAxisRange((Double_t)swminobt[1]*0.9,(Double_t)swmaxobt[1]*1.1,"X");
1246 lupstw[1]->SetXTitle("OBT");
1247 lupstw[1]->SetYTitle("Number of events");
1248 lupstw[1]->Draw();
1249 pd3->cd();
1250 lup[2]->SetAxisRange((Double_t)min(minobt[2],swminobt[2])*0.9,(Double_t)max(maxobt[2],swmaxobt[2])*1.1,"X");
1251 // lup[2]->SetAxisRange((Double_t)minobt[2]*0.9,(Double_t)maxobt[2]*1.1,"X");
1252 lup[2]->SetXTitle("OBT");
1253 lup[2]->SetYTitle("Number of events");
1254 lup[2]->Draw();
1255 pd7->cd();
1256 lupstw[2]->SetAxisRange((Double_t)min(minobt[2],swminobt[2])*0.9,(Double_t)max(maxobt[2],swmaxobt[2])*1.1,"X");
1257 // lupstw[2]->SetAxisRange((Double_t)swminobt[2]*0.9,(Double_t)swmaxobt[2]*1.1,"X");
1258 lupstw[2]->SetXTitle("OBT");
1259 lupstw[2]->SetYTitle("Number of events");
1260 lupstw[2]->Draw();
1261 pd4->cd();
1262 lup[3]->SetAxisRange((Double_t)min(minobt[3],swminobt[3])*0.9,(Double_t)max(maxobt[3],swmaxobt[3])*1.1,"X");
1263 // lup[3]->SetAxisRange((Double_t)minobt[3]*0.9,(Double_t)maxobt[3]*1.1,"X");
1264 lup[3]->SetXTitle("OBT");
1265 lup[3]->SetYTitle("Number of events");
1266 lup[3]->Draw();
1267 pd8->cd();
1268 lupstw[3]->SetAxisRange((Double_t)min(minobt[3],swminobt[3])*0.9,(Double_t)max(maxobt[3],swmaxobt[3])*1.1,"X");
1269 // lupstw[3]->SetAxisRange((Double_t)swminobt[3]*0.9,(Double_t)swmaxobt[3]*1.1,"X");
1270 lupstw[3]->SetXTitle("OBT");
1271 lupstw[3]->SetYTitle("Number of events");
1272 lupstw[3]->Draw();
1273 };
1274 //
1275 // output figures, report sheet:
1276 //
1277 TCanvas *rapporto= new TCanvas("Calorimeter_Detector_Report_3/3", "Calorimeter_Detector_Report_3/3", 1100, 900);
1278 rapporto->SetFillColor(10);
1279 rapporto->Range(0,0,100,100);
1280 t=new TLatex();
1281 t->SetTextFont(32);
1282 t->SetTextColor(1);
1283 t->SetTextSize(0.05);
1284 t->SetTextAlign(12);
1285 // t->DrawLatex(33.,95.,"Calorimeter quick look: ");
1286 errore.str("");
1287 errore << "BASIC: C1 - File: " << file;
1288 errore << " ";
1289 t->SetTextSize(0.02);
1290 t->DrawLatex(2.,99.,errore.str().c_str());
1291
1292 pad1 = new TPad("pad1","This is pad1",0.02,0.47,0.49,0.90,19);
1293 pad2 = new TPad("pad2","This is pad2",0.51,0.47,0.98,0.90,19);
1294 pad3 = new TPad("pad3","This is pad3",0.02,0.02,0.49,0.45,19);
1295 pad4 = new TPad("pad4","This is pad4",0.51,0.02,0.98,0.45,19);
1296 pad1->Range(0,0,100,100);
1297 pad2->Range(0,0,100,100);
1298 pad3->Range(0,0,100,100);
1299 pad4->Range(0,0,100,100);
1300
1301 pad1->Draw();
1302 pad2->Draw();
1303 pad3->Draw();
1304 pad4->Draw();
1305 //
1306 Bool_t redevent = true;
1307 //
1308 if ( ver[0][3]+ver[0][16]+ver[0][17] == ver[1][3]+ver[1][16]+ver[1][17] && ver[1][3]+ver[1][16]+ver[1][17] == ver[2][3]+ver[2][16]+ver[2][17] && ver[2][3]+ver[2][16]+ver[2][17] == ver[3][3]+ver[3][16]+ver[3][17] ){
1309 redevent = false;
1310 };
1311 if ( redevent ) check = true;
1312 //
1313 for (Int_t i = 0; i < 4; i++){
1314 if (i == 2)
1315 {
1316 pad1->cd() ;
1317 sezione = "** Section YE (x even) **";
1318 }
1319 if (i == 3)
1320 {
1321 pad2->cd();
1322 sezione = "** Section YO (x odd) **";
1323 }
1324 if (i == 0)
1325 {
1326 pad3->cd();
1327 sezione = "** Section XE (y odd) **";
1328 }
1329 if (i == 1)
1330 {
1331 pad4->cd();
1332 sezione = "** Section XO (y even) **";
1333 }
1334 t->SetTextFont(32);
1335 t->SetTextColor(1);
1336 t->SetTextSize(0.05);
1337 t->SetTextAlign(12);
1338 t->DrawLatex(33.,97.,sezione);
1339 t->SetTextSize(0.05);
1340 for (Int_t j = 0; j < 23; j++){
1341 if ( ver[i][j] || lver[i][j] ) {
1342 t->SetTextColor(50);
1343 if (j == 0) {
1344 errore.str("");
1345 errore << "* DSP ack error: " << ver[i][j];
1346 errore << " time(s)";
1347 t->DrawLatex(2.,30.,errore.str().c_str());
1348 check = true;
1349 }
1350 if (j == 1) {
1351 errore.str("");
1352 errore << "* Temperature alarm: " << ver[i][j];
1353 errore << " time(s)";
1354 t->DrawLatex(2.,74.,errore.str().c_str());
1355 check = true;
1356 }
1357 if (j == 2) {
1358 // printf("boh! lalarm[%i] = %i \n",i,lalarm[i]);
1359 if ( lalarm[i] ){
1360 errore.str("");
1361 errore << "* Latch up: " << ver[i][j];
1362 errore << " (" << lalarm[i];
1363 errore << " NOT rec!): ";
1364 t->DrawLatex(2.,70.,errore.str().c_str());
1365 check = true;
1366 } else {
1367 errore.str("");
1368 errore << "* Latch up alarm: " << ver[i][j];
1369 errore << " time(s). View(s): ";
1370 t->DrawLatex(2.,70.,errore.str().c_str());
1371 check = true;
1372 };
1373 errore.str("");
1374 errore << "(" << lver[i][j];
1375 errore << " view(s))";
1376 t->DrawLatex(27.,65.,errore.str().c_str());
1377 Float_t inc=1.;
1378 for (Int_t e = 0; e < 11; e++){
1379 if ( pshit[i][e] ) {
1380 errore.str("");
1381 errore << " " << (e+1);
1382 errore << " ";
1383 t->DrawLatex(52.+inc,69.,errore.str().c_str());
1384 Int_t numer = pshit[i][e];
1385 errore.str("");
1386 errore << " (" << numer;
1387 errore << ") ";
1388 t->SetTextAngle(-70);
1389 t->DrawLatex(55.+inc,67.,errore.str().c_str());
1390 t->SetTextAngle(0);
1391 inc += 4.;
1392 }
1393 }
1394 }
1395 if (j == 3) {
1396 errore.str("");
1397 errore << "RAW mode: " << ver[i][j];
1398 errore << " time(s)";
1399 if ( !redevent ) t->SetTextColor(32);
1400 t->DrawLatex(2.,90.,errore.str().c_str());
1401 }
1402 if (j == 4) {
1403 errore.str("");
1404 errore << "* CMD length error: " << ver[i][j];
1405 errore << " time(s)";
1406 t->DrawLatex(2.,66.,errore.str().c_str());
1407 check = true;
1408 }
1409 if (j == 5) {
1410 errore.str("");
1411 errore << "* Execution error: " << ver[i][j];
1412 errore << " time(s)";
1413 t->DrawLatex(2.,62.,errore.str().c_str());
1414 check = true;
1415 }
1416 if (j == 6) {
1417 errore.str("");
1418 errore << "* CRC error (st. word): " << ver[i][j];
1419 errore << " time(s)";
1420 t->DrawLatex(2.,58.,errore.str().c_str());
1421 check = true;
1422 }
1423 if (j == 7) {
1424 errore.str("");
1425 errore << "View or command not recognized: " << ver[i][j];
1426 errore << " time(s)";
1427 t->DrawLatex(2.,54.,errore.str().c_str());
1428 check = true;
1429 }
1430 if (j == 8) {
1431 errore.str("");
1432 errore << "Missing section: " << ver[i][j];
1433 errore << " time(s)";
1434 t->DrawLatex(2.,50.,errore.str().c_str());
1435 if ( ver[i][j] > 3 ) check = true;
1436 }
1437 if (j == 10) {
1438 errore.str("");
1439 errore << "Calevnum jump: " << ver[i][j];
1440 errore << " time(s)";
1441 t->DrawLatex(2.,42.,errore.str().c_str());
1442 if ( ver[i][j] > 3 ) check = true;
1443 }
1444 if (j == 11) {
1445 errore.str("");
1446 errore << "CRC error (data): " << ver[i][j];
1447 errore << " time(s)";
1448 t->DrawLatex(2.,38.,errore.str().c_str());
1449 if ( ver[i][j] > 10 ) check = true;
1450 }
1451 if (j == 12) {
1452 errore.str("");
1453 errore << "Length problems in RAW mode: " << ver[i][j];
1454 errore << " time(s)";
1455 t->DrawLatex(2.,34.,errore.str().c_str());
1456 check = true;
1457 }
1458 if (j == 13) {
1459 errore.str("");
1460 errore << "Length problems in COMPRESS mode: " << ver[i][j];
1461 errore << " time(s)";
1462 t->DrawLatex(2.,34.,errore.str().c_str());
1463 check = true;
1464 }
1465 if (j == 14) {
1466 errore.str("");
1467 errore << "Length problems in FULL mode: " << ver[i][j];
1468 errore << " time(s)";
1469 t->DrawLatex(2.,26.,errore.str().c_str());
1470 check = true;
1471 }
1472 if (j == 15) {
1473 errore.str("");
1474 errore << "Acquisition mode problems: " << ver[i][j];
1475 errore << " time(s)";
1476 t->DrawLatex(2.,22.,errore.str().c_str());
1477 check = true;
1478 }
1479 if (j == 16) {
1480 errore.str("");
1481 errore << "COMPRESS mode: " << ver[i][j];
1482 errore << " time(s)";
1483 if ( !redevent ) t->SetTextColor(32);
1484 t->DrawLatex(2.,86.,errore.str().c_str());
1485 }
1486 if (j == 17) {
1487 errore.str("");
1488 errore << "FULL mode: " << ver[i][j];
1489 errore << " time(s)";
1490 if ( !redevent ) t->SetTextColor(32);
1491 t->DrawLatex(2.,82.,errore.str().c_str());
1492 }
1493 if (j == 18) {
1494 errore.str("");
1495 errore << "Problems with coding: " << ver[i][j];
1496 errore << " time(s)";
1497 t->DrawLatex(2.,18.,errore.str().c_str());
1498 check = true;
1499 }
1500 if (j == 19) {
1501 errore.str("");
1502 errore << "Pedestal checksum wrong: " << ver[i][j];
1503 errore << " time(s)";
1504 t->DrawLatex(2.,14.,errore.str().c_str());
1505 check = true;
1506 }
1507 if (j == 20) {
1508 errore.str("");
1509 errore << "Thresholds checksum wrong: " << ver[i][j];
1510 errore << " time(s)";
1511 t->DrawLatex(2.,10.,errore.str().c_str());
1512 check = true;
1513 }
1514 if (j == 21) {
1515 errore.str("");
1516 errore << "WARNING! DEXYC < 0: " << ver[i][j];
1517 errore << " time(s)";
1518 t->DrawLatex(2.,6.,errore.str().c_str());
1519 check = true;
1520 }
1521 if (j == 22) {
1522 errore.str("");
1523 errore << "Packet length is zero (YODA input error), skipped: " << ver[i][j];
1524 errore << " time(s)";
1525 t->DrawLatex(2.,3.,errore.str().c_str());
1526 check = true;
1527 };
1528 };
1529 };
1530 t->SetTextColor(50);
1531 if ( fulldiff[i] !=0 ) {
1532 check = true;
1533 errore.str("");
1534 errore << "Full mode, differences between RAW and COMPRESS mode: " << fulldiff[i];
1535 errore << " time(s)";
1536 t->DrawLatex(2.,46.,errore.str().c_str());
1537 };
1538 if ( cpre[i] !=0 ) {
1539 errore.str("");
1540 errore << "Preamplifier fully transmitted: " << cpre[i];
1541 errore << " time(s)";
1542 t->SetTextColor(32);
1543 t->DrawLatex(2.,78.,errore.str().c_str());
1544 };
1545 };
1546 rapporto->cd();
1547 t->SetTextFont(32);
1548 t->SetTextColor(1);
1549 t->SetTextSize(0.05);
1550 t->SetTextAlign(12);
1551 t->DrawLatex(22.,95.,"Calorimeter quick look: ");
1552 //printf("check %i \n",check);
1553 if ( check ){
1554 t->SetTextColor(50);
1555 t->DrawLatex(60.,95.," WARNING, CHECK! ");
1556 printf("cdexyc %f cdexy %f ctshit %f cbase %f \n",cdexyc,cdexy,ctshit,cbase);
1557 } else {
1558 t->SetTextColor(32);
1559 t->DrawLatex(60.,95.," OK! ");
1560 };
1561 //
1562 // const string fil = (const char*)filename;
1563 // Int_t posiz = fil.find("dw_");
1564 // if ( posiz == -1 ) posiz = fil.find("DW_");
1565 // Int_t posiz2 = posiz+13;
1566 // TString file2;
1567 // stringcopy(file2,filename,posiz,posiz2);
1568 //
1569 const string fil = gSystem->BaseName(filename.Data());
1570 Int_t posiz = fil.find(".root");
1571 //
1572 TString file2;
1573 if ( posiz == -1 ){
1574 file2 = gSystem->BaseName(filename.Data());
1575 } else {
1576 Int_t posiz2 = 0;
1577 stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz);
1578 };
1579 const char *figrec = file2;
1580 //
1581 const char *outdir = outDir;
1582 stringstream figsave;
1583 stringstream figsave1;
1584 stringstream figsave2;
1585 const char *format = saveas;
1586 if ( !strcmp(format,"ps") ) {
1587 figsave.str("");
1588 figsave << outdir << "/" ;
1589 figsave << figrec << "_CaloQLOOK.";
1590 figsave << format << "(";
1591 rapporto->Print(figsave.str().c_str(),"Landscape");
1592 figsave1.str("");
1593 figsave1 << outdir << "/" ;
1594 figsave1 << figrec << "_CaloQLOOK.";
1595 figsave1 << format;
1596 figura->Print(figsave1.str().c_str(),"Landscape");
1597 figsave2.str("");
1598 figsave2 << outdir << "/" ;
1599 figsave2 << figrec << "_CaloQLOOK.";
1600 if ( printfigure3 ){
1601 figsave2 << format;
1602 figura2->Print(figsave2.str().c_str(),"Landscape");
1603 figsave2.str("");
1604 figsave2 << outdir << "/" ;
1605 figsave2 << figrec << "_CaloQLOOK.";
1606 figsave2 << format << ")";
1607 figura3->Print(figsave2.str().c_str(),"Landscape");
1608 } else {
1609 figsave2 << format << ")";;
1610 figura2->Print(figsave2.str().c_str(),"Landscape");
1611 };
1612 } else {
1613 figsave.str("");
1614 figsave << outdir << "/" ;
1615 figsave << figrec << "_CaloQLOOK1.";
1616 figsave << format;
1617 figura->SaveAs(figsave.str().c_str());
1618 figsave.str("");
1619 figsave << outdir << "/" ;
1620 figsave << figrec << "_CaloQLOOK2.";
1621 figsave << format;
1622 figura2->SaveAs(figsave.str().c_str());
1623 if ( printfigure3 ){
1624 figsave.str("");
1625 figsave << outdir << "/" ;
1626 figsave << figrec << "_CaloQLOOK2bis.";
1627 figsave << format;
1628 figura3->SaveAs(figsave.str().c_str());
1629 };
1630 figsave.str("");
1631 figsave << outdir << "/" ;
1632 figsave << figrec << "_CaloQLOOK3.";
1633 figsave << format;
1634 rapporto->SaveAs(figsave.str().c_str());
1635 };
1636 if ( iactive && w4i ){
1637 while ( gROOT->GetListOfCanvases()->FindObject(rapporto) || gROOT->GetListOfCanvases()->FindObject(figura3) || gROOT->GetListOfCanvases()->FindObject(figura2) || gROOT->GetListOfCanvases()->FindObject(figura) ){
1638 gSystem->ProcessEvents();
1639 gSystem->Sleep(10);
1640 };
1641 };
1642 }
1643

  ViewVC Help
Powered by ViewVC 1.1.23