1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
|
---|
19 | ! Author(s): Thomas Bretz 12/2000 (tbretz@uni-sw.gwdg.de)
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | #include "MMcTriggerRateCalc.h"
|
---|
27 |
|
---|
28 | #include "MLog.h"
|
---|
29 | #include "MLogManip.h"
|
---|
30 | #include "MParList.h"
|
---|
31 |
|
---|
32 | #include "MMcTrig.hxx"
|
---|
33 | #include "MHMcRate.h"
|
---|
34 |
|
---|
35 | ClassImp(MMcTriggerRateCalc)
|
---|
36 |
|
---|
37 | // --------------------------------------------------------------------------
|
---|
38 | //
|
---|
39 | // default constructor
|
---|
40 | // set member data to initial values
|
---|
41 | //
|
---|
42 | MMcTriggerRateCalc::MMcTriggerRateCalc (const char *name, const char *title)
|
---|
43 | {
|
---|
44 | // default constructor
|
---|
45 | *fName = name ? name : "MMcTriggerRateCalc";
|
---|
46 | *fTitle = title ? title : "Task to calc the trigger rate";
|
---|
47 |
|
---|
48 | fDimension=0;
|
---|
49 | for (int i=0;i<10;i++){
|
---|
50 | fTrigger[i]=0;
|
---|
51 | }
|
---|
52 | fShowers = 0;
|
---|
53 | fAnalShow = 100000;
|
---|
54 |
|
---|
55 | fPartId=14;
|
---|
56 |
|
---|
57 | fSpecInd=2.75;
|
---|
58 | fFlux0=10.92e-2;
|
---|
59 | }
|
---|
60 |
|
---|
61 | // --------------------------------------------------------------------------
|
---|
62 | //
|
---|
63 | // overloaded constructor I
|
---|
64 | //
|
---|
65 | // dim: fDimension
|
---|
66 | // part: fPartId
|
---|
67 | // *trigbg: number of shower from bacground that triggers
|
---|
68 | // a given trigger condition.
|
---|
69 | // simbg: Number of simulated showers for the bacground
|
---|
70 | // rate: rate of incident showers
|
---|
71 | //
|
---|
72 | MMcTriggerRateCalc::MMcTriggerRateCalc (int dim, int part, float *trigbg,
|
---|
73 | float simbg, float rate,
|
---|
74 | const char *name, const char *title)
|
---|
75 | {
|
---|
76 | *fName = name ? name : "MMcTriggerRateCalc";
|
---|
77 | *fTitle = title ? title : "Task to calc the trigger rate ";
|
---|
78 |
|
---|
79 | fDimension=dim;
|
---|
80 |
|
---|
81 | for (int i=0;i<10;i++){
|
---|
82 | fTrigger[i]=trigbg[i];
|
---|
83 | }
|
---|
84 |
|
---|
85 | fShowers = 0;
|
---|
86 | fAnalShow = simbg;
|
---|
87 |
|
---|
88 | fPartId=part;
|
---|
89 |
|
---|
90 | fSpecInd=rate;
|
---|
91 | fFlux0=0;
|
---|
92 | }
|
---|
93 |
|
---|
94 | // --------------------------------------------------------------------------
|
---|
95 | //
|
---|
96 | // overloaded constructor II
|
---|
97 | //
|
---|
98 | // dim: fDimension
|
---|
99 | // part: fPartId
|
---|
100 | // *trigbg: number of shower from bacground that triggers
|
---|
101 | // a given trigger condition.
|
---|
102 | // simbg: Number of simulated showers for the bacground
|
---|
103 | // spec: sSpecInd
|
---|
104 | // flux0; fFlux0
|
---|
105 | //
|
---|
106 | MMcTriggerRateCalc::MMcTriggerRateCalc (int dim, int part, float *trigbg,
|
---|
107 | float simbg, float spec, float flux0,
|
---|
108 | const char *name, const char *title)
|
---|
109 | {
|
---|
110 | *fName = name ? name : "MMcTriggerRateCalc";
|
---|
111 | *fTitle = title ? title : "Task to calc the trigger rate ";
|
---|
112 |
|
---|
113 | fDimension=dim;
|
---|
114 |
|
---|
115 | for (int i=0;i<10;i++){
|
---|
116 | fTrigger[i]=trigbg[i];
|
---|
117 | }
|
---|
118 |
|
---|
119 | fShowers = 0;
|
---|
120 | fAnalShow = simbg;
|
---|
121 |
|
---|
122 | fPartId=part;
|
---|
123 |
|
---|
124 | fSpecInd=spec;
|
---|
125 | fFlux0=flux0;
|
---|
126 | }
|
---|
127 |
|
---|
128 | // --------------------------------------------------------------------------
|
---|
129 | //
|
---|
130 | // The PreProcess connects the raw data with this task. It checks if the
|
---|
131 | // input containers exist, if not a kFalse flag is returned. It also checks
|
---|
132 | // if the output contaniers exist, if not they are created.
|
---|
133 | // This task can read either Montecarlo files with multiple trigger
|
---|
134 | // options, either Montecarlo files with a single trigger option.
|
---|
135 | //
|
---|
136 | Bool_t MMcTriggerRateCalc::PreProcess (MParList *pList)
|
---|
137 | {
|
---|
138 | // connect the raw data with this task
|
---|
139 | int i; // bucle variable
|
---|
140 | char auxname[15]; // string to write container names
|
---|
141 |
|
---|
142 | fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
|
---|
143 | if (!fMcEvt)
|
---|
144 | {
|
---|
145 | *fLog << dbginf << "MMcEvt not found... aborting." << endl;
|
---|
146 | return kFALSE;
|
---|
147 | }
|
---|
148 |
|
---|
149 | if(fDimension>0)
|
---|
150 | for(i=0;i<fDimension;i++){
|
---|
151 | sprintf(auxname,"MMcTrig;%i",i+1);
|
---|
152 | fMcTrig[i] = (MMcTrig*)pList->FindObject(auxname);
|
---|
153 | if (!fMcTrig[i])
|
---|
154 | {
|
---|
155 | *fLog << dbginf << "MMcTrig not found... aborting." << endl;
|
---|
156 | return kFALSE;
|
---|
157 | }
|
---|
158 | sprintf(auxname,"MHMcRate;%i",i+1);
|
---|
159 | fMcRate[i] = (MHMcRate*)pList->FindCreateObj(auxname);
|
---|
160 | if (!fMcTrig[i])
|
---|
161 | {
|
---|
162 | return kFALSE;
|
---|
163 | }
|
---|
164 | fMcRate[i]->SetParticle(fPartId);
|
---|
165 | fMcRate[i]->SetBackground(fTrigger[i],fAnalShow);
|
---|
166 | fTrigger[i]=0;
|
---|
167 | }
|
---|
168 | else if (fDimension==0)
|
---|
169 | {
|
---|
170 | fMcTrig[0] = (MMcTrig*)pList->FindObject("MMcTrig");
|
---|
171 | if (!fMcTrig[0])
|
---|
172 | {
|
---|
173 | *fLog << dbginf << "MMcTrig not found... aborting." << endl;
|
---|
174 | return kFALSE;
|
---|
175 | }
|
---|
176 | fMcRate[0] = (MHMcRate*)pList->FindCreateObj("MHMcRate");
|
---|
177 | if (!fMcTrig[0])
|
---|
178 | {
|
---|
179 | return kFALSE;
|
---|
180 | }
|
---|
181 | fMcRate[0]->SetParticle(fPartId);
|
---|
182 | fMcRate[0]->SetBackground(fTrigger[0],fAnalShow);
|
---|
183 | fTrigger[0]=0;
|
---|
184 | fDimension=1;
|
---|
185 | }
|
---|
186 | else
|
---|
187 | {
|
---|
188 | sprintf(auxname,"MMcTrig;%i.",-fDimension);
|
---|
189 | fMcTrig[0] = (MMcTrig*)pList->FindObject(auxname);
|
---|
190 | if (!fMcTrig[0])
|
---|
191 | {
|
---|
192 | *fLog << dbginf << "MMcTrig not found... aborting." << endl;
|
---|
193 | return kFALSE;
|
---|
194 | }
|
---|
195 | sprintf(auxname,"MHMcRate;%i.",-fDimension);
|
---|
196 | fMcRate[0] = (MHMcRate*)pList->FindCreateObj(auxname);
|
---|
197 | if (!fMcTrig[0])
|
---|
198 | {
|
---|
199 | return kFALSE;
|
---|
200 | }
|
---|
201 | fMcRate[0]->SetParticle(fPartId);
|
---|
202 | fMcRate[0]->SetBackground(fTrigger[0],fAnalShow);
|
---|
203 | fTrigger[0]=0;
|
---|
204 | fDimension=1;
|
---|
205 | }
|
---|
206 |
|
---|
207 | fAnalShow=0.0;
|
---|
208 | *fLog<<dbginf<< "Pre Process done"<<endl;
|
---|
209 |
|
---|
210 | return kTRUE ;
|
---|
211 |
|
---|
212 | }
|
---|
213 |
|
---|
214 | // --------------------------------------------------------------------------
|
---|
215 | //
|
---|
216 | // The Process-function counts the number of simulated showers, the
|
---|
217 | // number of analised showers and the number of triggers. It also updates
|
---|
218 | // the limits for theta, phi, energy and impact parameter in the
|
---|
219 | // MHMcRate container.
|
---|
220 | //
|
---|
221 | Bool_t MMcTriggerRateCalc::Process ()
|
---|
222 | {
|
---|
223 | Float_t Ener, Theta, Phi, Param;
|
---|
224 |
|
---|
225 | // Counting analysed and simulated showers
|
---|
226 |
|
---|
227 | fShowers++;
|
---|
228 | if (fMcEvt->GetPhotElfromShower()) fAnalShow++;
|
---|
229 |
|
---|
230 | // Getting angles, energy and impact parameter to set boundaries
|
---|
231 |
|
---|
232 | Theta=fMcEvt->GetTheta();
|
---|
233 | Phi=fMcEvt->GetPhi();
|
---|
234 | Param=fMcEvt->GetImpact();
|
---|
235 | Ener=fMcEvt->GetEnergy()/1000.0;
|
---|
236 |
|
---|
237 | // Counting number of triggers
|
---|
238 |
|
---|
239 | for(int i=0;i<fDimension;i++){
|
---|
240 | fTrigger[i]=fTrigger[i]+fMcTrig[i]->GetFirstLevel();
|
---|
241 | fMcRate[i]->Boundaries(Ener, Theta, Phi, Param);
|
---|
242 | }
|
---|
243 |
|
---|
244 | return kTRUE ;
|
---|
245 | }
|
---|
246 |
|
---|
247 | // --------------------------------------------------------------------------
|
---|
248 | //
|
---|
249 | // The PostProcess-function calculates and shows the trigger rate
|
---|
250 | //
|
---|
251 | Bool_t MMcTriggerRateCalc::PostProcess ()
|
---|
252 | {
|
---|
253 | // Computing trigger rate and showing it
|
---|
254 | for(int i=0;i<fDimension;i++){
|
---|
255 | fMcRate[i]->CalcRate(fTrigger[i],fAnalShow,fShowers);
|
---|
256 | fMcRate[i]->Print();
|
---|
257 | fMcRate[i]->Draw("S");
|
---|
258 | }
|
---|
259 |
|
---|
260 | return kTRUE ;
|
---|
261 | }
|
---|
262 |
|
---|
263 |
|
---|
264 |
|
---|