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

  ViewVC Help
Powered by ViewVC 1.1.23