source: trunk/Mars/macros/triglvl2.C@ 13414

Last change on this file since 13414 was 2489, checked in by galante, 21 years ago
*** empty log message ***
File size: 6.4 KB
Line 
1// triglvl2.C
2// Macro to use the class MMcTriggerLvl2, which calculates the
3// 2nd level trigger (L2T) selection parameters.
4// Filters to select events using these parameter and
5// histograms with selection variables distributions are also created.
6//
7// Inputs:
8// - filename name of data file
9// - CompactNN number of NN to define a compact pixel
10// - fValue comparision value for the filter
11//
12// 23/04/2003 Added example of MFEnergySlope filter
13//
14//
15void triglvl2(char *filename = "Gamma.root")
16 // USER: Data File Name ---^
17{
18 //
19 // first we have to create our empty lists
20 //
21 MParList parlist;
22 MTaskList tasklist;
23
24 parlist.AddToList(&tasklist);
25
26 //
27 // Setup our tasks:
28 // - First we have to read the events
29 // - Then we can fill the efficiency histograms
30 //
31
32
33 MReadMarsFile reader("Events", filename);
34 reader.DisableAutoScheme();
35 // reader.EnableBranch("fEnergy");
36 // reader.EnableBranch("fImpact"); reader.EnableBranch("fTimeFirst[4]");
37 // reader.EnableBranch("fPixelsFirst[73][4]");
38
39 tasklist.AddToList(&reader);
40 MGeomCamMagic geocam;
41 parlist.AddToList(&geocam);
42
43 // MHillas hillas;
44 // parlist.AddToList(&hillas);
45
46 // An instance of the class MMcTriggerLvl2 is created and added to the
47 // parameter list
48 MMcTriggerLvl2 cell;
49 parlist.AddToList(&cell);
50
51 MMcEvt mevt;
52 parlist.AddToList(&mevt);
53
54 // Set the number of Next Neighbourhoods that define a compact pixel
55 //
56 cell.SetCompactNN(3);
57 // USER: --^
58
59 //
60 // A filter to select events using the L2T parameters is created
61 //
62 // MF lvl2filter("MMcTriggerLvl2.fPseudoSize > 25 && MMcTriggerLvl2.fPseudoSize < 31");
63 // MF lvl2filter("MMcTriggerLvl2.fSizeBiggerCell > 34");
64 MF lvl2filter("MMcTriggerLvl2.fSizeBiggerCell > 18");
65
66 //
67 // A second filter is created using the class MFTriggerLvl2
68 //
69 MFTriggerLvl2 fTrig("MMcTriggerLvl2", '>', 8);
70 // USER: fValue to be compared --^
71
72 //
73 // A selection on the number and energy of the events
74 //
75 MF energyfilter("MMcEvt.fEnergy > 100");
76 MFEventSelector selector;
77 //selector.SetNumSelectEvts(4000);
78
79
80 // Filter to select events according to a give slope
81 MFEnergySlope eslope;
82
83 eslope.SetMcMinEnergy(50.);
84 eslope.SetMcMaxEnergy(400.);
85 eslope.SetNewSlope(-.5);
86
87 // A filter list is created; the filters created can be added to the list
88 //
89 MFilterList flist;
90 //flist.AddToList(&energyfilter);
91 flist.AddToList(&lvl2filter);
92 // flist.AddToList(&selector);
93 // flist.AddToList(&eslope);
94 // flist.AddToList(&fTrig);
95
96 //
97 // The task to calculate the L2T parameter is added to the task list
98 //
99 MMcTriggerLvl2Calc calcps("MMcTriggerLvl2","MMcTriggerLvl2");
100 tasklist.AddToList(&calcps);
101
102 //
103 // The filter list is added to the task list
104 //
105 tasklist.AddToList(&flist);
106
107
108 MContinue L1offline ("MMcTriggerLvl2.fLutPseudoSize < 6");
109 // tasklist.AddToList(&L1offline);
110
111 //
112 // Task to calculate and plot the effective area
113 //
114 MMcCollectionAreaCalc effi;
115 tasklist.AddToList(&effi);
116 //
117 // The filter list selects events for the effective area calculation
118 //
119 effi.SetFilter(&flist);
120
121
122 //
123 // Filling of histos for MHMcTriggerLvl2
124 //
125 MFillH hfill1("MHMcTriggerLvl2","MMcTriggerLvl2");
126 tasklist.AddToList(&hfill1);
127 //hfill1.SetFilter(&flist);
128 //MFillH hfill2("MHMcTriggerLvl2", &mevt, &cell);
129 //tasklist.AddToList(&hfill2);
130 //hfill2.SetFilter(&flist);
131
132
133
134 //
135 // set up the loop for the processing
136 //
137 MEvtLoop magic;
138 magic.SetParList(&parlist);
139
140
141 //
142 // Start to loop over all events
143 //
144 MProgressBar bar;
145 magic.SetProgressBar(&bar);
146
147
148 if (!magic.Eventloop())
149 return;
150 /*
151 if (!magic.PreProcess())
152 return;
153
154 while (tasklist.Process())
155 {
156 cout<< mevt.GetEnergy()<<endl;
157
158 cell.Print();
159 }
160 */
161 //fMcEvt = (MMcEvt*)parlist->FindObject("MMcEvt");
162 //if (!fMcEvt)
163 //{
164 //cout << "MMcEvt not found... exit." << endl;
165 //*fLog << err << dbginf << "MMcEvt not found... exit." << endl;
166 // return kFALSE;
167 //}
168 // cout << "fMcEvt = " << fMcEvt << endl;
169
170 //parlist.FindObject("MHMcTriggerLvl2")->Fill((Double_t) fMcEvt->GetEnergy(), cell);
171
172
173 tasklist.PrintStatistics();
174
175 //
176 // Now the histogram we wanted to get out of the data is
177 // filled and can be displayd
178 //
179
180
181 //parlist.FindObject("MHMcTriggerLvl2")->DrawClone("sbc");
182 //parlist.FindObject("MHMcTriggerLvl2")->DrawClone("lps");
183 //parlist.FindObject("MHMcTriggerLvl2")->DrawClone();
184 //parlist.FindObject("MHMcTriggerLvl2")->DrawClone("energy");
185 //parlist.FindObject("MHMcTriggerLvl2")->DrawClone("lut-energy");
186 //parlist.FindObject("MHMcCollectionArea")->DrawClone();
187 // Returns histogram of the class MHMcTriggerLvl2
188
189 MHMcTriggerLvl2 *htrig = (MHMcTriggerLvl2 *)parlist.FindObject("MHMcTriggerLvl2");
190 MHMcCollectionArea *collarea = (MHMcCollectionArea *)parlist.FindObject("MHMcCollectionArea");
191 TH1F *hps = (TH1F *)htrig->GetHistByName("fHistPseudoSize");
192 TH1F *hlps = (TH1F *)htrig->GetHistByName("fHistLutPseudoSize");
193 TH1F *hsbc = (TH1F *)htrig->GetHistSizeBiggerCell();
194 TH1F *hpsn = (TH1F *)htrig->GetHistByName("fHistPseudoSizeNorm");
195 TH1F *hlpsn = (TH1F *)htrig->GetHistByName("fHistLutPseudoSizeNorm");
196 TH1F *hsbcn = (TH1F *)htrig->GetHistSizeBiggerCellNorm();
197 TH2D *hlpse = (TH2D *)htrig->GetHistByName("fHistLutPseudoSizeEnergy");
198 TH2D *hpse = (TH2D *)htrig->GetHistByName("fHistPseudoSizeEnergy");
199 TH2D *hsbce = (TH2D *)htrig->GetHistSizeBiggerCellEnergy();
200 TH1D *hcollarea = collarea->GetHist();
201
202 // Please set rootfile as the directory where you want to store
203 // your file.root containing histograms
204 rootfile = new TString(filename);
205 if (rootfile->Index("/*.root",1)>=0){
206 rootfile->Resize(rootfile->Index("/*.root",1));
207 rootfile[0]+="_sbcmag18_CNN3.root";
208 }
209
210 hfile = new TFile((char *)rootfile[0], "RECREATE");
211 hlps->Write();
212 hps->Write();
213 hsbc->Write();
214 hlpsn->Write();
215 hpsn->Write();
216 hsbcn->Write();
217 hlpse->Write();
218 hpse->Write();
219 hsbce->Write();
220 hcollarea->Write();
221 hfile->Close();
222 cout << "Histograms stored into " << rootfile[0] << endl;
223
224
225}
226
227
228
Note: See TracBrowser for help on using the repository browser.