/[PAMELA software]/quicklook/trigger/src/TriggerScanExpert.cpp
ViewVC logotype

Contents of /quicklook/trigger/src/TriggerScanExpert.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Thu Sep 21 12:41:41 2006 UTC (18 years, 2 months ago) by campana
Branch: MAIN
CVS Tags: v1r08
Changes since 1.2: +1 -0 lines
only a minor bug fixed

1 /*
2 * TriggerScanExpert
3 * Author Nagni
4 * Modified by G. De Rosa
5 * Version 1.2
6 * Date 27 Apr 2006
7 * Version 1.4
8 * Date 26 Jun 2006: Inserted dependences on OnBoardTime and modified histogram ranges.
9 *
10 * Description:
11 * Describe the performance of the Trigger.
12 *
13 * Parameters:
14 * TString base - the path to the root directory for the specific Pamela unpack session
15 * TString outDirectory - the path where to save the output image (Default = base)
16 * TString format - the format which will be used for save the produced images (Default = "ps")
17 */
18
19 #include <TFile.h>
20 #include <TString.h>
21 #include <TObjString.h>
22 #include <TTree.h>
23 #include <TBranch.h>
24 #include <TGraph.h>
25 #include <TStyle.h>
26 #include <TH2S.h>
27 #include <TPaveText.h>
28 #include <TCanvas.h>
29 #include <TLatex.h>
30 #include <TGraph.h>
31 #include <physics/trigger/TriggerEvent.h>
32 #include <EventHeader.h>
33 #include <PscuHeader.h>
34 #include <iostream>
35
36 using namespace std;
37
38 char bit(int decimal, char pos)
39 {
40 return( (decimal>>pos)%2 );
41 }
42
43 void TriggerScanExpert(TString base, TString outDirectory = "", TString format = ""){
44
45 std::stringstream sst;
46 if (outDirectory == "") outDirectory = base.Data();
47 TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString();
48
49 TFile *file =new TFile(base.Data()) ;
50 if (!file){
51 printf("file not Found \n");
52 return;
53 }
54
55 TTree *PhysicsTr = (TTree*)file->Get("Physics");
56 TBranch *TrigBr = PhysicsTr->GetBranch("Trigger");
57 TBranch *HeadBr = PhysicsTr->GetBranch("Header");
58
59 pamela::EventHeader *eh = 0;
60
61 pamela::trigger::TriggerEvent *triggerEvent = 0;
62
63 PhysicsTr->SetBranchAddress("Trigger", &triggerEvent);
64 PhysicsTr->SetBranchAddress("Header", &eh);
65
66 Long64_t nevents = TrigBr->GetEntries();
67 if (nevents <= 0) {
68 printf("nevents = %llu \n", nevents);
69 file->Close();
70 return;
71 }
72
73 /* Histo DEF */
74
75 /*
76 * Pattern Trigger Rate histograms
77 */
78
79 TCanvas *PatternTrig0 = new TCanvas("PatternTrig0","PatternTrig0", 1280, 1024);
80 //----------
81 sst.str("");
82 sst << "Histogram of Calo pattern trigger " << base.Data();
83 TH1S *PatternTrig0Histo = new TH1S("PatternTrig0Histo", sst.str().c_str(), 4, 0, 4);
84
85 TCanvas *PatternTrig1 = new TCanvas("PatternTrig1","PatternTrig1", 1280, 1024);
86 //----------
87 sst.str("");
88 sst << "Histogram of S4 pattern trigger " << base.Data();
89 TH1S *PatternTrig1Histo = new TH1S("PatternTrig1Histo", sst.str().c_str(), 3, 0, 3);
90
91
92 TCanvas *PatternTrig2 = new TCanvas("PatternTrig2","PatternTrig2", 1280, 1024);
93 //----------
94 sst.str("");
95 sst << "Histogram of S3 pattern trigger " << base.Data();
96 TH1S *PatternTrig2Histo = new TH1S("PatternTrig2Histo", sst.str().c_str(), 12, 0, 12);
97
98
99 TCanvas *PatternTrig3 = new TCanvas("PatternTrig3","PatternTrig3", 1280, 1024);
100 //----------
101 sst.str("");
102 sst << "Histogram of S2 pattern trigger " << base.Data();
103 TH1S *PatternTrig3Histo = new TH1S("PatternTrig3Histo", sst.str().c_str(), 8, 0, 8);
104
105
106 TCanvas *PatternTrig4 = new TCanvas("PatternTrig4","PatternTrig4", 1280, 1024);
107 //----------
108 sst.str("");
109 sst << "Histogram of S12 pattern trigger " << base.Data();
110 TH1S *PatternTrig4Histo = new TH1S("PatternTrig4Histo", sst.str().c_str(), 12, 0, 12);
111
112
113 TCanvas *PatternTrig5 = new TCanvas("PatternTrig5","PatternTrig5", 1280, 1024);
114 //----------
115 sst.str("");
116 sst << "Histogram of S11 pattern trigger " << base.Data();
117 TH1S *PatternTrig5Histo = new TH1S("PatternTrig5Histo", sst.str().c_str(), 16, 0, 16);
118
119 int i = 0;
120
121 while(i < nevents){
122 HeadBr->GetEntry(i);
123 TrigBr->GetEntry(i);
124
125 gStyle->SetStatY(0.85);
126
127 int trte0=(int)triggerEvent->patterntrig[0];
128
129 PatternTrig0Histo->AddBinContent(1,bit(trte0,0));
130 PatternTrig0Histo->AddBinContent(2,bit(trte0,1));
131 PatternTrig0Histo->AddBinContent(3,bit(trte0,2));
132 PatternTrig0Histo->AddBinContent(4,bit(trte0,3));
133
134 int trte1=(int)triggerEvent->patterntrig[1];
135
136 PatternTrig1Histo->AddBinContent(1,bit(trte1,0));
137
138 int trte2=(int)triggerEvent->patterntrig[2];
139
140 PatternTrig2Histo->AddBinContent(1,bit(trte2,0));
141 PatternTrig2Histo->AddBinContent(2,bit(trte2,1));
142 PatternTrig2Histo->AddBinContent(3,bit(trte2,2));
143 PatternTrig2Histo->AddBinContent(4,bit(trte2,3));
144 PatternTrig2Histo->AddBinContent(5,bit(trte2,4));
145 PatternTrig2Histo->AddBinContent(6,bit(trte2,5));
146 PatternTrig2Histo->AddBinContent(7,bit(trte2,6));
147 PatternTrig2Histo->AddBinContent(8,bit(trte2,7));
148 PatternTrig2Histo->AddBinContent(9,bit(trte2,8));
149 PatternTrig2Histo->AddBinContent(10,bit(trte2,9));
150 PatternTrig2Histo->AddBinContent(11,bit(trte2,10));
151 PatternTrig2Histo->AddBinContent(12,bit(trte2,11));
152 PatternTrig2Histo->AddBinContent(13,bit(trte2,12));
153 PatternTrig2Histo->AddBinContent(14,bit(trte2,13));
154 PatternTrig2Histo->AddBinContent(15,bit(trte2,14));
155 PatternTrig2Histo->AddBinContent(16,bit(trte2,15));
156
157 int trte3=(int)triggerEvent->patterntrig[3];
158
159
160 PatternTrig3Histo->AddBinContent(1,bit(trte3,0));
161 PatternTrig3Histo->AddBinContent(2,bit(trte3,1));
162 PatternTrig3Histo->AddBinContent(3,bit(trte3,2));
163 PatternTrig3Histo->AddBinContent(4,bit(trte3,3));
164 PatternTrig3Histo->AddBinContent(5,bit(trte3,4));
165 PatternTrig3Histo->AddBinContent(6,bit(trte3,5));
166 PatternTrig3Histo->AddBinContent(7,bit(trte3,6));
167 PatternTrig3Histo->AddBinContent(8,bit(trte3,7));
168 PatternTrig3Histo->AddBinContent(9,bit(trte3,8));
169 PatternTrig3Histo->AddBinContent(10,bit(trte3,9));
170 PatternTrig3Histo->AddBinContent(11,bit(trte3,10));
171 PatternTrig3Histo->AddBinContent(12,bit(trte3,11));
172 PatternTrig3Histo->AddBinContent(13,bit(trte3,12));
173 PatternTrig3Histo->AddBinContent(14,bit(trte3,13));
174 PatternTrig3Histo->AddBinContent(15,bit(trte3,14));
175 PatternTrig3Histo->AddBinContent(16,bit(trte3,15));
176
177 int trte4=(int)triggerEvent->patterntrig[4];
178
179
180 PatternTrig4Histo->AddBinContent(1,bit(trte4,0));
181 PatternTrig4Histo->AddBinContent(2,bit(trte4,1));
182 PatternTrig4Histo->AddBinContent(3,bit(trte4,2));
183 PatternTrig4Histo->AddBinContent(4,bit(trte4,3));
184 PatternTrig4Histo->AddBinContent(5,bit(trte4,4));
185 PatternTrig4Histo->AddBinContent(6,bit(trte4,5));
186 PatternTrig4Histo->AddBinContent(7,bit(trte4,6));
187 PatternTrig4Histo->AddBinContent(8,bit(trte4,7));
188 PatternTrig4Histo->AddBinContent(9,bit(trte4,8));
189 PatternTrig4Histo->AddBinContent(10,bit(trte4,9));
190 PatternTrig4Histo->AddBinContent(11,bit(trte4,10));
191 PatternTrig4Histo->AddBinContent(12,bit(trte4,11));
192 PatternTrig4Histo->AddBinContent(13,bit(trte4,12));
193 PatternTrig4Histo->AddBinContent(14,bit(trte4,13));
194 PatternTrig4Histo->AddBinContent(15,bit(trte4,14));
195 PatternTrig4Histo->AddBinContent(16,bit(trte4,15));
196
197 int trte5=(int)triggerEvent->patterntrig[5];
198
199
200 PatternTrig5Histo->AddBinContent(1,bit(trte5,0));
201 PatternTrig5Histo->AddBinContent(2,bit(trte5,1));
202 PatternTrig5Histo->AddBinContent(3,bit(trte5,2));
203 PatternTrig5Histo->AddBinContent(4,bit(trte5,3));
204 PatternTrig5Histo->AddBinContent(5,bit(trte5,4));
205 PatternTrig5Histo->AddBinContent(6,bit(trte5,5));
206 PatternTrig5Histo->AddBinContent(7,bit(trte5,6));
207 PatternTrig5Histo->AddBinContent(8,bit(trte5,7));
208 PatternTrig5Histo->AddBinContent(9,bit(trte5,8));
209 PatternTrig5Histo->AddBinContent(10,bit(trte5,9));
210 PatternTrig5Histo->AddBinContent(11,bit(trte5,10));
211 PatternTrig5Histo->AddBinContent(12,bit(trte5,11));
212 PatternTrig5Histo->AddBinContent(13,bit(trte5,12));
213 PatternTrig5Histo->AddBinContent(14,bit(trte5,13));
214 PatternTrig5Histo->AddBinContent(15,bit(trte5,14));
215 PatternTrig5Histo->AddBinContent(16,bit(trte5,15));
216
217 i++;
218 }
219
220
221 gStyle->SetOptStat(111111);
222 gStyle->SetStatH(0.15);
223 gStyle->SetStatW(0.15);
224
225 /* Pattern Trigger draw*/
226
227 gStyle->SetOptStat("mr");
228
229
230 PatternTrig5->cd();
231 PatternTrig5Histo->SetMinimum(0.);
232 PatternTrig5Histo->Draw("");
233
234 PatternTrig4->cd();
235 PatternTrig4Histo->SetMinimum(0.);
236 PatternTrig4Histo->Draw("");
237
238 PatternTrig3->cd();
239 PatternTrig3Histo->SetMinimum(0.);
240 PatternTrig3Histo->Draw("");
241
242 PatternTrig2->cd();
243 PatternTrig2Histo->SetMinimum(0.);
244 PatternTrig2Histo->Draw("");
245
246 PatternTrig0->cd();
247 PatternTrig0Histo->SetMinimum(0.);
248 PatternTrig0Histo->Draw("");
249
250 PatternTrig1->cd();
251 PatternTrig1Histo->SetMinimum(0.);
252 PatternTrig1Histo->Draw("");
253
254
255 gStyle->SetOptStat("mr");
256 gStyle->SetStatH(0.3);
257 gStyle->SetStatW(0.3);
258
259 // print the output
260 const char *saveas = format;
261 if ( !strcmp(saveas,"ps") ) {
262 // ------print the ps
263
264 gStyle->SetOptStat(111111);
265
266 sst.str("");
267 sst << outDirectory.Data() << filename.Data() << "TriggerScanExpert." << saveas << "(";
268 gStyle->SetOptStat("mr");
269
270 PatternTrig5->Print(sst.str().c_str());
271 PatternTrig4->Print(sst.str().c_str());
272 PatternTrig3->Print(sst.str().c_str());
273 PatternTrig2->Print(sst.str().c_str());
274 PatternTrig0->Print(sst.str().c_str());
275 //
276 sst.str("");
277 sst << outDirectory.Data() << filename.Data() << "TriggerScanExpert." << saveas << ")";
278 PatternTrig1->Print(sst.str().c_str());
279
280 } else {
281
282 gStyle->SetOptStat("mr");
283
284 sst.str("");
285 sst << outDirectory.Data() << filename.Data() << "TriggerScanExpert1." << saveas;
286 PatternTrig5->SaveAs(sst.str().c_str());
287
288 sst.str("");
289 sst << outDirectory.Data() << filename.Data() << "TriggerScanExpert2." << saveas;
290 PatternTrig4->SaveAs(sst.str().c_str());
291
292 sst.str("");
293 sst << outDirectory.Data() << filename.Data() << "TriggerScanExpert3." << saveas;
294 PatternTrig3->SaveAs(sst.str().c_str());
295
296 sst.str("");
297 sst << outDirectory.Data() << filename.Data() << "TriggerScanExpert4." << saveas;
298 PatternTrig2->SaveAs(sst.str().c_str());
299
300 sst.str("");
301 sst << outDirectory.Data() << filename.Data() << "TriggerScanExpert5." << saveas;
302 PatternTrig0->SaveAs(sst.str().c_str());
303
304 sst.str("");
305 sst << outDirectory.Data() << filename.Data() << "TriggerScanExpert6." << saveas;
306 PatternTrig1->SaveAs(sst.str().c_str());
307 }
308
309 }
310
311
312 int main(int argc, char* argv[]){
313 TString path;
314 TString outDir ="./";
315 TString format ="ps";
316
317 if (argc < 2){
318 printf("You have to insert at least the file to analyze \n");
319 printf("Try '--help' for more information. \n");
320 exit(1);
321 }
322
323 if (!strcmp(argv[1], "--help")){
324 printf( "Usage: TriggerScanExpert FILE [OPTION] \n");
325 printf( "\t --help Print this help and exit \n");
326 printf( "\t -outDir[path] Path where to put the output [default ./] \n");
327 printf( "\t -format[ps] Format for output files [default 'ps'] \n");
328 exit(1);
329 }
330
331
332 path=argv[1];
333
334 for (int i = 2; i < argc; i++){
335
336 if (!strcmp(argv[i], "-outDir")){
337 if (++i >= argc){
338 printf( "-outDir needs arguments. \n");
339 printf( "Try '--help' for more information. \n");
340 exit(1);
341 }
342 else{
343 outDir = argv[i];
344 continue;
345 }
346 }
347
348
349
350 if (!strcmp(argv[i], "-format")){
351 if (++i >= argc){
352 printf( "-format needs arguments. \n");
353 printf( "Try '--help' for more information. \n");
354 exit(1);
355 }
356 else{
357 format = argv[i];
358 continue;
359 }
360 }
361 }
362
363 TriggerScanExpert(argv[1], outDir, format);
364
365 }

  ViewVC Help
Powered by ViewVC 1.1.23