/[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.24 - (show annotations) (download)
Tue Aug 11 14:20:01 2009 UTC (15 years, 3 months ago) by mocchiut
Branch: MAIN
Changes since 1.23: +3 -2 lines
Compilation warnings with gcc >= 4.3 fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23