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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.22 - (hide annotations) (download)
Sun Dec 24 00:59:04 2006 UTC (17 years, 11 months ago) by pam-fi
Branch: MAIN
CVS Tags: v1r21
Changes since 1.21: +350 -68 lines
new plot added for va1 analysis

1 pam-fi 1.1 /**
2     * FTrkScanQlook_EXPERT.cxx
3     *
4     * autor: D.Fedele
5 pam-fi 1.22 * version v2r01
6 pam-fi 1.1 * Parameters:
7     * file - the path to the root file to analyze
8     * outdir - total path of output file
9     * event - the number of the single event to analyze
10 pam-fi 1.19 * va1 - the number of the single va1 to analyze (dsp*100+va1)
11 pam-fi 1.22 * value - the number of events to store in the .dat file with va1 values*10 + # of calibration (if #of cal = 0, select every calibration)
12 pam-fi 1.19 * outfile - extension of output file (pdf,ps,gif,jpg)
13 pam-fi 1.1 *
14     */
15     //
16     #include <iostream>
17     #include <sstream>
18 pam-fi 1.20 #include <fstream>
19 pam-fi 1.1 //
20     #include <TPaveText.h>
21     #include <TLatex.h>
22     #include <TCanvas.h>
23     #include <TGraph.h>
24 pam-fi 1.5 #include <TFile.h>
25 pam-fi 1.1 #include <TTree.h>
26     #include <TStyle.h>
27     #include <TString.h>
28     //
29     #include <physics/tracker/TrackerEvent.h>
30 pam-fi 1.3 #include <PscuHeader.h>
31     #include <EventHeader.h>
32 pam-fi 1.22 #include <CalibTrk1Event.h>
33     #include <CalibTrk2Event.h>
34 pam-fi 1.3 #include <RunHeaderEvent.h>
35 pam-fi 1.1 //
36    
37     using namespace std;
38    
39     typedef struct trkword{
40     int type;
41     int decode;
42     };
43    
44     /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
45     *
46     | The function "datadecode" decodes the tracker words.
47     *
48     | Tracker words are of three types:
49     * - ADC data
50     | - strip address
51     * - end of ladder
52     |
53     * The function returns a struct variable (trkword)
54     | that contains two quantities, type and decode, which are assigned
55     * the following values:
56     |
57     * type decode
58     | ----------------------------------------------------
59     * -1 error 0
60     | 0 data 0-4095 ADC values
61     * 1 address 0-1023 strip address (relative to ladder)
62     | 2 end-of-ladder 1,2,3 ladder number (compressed acq mode)
63     * 4,5,6 ladder number + 3 (full acq mode)
64     |
65     *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
66     trkword datadecode(int word){
67     int type =0;
68     int data =0;
69     int nodata = word&0xf000;
70     int zero = 0;
71    
72     trkword thisword;
73    
74     switch (nodata>>12){
75    
76     case 0:
77    
78     thisword.decode = word;
79     thisword.type = 0;
80     // cout << thisword.decode << "\n";
81     return (thisword); //>>>>> ADC data (0)
82    
83     case 1:
84    
85     type = word&0xC00;
86     data = word&0x3ff;
87    
88     switch(type>>10){
89    
90     case 0:
91     thisword.decode = data;
92     thisword.type = 1; //>>> address (1)
93     return (thisword);
94    
95     case 2:
96     // if(data>=4)data = data-3;
97     if(data>6){
98     printf("Error on data \n");
99     thisword.decode = zero;
100     thisword.type = -1;
101     return (thisword); //>>>>> error (-1)
102     }
103     thisword.decode = data;
104     thisword.type = 2;
105     return (thisword); //>>> end-of-ladder
106    
107     default:
108     printf("Error on data \n");
109     thisword.decode = zero;
110     thisword.type = -1;
111     return (thisword); //>>>>> error (-1)
112    
113     }
114    
115     default:
116    
117     printf("Error on data \n");
118     thisword.decode = zero;
119     thisword.type = -1;
120     return (thisword); //>>>>> error (-1)
121     }
122     }
123    
124    
125 pam-fi 1.20 void FTrkScanQLook_EXPERT(TString file, TString outdir,Int_t event, Int_t va1, Int_t value, TString outfile)
126 pam-fi 1.1 {
127    
128     //
129     // obtain information about the data file and select the output file
130 pam-fi 1.5 Int_t dwpos = file.Last('/');
131     Int_t dwpos1 = file.Last('.');
132 pam-fi 1.1 TString base,ffile ;
133 pam-fi 1.5 ffile=file(dwpos+1,dwpos1-(dwpos+1));
134     if(dwpos>0) base=file(0,dwpos);
135 pam-fi 1.1
136     TString out;
137     if(outdir.Length()==0){
138     out = base;
139     }else{
140     out = outdir;
141     }
142 pam-fi 1.5 if(out.Last('/')+1<out.Length()) out+="/";
143 pam-fi 1.1
144     pamela::tracker::TrackerEvent *trk=0;
145 pam-fi 1.3 pamela::EventHeader *eh=0,*eH=0;
146     pamela::PscuHeader *ph=0,*pH=0;
147     pamela::RunHeaderEvent *reh=0;
148 pam-fi 1.22 pamela::CalibTrk1Event *trk1 = 0;
149     pamela::CalibTrk2Event *trk2 = 0;
150 pam-fi 1.18 pamela::EventCounter *cod=0;
151 pam-fi 1.1
152 pam-fi 1.18 pamela::PacketType *pctp=0;
153 pam-fi 1.1 // open files
154     TFile *trackerFile = new TFile(file);
155     if ( !trackerFile ){
156     trackerFile->Close();
157     printf("No tracker file! \n");
158     return;
159     }
160    
161     //Takes the tree and branches
162 pam-fi 1.3 TTree *tr = (TTree*)trackerFile->Get("Physics");
163     tr->SetBranchAddress("Tracker",&trk);
164     tr->SetBranchAddress("Header",&eh);
165    
166     TTree *otr = (TTree*)trackerFile->Get("RunHeader");
167     otr->SetBranchAddress("Header",&eH);
168     otr->SetBranchAddress("RunHeader",&reh);
169 pam-fi 1.1
170 pam-fi 1.22 TTree *otr1 = (TTree*)trackerFile->Get("CalibTrk1");
171     otr1->SetBranchAddress("CalibTrk1", &trk1);
172     TTree *otr2 = (TTree*)trackerFile->Get("CalibTrk2");
173     otr2->SetBranchAddress("CalibTrk2", &trk2);
174    
175 pam-fi 1.1 // Define variables
176 pam-fi 1.3 Int_t nevents = tr->GetEntries();
177     Int_t neventH = otr->GetEntries();
178 pam-fi 1.22 Int_t cevents=0;
179    
180     if(otr1->GetEntries()==otr2->GetEntries())
181     cevents = otr1->GetEntries();
182     else printf("\nWARNING: CalibTrk1 entries is different from CalibTrk2 entries\n\n");
183    
184    
185 pam-fi 1.1 if ( nevents <= 0 ) {
186     trackerFile->Close();
187     printf("The file is empty, exiting...\n");
188     return;
189     }
190    
191 pam-fi 1.20 //
192     // open the output text files for the alarms
193     TString fname = out+ffile;
194     int slen=fname.Length();
195     int last=fname.Last('_');
196     if(last<(slen-1))fname.Append('_');
197     fname.Append("FTrk-DSP-values.dat");
198     ofstream values(fname,ios::out);
199    
200     //
201 pam-fi 1.1 printf("\n Number of Entries: %d\n",nevents);
202 pam-fi 1.3 printf(" Number of Header Entries: %d\n",neventH);
203 pam-fi 1.22 printf(" Number of Calibration: %d\n",cevents);
204 pam-fi 1.1
205 pam-fi 1.3 Long64_t obt=0;
206 pam-fi 1.22 Int_t eve,cin=0,cins=0;
207 pam-fi 1.7 TString cal="";
208 pam-fi 1.22
209 pam-fi 1.19 eve=3;
210 pam-fi 1.3 for(Int_t i=0;i<neventH;i++){
211     otr->GetEntry(i);
212     pH = eH->GetPscuHeader();
213     if(reh->TRK_CALIB_USED!=104){
214     obt = pH->GetOrbitalTime();
215 pam-fi 1.7 cal="Event with online calibration";
216 pam-fi 1.3 break;
217     }
218     if(i==neventH-1){
219 pam-fi 1.7 cal="***** ONLINE CALIBRATION NOT FOUND IN THIS FILE *****";
220 pam-fi 1.19 eve=2;
221 pam-fi 1.3 }
222     }
223    
224 pam-fi 1.22 int tot=2,totvalues=0,TOT=0,totsum=0;
225 pam-fi 1.19 if(event<0) tot=abs(event);
226 pam-fi 1.22 if(value>0) totvalues=value/10;
227    
228 pam-fi 1.20 TOT= tot > totvalues ? tot : totvalues;
229 pam-fi 1.22 if(value>0) totsum= (value/10) > 100 ? (value/10) : 100;
230     else totsum=100;
231    
232     Int_t calev=cevents;
233 pam-fi 1.19
234     TH1F *histomax[12][tot]; //histos of max signals
235     TH1F *histocomp[12][tot]; //histos of compressed data
236     TH1F *histofull[12][tot]; //histos of full data
237 pam-fi 1.22 TCanvas *c1[tot],*csum[calev];
238     TH1F *histova[tot];
239     TGraph*sum[12][calev][totsum/2];
240 pam-fi 1.19 TCanvas *cva[tot];
241    
242 pam-fi 1.22 TPad *trkpad[12]; //pad for histos
243    
244     stringstream fromfile,title,hid,message;
245     TString figsa="",figsav="",figsava="";
246     Int_t canvasx=1200;
247     Int_t canvasy=900;
248 pam-fi 1.19
249     TLatex *t=new TLatex();
250     t->SetTextFont(32);
251     t->SetTextColor(1);
252     t->SetTextAlign(12);
253     t->SetTextSize(0.02);
254 pam-fi 1.3
255 pam-fi 1.22 gStyle->SetLabelSize(0.06,"x");
256     gStyle->SetLabelSize(0.06,"y");
257     gStyle->SetTitleFontSize(0.1);
258     gStyle->SetFillColor(10);
259     gStyle->SetTitleFillColor(10);
260     gStyle->SetOptStat(0);
261    
262     Int_t p[12],psum=0;
263     Int_t whistostrip[3072];
264     for(int s=0;s<3072;s++) whistostrip[s]=s+1;
265    
266     if(eve==3){
267     for(Int_t i=0;i<nevents;i++){
268     tr->GetEntry(i);
269     ph = eh->GetPscuHeader();
270     if(reh->TRK_CALIB_USED==104) continue;
271     cod = eh->GetCounter();
272     if(value%10!=0){
273     if(i==0) cin=cod->Get(pctp->CalibTrk1)+((value%10)-1);
274     if(cod->Get(pctp->CalibTrk1)==cin+1){
275     eve=i+3;
276     cin=100;
277     }
278     }
279     else {
280     if(i==0) cin=cod->Get(pctp->CalibTrk1);
281     if(event<0 && cod->Get(pctp->CalibTrk1)==cin+1){
282     eve=i+3;
283     cin=100;
284     }
285     else if(event>=0 && ph->GetOrbitalTime()>obt && obt>0){
286     eve=i+3;
287     obt=-1;
288     }
289     }
290     if(i==0) cins=cod->Get(pctp->CalibTrk1);
291     if(cod->Get(pctp->CalibTrk1)==cins+1){
292     psum=1;
293     cins=cod->Get(pctp->CalibTrk1);
294     }
295     if(psum==1){
296     figsa=out+ffile+"_FTrkScanQLook_EXPERT_sumof";
297     figsa+=totsum;
298     figsa+="events_cal";
299     figsa+=cins;
300     csum[cins-1] = new TCanvas(figsa.Data(),"FTrkQLookSCAN",canvasx,canvasy);
301     csum[cins-1]->SetFillColor(10);
302     csum[cins-1]->Range(0,0,1,1);
303     fromfile.str("");
304     fromfile<<"FTrkScanQLook_EXPERT File: "<<ffile<<" ----> Sum of "<<totsum<<" events after the "<<cins<<" calibration ";
305     t->SetTextSize(0.02);
306     t->DrawLatex(0.02,0.98,fromfile.str().c_str());
307    
308     // draw pads
309     Double_t posy = 0.95; // up y-coord - top pads
310     Double_t hpad = 0.15; // pad height
311     Double_t posx1=0; // left x-coord - pad column
312     Double_t posx0=0; // x-coord - column division
313     Double_t wrel = 0.6; // relative x size of first sub-column
314     Double_t marg = 0.004; // margin among pads
315    
316     hpad = (posy-marg*11)/6;
317     wrel = (1-marg*4)/2;
318     for(Int_t n = 0; n<12; n++){
319     if ( (n+1)%2 ) {
320     if(n>1)posy = posy-(marg*2+hpad);
321     posx1 = marg;
322     posx0 = posx1 + wrel;
323     } else {
324     posx1 = posx0 + 2*marg;
325     posx0 = posx1 + wrel;
326     };
327    
328     /* -----------> pad for histograms */
329     trkpad[n] = new TPad("pad"," ",posx1,posy-hpad,posx0,posy,18,0,0);
330     trkpad[n]->SetFillColor(19);
331     trkpad[n]->SetFrameFillColor(10);
332    
333     p[n]=0;
334     }
335     }
336     if(psum>0 && psum<=totsum){
337     // = = = = = = = = = = = = = = = = = = = = = = = = =
338     // create header dump retrieving event info
339     // = = = = = = = = = = = = = = = = = = = = = = = = =
340     Int_t ndsp=0;
341    
342     Int_t whistomax[3072];
343     Int_t whisto[3072];
344     Int_t whistocomp[3072];
345     Int_t whistofull[3072];
346    
347     // // transmitted words
348     Int_t word = 0;
349     Int_t iword = 0;
350     Int_t ii=0,ifull[12],icomp[12],imax[12],nn=0;
351     trkword thisword;
352    
353     Int_t address,ladder;
354    
355    
356     for(Int_t n = 0; n<12; n++){
357     ndsp = trk->DSPnumber[n];
358     nn = ndsp-1;
359     ifull[nn]=0;
360     icomp[nn]=0;
361     imax[nn]=0;
362    
363     for(Int_t vi = 0; vi< 3072; vi++){
364     whistomax[vi] = -200;
365     whistocomp[vi] = -200;
366     whistofull[vi] = -200;
367     whisto[vi] = -200;
368     }
369    
370     // // trasmitted data
371     //
372     address = 0;
373     ladder = 1;
374     for(Int_t vi = 0; vi < trk->DATAlength[n] ; vi++){
375     word = trk->TrackerData.At(iword);
376     thisword = datadecode(word);
377     iword++;
378     switch (thisword.type){
379    
380     case 0: //ADC value
381     whisto[address] = thisword.decode;
382     address++;
383     // cout << " adr " << address << "\n";
384     break;
385    
386     case 1: //address
387     address = 1024*(ladder-1) + thisword.decode;
388     // cout << " adr " << address << "\n";
389     break;
390    
391     case 2: //end-of-ladder
392     ladder = thisword.decode;
393     // cout << "Ladder " << ladder << "\n";
394     if(ladder==3){
395     // end of compressed data - FILL HISTO
396     //cout << ">>> COMPRESSED data" << "\n";
397     for(ii = 0; ii < 3072; ii++){
398     whistocomp[ii]=whisto[ii];
399     whisto[ii] = -200;
400     }
401     address = 0;
402     ladder = 1;
403     }else if(ladder==6){
404     // end of full data - FILL HISTO
405     //cout << ">>> FULL data" << "\n";
406     for(ii = 0; ii < 3072; ii++){
407     whistofull[ii]=whisto[ii];
408     whisto[ii] = -200;
409     }
410     address = 0;
411     ladder = 1;
412     }else{
413     if(ladder>3) ladder=ladder-3;
414     address= ladder*1024;
415     ladder = ladder + 1;
416     }
417     }
418     }
419    
420     for(Int_t vi = 0; vi < 3072; vi++){
421     if(whistofull[vi]>-200){
422     if(vi==3071){
423     sum[nn][cins-1][p[nn]] = new TGraph(3072,whistostrip,whistofull);
424     p[nn]++;
425     }
426     if(value%10==0 && value>0){
427     if(whistofull[vi]>0){
428     if(vi==0) values << (short int)ndsp << " ";
429     values <<(short int) whistofull[vi] <<" ";
430     if(vi==3071) values << endl;
431     }
432     }
433     }
434     }
435     }
436     psum++;
437     if(value%10==0 && value>0) values << (short int)0 << endl << endl;
438     }
439     if(psum==totsum+1){
440     if(value%10==0 && value>0) values << (short int)(-cins) << endl << endl;
441     psum=0;
442     for(Int_t vi = 0; vi < 12; vi++){
443     TLine li,liva1;
444     li.SetLineColor(38);
445     li.SetLineStyle(4);
446     li.SetLineWidth(2);
447     liva1.SetLineColor(42);
448     liva1.SetLineStyle(3);
449     liva1.SetLineWidth(1);
450    
451     Float_t va1x=0;
452     csum[cins-1]->cd();
453     trkpad[vi]->Draw();
454     trkpad[vi]->cd();
455     trkpad[vi]->SetFillColor(10);
456    
457     stringstream tit,hid;
458     tit.str("");
459     hid.str("");
460     tit<<"DSP "<<vi+1;
461     sum[vi][cins-1][0]->SetTitle(tit.str().c_str());
462     sum[vi][cins-1][0]->GetXaxis()->SetTitle("channel id");
463     sum[vi][cins-1][0]->GetXaxis()->CenterTitle();
464     sum[vi][cins-1][0]->GetXaxis()->SetRangeUser(0,3073);
465     sum[vi][cins-1][0]->GetXaxis()->SetTitleSize(0.06);
466     sum[vi][cins-1][0]->GetXaxis()->SetTitleOffset(0.8);
467     sum[vi][cins-1][0]->GetYaxis()->SetTitle("ADC value");
468     sum[vi][cins-1][0]->GetYaxis()->SetTitleSize(0.09);
469     sum[vi][cins-1][0]->GetYaxis()->SetTitleOffset(0.4);
470     sum[vi][cins-1][0]->GetYaxis()->CenterTitle();
471     sum[vi][cins-1][0]->GetYaxis()->SetRangeUser(0,4500);
472     sum[vi][cins-1][0]->SetMarkerStyle(20);
473     sum[vi][cins-1][0]->SetMarkerSize(0.1);
474     sum[vi][cins-1][0]->SetMarkerColor(4);
475     sum[vi][cins-1][0]->Draw("ap");
476     hid<<p[vi]<<" events";
477     t->SetTextSize(0.11);
478     t->DrawLatex(2400,4250,hid.str().c_str());
479     for(int pi=1; pi<p[vi];pi++){
480     sum[vi][cins-1][pi]->SetMarkerStyle(21);
481     sum[vi][cins-1][pi]->SetMarkerSize(0.1);
482     sum[vi][cins-1][pi]->SetMarkerColor(4);
483     sum[vi][cins-1][pi]->Draw("p");
484     }
485     for(int va=1; va<24; va++){
486     va1x=128*va;
487     liva1.DrawLine(va1x,0.,va1x,4500.);
488     }
489     li.DrawLine(1024.5,0.,1024.5,4500.);
490     li.DrawLine(2048.5,0.,2048.5,4500.);
491     csum[cins-1]->Update();
492     hid.str("");
493     }
494     if(strcmp(outfile.Data(),"ps") && strcmp(outfile.Data(),"pdf")){
495     figsa+="."+outfile;
496     csum[cins-1]->Print(figsa.Data());
497     }
498     }
499    
500     }
501     }
502    
503     if(!strcmp(outfile.Data(),"ps") || !strcmp(outfile.Data(),"pdf")){
504     stringstream nom1,nom2,nom3;
505     nom1<<out<<ffile<<"_FTrkScanQLook_EXPERT_sumof"<<totsum<<"event.ps(";
506     nom2<<out<<ffile<<"_FTrkScanQLook_EXPERT_sumof"<<totsum<<"event.ps";
507     nom3<<out<<ffile<<"_FTrkScanQLook_EXPERT_sumof"<<totsum<<"event.ps)";
508    
509     for(int va=0; va<cevents; va++){
510     if(cevents==1) csum[va]->Print(nom2.str().c_str(),"Landscape");
511     if(cevents>2){
512     if(va==0) csum[va]->Print(nom1.str().c_str(),"Landscape");
513     if(va>0 && va<cevents-1) csum[va]->Print(nom2.str().c_str(),"Landscape");
514     if(va>0 && va==cevents-1) csum[va]->Print(nom3.str().c_str(),"Landscape");
515     }
516     }
517     }
518     //
519     // Convert ps to pdf if required
520     if(!strcmp(outfile.Data(),"pdf")){
521     stringstream com;
522     com<<"ps2pdf13 "<<out<<ffile<<"_FTrkScanQLook_EXPERT_sumof"<<totsum<<"event.ps "<<out<<ffile<<"_FTrkScanQLook_EXPERT_sumof"<<totsum<<"event.pdf";
523     system(com.str().c_str());
524     printf("\n---> ps file converted in pdf format!\n");
525     com.str("");
526     com<<"rm -f "<<out<<ffile<<"_FTrkScanQLook_EXPERT_sumof"<<totsum<<"event.ps ";
527     system(com.str().c_str());
528     printf("---> ps file removed!\n\n");
529     com.str("");
530     }
531    
532    
533 pam-fi 1.3
534 pam-fi 1.20 for(Int_t e=0;e<TOT;e++){
535 pam-fi 1.22 if(event<=0 || (value%10!=0 && e==0))
536 pam-fi 1.19 event=eve;
537 pam-fi 1.15 else {
538 pam-fi 1.20 event=event+1;
539 pam-fi 1.19 if(event>eve-3 && eve>2)
540 pam-fi 1.15 cal="Event with online calibration";
541     else
542     cal="***** ONLINE CALIBRATION NOT FOUND IN THIS FILE *****";
543     }
544 pam-fi 1.7 printf("Scan of Entry %d\n",event);
545 pam-fi 1.1
546 pam-fi 1.7 tr->GetEntry(event);
547 pam-fi 1.3 //============================================================================
548    
549 pam-fi 1.22 // draw display area
550    
551     TPad *trkpad[12],*pad=0; //pad for histos
552     TPaveText *trkpadtext[12]; //pad for header
553     Int_t ndsp=0;
554    
555     if((tot<TOT && e<tot) || tot==TOT){
556 pam-fi 1.20 figsav=out+ffile+"_FTrkScanQLook_EXPERT_ev";
557     figsav+=event+1;
558     c1[e] = new TCanvas(figsav.Data(),"FTrkQLookSCAN",canvasx,canvasy);
559     c1[e]->SetFillColor(10);
560     c1[e]->Range(0,0,1,1);
561 pam-fi 1.19 fromfile.str("");
562 pam-fi 1.20 fromfile<<"FTrkScanQLook_EXPERT File: "<<ffile<<" ----> Entry "<<event;
563 pam-fi 1.22 t->SetTextSize(0.02);
564 pam-fi 1.19 t->DrawLatex(0.02,0.98,fromfile.str().c_str());
565 pam-fi 1.20 t->DrawLatex(0.60,0.98,cal.Data());
566 pam-fi 1.19
567 pam-fi 1.20 if(va1!=0){
568     figsava=out+ffile+"_FTrkScanQLook_EXPERT_ev";
569     figsava+=event+1;
570     figsava+="_DSP";
571     figsava+=(int)(va1/100);
572     figsava+="_VA1-";
573     figsava+=va1%100;
574     cva[e] = new TCanvas(figsava.Data(),"TrkQLookSCAN VA1",canvasx,canvasy);
575     cva[e]->SetFillColor(10);
576     cva[e]->Range(0,0,1,1);
577     fromfile.str("");
578     fromfile<<"FTrkScanQLook_EXPERT File: "<<ffile<<" ----> Entry "<<event<<" --> DSP "<<(int)(va1/100)<<" --> va1 "<<va1%100;
579     t->DrawLatex(0.02,0.98,fromfile.str().c_str());
580     // t->DrawLatex(0.65,0.98,cal.Data());
581     }
582 pam-fi 1.3
583 pam-fi 1.20 // draw pads
584     Double_t posy = 0.95; // up y-coord - top pads
585     Double_t hpad = 0.15; // pad height
586     Double_t posx1=0; // left x-coord - pad column
587     Double_t posx2=0; // right x-coord - pad olumn
588     Double_t posx0=0; // x-coord - column division
589     Double_t wrel = 0.6; // relative x size of first sub-column
590     Double_t marg = 0.004; // margin among pads
591    
592     for(Int_t n = 0; n<12; n++){
593     if ( (n+1)%2 ) {
594     if(n>1)posy = posy-(marg*2+hpad);
595     posx1 = marg;
596     posx2 = 0.5 - marg;
597     posx0 = 0.5*wrel;
598     } else {
599     posx1 = posx1 + 0.5;
600     posx2 = posx2 + 0.5;
601     posx0 = posx0 + 0.5;
602     };
603    
604     /* -----------> pad for histograms */
605     trkpad[n] = new TPad("pad"," ",posx1,posy-hpad,posx0-marg,posy,18,0,0);
606     trkpad[n]->SetFillColor(19);
607     trkpad[n]->SetFrameFillColor(10);
608     /* -----------> pad for header dump */
609     trkpadtext[n] = new TPaveText((posx0+marg),(posy-hpad),posx2,posy);
610     /* -----------> HISTOGRAMS */
611 pam-fi 1.22
612     title.str("");
613 pam-fi 1.20 title<<"DSP "<<n+1;
614     hid<<"h"<<n+e*100;
615     histomax[n][e] = new TH1F(hid.str().c_str(),title.str().c_str(),3073,-0.5,3072.5);
616     hid<<"hh"<<n+e*100;
617     histocomp[n][e] = new TH1F(hid.str().c_str(),title.str().c_str(),3073,-0.5,3072.5);
618     hid<<"hhh"<<n+e*100;
619     histofull[n][e] = new TH1F(hid.str().c_str(),title.str().c_str(),3073,-0.5,3072.5);
620     title.str("");
621     hid.str("");
622     }
623     if(va1!=0){
624     title.str("");
625     title<<"DSP "<<(int)(va1/100)<<" -- va1 "<<va1%100;
626     hid<<"va"<<e;
627     histova[e] = new TH1F(hid.str().c_str(),title.str().c_str(),130,0,129);
628     } //end loop on views
629 pam-fi 1.1
630 pam-fi 1.3 /* -----------> pad for histograms */
631 pam-fi 1.20 pad = new TPad("padva"," ",0,0,1,0.97,18,0,0);
632     pad->SetFillColor(19);
633     pad->SetFrameFillColor(10);
634 pam-fi 1.22 }
635 pam-fi 1.3 // = = = = = = = = = = = = = = = = = = = = = = = = =
636     // create header dump retrieving event info
637     // = = = = = = = = = = = = = = = = = = = = = = = = =
638 pam-fi 1.22
639 pam-fi 1.3
640     Double_t whistomax[3072];
641     Double_t whisto[3072];
642     Double_t whistocomp[3072];
643     Double_t whistofull[3072];
644    
645     //=============================================
646     // transmitted words
647     Int_t word = 0;
648     Int_t iword = 0;
649     Int_t TOTDATAlength_check = 0;
650     Int_t ii=0,ifull[12],icomp[12],imax[12],nn=0;
651     trkword thisword;
652 pam-fi 1.1
653 pam-fi 1.3 Int_t address,ladder;
654 pam-fi 1.20
655    
656 pam-fi 1.3 for(Int_t n = 0; n<12; n++){
657 pam-fi 1.1
658 pam-fi 1.3 ndsp = trk->DSPnumber[n];
659     nn = ndsp-1;
660     ifull[nn]=0;
661     icomp[nn]=0;
662     imax[nn]=0;
663 pam-fi 1.12 if(ndsp>0){
664     if(ndsp<13){
665 pam-fi 1.20 if((tot<TOT && e<tot) || tot==TOT){
666 pam-fi 1.1
667 pam-fi 1.20 /*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*
668     *
669     * Write event LEVEL0 report
670     *
671     *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*/
672    
673     trkpadtext[nn]->SetTextFont(40);
674     trkpadtext[nn]->SetFillColor(33);
675     trkpadtext[nn]->SetTextSize(0.012);
676     trkpadtext[nn]->SetTextAlign(13);
677    
678     trkpadtext[nn]->AddText(" ");
679     message<<"DAQ mode --------> "<<trk->DAQmode[n];
680     trkpadtext[nn]->AddText(message.str().c_str());
681     message.str("");
682     message<<"Event number --------> "<<trk->eventn[n];
683     trkpadtext[nn]->AddText(message.str().c_str());
684     message.str("");
685     message<<"13-bit words --------> "<<trk->DATAlength[n];
686     trkpadtext[nn]->AddText(message.str().c_str());
687     message.str("");
688     if (!(nn%2)&&trk->signcluster[n][0]!=0) message<<"L1 add: "<<trk->addrcluster[n][0]<<" - sign: "<<1024-(trk->signcluster[n][0]);
689     else message<<"L1 add: "<<trk->addrcluster[n][0]<<" - sign: "<<(trk->signcluster[n][0]);
690     trkpadtext[nn]->AddText(message.str().c_str());
691     message.str("");
692     if (!(nn%2)&&trk->signcluster[n][1]!=0) message<<"L2 add: "<<trk->addrcluster[n][1]<<" - sign: "<<1024-(trk->signcluster[n][1]);
693     else message<<"L2 add: "<<trk->addrcluster[n][1]<<" - sign: "<<trk->signcluster[n][1];
694     trkpadtext[nn]->AddText(message.str().c_str());
695     message.str("");
696     if (!(nn%2)&&trk->signcluster[n][2]!=0) message<<"L3 add: "<<trk->addrcluster[n][2]<<" - sign: "<<1024-(trk->signcluster[n][2]);
697     else message<<"L3 add: "<<trk->addrcluster[n][2]<<" - sign: "<<trk->signcluster[n][2];
698     trkpadtext[nn]->AddText(message.str().c_str());
699     message.str("");
700     message<<"NCLUST "<<trk->nclust[n]<<" CUTC "<<trk->cutc[n]<<" CUTCL "<<trk->cutcl[n];
701     trkpadtext[nn]->AddText(message.str().c_str());
702     message.str("");
703     message<<"Comp. time "<<trk->compressiontime[n]<<" x 0.051ms = "<<0.051*trk->compressiontime[n]<<" ms";
704     trkpadtext[nn]->AddText(message.str().c_str());
705     message.str("");
706     trkpadtext[nn]->AddText(" ");
707     message<<"CRC --> "<<trk->crc[n];
708     trkpadtext[nn]->AddText(message.str().c_str());
709     message.str("");
710     message<<"FL1-6 --> "<<trk->fl1[n]<<" "<<trk->fl2[n]<<" "<<trk->fl3[n]<<" "<<trk->fl4[n]<<" "<<trk->fl5[n]<<" "<<trk->fl6[n]<<" FC "<<trk->fc[n];
711     trkpadtext[nn]->AddText(message.str().c_str());
712     message.str("");
713     trkpadtext[nn]->AddText(" ");
714     trkpadtext[nn]->AddLine(0,0,0,0);
715     message<<"PNum "<<trk->pnum[n]<<" - BId "<<trk->bid[n]<<" ALARM "<<trk->alarm[n];
716     trkpadtext[nn]->AddText(message.str().c_str());
717     message.str("");
718     message<<"Cmd "<<trk->cmdnum[n]<<" --- Answer length "<<trk->aswr[n]<<" byte";
719     trkpadtext[nn]->AddText(message.str().c_str());
720     message.str("");
721     trkpadtext[nn]->AddText(" ");
722 pam-fi 1.1
723 pam-fi 1.20 TOTDATAlength_check = TOTDATAlength_check + trk->DATAlength[n];
724     }
725 pam-fi 1.12 /*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*
726     *
727     * Plot event LEVEL0 histo
728     *
729     *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*/
730    
731     //=============================================
732 pam-fi 1.20 }
733     for(Int_t i = 0; i< 3072; i++){
734     whistomax[i] = -200;
735     whistocomp[i] = -200;
736     whistofull[i] = -200;
737     whisto[i] = -200;
738     }
739 pam-fi 1.12
740 pam-fi 1.20 // ===============
741     // trasmitted data
742     // ===============
743    
744     address = 0;
745     ladder = 1;
746     for(Int_t i = 0; i < trk->DATAlength[n] ; i++){
747     word = trk->TrackerData.At(iword);
748     thisword = datadecode(word);
749     iword++;
750     switch (thisword.type){
751 pam-fi 1.1
752 pam-fi 1.20 case 0: //ADC value
753     whisto[address] = thisword.decode;
754     address++;
755     // cout << " adr " << address << "\n";
756     break;
757    
758     case 1: //address
759     address = 1024*(ladder-1) + thisword.decode;
760     // cout << " adr " << address << "\n";
761     break;
762    
763     case 2: //end-of-ladder
764     ladder = thisword.decode;
765     // cout << "Ladder " << ladder << "\n";
766     if(ladder==3){
767     // end of compressed data - FILL HISTO
768     //cout << ">>> COMPRESSED data" << "\n";
769     for(ii = 0; ii < 3072; ii++){
770     whistocomp[ii]=whisto[ii];
771     whisto[ii] = -200;
772 pam-fi 1.12 }
773 pam-fi 1.20 address = 0;
774     ladder = 1;
775     }else if(ladder==6){
776     // end of full data - FILL HISTO
777     //cout << ">>> FULL data" << "\n";
778     for(ii = 0; ii < 3072; ii++){
779     whistofull[ii]=whisto[ii];
780     whisto[ii] = -200;
781     }
782     address = 0;
783     ladder = 1;
784     }else{
785     if(ladder>3) ladder=ladder-3;
786     address= ladder*1024;
787     ladder = ladder + 1;
788     }
789 pam-fi 1.12 }
790 pam-fi 1.20 }
791 pam-fi 1.1
792    
793 pam-fi 1.20 // ===============
794     // maximum signals
795     // ===============
796     if(trk->signcluster[nn][0]!=0) whistomax[ 0+(int)trk->addrcluster[nn][0]] = whistocomp[ 0+(int)trk->addrcluster[nn][0]];
797     if(trk->signcluster[nn][1]!=0) whistomax[1024+(int)trk->addrcluster[nn][1]] = whistocomp[1024+(int)trk->addrcluster[nn][1]];
798     if(trk->signcluster[nn][2]!=0) whistomax[2048+(int)trk->addrcluster[nn][2]] = whistocomp[2048+(int)trk->addrcluster[nn][2]];
799    
800     for(Int_t i = 0; i < 3072; i++){
801     if(whistomax[i]>-200) imax[nn]=1;
802     if(whistocomp[i]>-200) icomp[nn]=1;
803     if(whistofull[i]>-200) ifull[nn]=1;
804 pam-fi 1.22 if(value%10!=0){
805     if((totvalues<TOT && e<totvalues) || totvalues==TOT){
806     if(whistofull[i]>0){
807     if(i==0) values << (short int)ndsp << " ";
808     values <<(short int) whistofull[i] <<" ";
809     if(i==3071) values << endl;
810     }
811 pam-fi 1.20 }
812     }
813     if((tot<TOT && e<tot) || tot==TOT){
814 pam-fi 1.12 histomax[nn][e]->Fill((Float_t)i,whistomax[i]);
815     histocomp[nn][e]->Fill((Float_t)i,whistocomp[i]);
816     histofull[nn][e]->Fill((Float_t)i,whistofull[i]);
817 pam-fi 1.19 if(va1!=0 && ndsp==(int)(va1/100) && i>=128*((va1%100)-1)){
818     if(i<128*(va1%100))
819     histova[e]->Fill((Float_t)(i-128*((va1%100)-1)+1),whistofull[i]);
820     }
821 pam-fi 1.12 }
822 pam-fi 1.20 }
823 pam-fi 1.2
824 pam-fi 1.20 if((tot<TOT && e<tot) || tot==TOT){
825 pam-fi 1.12 TBox b;
826 pam-fi 1.19 TLine li,liva1;
827     li.SetLineColor(38);
828     li.SetLineStyle(4);
829     li.SetLineWidth(2);
830     liva1.SetLineColor(42);
831     liva1.SetLineStyle(3);
832     liva1.SetLineWidth(1);
833    
834     Float_t va1x=0;
835    
836     if(va1!=0){
837     cva[e]->cd();
838     pad->Draw();
839     pad->cd();
840     pad->SetFillColor(10);
841     histova[e]->SetTitleSize(0.01);
842     histova[e]->GetYaxis()->SetRangeUser(1500,4500);
843     histova[e]->SetLineColor(40);
844     histova[e]->SetFillColor(40);
845     histova[e]->SetLineWidth(1);
846     histova[e]->SetLineStyle(2);
847     // histova[e]->GetYaxis()->SetLabelSize(0.03);
848     histova[e]->Draw("");
849     cva[e]->Update();
850     }
851 pam-fi 1.3
852 pam-fi 1.12 c1[e]->cd();
853     trkpadtext[nn]->Draw();
854     trkpad[nn]->Draw();
855     trkpad[nn]->cd();
856     trkpad[nn]->SetFillColor(10);
857    
858 pam-fi 1.19 histocomp[nn][e]->SetTitleSize(0.1);
859 pam-fi 1.12 histocomp[nn][e]->GetYaxis()->SetRangeUser(-500,4500);
860     histocomp[nn][e]->SetLineStyle(1);
861     histocomp[nn][e]->SetLineColor(38);
862     histocomp[nn][e]->SetFillColor(38);
863     histocomp[nn][e]->SetLineWidth(1);
864     histocomp[nn][e]->Draw("");
865    
866     histofull[nn][e]->SetLineColor(40);
867     histofull[nn][e]->SetFillColor(40);
868     histofull[nn][e]->SetLineWidth(1);
869     histofull[nn][e]->SetLineStyle(2);
870    
871     histomax[nn][e]->SetLineColor(2);
872     histomax[nn][e]->SetLineWidth(1);
873     histomax[nn][e]->SetLineStyle(3);
874    
875     if(ifull[nn]==1) histofull[nn][e]->Draw("9bsame][");
876     if(icomp[nn]==1) histocomp[nn][e]->Draw("9bsame][");
877     if(imax[nn]==1) histomax[nn][e]->Draw("same][");
878     histocomp[nn][e]->Draw("axis same");
879 pam-fi 1.15 if(nn==0){
880     b.SetFillColor(107);
881     b.SetFillStyle(3945);
882     b.DrawBox(768.,-500.,2047.,4500.);
883     }
884     else if(nn==1){
885 pam-fi 1.12 b.SetFillColor(6);
886     b.SetFillStyle(3945);
887     b.DrawBox(2944.,-500.,3060.,4500.);
888 pam-fi 1.8
889 pam-fi 1.12 b.SetFillColor(107);
890     b.SetFillStyle(3954);
891 pam-fi 1.22 b.DrawBox(384.,-500.,512.,4500.);
892 pam-fi 1.12 b.DrawBox(2816.,-500.,2944.,4500.);
893     b.DrawBox(2048.,-500.,2176.,4500.);
894     }
895     else if(nn==4){
896     b.SetFillColor(107);
897     b.SetFillStyle(3954);
898     b.DrawBox(384.,-500.,512.,4500.);
899     }
900     else if(nn==6){
901     b.SetFillColor(6);
902     b.SetFillStyle(3945);
903     b.DrawBox(2560.,-500.,2816.,4500.);
904 pam-fi 1.22 b.DrawBox(1024.,-500.,1280.,4500.);
905 pam-fi 1.8
906 pam-fi 1.12 b.SetFillColor(107);
907     b.SetFillStyle(3954);
908     b.DrawBox(512.,-500.,768.,4500.);
909 pam-fi 1.22 b.DrawBox(1280.,-500.,1792.,4500.);
910 pam-fi 1.12 }
911     else if(nn==7){
912     b.SetFillColor(107);
913     b.SetFillStyle(3954);
914     b.DrawBox(512.,-500.,768.,4500.);
915     }
916 pam-fi 1.16 else if(nn==8){
917     b.SetFillColor(107);
918     b.SetFillStyle(3954);
919 pam-fi 1.17 b.DrawBox(512.,-500.,768.,4500.);
920 pam-fi 1.16 }
921 pam-fi 1.13 else if(nn==9){
922     b.SetFillColor(107);
923     b.SetFillStyle(3954);
924 pam-fi 1.17 b.DrawBox(256.,-500.,384.,4500.);
925 pam-fi 1.22 b.DrawBox(1280.,-500.,1535.,4500.);
926     b.DrawBox(1792.,-500.,1920.,4500.);
927 pam-fi 1.17 }
928     else if(nn==10){
929     b.SetFillColor(107);
930     b.SetFillStyle(3954);
931 pam-fi 1.18 b.DrawBox(2048.,-500.,3070.,4500.);
932 pam-fi 1.13 }
933 pam-fi 1.12 else if(nn==11){
934     b.SetFillColor(6);
935     b.SetFillStyle(3945);
936     b.DrawBox(768.,-500.,1024.,4500.);
937 pam-fi 1.8
938 pam-fi 1.12 b.SetFillColor(107);
939     b.SetFillStyle(3954);
940 pam-fi 1.17 b.DrawBox(0.,-500.,512.,4500.);
941     b.DrawBox(1920.,-500.,2560.,4500.);
942 pam-fi 1.12 }
943 pam-fi 1.19 for(int va=1; va<24; va++){
944     va1x=128*va;
945     liva1.DrawLine(va1x,-500.,va1x,4500.);
946     }
947     li.DrawLine(1024.5,-500.,1024.5,4500.);
948     li.DrawLine(2048.5,-500.,2048.5,4500.);
949 pam-fi 1.12 c1[e]->Update();
950     }
951 pam-fi 1.20
952 pam-fi 1.3 }
953     }//end loop on views
954 pam-fi 1.19
955 pam-fi 1.20 if((tot<TOT && e<tot) || tot==TOT){
956     stringstream nom1,nom2,nom3;
957     nom1<<out<<ffile<<"_FTrkScanQLook_EXPERT.ps(";
958     nom2<<out<<ffile<<"_FTrkScanQLook_EXPERT.ps";
959     nom3<<out<<ffile<<"_FTrkScanQLook_EXPERT.ps)";
960    
961     if(!strcmp(outfile.Data(),"ps")||!strcmp(outfile.Data(),"pdf")){
962     if(e==0){
963 pam-fi 1.22 c1[e]->Print(nom1.str().c_str(),"Landscape");
964     if(va1!=0) cva[e]->Print(nom2.str().c_str(),"Landscape");
965 pam-fi 1.20 }
966     if(e>0 && tot>2){
967 pam-fi 1.22 c1[e]->Print(nom2.str().c_str(),"Landscape");
968     if(va1!=0) cva[e]->Print(nom2.str().c_str(),"Landscape");
969 pam-fi 1.20 }
970     if(e==tot-1){
971 pam-fi 1.22 c1[e]->Print(nom2.str().c_str(),"Landscape");
972     if(va1!=0) cva[e]->Print(nom3.str().c_str(),"Landscape");
973 pam-fi 1.20 }
974 pam-fi 1.19 }
975 pam-fi 1.20 else{
976     figsav+="."+outfile;
977     c1[e]->Print(figsav.Data());
978     if(va1!=0){
979     figsava+="."+outfile;
980     cva[e]->Print(figsava.Data());
981     }
982 pam-fi 1.19 }
983     }
984 pam-fi 1.22 if(value%10!=0){
985     if(totvalues==TOT || (totvalues<TOT && e<totvalues))
986     values << (short int)0 << endl << endl;
987     }
988 pam-fi 1.20 }
989     stringstream com;
990    
991     values.close();
992     if(value==0){
993     com<<"rm -f "<<fname;
994     system(com.str().c_str());
995 pam-fi 1.19 }
996     //
997     // Convert ps to pdf if required
998     if(!strcmp(outfile.Data(),"pdf")){
999     com<<"ps2pdf13 "<<out<<ffile<<"_FTrkScanQLook_EXPERT.ps "<<out<<ffile<<"_FTrkScanQLook_EXPERT.pdf";
1000     system(com.str().c_str());
1001     printf("\n---> ps file converted in pdf format!\n");
1002     com.str("");
1003     com<<"rm -f "<<out<<ffile<<"_FTrkScanQLook_EXPERT.ps ";
1004     system(com.str().c_str());
1005     printf("---> ps file removed!\n\n");
1006     com.str("");
1007 pam-fi 1.3 }
1008 pam-fi 1.20
1009 pam-fi 1.1 return;
1010     }

  ViewVC Help
Powered by ViewVC 1.1.23