/[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.7 - (show annotations) (download)
Thu Jun 8 17:03:57 2006 UTC (18 years, 5 months ago) by pam-fi
Branch: MAIN
CVS Tags: R3v00
Changes since 1.6: +61 -53 lines
release R3v00

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

  ViewVC Help
Powered by ViewVC 1.1.23