/[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.24 - (hide annotations) (download)
Mon Feb 12 10:18:17 2007 UTC (17 years, 9 months ago) by pam-fi
Branch: MAIN
CVS Tags: v1r24, v1r25, v1r23
Changes since 1.23: +11 -4 lines
*** empty log message ***

1 pam-fi 1.1 /**
2     * FTrkScanQlook_EXPERT.cxx
3     *
4     * autor: D.Fedele
5 pam-fi 1.24 * version v2r03
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.23 Long64_t obt=0,hobt[neventH];
206     Int_t eve,cin=0,cins=0,br=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 pam-fi 1.23 hobt[i]= pH->GetOrbitalTime();
214     if(reh->TRK_CALIB_USED!=104 && br==0){
215 pam-fi 1.3 obt = pH->GetOrbitalTime();
216 pam-fi 1.7 cal="Event with online calibration";
217 pam-fi 1.23 br=1;
218 pam-fi 1.3 }
219 pam-fi 1.23 if(i==neventH-1 && br==0){
220 pam-fi 1.7 cal="***** ONLINE CALIBRATION NOT FOUND IN THIS FILE *****";
221 pam-fi 1.19 eve=2;
222 pam-fi 1.3 }
223     }
224    
225 pam-fi 1.22 int tot=2,totvalues=0,TOT=0,totsum=0;
226 pam-fi 1.19 if(event<0) tot=abs(event);
227 pam-fi 1.22 if(value>0) totvalues=value/10;
228    
229 pam-fi 1.20 TOT= tot > totvalues ? tot : totvalues;
230 pam-fi 1.22 if(value>0) totsum= (value/10) > 100 ? (value/10) : 100;
231     else totsum=100;
232    
233     Int_t calev=cevents;
234 pam-fi 1.19
235     TH1F *histomax[12][tot]; //histos of max signals
236     TH1F *histocomp[12][tot]; //histos of compressed data
237     TH1F *histofull[12][tot]; //histos of full data
238 pam-fi 1.22 TCanvas *c1[tot],*csum[calev];
239     TH1F *histova[tot];
240     TGraph*sum[12][calev][totsum/2];
241 pam-fi 1.19 TCanvas *cva[tot];
242    
243 pam-fi 1.22 TPad *trkpad[12]; //pad for histos
244    
245     stringstream fromfile,title,hid,message;
246     TString figsa="",figsav="",figsava="";
247     Int_t canvasx=1200;
248     Int_t canvasy=900;
249 pam-fi 1.19
250     TLatex *t=new TLatex();
251     t->SetTextFont(32);
252     t->SetTextColor(1);
253     t->SetTextAlign(12);
254     t->SetTextSize(0.02);
255 pam-fi 1.3
256 pam-fi 1.22 gStyle->SetLabelSize(0.06,"x");
257     gStyle->SetLabelSize(0.06,"y");
258     gStyle->SetTitleFontSize(0.1);
259     gStyle->SetFillColor(10);
260     gStyle->SetTitleFillColor(10);
261     gStyle->SetOptStat(0);
262    
263     Int_t p[12],psum=0;
264     Int_t whistostrip[3072];
265     for(int s=0;s<3072;s++) whistostrip[s]=s+1;
266    
267     if(eve==3){
268     for(Int_t i=0;i<nevents;i++){
269     tr->GetEntry(i);
270     ph = eh->GetPscuHeader();
271     if(reh->TRK_CALIB_USED==104) continue;
272     cod = eh->GetCounter();
273     if(value%10!=0){
274     if(i==0) cin=cod->Get(pctp->CalibTrk1)+((value%10)-1);
275     if(cod->Get(pctp->CalibTrk1)==cin+1){
276     eve=i+3;
277     cin=100;
278     }
279     }
280     else {
281     if(i==0) cin=cod->Get(pctp->CalibTrk1);
282     if(event<0 && cod->Get(pctp->CalibTrk1)==cin+1){
283     eve=i+3;
284     cin=100;
285     }
286     else if(event>=0 && ph->GetOrbitalTime()>obt && obt>0){
287     eve=i+3;
288     obt=-1;
289     }
290     }
291     if(i==0) cins=cod->Get(pctp->CalibTrk1);
292     if(cod->Get(pctp->CalibTrk1)==cins+1){
293     psum=1;
294     cins=cod->Get(pctp->CalibTrk1);
295     }
296     if(psum==1){
297     figsa=out+ffile+"_FTrkScanQLook_EXPERT_sumof";
298     figsa+=totsum;
299     figsa+="events_cal";
300     figsa+=cins;
301     csum[cins-1] = new TCanvas(figsa.Data(),"FTrkQLookSCAN",canvasx,canvasy);
302     csum[cins-1]->SetFillColor(10);
303     csum[cins-1]->Range(0,0,1,1);
304     fromfile.str("");
305 pam-fi 1.23 fromfile<<"FTrkScanQLook_EXPERT File: "<<ffile<<" ----> Sum of "<<totsum<<" events after the "<<cins<<" calibration at OBT= "<<hobt[(cod->Get(pctp->RunHeader))-1];
306 pam-fi 1.22 t->SetTextSize(0.02);
307     t->DrawLatex(0.02,0.98,fromfile.str().c_str());
308    
309     // draw pads
310     Double_t posy = 0.95; // up y-coord - top pads
311     Double_t hpad = 0.15; // pad height
312     Double_t posx1=0; // left x-coord - pad column
313     Double_t posx0=0; // x-coord - column division
314     Double_t wrel = 0.6; // relative x size of first sub-column
315     Double_t marg = 0.004; // margin among pads
316    
317     hpad = (posy-marg*11)/6;
318     wrel = (1-marg*4)/2;
319     for(Int_t n = 0; n<12; n++){
320     if ( (n+1)%2 ) {
321     if(n>1)posy = posy-(marg*2+hpad);
322     posx1 = marg;
323     posx0 = posx1 + wrel;
324     } else {
325     posx1 = posx0 + 2*marg;
326     posx0 = posx1 + wrel;
327     };
328    
329     /* -----------> pad for histograms */
330     trkpad[n] = new TPad("pad"," ",posx1,posy-hpad,posx0,posy,18,0,0);
331     trkpad[n]->SetFillColor(19);
332     trkpad[n]->SetFrameFillColor(10);
333    
334     p[n]=0;
335     }
336     }
337     if(psum>0 && psum<=totsum){
338     // = = = = = = = = = = = = = = = = = = = = = = = = =
339     // create header dump retrieving event info
340     // = = = = = = = = = = = = = = = = = = = = = = = = =
341     Int_t ndsp=0;
342    
343     Int_t whistomax[3072];
344     Int_t whisto[3072];
345     Int_t whistocomp[3072];
346     Int_t whistofull[3072];
347    
348     // // transmitted words
349     Int_t word = 0;
350     Int_t iword = 0;
351     Int_t ii=0,ifull[12],icomp[12],imax[12],nn=0;
352     trkword thisword;
353    
354     Int_t address,ladder;
355    
356    
357     for(Int_t n = 0; n<12; n++){
358     ndsp = trk->DSPnumber[n];
359     nn = ndsp-1;
360     ifull[nn]=0;
361     icomp[nn]=0;
362     imax[nn]=0;
363    
364     for(Int_t vi = 0; vi< 3072; vi++){
365     whistomax[vi] = -200;
366     whistocomp[vi] = -200;
367     whistofull[vi] = -200;
368     whisto[vi] = -200;
369     }
370    
371     // // trasmitted data
372     //
373     address = 0;
374     ladder = 1;
375     for(Int_t vi = 0; vi < trk->DATAlength[n] ; vi++){
376     word = trk->TrackerData.At(iword);
377     thisword = datadecode(word);
378     iword++;
379     switch (thisword.type){
380    
381     case 0: //ADC value
382     whisto[address] = thisword.decode;
383     address++;
384     // cout << " adr " << address << "\n";
385     break;
386    
387     case 1: //address
388     address = 1024*(ladder-1) + thisword.decode;
389     // cout << " adr " << address << "\n";
390     break;
391    
392     case 2: //end-of-ladder
393     ladder = thisword.decode;
394     // cout << "Ladder " << ladder << "\n";
395     if(ladder==3){
396     // end of compressed data - FILL HISTO
397     //cout << ">>> COMPRESSED data" << "\n";
398     for(ii = 0; ii < 3072; ii++){
399     whistocomp[ii]=whisto[ii];
400     whisto[ii] = -200;
401     }
402     address = 0;
403     ladder = 1;
404     }else if(ladder==6){
405     // end of full data - FILL HISTO
406     //cout << ">>> FULL data" << "\n";
407     for(ii = 0; ii < 3072; ii++){
408     whistofull[ii]=whisto[ii];
409     whisto[ii] = -200;
410     }
411     address = 0;
412     ladder = 1;
413     }else{
414     if(ladder>3) ladder=ladder-3;
415     address= ladder*1024;
416     ladder = ladder + 1;
417     }
418     }
419     }
420    
421     for(Int_t vi = 0; vi < 3072; vi++){
422     if(whistofull[vi]>-200){
423     if(vi==3071){
424     sum[nn][cins-1][p[nn]] = new TGraph(3072,whistostrip,whistofull);
425     p[nn]++;
426     }
427     if(value%10==0 && value>0){
428     if(whistofull[vi]>0){
429     if(vi==0) values << (short int)ndsp << " ";
430     values <<(short int) whistofull[vi] <<" ";
431     if(vi==3071) values << endl;
432     }
433     }
434     }
435     }
436     }
437     psum++;
438     if(value%10==0 && value>0) values << (short int)0 << endl << endl;
439     }
440     if(psum==totsum+1){
441     if(value%10==0 && value>0) values << (short int)(-cins) << endl << endl;
442     psum=0;
443     for(Int_t vi = 0; vi < 12; vi++){
444     TLine li,liva1;
445     li.SetLineColor(38);
446     li.SetLineStyle(4);
447     li.SetLineWidth(2);
448     liva1.SetLineColor(42);
449     liva1.SetLineStyle(3);
450     liva1.SetLineWidth(1);
451    
452     Float_t va1x=0;
453     csum[cins-1]->cd();
454     trkpad[vi]->Draw();
455     trkpad[vi]->cd();
456     trkpad[vi]->SetFillColor(10);
457    
458     stringstream tit,hid;
459     tit.str("");
460     hid.str("");
461     tit<<"DSP "<<vi+1;
462     sum[vi][cins-1][0]->SetTitle(tit.str().c_str());
463     sum[vi][cins-1][0]->GetXaxis()->SetTitle("channel id");
464     sum[vi][cins-1][0]->GetXaxis()->CenterTitle();
465     sum[vi][cins-1][0]->GetXaxis()->SetRangeUser(0,3073);
466     sum[vi][cins-1][0]->GetXaxis()->SetTitleSize(0.06);
467     sum[vi][cins-1][0]->GetXaxis()->SetTitleOffset(0.8);
468     sum[vi][cins-1][0]->GetYaxis()->SetTitle("ADC value");
469     sum[vi][cins-1][0]->GetYaxis()->SetTitleSize(0.09);
470     sum[vi][cins-1][0]->GetYaxis()->SetTitleOffset(0.4);
471     sum[vi][cins-1][0]->GetYaxis()->CenterTitle();
472     sum[vi][cins-1][0]->GetYaxis()->SetRangeUser(0,4500);
473     sum[vi][cins-1][0]->SetMarkerStyle(20);
474     sum[vi][cins-1][0]->SetMarkerSize(0.1);
475     sum[vi][cins-1][0]->SetMarkerColor(4);
476     sum[vi][cins-1][0]->Draw("ap");
477     hid<<p[vi]<<" events";
478     t->SetTextSize(0.11);
479     t->DrawLatex(2400,4250,hid.str().c_str());
480     for(int pi=1; pi<p[vi];pi++){
481     sum[vi][cins-1][pi]->SetMarkerStyle(21);
482     sum[vi][cins-1][pi]->SetMarkerSize(0.1);
483     sum[vi][cins-1][pi]->SetMarkerColor(4);
484     sum[vi][cins-1][pi]->Draw("p");
485     }
486     for(int va=1; va<24; va++){
487     va1x=128*va;
488     liva1.DrawLine(va1x,0.,va1x,4500.);
489     }
490     li.DrawLine(1024.5,0.,1024.5,4500.);
491     li.DrawLine(2048.5,0.,2048.5,4500.);
492     csum[cins-1]->Update();
493     hid.str("");
494     }
495     if(strcmp(outfile.Data(),"ps") && strcmp(outfile.Data(),"pdf")){
496     figsa+="."+outfile;
497     csum[cins-1]->Print(figsa.Data());
498     }
499     }
500    
501     }
502     }
503    
504     if(!strcmp(outfile.Data(),"ps") || !strcmp(outfile.Data(),"pdf")){
505     stringstream nom1,nom2,nom3;
506     nom1<<out<<ffile<<"_FTrkScanQLook_EXPERT_sumof"<<totsum<<"event.ps(";
507     nom2<<out<<ffile<<"_FTrkScanQLook_EXPERT_sumof"<<totsum<<"event.ps";
508     nom3<<out<<ffile<<"_FTrkScanQLook_EXPERT_sumof"<<totsum<<"event.ps)";
509    
510     for(int va=0; va<cevents; va++){
511     if(cevents==1) csum[va]->Print(nom2.str().c_str(),"Landscape");
512     if(cevents>2){
513     if(va==0) csum[va]->Print(nom1.str().c_str(),"Landscape");
514     if(va>0 && va<cevents-1) csum[va]->Print(nom2.str().c_str(),"Landscape");
515     if(va>0 && va==cevents-1) csum[va]->Print(nom3.str().c_str(),"Landscape");
516     }
517     }
518     }
519     //
520     // Convert ps to pdf if required
521     if(!strcmp(outfile.Data(),"pdf")){
522     stringstream com;
523     com<<"ps2pdf13 "<<out<<ffile<<"_FTrkScanQLook_EXPERT_sumof"<<totsum<<"event.ps "<<out<<ffile<<"_FTrkScanQLook_EXPERT_sumof"<<totsum<<"event.pdf";
524     system(com.str().c_str());
525     printf("\n---> ps file converted in pdf format!\n");
526     com.str("");
527     com<<"rm -f "<<out<<ffile<<"_FTrkScanQLook_EXPERT_sumof"<<totsum<<"event.ps ";
528     system(com.str().c_str());
529     printf("---> ps file removed!\n\n");
530     com.str("");
531     }
532    
533    
534 pam-fi 1.3
535 pam-fi 1.20 for(Int_t e=0;e<TOT;e++){
536 pam-fi 1.22 if(event<=0 || (value%10!=0 && e==0))
537 pam-fi 1.19 event=eve;
538 pam-fi 1.15 else {
539 pam-fi 1.20 event=event+1;
540 pam-fi 1.19 if(event>eve-3 && eve>2)
541 pam-fi 1.15 cal="Event with online calibration";
542     else
543     cal="***** ONLINE CALIBRATION NOT FOUND IN THIS FILE *****";
544     }
545 pam-fi 1.7 printf("Scan of Entry %d\n",event);
546 pam-fi 1.1
547 pam-fi 1.7 tr->GetEntry(event);
548 pam-fi 1.3 //============================================================================
549    
550 pam-fi 1.22 // draw display area
551    
552     TPad *trkpad[12],*pad=0; //pad for histos
553     TPaveText *trkpadtext[12]; //pad for header
554     Int_t ndsp=0;
555    
556     if((tot<TOT && e<tot) || tot==TOT){
557 pam-fi 1.20 figsav=out+ffile+"_FTrkScanQLook_EXPERT_ev";
558     figsav+=event+1;
559     c1[e] = new TCanvas(figsav.Data(),"FTrkQLookSCAN",canvasx,canvasy);
560     c1[e]->SetFillColor(10);
561     c1[e]->Range(0,0,1,1);
562 pam-fi 1.19 fromfile.str("");
563 pam-fi 1.20 fromfile<<"FTrkScanQLook_EXPERT File: "<<ffile<<" ----> Entry "<<event;
564 pam-fi 1.22 t->SetTextSize(0.02);
565 pam-fi 1.19 t->DrawLatex(0.02,0.98,fromfile.str().c_str());
566 pam-fi 1.20 t->DrawLatex(0.60,0.98,cal.Data());
567 pam-fi 1.19
568 pam-fi 1.20 if(va1!=0){
569     figsava=out+ffile+"_FTrkScanQLook_EXPERT_ev";
570     figsava+=event+1;
571     figsava+="_DSP";
572     figsava+=(int)(va1/100);
573     figsava+="_VA1-";
574     figsava+=va1%100;
575     cva[e] = new TCanvas(figsava.Data(),"TrkQLookSCAN VA1",canvasx,canvasy);
576     cva[e]->SetFillColor(10);
577     cva[e]->Range(0,0,1,1);
578     fromfile.str("");
579     fromfile<<"FTrkScanQLook_EXPERT File: "<<ffile<<" ----> Entry "<<event<<" --> DSP "<<(int)(va1/100)<<" --> va1 "<<va1%100;
580     t->DrawLatex(0.02,0.98,fromfile.str().c_str());
581     // t->DrawLatex(0.65,0.98,cal.Data());
582     }
583 pam-fi 1.3
584 pam-fi 1.20 // draw pads
585     Double_t posy = 0.95; // up y-coord - top pads
586     Double_t hpad = 0.15; // pad height
587     Double_t posx1=0; // left x-coord - pad column
588     Double_t posx2=0; // right x-coord - pad olumn
589     Double_t posx0=0; // x-coord - column division
590     Double_t wrel = 0.6; // relative x size of first sub-column
591     Double_t marg = 0.004; // margin among pads
592    
593     for(Int_t n = 0; n<12; n++){
594     if ( (n+1)%2 ) {
595     if(n>1)posy = posy-(marg*2+hpad);
596     posx1 = marg;
597     posx2 = 0.5 - marg;
598     posx0 = 0.5*wrel;
599     } else {
600     posx1 = posx1 + 0.5;
601     posx2 = posx2 + 0.5;
602     posx0 = posx0 + 0.5;
603     };
604    
605     /* -----------> pad for histograms */
606     trkpad[n] = new TPad("pad"," ",posx1,posy-hpad,posx0-marg,posy,18,0,0);
607     trkpad[n]->SetFillColor(19);
608     trkpad[n]->SetFrameFillColor(10);
609     /* -----------> pad for header dump */
610     trkpadtext[n] = new TPaveText((posx0+marg),(posy-hpad),posx2,posy);
611     /* -----------> HISTOGRAMS */
612 pam-fi 1.22
613     title.str("");
614 pam-fi 1.20 title<<"DSP "<<n+1;
615     hid<<"h"<<n+e*100;
616     histomax[n][e] = new TH1F(hid.str().c_str(),title.str().c_str(),3073,-0.5,3072.5);
617     hid<<"hh"<<n+e*100;
618     histocomp[n][e] = new TH1F(hid.str().c_str(),title.str().c_str(),3073,-0.5,3072.5);
619     hid<<"hhh"<<n+e*100;
620     histofull[n][e] = new TH1F(hid.str().c_str(),title.str().c_str(),3073,-0.5,3072.5);
621     title.str("");
622     hid.str("");
623     }
624     if(va1!=0){
625     title.str("");
626     title<<"DSP "<<(int)(va1/100)<<" -- va1 "<<va1%100;
627     hid<<"va"<<e;
628     histova[e] = new TH1F(hid.str().c_str(),title.str().c_str(),130,0,129);
629     } //end loop on views
630 pam-fi 1.1
631 pam-fi 1.3 /* -----------> pad for histograms */
632 pam-fi 1.20 pad = new TPad("padva"," ",0,0,1,0.97,18,0,0);
633     pad->SetFillColor(19);
634     pad->SetFrameFillColor(10);
635 pam-fi 1.22 }
636 pam-fi 1.3 // = = = = = = = = = = = = = = = = = = = = = = = = =
637     // create header dump retrieving event info
638     // = = = = = = = = = = = = = = = = = = = = = = = = =
639 pam-fi 1.22
640 pam-fi 1.3
641     Double_t whistomax[3072];
642     Double_t whisto[3072];
643     Double_t whistocomp[3072];
644     Double_t whistofull[3072];
645    
646     //=============================================
647     // transmitted words
648     Int_t word = 0;
649     Int_t iword = 0;
650     Int_t TOTDATAlength_check = 0;
651     Int_t ii=0,ifull[12],icomp[12],imax[12],nn=0;
652     trkword thisword;
653 pam-fi 1.1
654 pam-fi 1.3 Int_t address,ladder;
655 pam-fi 1.20
656    
657 pam-fi 1.3 for(Int_t n = 0; n<12; n++){
658 pam-fi 1.1
659 pam-fi 1.3 ndsp = trk->DSPnumber[n];
660     nn = ndsp-1;
661     ifull[nn]=0;
662     icomp[nn]=0;
663     imax[nn]=0;
664 pam-fi 1.12 if(ndsp>0){
665     if(ndsp<13){
666 pam-fi 1.20 if((tot<TOT && e<tot) || tot==TOT){
667 pam-fi 1.1
668 pam-fi 1.20 /*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*
669     *
670     * Write event LEVEL0 report
671     *
672     *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*/
673    
674     trkpadtext[nn]->SetTextFont(40);
675     trkpadtext[nn]->SetFillColor(33);
676     trkpadtext[nn]->SetTextSize(0.012);
677     trkpadtext[nn]->SetTextAlign(13);
678    
679     trkpadtext[nn]->AddText(" ");
680     message<<"DAQ mode --------> "<<trk->DAQmode[n];
681     trkpadtext[nn]->AddText(message.str().c_str());
682     message.str("");
683     message<<"Event number --------> "<<trk->eventn[n];
684     trkpadtext[nn]->AddText(message.str().c_str());
685     message.str("");
686     message<<"13-bit words --------> "<<trk->DATAlength[n];
687     trkpadtext[nn]->AddText(message.str().c_str());
688     message.str("");
689     if (!(nn%2)&&trk->signcluster[n][0]!=0) message<<"L1 add: "<<trk->addrcluster[n][0]<<" - sign: "<<1024-(trk->signcluster[n][0]);
690     else message<<"L1 add: "<<trk->addrcluster[n][0]<<" - sign: "<<(trk->signcluster[n][0]);
691     trkpadtext[nn]->AddText(message.str().c_str());
692     message.str("");
693     if (!(nn%2)&&trk->signcluster[n][1]!=0) message<<"L2 add: "<<trk->addrcluster[n][1]<<" - sign: "<<1024-(trk->signcluster[n][1]);
694     else message<<"L2 add: "<<trk->addrcluster[n][1]<<" - sign: "<<trk->signcluster[n][1];
695     trkpadtext[nn]->AddText(message.str().c_str());
696     message.str("");
697     if (!(nn%2)&&trk->signcluster[n][2]!=0) message<<"L3 add: "<<trk->addrcluster[n][2]<<" - sign: "<<1024-(trk->signcluster[n][2]);
698     else message<<"L3 add: "<<trk->addrcluster[n][2]<<" - sign: "<<trk->signcluster[n][2];
699     trkpadtext[nn]->AddText(message.str().c_str());
700     message.str("");
701     message<<"NCLUST "<<trk->nclust[n]<<" CUTC "<<trk->cutc[n]<<" CUTCL "<<trk->cutcl[n];
702     trkpadtext[nn]->AddText(message.str().c_str());
703     message.str("");
704     message<<"Comp. time "<<trk->compressiontime[n]<<" x 0.051ms = "<<0.051*trk->compressiontime[n]<<" ms";
705     trkpadtext[nn]->AddText(message.str().c_str());
706     message.str("");
707     trkpadtext[nn]->AddText(" ");
708     message<<"CRC --> "<<trk->crc[n];
709     trkpadtext[nn]->AddText(message.str().c_str());
710     message.str("");
711     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];
712     trkpadtext[nn]->AddText(message.str().c_str());
713     message.str("");
714     trkpadtext[nn]->AddText(" ");
715     trkpadtext[nn]->AddLine(0,0,0,0);
716     message<<"PNum "<<trk->pnum[n]<<" - BId "<<trk->bid[n]<<" ALARM "<<trk->alarm[n];
717     trkpadtext[nn]->AddText(message.str().c_str());
718     message.str("");
719     message<<"Cmd "<<trk->cmdnum[n]<<" --- Answer length "<<trk->aswr[n]<<" byte";
720     trkpadtext[nn]->AddText(message.str().c_str());
721     message.str("");
722     trkpadtext[nn]->AddText(" ");
723 pam-fi 1.1
724 pam-fi 1.20 TOTDATAlength_check = TOTDATAlength_check + trk->DATAlength[n];
725     }
726 pam-fi 1.12 /*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*
727     *
728     * Plot event LEVEL0 histo
729     *
730     *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*/
731    
732     //=============================================
733 pam-fi 1.20 }
734     for(Int_t i = 0; i< 3072; i++){
735     whistomax[i] = -200;
736     whistocomp[i] = -200;
737     whistofull[i] = -200;
738     whisto[i] = -200;
739     }
740 pam-fi 1.12
741 pam-fi 1.20 // ===============
742     // trasmitted data
743     // ===============
744    
745     address = 0;
746     ladder = 1;
747     for(Int_t i = 0; i < trk->DATAlength[n] ; i++){
748     word = trk->TrackerData.At(iword);
749     thisword = datadecode(word);
750     iword++;
751     switch (thisword.type){
752 pam-fi 1.1
753 pam-fi 1.20 case 0: //ADC value
754     whisto[address] = thisword.decode;
755     address++;
756     // cout << " adr " << address << "\n";
757     break;
758    
759     case 1: //address
760     address = 1024*(ladder-1) + thisword.decode;
761     // cout << " adr " << address << "\n";
762     break;
763    
764     case 2: //end-of-ladder
765     ladder = thisword.decode;
766     // cout << "Ladder " << ladder << "\n";
767     if(ladder==3){
768     // end of compressed data - FILL HISTO
769     //cout << ">>> COMPRESSED data" << "\n";
770     for(ii = 0; ii < 3072; ii++){
771     whistocomp[ii]=whisto[ii];
772     whisto[ii] = -200;
773 pam-fi 1.12 }
774 pam-fi 1.20 address = 0;
775     ladder = 1;
776     }else if(ladder==6){
777     // end of full data - FILL HISTO
778     //cout << ">>> FULL data" << "\n";
779     for(ii = 0; ii < 3072; ii++){
780     whistofull[ii]=whisto[ii];
781     whisto[ii] = -200;
782     }
783     address = 0;
784     ladder = 1;
785     }else{
786     if(ladder>3) ladder=ladder-3;
787     address= ladder*1024;
788     ladder = ladder + 1;
789     }
790 pam-fi 1.12 }
791 pam-fi 1.20 }
792 pam-fi 1.1
793    
794 pam-fi 1.20 // ===============
795     // maximum signals
796     // ===============
797     if(trk->signcluster[nn][0]!=0) whistomax[ 0+(int)trk->addrcluster[nn][0]] = whistocomp[ 0+(int)trk->addrcluster[nn][0]];
798     if(trk->signcluster[nn][1]!=0) whistomax[1024+(int)trk->addrcluster[nn][1]] = whistocomp[1024+(int)trk->addrcluster[nn][1]];
799     if(trk->signcluster[nn][2]!=0) whistomax[2048+(int)trk->addrcluster[nn][2]] = whistocomp[2048+(int)trk->addrcluster[nn][2]];
800    
801     for(Int_t i = 0; i < 3072; i++){
802     if(whistomax[i]>-200) imax[nn]=1;
803     if(whistocomp[i]>-200) icomp[nn]=1;
804     if(whistofull[i]>-200) ifull[nn]=1;
805 pam-fi 1.22 if(value%10!=0){
806     if((totvalues<TOT && e<totvalues) || totvalues==TOT){
807     if(whistofull[i]>0){
808     if(i==0) values << (short int)ndsp << " ";
809     values <<(short int) whistofull[i] <<" ";
810     if(i==3071) values << endl;
811     }
812 pam-fi 1.20 }
813     }
814     if((tot<TOT && e<tot) || tot==TOT){
815 pam-fi 1.12 histomax[nn][e]->Fill((Float_t)i,whistomax[i]);
816     histocomp[nn][e]->Fill((Float_t)i,whistocomp[i]);
817     histofull[nn][e]->Fill((Float_t)i,whistofull[i]);
818 pam-fi 1.19 if(va1!=0 && ndsp==(int)(va1/100) && i>=128*((va1%100)-1)){
819     if(i<128*(va1%100))
820     histova[e]->Fill((Float_t)(i-128*((va1%100)-1)+1),whistofull[i]);
821     }
822 pam-fi 1.12 }
823 pam-fi 1.20 }
824 pam-fi 1.2
825 pam-fi 1.20 if((tot<TOT && e<tot) || tot==TOT){
826 pam-fi 1.12 TBox b;
827 pam-fi 1.19 TLine li,liva1;
828     li.SetLineColor(38);
829     li.SetLineStyle(4);
830     li.SetLineWidth(2);
831     liva1.SetLineColor(42);
832     liva1.SetLineStyle(3);
833     liva1.SetLineWidth(1);
834    
835     Float_t va1x=0;
836    
837     if(va1!=0){
838     cva[e]->cd();
839     pad->Draw();
840     pad->cd();
841     pad->SetFillColor(10);
842     histova[e]->SetTitleSize(0.01);
843     histova[e]->GetYaxis()->SetRangeUser(1500,4500);
844     histova[e]->SetLineColor(40);
845     histova[e]->SetFillColor(40);
846     histova[e]->SetLineWidth(1);
847     histova[e]->SetLineStyle(2);
848     // histova[e]->GetYaxis()->SetLabelSize(0.03);
849     histova[e]->Draw("");
850     cva[e]->Update();
851     }
852 pam-fi 1.3
853 pam-fi 1.12 c1[e]->cd();
854     trkpadtext[nn]->Draw();
855     trkpad[nn]->Draw();
856     trkpad[nn]->cd();
857     trkpad[nn]->SetFillColor(10);
858    
859 pam-fi 1.19 histocomp[nn][e]->SetTitleSize(0.1);
860 pam-fi 1.12 histocomp[nn][e]->GetYaxis()->SetRangeUser(-500,4500);
861     histocomp[nn][e]->SetLineStyle(1);
862     histocomp[nn][e]->SetLineColor(38);
863     histocomp[nn][e]->SetFillColor(38);
864     histocomp[nn][e]->SetLineWidth(1);
865     histocomp[nn][e]->Draw("");
866    
867     histofull[nn][e]->SetLineColor(40);
868     histofull[nn][e]->SetFillColor(40);
869     histofull[nn][e]->SetLineWidth(1);
870     histofull[nn][e]->SetLineStyle(2);
871    
872     histomax[nn][e]->SetLineColor(2);
873     histomax[nn][e]->SetLineWidth(1);
874     histomax[nn][e]->SetLineStyle(3);
875    
876     if(ifull[nn]==1) histofull[nn][e]->Draw("9bsame][");
877     if(icomp[nn]==1) histocomp[nn][e]->Draw("9bsame][");
878     if(imax[nn]==1) histomax[nn][e]->Draw("same][");
879     histocomp[nn][e]->Draw("axis same");
880 pam-fi 1.15 if(nn==0){
881     b.SetFillColor(107);
882     b.SetFillStyle(3945);
883 pam-fi 1.24 b.DrawBox(256.,-500.,384.,4500);
884 pam-fi 1.15 b.DrawBox(768.,-500.,2047.,4500.);
885     }
886     else if(nn==1){
887 pam-fi 1.12 b.SetFillColor(6);
888     b.SetFillStyle(3945);
889     b.DrawBox(2944.,-500.,3060.,4500.);
890 pam-fi 1.8
891 pam-fi 1.12 b.SetFillColor(107);
892     b.SetFillStyle(3954);
893 pam-fi 1.22 b.DrawBox(384.,-500.,512.,4500.);
894 pam-fi 1.23 b.DrawBox(2048.,-500.,2432.,4500.);
895 pam-fi 1.12 b.DrawBox(2816.,-500.,2944.,4500.);
896     }
897 pam-fi 1.24 else if(nn==3){
898     b.SetFillColor(107);
899     b.SetFillStyle(3954);
900     b.DrawBox(2816.,-500.,3070.,4500.);
901     }
902 pam-fi 1.12 else if(nn==4){
903     b.SetFillColor(107);
904     b.SetFillStyle(3954);
905 pam-fi 1.24 b.DrawBox(256.,-500.,512.,4500.);
906     b.DrawBox(2816.,-500.,3070.,4500.);
907 pam-fi 1.12 }
908     else if(nn==6){
909     b.SetFillColor(6);
910     b.SetFillStyle(3945);
911 pam-fi 1.22 b.DrawBox(1024.,-500.,1280.,4500.);
912 pam-fi 1.8
913 pam-fi 1.12 b.SetFillColor(107);
914     b.SetFillStyle(3954);
915     b.DrawBox(512.,-500.,768.,4500.);
916 pam-fi 1.22 b.DrawBox(1280.,-500.,1792.,4500.);
917 pam-fi 1.23 b.DrawBox(2560.,-500.,2816.,4500.);
918 pam-fi 1.12 }
919     else if(nn==7){
920     b.SetFillColor(107);
921     b.SetFillStyle(3954);
922     b.DrawBox(512.,-500.,768.,4500.);
923 pam-fi 1.24 b.DrawBox(1024.,-500.,1535.,4500.);
924 pam-fi 1.12 }
925 pam-fi 1.16 else if(nn==8){
926     b.SetFillColor(107);
927     b.SetFillStyle(3954);
928 pam-fi 1.17 b.DrawBox(512.,-500.,768.,4500.);
929 pam-fi 1.16 }
930 pam-fi 1.13 else if(nn==9){
931     b.SetFillColor(107);
932     b.SetFillStyle(3954);
933 pam-fi 1.17 b.DrawBox(256.,-500.,384.,4500.);
934 pam-fi 1.22 b.DrawBox(1280.,-500.,1535.,4500.);
935     b.DrawBox(1792.,-500.,1920.,4500.);
936 pam-fi 1.17 }
937     else if(nn==10){
938     b.SetFillColor(107);
939     b.SetFillStyle(3954);
940 pam-fi 1.24 b.DrawBox(1024.,-500.,1152.,4500.);
941 pam-fi 1.18 b.DrawBox(2048.,-500.,3070.,4500.);
942 pam-fi 1.13 }
943 pam-fi 1.12 else if(nn==11){
944     b.SetFillColor(6);
945     b.SetFillStyle(3945);
946     b.DrawBox(768.,-500.,1024.,4500.);
947 pam-fi 1.8
948 pam-fi 1.12 b.SetFillColor(107);
949     b.SetFillStyle(3954);
950 pam-fi 1.17 b.DrawBox(0.,-500.,512.,4500.);
951     b.DrawBox(1920.,-500.,2560.,4500.);
952 pam-fi 1.12 }
953 pam-fi 1.19 for(int va=1; va<24; va++){
954     va1x=128*va;
955     liva1.DrawLine(va1x,-500.,va1x,4500.);
956     }
957     li.DrawLine(1024.5,-500.,1024.5,4500.);
958     li.DrawLine(2048.5,-500.,2048.5,4500.);
959 pam-fi 1.12 c1[e]->Update();
960     }
961 pam-fi 1.20
962 pam-fi 1.3 }
963     }//end loop on views
964 pam-fi 1.19
965 pam-fi 1.20 if((tot<TOT && e<tot) || tot==TOT){
966     stringstream nom1,nom2,nom3;
967     nom1<<out<<ffile<<"_FTrkScanQLook_EXPERT.ps(";
968     nom2<<out<<ffile<<"_FTrkScanQLook_EXPERT.ps";
969     nom3<<out<<ffile<<"_FTrkScanQLook_EXPERT.ps)";
970    
971     if(!strcmp(outfile.Data(),"ps")||!strcmp(outfile.Data(),"pdf")){
972     if(e==0){
973 pam-fi 1.22 c1[e]->Print(nom1.str().c_str(),"Landscape");
974     if(va1!=0) cva[e]->Print(nom2.str().c_str(),"Landscape");
975 pam-fi 1.20 }
976     if(e>0 && tot>2){
977 pam-fi 1.22 c1[e]->Print(nom2.str().c_str(),"Landscape");
978     if(va1!=0) cva[e]->Print(nom2.str().c_str(),"Landscape");
979 pam-fi 1.20 }
980     if(e==tot-1){
981 pam-fi 1.22 c1[e]->Print(nom2.str().c_str(),"Landscape");
982     if(va1!=0) cva[e]->Print(nom3.str().c_str(),"Landscape");
983 pam-fi 1.20 }
984 pam-fi 1.19 }
985 pam-fi 1.20 else{
986     figsav+="."+outfile;
987     c1[e]->Print(figsav.Data());
988     if(va1!=0){
989     figsava+="."+outfile;
990     cva[e]->Print(figsava.Data());
991     }
992 pam-fi 1.19 }
993     }
994 pam-fi 1.22 if(value%10!=0){
995     if(totvalues==TOT || (totvalues<TOT && e<totvalues))
996     values << (short int)0 << endl << endl;
997     }
998 pam-fi 1.20 }
999     stringstream com;
1000    
1001     values.close();
1002     if(value==0){
1003     com<<"rm -f "<<fname;
1004     system(com.str().c_str());
1005 pam-fi 1.19 }
1006     //
1007     // Convert ps to pdf if required
1008     if(!strcmp(outfile.Data(),"pdf")){
1009     com<<"ps2pdf13 "<<out<<ffile<<"_FTrkScanQLook_EXPERT.ps "<<out<<ffile<<"_FTrkScanQLook_EXPERT.pdf";
1010     system(com.str().c_str());
1011     printf("\n---> ps file converted in pdf format!\n");
1012     com.str("");
1013     com<<"rm -f "<<out<<ffile<<"_FTrkScanQLook_EXPERT.ps ";
1014     system(com.str().c_str());
1015     printf("---> ps file removed!\n\n");
1016     com.str("");
1017 pam-fi 1.3 }
1018 pam-fi 1.20
1019 pam-fi 1.1 return;
1020     }

  ViewVC Help
Powered by ViewVC 1.1.23