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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Fri Feb 2 17:07:34 2007 UTC (17 years, 10 months ago) by campana
Branch: MAIN
CVS Tags: v1r11, v1r10, v1r09
Changes since 1.3: +32 -40 lines
Trigger QLook new release 2007

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

  ViewVC Help
Powered by ViewVC 1.1.23