source: trunk/MagicSoft/Mars/mhistmc/MHMcRate.cc@ 2017

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