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

  ViewVC Help
Powered by ViewVC 1.1.23