/[PAMELA software]/quicklook/tracker/flight/macros/FTrkQLook_EXPERT.cxx
ViewVC logotype

Contents of /quicklook/tracker/flight/macros/FTrkQLook_EXPERT.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Thu Jun 1 18:44:26 2006 UTC (18 years, 6 months ago) by pam-fi
Branch: MAIN
Changes since 1.2: +721 -607 lines
*** empty log message ***

1 /**
2 * FTrkQLook_EXPERT
3 *
4 * autor: D.Fedele
5 * version 2.0
6 * Parameters:
7 * file - the data file to analyze
8 * fromevent - first event to analyze
9 * toevent - last event to analyze
10 * outdir - total path of output file
11 * outfile - extension of output file (pdf,ps,gif,jpg)
12 *
13 *
14 */
15 //
16 #include <fstream>
17 //
18 #include <TPaveText.h>
19 #include <TLatex.h>
20 #include <TCanvas.h>
21 #include <TGraph.h>
22 #include <TTree.h>
23 #include <TStyle.h>
24 //
25 #include <physics/tracker/TrackerEvent.h>
26 #include <PscuHeader.h>
27 #include <EventHeader.h>
28 #include <RunHeaderEvent.h>
29 #include <TrkAlarmEvent.h>
30 #include <tsbt/TsbTRecord.h>
31 #include <tsbt/TsbTEvent.h>
32 //
33
34 void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){
35 if ( to == 0 ){
36 Int_t t2length = s2.Length();
37 s1 = "";
38 to = t2length;
39 };
40 for (Int_t i = from; i<to; i++){
41 s1.Append(s2[i],1);
42 };
43 };
44
45
46 void FTrkQLook_EXPERT(TString file,Int_t fromevent,Int_t toevent, TString outdir, TString outfile)
47 {
48 //
49 // obtain information about the data file and select the output dir
50 const string filepath=file.Data();
51 Int_t dwpos = filepath.rfind("/");
52 Int_t dwpos1 = filepath.find(".root");
53 TString fpath=(filepath.c_str());
54 TString base,ffile ;
55 stringcopy(ffile,fpath,dwpos+1,dwpos1);
56 stringcopy(base,fpath,0,dwpos);
57 if(dwpos>0) base+="/";
58
59 TString out;
60 if(outdir.Length()==0){
61 out = base;
62 }else{
63 out = outdir;
64 }
65
66 //
67 // inizialise the variables and open the file
68 pamela::TsbTEvent *event = 0;
69 pamela::TsbTRecord *record = 0;
70 pamela::tracker::TrackerEvent *te=0;
71 pamela::EventHeader *eh=0,*aleh=0,*eH=0,*eT=0;
72 pamela::PscuHeader *ph=0,*pH=0;
73 pamela::TrkAlarmEvent *al=0;
74 pamela::RunHeaderEvent *reh=0;
75
76 TFile *datafile = new TFile(file);
77
78 TTree *tree = (TTree*)datafile->Get("TsbT");
79 tree->SetBranchAddress("TsbT",&event);
80 tree->SetBranchAddress("Header",&eT);
81
82 TTree *altr = (TTree*)datafile->Get("TrkAlarm");
83 altr->SetBranchAddress("TrkAlarm",&al);
84 altr->SetBranchAddress("Header",&aleh);
85
86 TTree *tr = (TTree*)datafile->Get("Physics");
87 tr->SetBranchAddress("Tracker",&te);
88 tr->SetBranchAddress("Header",&eh);
89
90 TTree *otr = (TTree*)datafile->Get("RunHeader");
91 otr->SetBranchAddress("Header",&eH);
92 otr->SetBranchAddress("RunHeader",&reh);
93
94 Long64_t nevent = tr->GetEntries();
95 Long64_t neventH = otr->GetEntries();
96 Long64_t tnevent = tree->GetEntries();
97 Long64_t alnevent = altr->GetEntries();
98 Int_t minevent=0;
99 Int_t maxevent=0;
100
101 printf("Number of total events: %lld\n",nevent);
102 printf("Number of header events: %lld\n",neventH);
103 printf("Number of TsbT events: %lld\n",tnevent);
104 printf("Number of TrkAlarm packet events: %lld\n",alnevent);
105
106 if (nevent<=0){
107 datafile->Close();
108 return;
109 }
110 if ( fromevent > toevent && toevent>0 ){
111 printf("It must be fromevent < toevent \n");
112 return;
113 }
114 if ( fromevent > nevent || fromevent < 0 ) {
115 printf("You can choose fromevent between 0 (all) and %lld \n",nevent);
116 return;
117 }
118 if ( toevent > nevent || toevent < 0 ) {
119 printf("You can choose toevent between 0 (all) and %lld \n",nevent);
120 return;
121 }
122 if ( fromevent == 0 ) {
123 minevent = 0;
124 maxevent = nevent;
125 } else {
126 minevent = fromevent;
127 if ( toevent > 0 ){
128 maxevent = toevent+1;
129 } else if (toevent > nevent) {
130 maxevent = nevent;
131 } else {
132 maxevent = toevent+1;
133 }
134 nevent=maxevent-minevent ;
135 }
136
137 Long64_t obt=0;
138 const Int_t sizeH=neventH;
139 ULong64_t HOBT[sizeH];
140 Int_t trk_cal_us[sizeH],countrun=1;
141 for (Int_t vi=0; vi<sizeH;vi++){
142 HOBT[vi]=0;
143 trk_cal_us[vi]=0;
144 }
145 for (Int_t ev=0; ev<neventH; ev++){
146 otr->GetEntry(ev);
147 pH = eH->GetPscuHeader();
148 HOBT[ev]= pH->GetOrbitalTime();
149 trk_cal_us[ev]=reh->TRK_CALIB_USED;
150 if((HOBT[ev]<HOBT[ev-1]) && ev>0)
151 countrun+=1;
152 // printf("\n%lld\t\tcountrun=%d\n",HOBT[ev],countrun);
153 }
154 countrun+=(Int_t)nevent/30000;
155 printf("\ncountrun=%d\n",countrun);
156
157 //
158 // other variables definitions
159 stringstream oss1,oss2,oss3,oss4,fromfile,isfile,tit;
160 Int_t ALARM=0;
161 Int_t WARNING[12];
162 Float_t hi=0;
163
164 //
165 // information about the entries for the temperatures
166 Int_t tmpSize=0,siztmp=0,maxsize=0;
167 for (Int_t ev=0; ev<tnevent; ev++){
168 tree->GetEntry(ev);
169 tmpSize = event->Records->GetEntries();
170 maxsize+=tmpSize;
171 }
172 const Int_t tsize=maxsize;
173 Int_t tempt[tsize][5],xt[tsize], tempt_tmp[tsize];
174 //
175 // information about the temperatures
176 for (Int_t ev=0; ev<tnevent; ev++){
177 tree->GetEntry(ev);
178 tmpSize = event->Records->GetEntries();
179 for (Int_t j = 0; j < tmpSize; j++){
180 record = (pamela::TsbTRecord*)event->Records->At(j);
181 xt[siztmp]=record->RECORD_OBT; //0.051*record->RECORD_OBT;
182 for (Int_t z = 0; z < 5; z++){
183 tempt[siztmp][z] = record->TEMPERATURES[z+1];
184 }
185 siztmp++;
186 }
187 }
188
189 //
190 // open the output text files for the alarms
191 TString fname1 = out+ffile;
192 TString fname = out+ffile;
193 int slen=fname.Length();
194 int last=fname.Last('_');
195 if(last<(slen-1))fname.Append('_');
196 fname.Append("FTrk-DSP-report.txt");
197 ofstream alarm(fname,ios::out);
198 alarm << "TRACKER DSP REPORT - Downlink " << ffile<< endl;
199 fname1.Append("_FTrkAlarm-pkt-report.txt");
200 ofstream alarm1(fname1,ios::out);
201 alarm1 << "TrkAlarm pkt REPORT - Downlink " << ffile<< endl;
202
203 //
204 // write the file for the TrkAlarm packet
205 if(alnevent==0) alarm1 <<endl<< "------> NO ALARM!!! <-------"<< endl;
206 else{
207 for (Int_t ev=0; ev<alnevent; ev++){
208 altr->GetEntry(ev);
209 ph = aleh->GetPscuHeader();
210
211 if(ph->GetOrbitalTime()<obt && ev>0)
212 alarm1<<endl<<"NEW CPU BOOT"<<endl;
213 obt=ph->GetOrbitalTime();
214
215 alarm1 << "================================================="<< endl;
216 alarm1 << "PSCU-Pkt N. "<< ph->GetCounter() ;
217 alarm1 << " - OBT "<< ph->GetOrbitalTime() << " ms"<<endl;
218 alarm1 << "(ROOT-tree entry "<<ev<<")"<<endl;
219 alarm1 << "================================================="<< endl<<endl;
220
221 alarm1 << "Alarm variables (range 0-1)"<<endl;
222 alarm1 << " ALARM[1]= "<< hex<< (Int_t)al->ALARM[1]<<dec<<endl;
223 alarm1 << " ALARM[2]= "<< hex<< (Int_t)al->ALARM[2]<<dec<<endl;
224 alarm1 << " CmdDuringTrig= "<< hex<<(Int_t)al->CmdDuringTrig<<endl;
225 alarm1 << " FinalCheck= "<< hex<<(Int_t)al->FinalCheck<<endl;
226 alarm1 << " FlashData= "<< hex<<(Int_t)al->FlashData<<endl;
227 alarm1 << " FlashShutdown= "<< hex<<(Int_t)al->FlashShutdown<<endl;
228 alarm1 << " FlashUpset= "<< hex<<(Int_t)al->FlashUpset<<endl;
229 alarm1 << " InterCheck= "<< hex<<(Int_t)al->InterCheck<<endl;
230 alarm1 << " UnknownCmd= "<< hex<<(Int_t)al->UnknownCmd<<endl<<endl;
231
232 alarm1 << "Alarm variables (range 0-3F)"<<endl;
233 alarm1 << " CmdIDMA= "<< hex<<(Int_t)al->CmdIDMA<<endl;
234 alarm1 << " DSPSoft= "<< hex<<(Int_t)al->DSPSoft<<endl;
235 alarm1 << " TrigIDMA= "<< hex<<(Int_t)al->TrigIDMA<<endl<<endl;
236
237 alarm1 << "Alarm bits (range 0-1)"<<endl;
238 alarm1 << " Aswr= "<< hex<<(Int_t)al->Aswr<<endl;
239 alarm1 << " BID[1]= "<< hex<<(Int_t)al->BID[0]<<endl;
240 alarm1 << " BID[2]= "<< hex<<(Int_t)al->BID[1]<<endl;
241 alarm1 << " BID[3]= "<< hex<<(Int_t)al->BID[2]<<endl;
242 alarm1 << " BID[4]= "<< hex<<(Int_t)al->BID[3]<<endl;
243 alarm1 << " BID[5]= "<< hex<<(Int_t)al->BID[4]<<endl;
244 alarm1 << " BID[6]= "<< hex<<(Int_t)al->BID[5]<<endl;
245 alarm1 << " BID[7]= "<< hex<<(Int_t)al->BID[6]<<endl;
246 alarm1 << " CmdNum= "<< hex<<(Int_t)al->CmdNum<<endl;
247 alarm1 << " DSPBusy= "<< hex<<(Int_t)al->DSPBusy<<endl;
248 alarm1 << " DSPMask= "<< hex<<(Int_t)al->DSPMask<<endl;
249 alarm1 << " FlashOn= "<< hex<<(Int_t)al->FlashOn<<endl;
250 alarm1 << " PNum= "<< hex<<(Int_t)al->PNum<<endl;
251 alarm1 << " TrigMask= "<< hex<<(Int_t)al->TrigMask<<endl;
252 alarm1 << "================================================="<< endl<<endl;
253
254 }
255 }
256
257
258 gStyle->SetLabelSize(0.05,"x");
259 gStyle->SetLabelSize(0.06,"y");
260 gStyle->SetStatFontSize(0.075);
261 gStyle->SetOptStat(1110);
262 gStyle->SetFillColor(10);
263 gStyle->SetTitleFillColor(10);
264 gStyle->SetTitleFontSize(0.1);
265 gStyle->SetTitleOffset(0.8,"y");
266 gStyle->SetTitleOffset(0.9,"x");
267 gStyle->SetTitleSize(0.06,"y");
268 gStyle->SetTitleSize(0.055,"x");
269
270
271 //***************************************************************************************
272 // LOOP on each event
273 //***************************************************************************************
274
275 if (fromevent!=0)
276 printf("\n Scan of events from %i to %i ... \n",minevent,maxevent-1);
277 else
278 printf("\n Scan of events from %i to %i ... \n",minevent+1,maxevent);
279
280
281 Int_t minev=minevent,maxev=maxevent,countTEMP=0;
282 TCanvas *CompTimeCanv[countrun],*EventNumCanv[countrun],*LandauCanv1[countrun],*LandauCanv2[countrun],*LandauCanv3[countrun];
283 TCanvas *IlluminaCanv[countrun],*TempCanv[countrun];
284 TGraph *comprtime[12][countrun],*temp[5][countrun];
285 TGraph *eventnumb[countrun];
286 TH1F *landau1[12][countrun],*landau2[12][countrun],*landau3[12][countrun],*illuminazione[12][countrun];
287
288 for(Int_t ii=0; ii<countrun;ii++){
289 TPaveText *pt1;
290 TPad *pt,*pt0;
291 TPad *pad1[12],*pad2[12],*pad3[12],*pad4[12],*pad5[12],*pad6[5]; //pad for histos
292
293
294 ofstream warning(out + "warning.txt",ios::out);
295
296 //****************************************************************************************
297 //Output figures --- First sheet:
298 //****************************************************************************************
299
300 fromfile<<"FTrkQLook_EXPERT File: "<<ffile;
301 isfile<<"COMPRESSIONTIME vs. OBT pag"<<ii+1;
302 CompTimeCanv[ii]=new TCanvas(isfile.str().c_str(),isfile.str().c_str(),900,1200);
303 CompTimeCanv[ii]->SetFillColor(10);
304 CompTimeCanv[ii]->Range(0,0,100,100);
305 TLatex *t=new TLatex();
306 t->SetTextFont(32);
307 t->SetTextColor(1);
308 t->SetTextAlign(12);
309 t->SetTextSize(0.02);
310 t->DrawLatex(2.,98.7,fromfile.str().c_str());
311 TLatex *t1=new TLatex();
312 t1->SetTextFont(32);
313 t1->SetTextColor(1);
314 t1->SetTextAlign(12);
315 t1->SetTextSize(0.02);
316 t1->DrawLatex(59.,98.7,isfile.str().c_str());
317 isfile.str("");
318
319 //****************************************************************************************
320 //Output figures --- Second sheet:
321 //****************************************************************************************
322
323 isfile<<"WARNINGS on DSP EVENT NUMBER pag"<<ii+1;
324 EventNumCanv[ii]=new TCanvas(isfile.str().c_str(),isfile.str().c_str(),900,1200);
325 EventNumCanv[ii]->SetFillColor(10);
326 EventNumCanv[ii]->Range(0,0,100,100);
327 t->SetTextFont(32);
328 t->SetTextColor(1);
329 t->SetTextAlign(12);
330 t->SetTextSize(0.02);
331 t->DrawLatex(2.,98.7,fromfile.str().c_str());
332 t1->SetTextFont(32);
333 t1->SetTextColor(1);
334 t1->SetTextAlign(12);
335 t1->SetTextSize(0.02);
336 t1->DrawLatex(63.4,98.7,isfile.str().c_str());
337 isfile.str("");
338
339 //****************************************************************************************
340 //Output figures --- Third sheet:
341 //****************************************************************************************
342
343 isfile<<"Cluster Signal ladder1 pag"<<ii+1;
344 LandauCanv1[ii]=new TCanvas(isfile.str().c_str(),isfile.str().c_str(),900,1200);
345 LandauCanv1[ii]->SetFillColor(10);
346 LandauCanv1[ii]->Range(0,0,100,100);
347
348 t->SetTextFont(32);
349 t->SetTextColor(1);
350 t->SetTextAlign(12);
351 t->SetTextSize(0.02);
352 t->DrawLatex(2.,98.7,fromfile.str().c_str());
353 t1->SetTextFont(32);
354 t1->SetTextColor(1);
355 t1->SetTextAlign(12);
356 t1->SetTextSize(0.02);
357 t1->DrawLatex(60.,98.7,isfile.str().c_str());
358 isfile.str("");
359
360 //****************************************************************************************
361 //Output figures --- Third sheet:
362 //****************************************************************************************
363
364 isfile<<"Cluster Signal ladder2 pag"<<ii+1;
365 LandauCanv2[ii]=new TCanvas(isfile.str().c_str(),isfile.str().c_str(),900,1200);
366 LandauCanv2[ii]->SetFillColor(10);
367 LandauCanv2[ii]->Range(0,0,100,100);
368
369 t->SetTextFont(32);
370 t->SetTextColor(1);
371 t->SetTextAlign(12);
372 t->SetTextSize(0.02);
373 t->DrawLatex(2.,98.7,fromfile.str().c_str());
374 t1->SetTextFont(32);
375 t1->SetTextColor(1);
376 t1->SetTextAlign(12);
377 t1->SetTextSize(0.02);
378 t1->DrawLatex(60.,98.7,isfile.str().c_str());
379 isfile.str("");
380
381 //****************************************************************************************
382 //Output figures --- Third sheet:
383 //****************************************************************************************
384
385 isfile<<"Cluster Signal ladder3 pag"<<ii+1;
386 LandauCanv3[ii]=new TCanvas(isfile.str().c_str(),isfile.str().c_str(),900,1200);
387 LandauCanv3[ii]->SetFillColor(10);
388 LandauCanv3[ii]->Range(0,0,100,100);
389
390 t->SetTextFont(32);
391 t->SetTextColor(1);
392 t->SetTextAlign(12);
393 t->SetTextSize(0.02);
394 t->DrawLatex(2.,98.7,fromfile.str().c_str());
395 t1->SetTextFont(32);
396 t1->SetTextColor(1);
397 t1->SetTextAlign(12);
398 t1->SetTextSize(0.02);
399 t1->DrawLatex(60.,98.7,isfile.str().c_str());
400 isfile.str("");
401
402 //****************************************************************************************
403 //Output figures --- Fourth sheet:
404 //****************************************************************************************
405
406 isfile<<"lighting of the views pag"<<ii+1;
407 IlluminaCanv[ii]=new TCanvas(isfile.str().c_str(),isfile.str().c_str(),900,1200);
408 IlluminaCanv[ii]->SetFillColor(10);
409 IlluminaCanv[ii]->Range(0,0,100,100);
410 t->SetTextFont(32);
411 t->SetTextColor(1);
412 t->SetTextAlign(12);
413 t->SetTextSize(0.02);
414 t->DrawLatex(2.,98.7,fromfile.str().c_str());
415 t1->SetTextFont(32);
416 t1->SetTextColor(1);
417 t1->SetTextAlign(12);
418 t1->SetTextSize(0.02);
419 t1->DrawLatex(65.,98.7,isfile.str().c_str());
420 isfile.str("");
421
422 //****************************************************************************************
423 //Output figures --- Fifth sheet:
424 //****************************************************************************************
425
426 isfile<<"Temperatures vs OBT pag"<<ii+1;
427 TempCanv[ii]=new TCanvas(isfile.str().c_str(),isfile.str().c_str(),900,1200);
428 TempCanv[ii]->SetFillColor(10);
429 TempCanv[ii]->Range(0,0,100,100);
430
431 t->SetTextFont(32);
432 t->SetTextColor(1);
433 t->SetTextAlign(12);
434 t->SetTextSize(0.02);
435 t->DrawLatex(2.,98.7,fromfile.str().c_str());
436 t1->SetTextFont(32);
437 t1->SetTextColor(1);
438 t1->SetTextAlign(12);
439 t1->SetTextSize(0.02);
440 t1->DrawLatex(75.,98.7,isfile.str().c_str());
441 isfile.str("");
442
443 //*************************************************************************************
444 //book pads and histos
445 //***************************************************************************************
446 Float_t posy = 0.95; // up y-coord - top pads
447 Float_t hpad = 0; // pad height
448 Float_t posx1=0; // left x-coord - pad column
449 Float_t posx0=0; // x-coord - column division
450 Float_t wrel = 0; // relative x size of first sub-column
451 Float_t marg = 0.004; // margin among pads
452 Float_t tposy = 0.95; // up y-coord - top pads
453 Float_t thpad = 0; // pad height
454 Float_t tposx1=0; // left x-coord - pad column
455 Float_t tposx0=0; // x-coord - column division
456 Float_t twrel = 0; // relative x size of first sub-column
457 Float_t tmarg = 0.004; // margin among pads
458
459 hpad = (posy-marg*11)/6;
460 wrel = (1-marg*4)/2;
461 thpad = (tposy-tmarg*5)/3;
462 twrel = (1-tmarg*4)/2;
463
464 for(Int_t n = 0; n<12; n++) {
465
466 if ( (n+1)%2==1 ) {
467 if(n>1) posy = posy-(marg*2+hpad);
468 posx1 = marg;
469 posx0 = posx1 + wrel;
470 }
471 else {
472 posx1 = posx0 + 2*marg;
473 posx0 = posx1 + wrel;
474 }
475
476 if ( (n+1)%2==1 ) {
477 if(n>1) tposy = tposy-(tmarg*2+thpad);
478 tposx1 = tmarg;
479 tposx0 = tposx1 + twrel;
480 }
481 else {
482 tposx1 = tposx0 + 2*tmarg;
483 tposx0 = tposx1 + twrel;
484 }
485
486
487 /* -----------> pad for histograms */
488 pad1[n] = new TPad("pad1"," ",posx1,posy-hpad,posx0,posy,18,0,0);
489 pad2[n] = new TPad("pad2"," ",posx1,posy-hpad,posx0,posy,18,0,0);
490 pad3[n] = new TPad("pad3"," ",posx1,posy-hpad,posx0,posy,18,0,0);
491 pad4[n] = new TPad("pad4"," ",posx1,posy-hpad,posx0,posy,18,0,0);
492 pad5[n] = new TPad("pad5"," ",posx1,posy-hpad,posx0,posy,18,0,0);
493 if(n<5) pad6[n] = new TPad("pad6"," ",tposx1,tposy-thpad,tposx0,tposy,18,0,0);
494
495
496 /* -----------> HISTOGRAMS */
497
498 oss1<<"DSP "<<n*100+ii;
499 oss2<<"DSPh "<<n*100+ii;
500 oss3<<"DSP h "<<n*100+ii;
501 oss4<<"DSP h"<<n*100+ii;
502
503 landau1[n][ii]=new TH1F(oss1.str().c_str(),oss1.str().c_str(),401,-0.5,1200.5);
504 landau1[n][ii]->GetXaxis()->SetTitle("max signal");
505 landau1[n][ii]->GetXaxis()->CenterTitle();
506 landau2[n][ii]=new TH1F(oss2.str().c_str(),oss1.str().c_str(),401,-0.5,1200.5);
507 landau2[n][ii]->GetXaxis()->SetTitle("max signal");
508 landau2[n][ii]->GetXaxis()->CenterTitle();
509 landau3[n][ii]=new TH1F(oss3.str().c_str(),oss1.str().c_str(),401,-0.5,1200.5);
510 landau3[n][ii]->GetXaxis()->SetTitle("max signal");
511 landau3[n][ii]->GetXaxis()->CenterTitle();
512
513 illuminazione[n][ii]=new TH1F(oss4.str().c_str(),oss1.str().c_str(),3073,-0.5,3072.5);
514 illuminazione[n][ii]->GetXaxis()->SetTitle("strip with max signal");
515 illuminazione[n][ii]->GetXaxis()->CenterTitle();
516
517 oss1.str("");
518 oss2.str("");
519 oss3.str("");
520 oss4.str("");
521 };
522
523
524 // printf("\nprova0\n");
525
526
527 //**********************************************************************************
528 // Fill Graphs and Histos
529 //**********************************************************************************
530
531 //
532 // information about the tracker data
533 Int_t warning_dspnumber=0;
534 Float_t x[30000];
535 Float_t yc[30000][12];
536 Float_t eventint[30000];
537
538 for (Int_t ev=minev; ev<maxevent; ev++){
539 tr->GetEntry(ev);
540 ph = eh->GetPscuHeader();
541
542 if(ev==maxevent-1) maxev=maxevent-1;
543
544 if((ph->GetOrbitalTime()<x[ev-minev-1] && ev-minev!=0) || ev-minev==30000){
545 maxev=ev;
546 printf("prova12 ev=%d\tev-minev=%d\n",ev,ev-minev);
547 break;
548 }
549 else{
550 // if(ii==32)printf("\nprova1 %d\tev-minev=%d\n",ev,ev-minev);
551 x[(ev-minev)]= ph->GetOrbitalTime();
552 ALARM=0;
553
554 Int_t dsp=0;
555 for(Int_t i=0; i<12; i++){
556 dsp=te->DSPnumber[i]-1;
557 yc[(ev-minev)][dsp]= 0.051*te->compressiontime[i];
558
559 for(Int_t j=0;j<3;j++){
560 if(te->signcluster[i][j]!=0){
561 hi=(j*1024)+te->addrcluster[i][j];
562 if((hi>505 && hi<519) ||(hi>1017 && hi<1031) ||(hi>1529 && hi<1543) || (hi>2041 && hi<2055) ||(hi>2553 && hi<2567))
563 continue;
564 else illuminazione[dsp][ii]->Fill(hi);
565
566 if(!(dsp%2)){
567 landau1[dsp][ii]->Fill(1024-(te->signcluster[i][j]));
568 landau2[dsp][ii]->Fill(1024-(te->signcluster[i][j]));
569 landau3[dsp][ii]->Fill(1024-(te->signcluster[i][j]));
570 }
571 else{
572 landau1[dsp][ii]->Fill(te->signcluster[i][j]);
573 landau2[dsp][ii]->Fill(te->signcluster[i][j]);
574 landau3[dsp][ii]->Fill(te->signcluster[i][j]);
575 }
576 }
577 }
578
579 WARNING[i]=0;
580 if(te->fc[i]!=0 || te->fl1[i]!=0 || te->fl2[i]!=0 || te->fl3[i]!=0 || te->fl4[i]!=0 || te->fl5[i]!=0 || te->fl6[i]!=0){
581 ALARM = 1; //general alarm
582 WARNING[i] = 1; // DSP warning
583 };
584
585 if(te->alarm[i]!=0){ // hardware alarm
586 ALARM = 1;
587 };
588
589 //**************************************************************************************
590 // warning for internal number
591 //**************************************************************************************
592 if(i<=10){
593 if(te->eventn[i]!=te->eventn[i+1]){
594 warning_dspnumber++;
595 warning<< "==> WARNING!! Check entry "<< ev<<" (DSP "<<dsp<<")" <<endl<<
596 "eventn["<<i<<"]= "<<te->eventn[i]<<"!= eventn["<<i+1<<"]= "<< te->eventn[i+1]<<endl;
597 }
598 else
599 eventint[(ev-minev)]=te->eventn[0];
600 }
601 }
602
603 if(ev<=maxevent-1){
604
605 if((ev-minev)>=1 && eventint[(ev-minev)]!=eventint[(ev-minev)-1]+1 && eventint[(ev-minev)]!=1){
606 warning_dspnumber++;
607 warning<< "==> WARNING!! Check entry "<< ev<<endl<<
608 " DSP event num.= "<< eventint[(ev-minev)]<<
609 " is different from (previus+1) ="<<eventint[(ev-minev)-1]+1 <<"\n"<<endl;
610 }
611 }
612
613 //********************************************************************************************
614 // file ALARM
615 //********************************************************************************************
616
617 alarm <<endl<< "================================================="<< endl;
618 alarm << "PSCU-Pkt N. "<< ph->GetCounter() ;
619 alarm << " - OBT "<< ph->GetOrbitalTime() << " ms"<<endl;
620 alarm << "(ROOT-tree entry "<<ev<<")"<<endl;
621 alarm << "================================================="<< endl;
622
623 if(ALARM==1) {
624 alarm << " DSPn";
625 alarm << " Event";
626 alarm << " Words";
627 alarm << " crc";
628 alarm << " FC";
629 alarm << " FL1";
630 alarm << " FL2";
631 alarm << " FL3";
632 alarm << " FL4";
633 alarm << " FL5";
634 alarm << " FL6" << endl;
635
636 for(Int_t i=0; i<12 ; i++){
637 alarm.width(5); alarm << te->DSPnumber[i];
638 alarm.width(6); alarm << te->eventn[i];
639 alarm.width(6); alarm << te->DATAlength[i];
640 alarm.width(4); alarm << te->crc[i];
641 alarm.width(4); alarm << te->fc[i];
642 alarm.width(4); alarm << te->fl1[i];
643 alarm.width(4); alarm << te->fl2[i];
644 alarm.width(4); alarm << te->fl3[i];
645 alarm.width(4); alarm << te->fl4[i];
646 alarm.width(4); alarm << te->fl5[i];
647 alarm.width(4); alarm << te->fl6[i];
648 if(te->alarm[i]!=0)alarm<<" >> ALARM ";
649 if(WARNING[i]!=0)alarm<<" (DSP warning) ";
650 alarm << endl;
651 }
652 }
653 }
654 if(ALARM==0) alarm << endl<< "------> NO ALARM!!! <-------"<<endl;
655
656 if(warning_dspnumber==0) warning<<"NONE"<<endl;
657 }
658
659 // printf("prova2\n");
660
661 Float_t maxhist=0;
662 TBox b;
663 b.SetFillColor(5);
664
665 for (Int_t i=0; i<12 ; i++){
666 Float_t yyc[maxev-minev];
667 for (Int_t v=0; v<maxev-minev; v++){
668 yyc[v]=yc[v][i];
669 }
670
671 printf("prova3\n");
672 LandauCanv1[ii]->cd();
673 pad1[i]->SetFillColor(10);
674 pad1[i]->SetFrameFillColor(10);
675 pad1[i]->Draw();
676 pad1[i]->cd();
677 landau1[i][ii]->Draw("");
678 LandauCanv2[ii]->cd();
679 pad4[i]->SetFillColor(10);
680 pad4[i]->SetFrameFillColor(10);
681 pad4[i]->Draw();
682 pad4[i]->cd();
683 landau2[i][ii]->Draw("");
684 LandauCanv3[ii]->cd();
685 pad5[i]->SetFillColor(10);
686 pad5[i]->SetFrameFillColor(10);
687 pad5[i]->Draw();
688 pad5[i]->cd();
689 landau3[i][ii]->Draw("");
690
691 printf("prova4\n");
692 IlluminaCanv[ii]->cd();
693 pad2[i]->SetFillColor(10);
694 pad2[i]->SetFrameFillColor(10);
695 pad2[i]->Draw();
696 pad2[i]->cd();
697 pad2[i]->SetLogy();
698 // illuminazione[i][ii]->SetStats(KFALSE);
699 if(i==1){
700 illuminazione[i][ii]->Draw("ah");
701 maxhist= illuminazione[i][ii]->GetMaximum();
702 b.DrawBox(2816.,0.,3060.,maxhist);
703 illuminazione[i][ii]->Draw("axis same");
704 illuminazione[i][ii]->Draw("same ][");
705 }
706 else if(i==6){
707 illuminazione[i][ii]->Draw("ah");
708 maxhist= illuminazione[i][ii]->GetMaximum();
709 b.DrawBox(2560.,0.,2816.,maxhist);
710 b.DrawBox(512.,0.,768.,maxhist);
711 b.DrawBox(1024.,0.,1792.,maxhist);
712 illuminazione[i][ii]->Draw("axis same");
713 illuminazione[i][ii]->Draw("same][");
714 }
715 else if(i==11){
716 illuminazione[i][ii]->Draw("ah");
717 maxhist= illuminazione[i][ii]->GetMaximum();
718 b.DrawBox(768.,0.,1024.,maxhist);
719 illuminazione[i][ii]->Draw("axis same");
720 illuminazione[i][ii]->Draw("same][");
721 }
722 else illuminazione[i][ii]->Draw("");
723
724 printf("prova5\n");
725
726
727 CompTimeCanv[ii]->cd();
728 pad3[i]->SetFillColor(10);
729 pad3[i]->SetFrameFillColor(10);
730 pad3[i]->Draw();
731 pad3[i]->cd();
732 comprtime[i][ii]= new TGraph(maxev-minev,x,yyc);
733 oss1<<"DSP "<<i+1;
734 comprtime[i][ii]->SetTitle(oss1.str().c_str());
735 comprtime[i][ii]->GetXaxis()->SetTitle("OBT (ms)");
736 comprtime[i][ii]->GetXaxis()->CenterTitle();
737 comprtime[i][ii]->GetYaxis()->SetTitle("compressiontime (ms)");
738 comprtime[i][ii]->GetYaxis()->CenterTitle();
739 comprtime[i][ii]->GetYaxis()->SetRangeUser(0,2);
740 comprtime[i][ii]->Draw("ap");
741 oss1.str("");
742
743 CompTimeCanv[ii]->Update();
744 LandauCanv1[ii]->Update();
745 LandauCanv2[ii]->Update();
746 LandauCanv3[ii]->Update();
747 IlluminaCanv[ii]->Update();
748 };
749
750 printf("prova6\n");
751 EventNumCanv[ii]->cd();
752 pt0=new TPad("pt0"," ",0.704,0.004,0.996,0.98);
753 pt1 = new TPaveText(0.004,0.004,0.986,0.996);
754 pt = new TPad("pt"," ",0.004,0.004,0.7,0.98,18,0,0);
755 pt1->SetFillColor(10);
756 pt1->ReadFile(out + "warning.txt");
757 pt1->SetTextAlign(22);
758 pt1->SetTextSize(0.035);
759 pt0->SetFillColor(10);
760 pt0->SetFrameFillColor(10);
761 pt0->Draw();
762 pt0->cd();
763 pt1->Draw();
764 EventNumCanv[ii]->cd();
765 pt->SetFillColor(10);
766 pt->SetFrameFillColor(10);
767 pt->Draw();
768 pt->cd();
769 eventnumb[ii]=new TGraph(maxev-minev,x,eventint);
770 eventnumb[ii]->SetTitle("");
771 eventnumb[ii]->GetXaxis()->SetLabelSize(0.04);
772 eventnumb[ii]->GetXaxis()->SetTitleSize(0.04);
773 eventnumb[ii]->GetXaxis()->SetTitle("OBT (ms)");
774 eventnumb[ii]->GetXaxis()->CenterTitle();
775 eventnumb[ii]->GetXaxis()->SetTickLength(0.01);
776 eventnumb[ii]->GetXaxis()->SetTitleOffset(1.2);
777 eventnumb[ii]->GetYaxis()->SetLabelSize(0.04);
778 eventnumb[ii]->GetYaxis()->SetTitleSize(0.04);
779 eventnumb[ii]->GetYaxis()->SetTitle("DSP event-number");
780 eventnumb[ii]->GetYaxis()->CenterTitle();
781 eventnumb[ii]->GetYaxis()->SetTitleOffset(1.5);
782 eventnumb[ii]->SetMarkerStyle(21);
783 eventnumb[ii]->SetMarkerColor(kBlue);
784 eventnumb[ii]->SetMarkerSize(0.3);
785 eventnumb[ii]->Draw("ap");
786 EventNumCanv[ii]->Update();
787
788 printf("prova7\n");
789
790 obt=0;
791 for(Int_t i=0; i<5; i++){
792 Int_t v=0;
793 for (Int_t ev=countTEMP; ev<tsize; ev++){
794 tree->GetEntry(ev);
795 ph=eT->GetPscuHeader();
796
797 if(ph->GetOrbitalTime()<obt && ev>countTEMP){
798 countTEMP=ev;
799 break;
800 }
801 else{
802 obt=ph->GetOrbitalTime();
803 tempt_tmp[v++]=(Int_t)(((3.3*tempt[ev][i]/4096)-0.586)/0.0231);
804 }
805 }
806 TempCanv[ii]->cd();
807 tit<<"T"<<i+5<<" (magnetic module "<<i+1<<")";
808 pad6[i]->SetFillColor(10);
809 pad6[i]->Draw();
810 pad6[i]->cd();
811 temp[i][ii]= new TGraph(v,xt,tempt_tmp);
812 temp[i][ii]->SetTitle(tit.str().c_str());
813 temp[i][ii]->GetXaxis()->SetLabelSize(0.04);
814 temp[i][ii]->GetXaxis()->SetTitleSize(0.04);
815 temp[i][ii]->GetXaxis()->SetTitle("OBT (ms)");
816 temp[i][ii]->GetXaxis()->CenterTitle();
817 temp[i][ii]->GetXaxis()->SetTitleOffset(0.85);
818 temp[i][ii]->GetYaxis()->SetTitleOffset(1.2);
819 temp[i][ii]->GetYaxis()->SetLabelOffset(0.001);
820 temp[i][ii]->GetYaxis()->SetLabelSize(0.04);
821 temp[i][ii]->GetYaxis()->SetTitleSize(0.04);
822 temp[i][ii]->GetYaxis()->SetTitle("Temperatures ( ^{o}C)");
823 temp[i][ii]->GetYaxis()->CenterTitle();
824 temp[i][ii]->SetMarkerStyle(21);
825 temp[i][ii]->SetMarkerSize(0.2);
826 temp[i][ii]->Draw("ap");
827 tit.str("");
828 TempCanv[ii]->Update();
829 }
830
831 printf("prova8\n");
832 minev=maxev;
833 printf("\ncountrun=%d\n",ii);
834 if(maxev==maxevent-1) {
835 countrun=ii+1;
836 break;
837 }
838
839 warning.close();
840
841 }
842
843 //*****************************************
844 //close all files
845 //*****************************************
846 alarm.close();
847 datafile->Close();
848
849 printf("... end of packets. \n");
850 //*************************************************************************
851 // Save output Files
852 //*************************************************************************
853 stringstream out1,out2,out3,command;
854
855 for(Int_t fl=0;fl<countrun;fl++){
856 if(!strcmp(outfile.Data(),"ps")||!strcmp(outfile.Data(),"pdf")){
857 out1.str("");
858 out2.str("");
859 out3.str("");
860
861 out1<<ffile<<"_FTrkQLook_EXPERT.ps(";
862 out2<<ffile<<"_FTrkQLook_EXPERT.ps";
863 out3<<ffile<<"_FTrkQLook_EXPERT.ps)";
864
865 if(countrun==1){
866 CompTimeCanv[fl]->Print(out+out1.str().c_str(),"Portrait");
867 EventNumCanv[fl]->Print(out+out2.str().c_str(),"Portrait");
868 LandauCanv1[fl]->Print(out+out2.str().c_str(),"Portrait");
869 LandauCanv2[fl]->Print(out+out2.str().c_str(),"Portrait");
870 LandauCanv3[fl]->Print(out+out2.str().c_str(),"Portrait");
871 IlluminaCanv[fl]->Print(out+out2.str().c_str(),"Portrait");
872 TempCanv[fl]->Print(out+out3.str().c_str(),"Portrait");
873 }
874 else if(countrun>=1){
875 if(fl==0) CompTimeCanv[fl]->Print(out+out1.str().c_str(),"Portrait");
876 else CompTimeCanv[fl]->Print(out+out2.str().c_str(),"Portrait");
877 EventNumCanv[fl]->Print(out+out2.str().c_str(),"Portrait");
878 LandauCanv1[fl]->Print(out+out2.str().c_str(),"Portrait");
879 LandauCanv2[fl]->Print(out+out2.str().c_str(),"Portrait");
880 LandauCanv3[fl]->Print(out+out2.str().c_str(),"Portrait");
881 IlluminaCanv[fl]->Print(out+out2.str().c_str(),"Portrait");
882 if(fl!=countrun-1) TempCanv[fl]->Print(out+out2.str().c_str(),"Portrait");
883 else TempCanv[fl]->Print(out+out3.str().c_str(),"Portrait");
884 }
885
886 if(!strcmp(outfile.Data(),"pdf")){
887 stringstream com;
888 com<<"ps2pdf13 "<<out<<ffile<<"_FTrkQLook_EXPERT.ps "<<out<<ffile<<"_FTrkQLook_EXPERT.pdf";
889 system(com.str().c_str());
890 printf("\n---> ps file converted in pdf format!\n");
891 com.str("");
892 com<<"rm -f "<<out<<ffile<<"_FTrkQLook_EXPERT.ps ";
893 system(com.str().c_str());
894 printf("---> ps file removed!\n\n");
895 com.str("");
896 }
897 }
898 else{
899 out1.str("");
900 out1<<ffile<<"_FTrkQLook_EXPERT-CompTime-pag"<<fl+1<<"."<<outfile.Data();
901 CompTimeCanv[fl]->Print(out+out1.str().c_str());
902 out1.str("");
903 out1<<ffile<<"_FTrkQLook_EXPERT-Temp-pag"<<fl+1<<"."<<outfile.Data();
904 TempCanv[fl]->Print(out+out1.str().c_str());
905 out1.str("");
906 out1<<ffile<<"_FTrkQLook_EXPERT-EvNum-pag"<<fl+1<<"."<<outfile.Data();
907 EventNumCanv[fl]->Print(out+out1.str().c_str());
908 out1.str("");
909 out1<<ffile<<"_FTrkQLook_EXPERT-LandauL1-pag"<<fl+1<<"."<<outfile.Data();
910 LandauCanv1[fl]->Print(out+out1.str().c_str());
911 out1.str("");
912 out1<<ffile<<"_FTrkQLook_EXPERT-LandauL2-pag"<<fl+1<<"."<<outfile.Data();
913 LandauCanv2[fl]->Print(out+out1.str().c_str());
914 out1.str("");
915 out1<<ffile<<"_FTrkQLook_EXPERT-LandauL3-pag"<<fl+1<<"."<<outfile.Data();
916 LandauCanv3[fl]->Print(out+out1.str().c_str());
917 out1.str("");
918 out1<<ffile<<"_FTrkQLook_EXPERT-Lighting-pag"<<fl+1<<"."<<outfile.Data();
919 IlluminaCanv[fl]->Print(out+out1.str().c_str());
920 }
921 }
922 command.str("");
923 command<<"rm -f "<<out<<"warning.txt";
924 system(command.str().c_str());
925
926 gROOT->Reset();
927 return;
928 }

  ViewVC Help
Powered by ViewVC 1.1.23