/[PAMELA software]/quicklook/tracker/flight/macros/TrkScanQLook.cpp
ViewVC logotype

Contents of /quicklook/tracker/flight/macros/TrkScanQLook.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Mar 14 16:09:30 2006 UTC (18 years, 8 months ago) by pam-fi
Branch: trk-QLook
CVS Tags: R1v00, R1v01
Changes since 1.1: +0 -0 lines
First CVS release of tracker flight quick-look 

1 // change the path "/opt/yoda/include/yoda/event/"
2 // relatively to the install yoda directory
3 #include </opt/yoda/include/yoda/event/PscuHeader.h>
4 #include </opt/yoda/include/yoda/event/EventHeader.h>
5 #include </opt/yoda/include/yoda/event/physics/tracker/TrackerEvent.h>
6 #include </opt/yoda/include/utils/yodaUtility.h>
7 //
8 #include "TrkFunctions.cpp"
9 #include <TPaveText.h>
10 #include <TLatex.h>
11 #include <TCanvas.h>
12 #include <TObjString.h>
13 #include <TGraph.h>
14 #include <iostream>
15 #include <fstream>
16 #include <TStyle.h>
17 #include <TString.h>
18
19 /**
20 * TrkScanQlook.cpp
21 *
22 * autor: D.Fedele
23 * version 1.0
24 * Parameters:
25 * file - the path to the root file to analyse
26 * outdir - total path of output file
27 * event - the number of the single event to analyse
28 * DSPprint - the number of a particular DSP to draw (0 don't draw)
29 *
30 */
31
32 void TrkScanQlook(TString file, TString outdir = "",Int_t event = 1,Int_t DSPprint=0){
33
34 gROOT->Reset();
35
36 //
37 // obtain information about the data file and select the output file
38 const string filepath=file.Data();
39 Int_t dwpos = filepath.find("DW_");
40 Int_t dwpos1 = filepath.find(".root");
41 TString fpath=(filepath.c_str());
42 TString base,ffile ;
43 stringcopy(ffile,fpath,dwpos,dwpos1);
44 stringcopy(base,fpath,0,dwpos);
45
46 TString out;
47 if(outdir.Length()==0){
48 out = base;
49 }else{
50 out = outdir;
51 }
52
53
54 // Define variables
55 Int_t nevents = otr->GetEntries();
56 if ( nevents <= 0 ) {
57 trackerFile->Close();
58 printf("The file is empty, exiting...\n");
59 return;
60 }
61
62 pamela::tracker::TrackerEvent *trk=0;
63 pamela::EventHeader *eh=0;
64 pamela::PscuHeader *ph=0;
65
66
67 // open files
68 TFile *trackerFile = new TFile(file);
69 if ( !trackerFile ){
70 trackerFile->Close();
71 printf("No tracker file! \n");
72 return;
73 }
74
75 //Takes the tree and branches
76 TTree *otr = (TTree*)trackerFile->Get("Physics");
77
78 cout << "\n Number of Entries: " << nevents << endl;
79
80 cout<<"Scan of Entry "<<event-1<<"\n"<<endl;
81
82 otr->SetBranchAddress("Header",&eh);
83 otr->SetBranchAddress("Tracker", &trk);
84 otr->GetEntry(event-1);
85 //============================================================================
86
87 gStyle->SetLabelSize(0.06,"x");
88 gStyle->SetLabelSize(0.06,"y");
89
90 gStyle->SetTitleFontSize(0.08);
91 gStyle->SetTitleFillColor(10);
92 gStyle->SetTitleFontSize(0.1);
93 gStyle->SetTitleOffset(-1,"Y");
94
95 gStyle->SetOptStat(0);
96
97 // draw display area
98
99 Int_t canvasx=1200;
100 Int_t canvasy=900;
101 stringstream figsav;
102 figsav.str("");
103 figsav<<out<<ffile<<"_TrkScanQlook_ev"<<event+1;
104 TCanvas *c1 = new TCanvas(figsav.str().c_str(),"TrkQLookSCAN",canvasx,canvasy);
105 c1->SetFillColor(10);
106 c1->Range(0,0,1,1);
107 stringstream fromfile;
108 fromfile<<"TrkScanQlook File: "<<ffile<<" ----> Entry "<<event-1;
109 TLatex *t=new TLatex();
110 t->SetTextFont(32);
111 t->SetTextColor(1);
112 t->SetTextAlign(12);
113 t->SetTextSize(0.02);
114 t->DrawLatex(0.02,0.98,fromfile.str().c_str());
115
116 // draw pads
117 TPad *trkpad[12]; //pad for histos
118 TPaveText *trkpadtext[12]; //pad for header
119 TH1F *histomax[12]; //histos of max signals
120 TH1F *histocomp[12]; //histos of compressed data
121 TH1F *histofull[12]; //histos of full data
122
123 Double_t posy = 0.95; // up y-coord - top pads
124 Double_t hpad = 0.15; // pad height
125 Double_t posx1=0; // left x-coord - pad column
126 Double_t posx2=0; // right x-coord - pad olumn
127 Double_t posx0=0; // x-coord - column division
128 Double_t wrel = 0.6; // relative x size of first sub-column
129 Double_t marg = 0.004; // margin among pads
130
131
132 stringstream title;
133 stringstream hid;
134 for(Int_t n = 0; n<12; n++){
135 if ( (n+1)%2 ) {
136 if(n>1)posy = posy-(marg*2+hpad);
137 posx1 = marg;
138 posx2 = 0.5 - marg;
139 posx0 = 0.5*wrel;
140 } else {
141 posx1 = posx1 + 0.5;
142 posx2 = posx2 + 0.5;
143 posx0 = posx0 + 0.5;
144 };
145
146 /* -----------> pad for histograms */
147 trkpad[n] = new TPad("pad"," ",posx1,posy-hpad,posx0-marg,posy,18,0,0);
148 trkpad[n]->SetFillColor(19);
149 trkpad[n]->SetFrameFillColor(10);
150 /* -----------> pad for header dump */
151 trkpadtext[n] = new TPaveText((posx0+marg),(posy-hpad),posx2,posy);
152 /* -----------> HISTOGRAMS */
153
154 title<<"DSP "<<n+1;
155 hid<<"h"<<n;
156 histomax[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3072,0.5,3072.5);
157 hid<<"hh"<<n;
158 histocomp[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3072,0.5,3072.5);
159 hid<<"hhh"<<n;
160 histofull[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3072,0.5,3072.5);
161 title.str("");
162 hid.str("");
163 } //end loop on views
164
165 // = = = = = = = = = = = = = = = = = = = = = = = = =
166 // create header dump retrieving event info
167 // = = = = = = = = = = = = = = = = = = = = = = = = =
168 Int_t ndsp=0;
169 stringstream message;
170
171 Double_t whistomax[3072];
172 Double_t whisto[3072];
173 Double_t whistocomp[3072];
174 Double_t whistofull[3072];
175
176 //=============================================
177 // transmitted words
178 Int_t word = 0;
179 Int_t iword = 0;
180 Int_t TOTDATAlength_check = 0;
181 Int_t ii=0,ifull[12],icomp[12],imax[12],nn=0;
182 trkword thisword;
183
184 Int_t address,ladder,adcvalue;
185
186 for(Int_t n = 0; n<12; n++){
187
188 ndsp = trk->DSPnumber[n];
189 nn = ndsp-1;
190 ifull[nn]=0;
191 icomp[nn]=0;
192 imax[nn]=0;
193
194 /*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*
195 *
196 * Write event LEVEL0 report
197 *
198 *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*/
199
200 trkpadtext[nn]->SetTextFont(40);
201 trkpadtext[nn]->SetFillColor(33);
202 trkpadtext[nn]->SetTextSize(0.012);
203 trkpadtext[nn]->SetTextAlign(13);
204
205 trkpadtext[nn]->AddText(" ");
206 message<<"DAQ mode --------> "<<trk->DAQmode[n];
207 trkpadtext[nn]->AddText(message.str().c_str());
208 message.str("");
209 message<<"Event number --------> "<<trk->eventn[n];
210 trkpadtext[nn]->AddText(message.str().c_str());
211 message.str("");
212 message<<"13-bit words --------> "<<trk->DATAlength[n];
213 trkpadtext[nn]->AddText(message.str().c_str());
214 message.str("");
215 if (!(nn%2)&&trk->signcluster[n][0]!=0) message<<"L1 add: "<<trk->addrcluster[n][0]<<" - sign: "<<1024-(trk->signcluster[n][0]);
216 else message<<"L1 add: "<<trk->addrcluster[n][0]<<" - sign: "<<(trk->signcluster[n][0]);
217 trkpadtext[nn]->AddText(message.str().c_str());
218 message.str("");
219 if (!(nn%2)&&trk->signcluster[n][1]!=0) message<<"L2 add: "<<trk->addrcluster[n][1]<<" - sign: "<<1024-(trk->signcluster[n][1]);
220 else message<<"L2 add: "<<trk->addrcluster[n][1]<<" - sign: "<<trk->signcluster[n][1];
221 trkpadtext[nn]->AddText(message.str().c_str());
222 message.str("");
223 if (!(nn%2)&&trk->signcluster[n][2]!=0) message<<"L3 add: "<<trk->addrcluster[n][2]<<" - sign: "<<1024-(trk->signcluster[n][2]);
224 else message<<"L3 add: "<<trk->addrcluster[n][2]<<" - sign: "<<trk->signcluster[n][2];
225 trkpadtext[nn]->AddText(message.str().c_str());
226 message.str("");
227 message<<"NCLUST "<<trk->nclust[n]<<" CUTC "<<trk->cutc[n]<<" CUTCL "<<trk->cutcl[n];
228 trkpadtext[nn]->AddText(message.str().c_str());
229 message.str("");
230 message<<"Comp. time "<<trk->compressiontime[n]<<" x 0.051ms = "<<0.051*trk->compressiontime[n]<<" ms";
231 trkpadtext[nn]->AddText(message.str().c_str());
232 message.str("");
233 trkpadtext[nn]->AddText(" ");
234 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];
235 trkpadtext[nn]->AddText(message.str().c_str());
236 message.str("");
237 trkpadtext[nn]->AddText(" ");
238 trkpadtext[nn]->AddLine(0,0,0,0);
239 message<<"PNum "<<trk->pnum[n]<<" - BId "<<trk->bid[n]<<" ALARM "<<trk->alarm[n];
240 trkpadtext[nn]->AddText(message.str().c_str());
241 message.str("");
242 message<<"Cmd "<<trk->cmdnum[n]<<" --- Answer length "<<trk->aswr[n]<<" byte";
243 trkpadtext[nn]->AddText(message.str().c_str());
244 message.str("");
245 trkpadtext[nn]->AddText(" ");
246
247 TOTDATAlength_check = TOTDATAlength_check + trk->DATAlength[n];
248
249 /*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*
250 *
251 * Plot event LEVEL0 histo
252 *
253 *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*/
254
255 //=============================================
256
257 for(Int_t i = 0; i< 3072; i++){
258 whistomax[i] = -200;
259 whistocomp[i] = -200;
260 whistofull[i] = -200;
261 whisto[i] = -200;
262 }
263
264 // ===============
265 // trasmitted data
266 // ===============
267
268 address = 0;
269 ladder = 1;
270 for(Int_t i = 0; i < trk->DATAlength[n] ; i++){
271 word = trk->TrackerData.At(iword);
272 thisword = datadecode(word);
273 iword++;
274 switch (thisword.type){
275
276 case 0: //ADC value
277 whisto[address] = thisword.decode;
278 address++;
279 // cout << " adr " << address << "\n";
280 break;
281
282 case 1: //address
283 address = 1024*(ladder-1) + thisword.decode;
284 // cout << " adr " << address << "\n";
285 break;
286
287 case 2: //end-of-ladder
288 ladder = thisword.decode;
289 // cout << "Ladder " << ladder << "\n";
290 if(ladder==3){
291 // end of compressed data - FILL HISTO
292 //cout << ">>> COMPRESSED data" << "\n";
293 for(ii = 0; ii < 3072; ii++){
294 whistocomp[ii]=whisto[ii];
295 whisto[ii] = -200;
296 }
297 address = 0;
298 ladder = 1;
299 }else if(ladder==6){
300 // end of full data - FILL HISTO
301 //cout << ">>> FULL data" << "\n";
302 for(ii = 0; ii < 3072; ii++){
303 whistofull[ii]=whisto[ii];
304 whisto[ii] = -200;
305 }
306 address = 0;
307 ladder = 1;
308 }else{
309 if(ladder>3) ladder=ladder-3;
310 address= ladder*1024;
311 ladder = ladder + 1;
312 }
313 }
314 }
315
316
317 // ===============
318 // maximum signals
319 // ===============
320 if(trk->signcluster[nn][0]!=0) whistomax[ 0+(int)trk->addrcluster[nn][0]] = whistocomp[ 0+(int)trk->addrcluster[nn][0]];
321 if(trk->signcluster[nn][1]!=0) whistomax[1024+(int)trk->addrcluster[nn][1]] = whistocomp[1024+(int)trk->addrcluster[nn][1]];
322 if(trk->signcluster[nn][2]!=0) whistomax[2048+(int)trk->addrcluster[nn][2]] = whistocomp[2048+(int)trk->addrcluster[nn][2]];
323
324 for(Int_t i = 0; i < 3072; i++){
325 if(whistomax[i]>-200) imax[nn]=1;
326 if(whistocomp[i]>-200) icomp[nn]=1;
327 if(whistofull[i]>-200) ifull[nn]=1;
328 histomax[nn]->Fill((Float_t)i,whistomax[i]);
329 histocomp[nn]->Fill((Float_t)i,whistocomp[i]);
330 histofull[nn]->Fill((Float_t)i,whistofull[i]);
331 }
332 c1->cd();
333 trkpadtext[nn]->Draw();
334 trkpad[nn]->Draw();
335 trkpad[nn]->cd();
336
337 histocomp[nn]->GetYaxis()->SetRangeUser(-500,4500);
338 histocomp[nn]->SetLineStyle(1);
339 histocomp[nn]->SetLineColor(38);
340 histocomp[nn]->SetFillColor(38);
341 histocomp[nn]->SetLineWidth(1);
342 if(icomp[nn]==1) histocomp[nn]->Draw("9b");
343
344 histofull[nn]->SetLineColor(40);
345 histofull[nn]->SetFillColor(40);
346 histofull[nn]->SetLineWidth(1);
347 histofull[nn]->SetLineStyle(2);
348 if(ifull[nn]==1) histofull[nn]->Draw("9bsame][");
349
350 histomax[nn]->SetLineColor(2);
351 histomax[nn]->SetLineWidth(1);
352 histomax[nn]->SetLineStyle(3);
353 if(imax[nn]==1) histomax[nn]->Draw("same][");
354 c1->Update();
355
356 }//end loop on views
357
358 if(DSPprint!=0){
359 if(DSPprint<=12){
360 stringstream figsav;
361 figsav.str("");
362 figsav<<out<<ffile<<"_TrkScanQlook_ev"<<event+1<<"-DSP"<<DSPprint;
363 TCanvas *c2 = new TCanvas(figsav.str().c_str(),"TrkQLookSCAN DSP",canvasx,canvasy);
364 c2->SetFillColor(10);
365 c2->Range(0,0,1,1);
366 stringstream fromfile;
367 fromfile<<"TrkScanQlook File: "<<ffile<<" ----> Entry "<<event<<" ------> DSP "<<DSPprint;
368 TLatex *t=new TLatex();
369 t->SetTextFont(32);
370 t->SetTextColor(1);
371 t->SetTextAlign(12);
372 t->SetTextSize(0.02);
373 t->DrawLatex(0.02,0.98,fromfile.str().c_str());
374
375 c2->cd();
376 gStyle->SetTitleFontSize(0.022);
377 histocomp[DSPprint-1]->GetXaxis()->SetLabelSize(0.015);
378 histocomp[DSPprint-1]->GetYaxis()->SetLabelSize(0.015);
379 if(icomp[DSPprint-1]==1) histocomp[DSPprint-1]->Draw("9b");
380 if(ifull[DSPprint-1]==1) histofull[DSPprint-1]->Draw("9bsame][");
381 if(imax[DSPprint-1]==1) histomax[DSPprint-1]->Draw("same][");
382 c2->Update();
383 }
384 else if(DSPprint>12)
385 printf("The DSP number has to be between 1 and 12\n");
386 }
387
388 return;
389
390 }
391

  ViewVC Help
Powered by ViewVC 1.1.23