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): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
|
---|
19 | ! Author(s): Harald Kornmayer 1/2001
|
---|
20 | ! Author(s): Abelardo Moralejo 2/2003
|
---|
21 | !
|
---|
22 | ! Explanations on the rate calculation can be found in
|
---|
23 | ! chapter 7 of the following diploma thesis:
|
---|
24 | ! http://www.pd.infn.it/magic/tesi2.ps.gz (in Italian)
|
---|
25 | !
|
---|
26 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
27 | !
|
---|
28 | !
|
---|
29 | \* ======================================================================== */
|
---|
30 |
|
---|
31 | #include "MHMcRate.h"
|
---|
32 |
|
---|
33 | #include "MLog.h"
|
---|
34 | #include "MLogManip.h"
|
---|
35 |
|
---|
36 | ClassImp(MHMcRate);
|
---|
37 |
|
---|
38 | void MHMcRate::Init(const char *name, const char *title)
|
---|
39 | {
|
---|
40 | fName = name ? name : "MMcTriggerRate";
|
---|
41 | fTitle = title ? title : "Task to calc the collection area ";
|
---|
42 |
|
---|
43 | fPartId=0; // Type of particle
|
---|
44 |
|
---|
45 | fEnergyMax=0.0; // Maximum Energy (TeV)
|
---|
46 | fEnergyMin=1000000.0; // Minimum Energy (TeV)
|
---|
47 |
|
---|
48 | fSolidAngle = -1.; // Solid angle within which incident directions
|
---|
49 | // are distributed
|
---|
50 | fThetaMax=0.0; // Maximum theta angle of run
|
---|
51 | fThetaMin=370.0; // Minimum theta angle of run
|
---|
52 | fPhiMax=0.0; // Maximum phi angle of run
|
---|
53 | fPhiMin=370.0; // Minimum phi angle of run
|
---|
54 |
|
---|
55 | fImpactMax=0.0; // Maximum impact parameter
|
---|
56 | fImpactMin=100000.0; // Minimum impact parameter
|
---|
57 |
|
---|
58 | fBackTrig=-1.0; // Number of triggers from background
|
---|
59 | fBackSim=-1.0; // Number of simulated showers for the background
|
---|
60 |
|
---|
61 | fTriggerRate= -1.0; // Trigger rate in Hz
|
---|
62 | fTriggerRateError= -1.0; // Estimated error for the trigger rate in Hz
|
---|
63 | }
|
---|
64 |
|
---|
65 | // --------------------------------------------------------------------------
|
---|
66 | //
|
---|
67 | // default constructor
|
---|
68 | // fills all member data with initial values
|
---|
69 | //
|
---|
70 | MHMcRate::MHMcRate(const char *name, const char *title)
|
---|
71 | {
|
---|
72 | Init(name, title);
|
---|
73 |
|
---|
74 | fSpecIndex=0.0; // dn/dE = k * e^{- fSpecIndex}
|
---|
75 | fFlux0=-1.0; // dn/dE = fFlux0 * E^{-a}
|
---|
76 |
|
---|
77 | fShowerRate= -1.0; // Showers rate in Hz
|
---|
78 | fShowerRateError=0.0; // Estimated error of shower rate in Hz
|
---|
79 | }
|
---|
80 |
|
---|
81 | // --------------------------------------------------------------------------
|
---|
82 | //
|
---|
83 | // overloaded constructor I
|
---|
84 | // fills all member data with initial values and sets the rate of
|
---|
85 | // incident showers to ShowRate
|
---|
86 | //
|
---|
87 | MHMcRate::MHMcRate(Float_t showrate,
|
---|
88 | const char *name, const char *title)
|
---|
89 | {
|
---|
90 | Init(name, title);
|
---|
91 |
|
---|
92 | fSpecIndex=0.0; // dn/dE = k * e^{- fSpecIndex}
|
---|
93 | fFlux0=-1.0; // dn/dE = fFlux0 * E^{-a}
|
---|
94 |
|
---|
95 | fShowerRate= showrate; // Showers rate in Hz
|
---|
96 | fShowerRateError=sqrt(showrate); // Estimated error of shower rate in Hz
|
---|
97 | }
|
---|
98 |
|
---|
99 | // --------------------------------------------------------------------------
|
---|
100 | //
|
---|
101 | // overloaded constructor I
|
---|
102 | // fills all member data with initial values and sets the
|
---|
103 | // spectral index and the initial flux to SpecIndex and Flux0
|
---|
104 | //
|
---|
105 | MHMcRate::MHMcRate(Float_t specindex, Float_t flux0,
|
---|
106 | const char *name, const char *title)
|
---|
107 | {
|
---|
108 | Init(name, title);
|
---|
109 |
|
---|
110 | fSpecIndex=specindex; // dn/dE = k * e^{- fSpecIndex}
|
---|
111 | fFlux0=flux0; // dn/dE = fFlux0 * E^{-a}
|
---|
112 |
|
---|
113 | fShowerRate= -1.0;
|
---|
114 | fShowerRateError=0.0;
|
---|
115 | }
|
---|
116 |
|
---|
117 | // --------------------------------------------------------------------------
|
---|
118 | //
|
---|
119 | // set the particle that produces the showers in the athmosphere
|
---|
120 | //
|
---|
121 | void MHMcRate:: SetParticle(UShort_t part)
|
---|
122 | {
|
---|
123 | fPartId=part;
|
---|
124 | }
|
---|
125 |
|
---|
126 | // --------------------------------------------------------------------------
|
---|
127 | //
|
---|
128 | // Set the information about trigger due only to the Night Sky Background:
|
---|
129 | //
|
---|
130 | void MHMcRate::SetBackground (Float_t showers, Float_t triggers)
|
---|
131 | {
|
---|
132 | fBackTrig=showers; // Number of triggers from background
|
---|
133 | fBackSim=triggers; // Number of simulated showers for the background
|
---|
134 | }
|
---|
135 |
|
---|
136 | // --------------------------------------------------------------------------
|
---|
137 | //
|
---|
138 | // set the parameters to compute the incident rate
|
---|
139 | //
|
---|
140 | void MHMcRate:: SetFlux(Float_t flux0, Float_t specindx)
|
---|
141 | {
|
---|
142 | fFlux0=flux0;
|
---|
143 | fSpecIndex=specindx;
|
---|
144 |
|
---|
145 | }
|
---|
146 |
|
---|
147 | // --------------------------------------------------------------------------
|
---|
148 | //
|
---|
149 | // set the incident rate
|
---|
150 | //
|
---|
151 | void MHMcRate:: SetIncidentRate(Float_t showerrate)
|
---|
152 | {
|
---|
153 | fShowerRate=showerrate;
|
---|
154 | }
|
---|
155 |
|
---|
156 | // --------------------------------------------------------------------------
|
---|
157 | //
|
---|
158 | // update the limits for energy, theta, phi and impact parameter
|
---|
159 | //
|
---|
160 | void MHMcRate::UpdateBoundaries(Float_t energy, Float_t theta,
|
---|
161 | Float_t phi, Float_t impact)
|
---|
162 | {
|
---|
163 | // It updates the limit values
|
---|
164 |
|
---|
165 | if (fThetaMax<theta) fThetaMax=theta;
|
---|
166 | if (fThetaMin>theta) fThetaMin=theta;
|
---|
167 |
|
---|
168 | if (fPhiMax<phi) fPhiMax=phi;
|
---|
169 | if (fPhiMin>phi) fPhiMin=phi;
|
---|
170 |
|
---|
171 | if (fImpactMax<impact) fImpactMax=impact;
|
---|
172 | if (fImpactMin>impact) fImpactMin=impact;
|
---|
173 |
|
---|
174 | if (fEnergyMax<energy) fEnergyMax=energy;
|
---|
175 | if (fEnergyMin>energy) fEnergyMin=energy;
|
---|
176 | }
|
---|
177 |
|
---|
178 | // --------------------------------------------------------------------------
|
---|
179 | //
|
---|
180 | // compute the trigger rate and set the ReadyToSave bit
|
---|
181 | //
|
---|
182 | void MHMcRate::CalcRate(Float_t trig, Float_t anal, Float_t simu)
|
---|
183 | {
|
---|
184 | // It computes the trigger rate
|
---|
185 |
|
---|
186 | // First one computes the rate of incident showers.
|
---|
187 | const Double_t specidx = 1.0-fSpecIndex;
|
---|
188 |
|
---|
189 | const Double_t epowmax = pow(fEnergyMax, specidx);
|
---|
190 | const Double_t epowmin = pow(fEnergyMin, specidx);
|
---|
191 |
|
---|
192 | if (fShowerRate <= 0)
|
---|
193 | fShowerRate = fFlux0/specidx*(epowmax-epowmin);
|
---|
194 |
|
---|
195 | if (fSolidAngle < 0.)
|
---|
196 | fSolidAngle = (fPhiMax-fPhiMin)*(cos(fThetaMin)-cos(fThetaMax));
|
---|
197 |
|
---|
198 | if (fPartId!=1)
|
---|
199 | fShowerRate *= fSolidAngle;
|
---|
200 |
|
---|
201 | fShowerRate *= TMath::Pi()*(fImpactMax/100.0*fImpactMax/100.0 -
|
---|
202 | fImpactMin/100.0*fImpactMin/100.0);
|
---|
203 |
|
---|
204 | fShowerRateError = sqrt(fShowerRate);
|
---|
205 |
|
---|
206 | // The simulated trigger time in the camera program is 160 ns:
|
---|
207 | // 9/10/2002, AM: Fixed error below in calculation of "anal2"
|
---|
208 | // ( added factor fShowerRate/simu )
|
---|
209 |
|
---|
210 | const Double_t anal2 = 1.0-fShowerRate*(anal/simu)*160.0e-9;
|
---|
211 | const Double_t back2 = fBackSim*160.0e-9;
|
---|
212 |
|
---|
213 | // Then the trigger rate and its error is evaluated
|
---|
214 | if(fBackTrig<0){
|
---|
215 | fTriggerRateError = sqrt((trig*fShowerRate*fShowerRate/(simu*simu)) +
|
---|
216 | (anal2*anal2*1/(fBackSim*back2*back2)));
|
---|
217 | fBackTrig=0;
|
---|
218 | }
|
---|
219 | else
|
---|
220 | fTriggerRateError = sqrt((trig*fShowerRate*fShowerRate/(simu*simu)) +
|
---|
221 | (anal2*anal2*fBackTrig/(back2*back2)));
|
---|
222 |
|
---|
223 | fTriggerRate = trig*fShowerRate/simu + anal2*fBackTrig/back2;
|
---|
224 |
|
---|
225 | SetReadyToSave();
|
---|
226 | }
|
---|
227 |
|
---|
228 | // --------------------------------------------------------------------------
|
---|
229 | //
|
---|
230 | // print the trigger rate
|
---|
231 | //
|
---|
232 | void MHMcRate::Print(Option_t *) const
|
---|
233 | {
|
---|
234 | *fLog << all << "Incident rate " << fShowerRate << " Hz " << endl;
|
---|
235 | *fLog << "Trigger Rate " << fTriggerRate << " +- " << fTriggerRateError << " Hz" << endl;
|
---|
236 | }
|
---|
237 |
|
---|
238 | // --------------------------------------------------------------------------
|
---|
239 | //
|
---|
240 | // draw the trigger rate
|
---|
241 | //
|
---|
242 | void MHMcRate::Draw(Option_t *)
|
---|
243 | {
|
---|
244 | *fLog << all << dbginf << " - MHMcRate::Draw: To be iplemented" << endl;
|
---|
245 | }
|
---|
246 |
|
---|
247 | TObject *MHMcRate::DrawClone(Option_t *) const
|
---|
248 | {
|
---|
249 | *fLog << all << dbginf << " - MHMcRate::DrawClone: To be iplemented" << endl;
|
---|
250 | return NULL;
|
---|
251 | }
|
---|