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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.23 - (show annotations) (download)
Mon Sep 22 20:12:28 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: MAIN
Changes since 1.22: +1 -0 lines
Added -m32 flag for cross compilation on 64bit machines

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

  ViewVC Help
Powered by ViewVC 1.1.23