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 | //
|
---|
15 | void 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 |
|
---|
41 | MGeomCamMagic geocam;
|
---|
42 | parlist.AddToList(&geocam);
|
---|
43 |
|
---|
44 | // MHillas hillas;
|
---|
45 | // parlist.AddToList(&hillas);
|
---|
46 |
|
---|
47 | // An instance of the class MMcTriggerLvl2 is created and added to the
|
---|
48 | // parameter list
|
---|
49 | MMcTriggerLvl2 cell;
|
---|
50 | parlist.AddToList(&cell);
|
---|
51 |
|
---|
52 | MMcEvt mevt;
|
---|
53 | parlist.AddToList(&mevt);
|
---|
54 |
|
---|
55 | // Set the number of Next Neighbourhoods that define a compact pixel
|
---|
56 | //
|
---|
57 | cell.SetCompactNN(2);
|
---|
58 | // USER: --^
|
---|
59 |
|
---|
60 | //
|
---|
61 | // A filter to select events using the L2T parameters is created
|
---|
62 | //
|
---|
63 |
|
---|
64 | // MF lvl2filter("MMcTriggerLvl2.fPseudoSize > 25 && MMcTriggerLvl2.fPseudoSize < 31");
|
---|
65 | MF lvl2filter("MMcTriggerLvl2.fPseudoSize > 15");
|
---|
66 |
|
---|
67 | //
|
---|
68 | // A second filter is created using the class MFTriggerLvl2
|
---|
69 | //
|
---|
70 | MFTriggerLvl2 fTrig("MMcTriggerLvl2", '>', 8);
|
---|
71 | // USER: fValue to be compared --^
|
---|
72 |
|
---|
73 | //
|
---|
74 | // A selection on the number and energy of the events
|
---|
75 | //
|
---|
76 | MF energyfilter("MMcEvt.fEnergy > 100");
|
---|
77 | MFEventSelector selector;
|
---|
78 | //selector.SetNumSelectEvts(4000);
|
---|
79 |
|
---|
80 |
|
---|
81 | // Filter to select events according to a give slope
|
---|
82 | MFEnergySlope eslope;
|
---|
83 |
|
---|
84 | eslope.SetMcMinEnergy(50.);
|
---|
85 | eslope.SetMcMaxEnergy(400.);
|
---|
86 | eslope.SetNewSlope(-.5);
|
---|
87 |
|
---|
88 | // A filter list is created; the filters created can be added to the list
|
---|
89 | //
|
---|
90 | MFilterList flist;
|
---|
91 | //flist.AddToList(&energyfilter);
|
---|
92 | //flist.AddToList(&lvl2filter);
|
---|
93 | // flist.AddToList(&selector);
|
---|
94 | // flist.AddToList(&eslope);
|
---|
95 | // flist.AddToList(&fTrig);
|
---|
96 |
|
---|
97 |
|
---|
98 |
|
---|
99 | //
|
---|
100 | // The task to calculate the L2T parameter is added to the task list
|
---|
101 | //
|
---|
102 | MMcTriggerLvl2Calc calcps("MMcTriggerLvl2","MMcTriggerLvl2");
|
---|
103 | tasklist.AddToList(&calcps);
|
---|
104 |
|
---|
105 | //
|
---|
106 | // The filter list is added to the task list
|
---|
107 | //
|
---|
108 | tasklist.AddToList(&flist);
|
---|
109 |
|
---|
110 | //
|
---|
111 | // Task to calculate and plot the effective area
|
---|
112 | //
|
---|
113 | MMcCollectionAreaCalc effi;
|
---|
114 | tasklist.AddToList(&effi);
|
---|
115 | //
|
---|
116 | // The filter list selects events for the effective area calculation
|
---|
117 | //
|
---|
118 | effi.SetFilter(&flist);
|
---|
119 |
|
---|
120 |
|
---|
121 | //
|
---|
122 | // Filling of histos for MHMcTriggerLvl2
|
---|
123 | //
|
---|
124 | MFillH hfill1("MHMcTriggerLvl2","MMcTriggerLvl2");
|
---|
125 | tasklist.AddToList(&hfill1);
|
---|
126 | //hfill1.SetFilter(&flist);
|
---|
127 | //MFillH hfill2("MHMcTriggerLvl2", &mevt, &cell);
|
---|
128 | //tasklist.AddToList(&hfill2);
|
---|
129 | //hfill2.SetFilter(&flist);
|
---|
130 |
|
---|
131 |
|
---|
132 |
|
---|
133 | //
|
---|
134 | // set up the loop for the processing
|
---|
135 | //
|
---|
136 | MEvtLoop magic;
|
---|
137 | magic.SetParList(&parlist);
|
---|
138 |
|
---|
139 |
|
---|
140 | //
|
---|
141 | // Start to loop over all events
|
---|
142 | //
|
---|
143 | MProgressBar bar;
|
---|
144 | magic.SetProgressBar(&bar);
|
---|
145 |
|
---|
146 |
|
---|
147 | if (!magic.Eventloop())
|
---|
148 | return;
|
---|
149 | /*
|
---|
150 | if (!magic.PreProcess())
|
---|
151 | return;
|
---|
152 |
|
---|
153 | while (tasklist.Process())
|
---|
154 | {
|
---|
155 | cout<< mevt.GetEnergy()<<endl;
|
---|
156 |
|
---|
157 | cell.Print();
|
---|
158 | }
|
---|
159 | */
|
---|
160 | //fMcEvt = (MMcEvt*)parlist->FindObject("MMcEvt");
|
---|
161 | //if (!fMcEvt)
|
---|
162 | //{
|
---|
163 | //cout << "MMcEvt not found... exit." << endl;
|
---|
164 | //*fLog << err << dbginf << "MMcEvt not found... exit." << endl;
|
---|
165 | // return kFALSE;
|
---|
166 | //}
|
---|
167 | // cout << "fMcEvt = " << fMcEvt << endl;
|
---|
168 |
|
---|
169 | //parlist.FindObject("MHMcTriggerLvl2")->Fill((Double_t) fMcEvt->GetEnergy(), cell);
|
---|
170 |
|
---|
171 |
|
---|
172 | tasklist.PrintStatistics();
|
---|
173 |
|
---|
174 | //
|
---|
175 | // Now the histogram we wanted to get out of the data is
|
---|
176 | // filled and can be displayd
|
---|
177 | //
|
---|
178 | parlist.FindObject("MHMcCollectionArea")->DrawClone();
|
---|
179 |
|
---|
180 | parlist.FindObject("MHMcTriggerLvl2")->DrawClone("sbc");
|
---|
181 | parlist.FindObject("MHMcTriggerLvl2")->DrawClone("lps");
|
---|
182 | parlist.FindObject("MHMcTriggerLvl2")->DrawClone();
|
---|
183 | //parlist.FindObject("MHMcTriggerLvl2")->DrawClone("energy");
|
---|
184 | parlist.FindObject("MHMcTriggerLvl2")->DrawClone("size-energy");
|
---|
185 |
|
---|
186 | // Returns histogram of the class MHMcTriggerLvl2
|
---|
187 |
|
---|
188 | MHMcTriggerLvl2 *htrig = (MHMcTriggerLvl2 *)parlist.FindObject("MHMcTriggerLvl2");
|
---|
189 | TH1F *h1 = (TH1F *)htrig->GetHistByName("fHistPseudoSize");
|
---|
190 | TH2D *h2 = htrig->GetHistSizeBiggerCellEnergy();
|
---|
191 | TH2D *h3 = (TH2D *)htrig->GetHistByName("fHistLutPseudoSizeEnergy");
|
---|
192 | //csbce = new TCanvas();
|
---|
193 | //h2->DrawClone();
|
---|
194 |
|
---|
195 | hfile = new TFile("HistFileLUT.root", "RECREATE");
|
---|
196 | h1->Write();
|
---|
197 | h2->Write();
|
---|
198 | h3->Write();
|
---|
199 | hfile->Close();
|
---|
200 |
|
---|
201 | }
|
---|
202 |
|
---|
203 |
|
---|
204 |
|
---|