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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Mon Jun 5 08:37:53 2006 UTC (18 years, 6 months ago) by pam-fi
Branch: MAIN
Changes since 1.3: +94 -98 lines
*** empty log message ***

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

  ViewVC Help
Powered by ViewVC 1.1.23