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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.23