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

  ViewVC Help
Powered by ViewVC 1.1.23