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

  ViewVC Help
Powered by ViewVC 1.1.23