/[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.1 - (show annotations) (download)
Wed Jun 28 16:43:38 2006 UTC (18 years, 5 months ago) by campana
Branch: MAIN
CVS Tags: v1r06, v1r05
new release of Trigger QLook

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

  ViewVC Help
Powered by ViewVC 1.1.23