source: trunk/MagicSoft/Mars/mhist/MHMcRate.cc@ 893

Last change on this file since 893 was 874, checked in by magicsol, 23 years ago
Container to store data needed for the calculation of the trigger rate from MonteCarlo files.
File size: 7.9 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): 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 "MHMcRate.h"
27
28#include "MLog.h"
29
30ClassImp(MHMcRate)
31
32// --------------------------------------------------------------------------
33//
34// default constructor
35// fills all member data with initial values
36//
37MHMcRate::MHMcRate (const char *name, const char *title)
38{
39 *fName = name ? name : "MMcTriggerRate";
40 *fTitle = title ? title : "Task to calc the collection area ";
41
42 fPartId=0; // Type of particle
43
44 fEnergyMax=0.0; // Maximum Energy in GeV
45 fEnergyMin=1000000.0; // Minimum Energy in GeV
46
47 fThetaMax=0.0; // Maximum theta angle of run
48 fThetaMin=370.0; // Minimum theta angle of run
49 fPhiMax=0.0; // Maximum phi angle of run
50 fPhiMin=370.0; // Minimum phi angle of run
51
52 fImpactMax=0.0; // Maximum impact parameter
53 fImpactMin=100000.0; // Minimum impact parameter
54
55 fBackTrig=-1.0; // Number of triggers from background
56 fBackSim=-1.0; // Number of simulated showers for the background
57
58 fSpecIndex=0.0; // dn/dE = k * e^{- fSpecIndex}
59 fFlux0=-1.0; // dn/dE = fFlux0 * E^{-a}
60
61 fShowRate= -1.0; // Showers rate in Hz
62 fShowRateError=0.0; // Estimated error of shower rate in Hz
63
64 fTrigRate= -1.0; // Trigger rate in Hz
65 fTrigRateError= -1.0; // Estimated error for the trigger rate in Hz
66}
67
68// --------------------------------------------------------------------------
69//
70// overloaded constructor I
71// fills all member data with initial values and sets the rate of
72// incident showers to ShowRate
73//
74MHMcRate::MHMcRate (Float_t ShowRate,
75 const char *name, const char *title)
76{
77
78 *fName = name ? name : "MMcTriggerRate";
79 *fTitle = title ? title : "Task to calc the collection area ";
80
81 fPartId=0; // Type of particle
82
83 fEnergyMax=0.0; // Maximum Energy in GeV
84 fEnergyMin=1000000.0; // Minimum Energy in GeV
85
86 fThetaMax=0.0; // Maximum theta angle of run
87 fThetaMin=370.0; // Minimum theta angle of run
88 fPhiMax=0.0; // Maximum phi angle of run
89 fPhiMin=370.0; // Minimum phi angle of run
90
91 fImpactMax=0.0; // Maximum impact parameter
92 fImpactMin=100000.0; // Minimum impact parameter
93
94 fBackTrig=-1.0; // Number of triggers from background
95 fBackSim=-1.0; // Number of simulated showers for the background
96
97 fSpecIndex=0.0; // dn/dE = k * e^{- fSpecIndex}
98 fFlux0=-1.0; // dn/dE = fFlux0 * E^{-a}
99
100 fShowRate= ShowRate; // Showers rate in Hz
101 fShowRateError=sqrt(ShowRate); // Estimated error of shower rate in Hz
102
103 fTrigRate= -1.0; // Trigger rate in Hz
104 fTrigRateError= -1.0; // Estimated error for the trigger rate in Hz
105}
106
107// --------------------------------------------------------------------------
108//
109// overloaded constructor I
110// fills all member data with initial values and sets the
111// spectral index and the initial flux to SpecIndex and Flux0
112//
113MHMcRate::MHMcRate (Float_t SpecIndex, Float_t Flux0,
114 const char *name, const char *title)
115{
116 *fName = name ? name : "MMcTriggerRate";
117 *fTitle = title ? title : "Task to calc the collection area ";
118
119 fPartId=0; // Type of particle
120
121 fEnergyMax=0.0; // Maximum Energy in GeV
122 fEnergyMin=1000000.0; // Minimum Energy in GeV
123
124 fThetaMax=0.0; // Maximum theta angle of run
125 fThetaMin=370.0; // Minimum theta angle of run
126 fPhiMax=0.0; // Maximum phi angle of run
127 fPhiMin=370.0; // Minimum phi angle of run
128
129 fImpactMax=0.0; // Maximum impact parameter
130 fImpactMin=100000.0; // Minimum impact parameter
131
132 fBackTrig=-1.0; // Number of triggers from background
133 fBackSim=-1.0; // Number of simulated showers for the background
134
135 fSpecIndex=SpecIndex; // dn/dE = k * e^{- fSpecIndex}
136 fFlux0=Flux0; // dn/dE = fFlux0 * E^{-a}
137
138 fShowRate= -1.0;
139 fShowRateError=0.0;
140
141 fTrigRate= -1.0; // Trigger rate in Hz
142 fTrigRateError= -1.0; // Estimated error for the trigger rate in Hz
143}
144
145// --------------------------------------------------------------------------
146//
147// default constructor
148//
149MHMcRate::~MHMcRate()
150{
151}
152
153// --------------------------------------------------------------------------
154//
155// set the particle that produces the showers in the athmosphere
156//
157void MHMcRate:: SetParticle(UShort_t part)
158{
159 fPartId=part;
160}
161
162// --------------------------------------------------------------------------
163//
164// Set the information about trigger due only to the background conditions
165//
166void MHMcRate::SetBackground (Float_t Showers, Float_t Triggers)
167{
168 fBackTrig=Showers; // Number of triggers from background
169 fBackSim=Triggers; // Number of simulated showers for the background
170}
171
172// --------------------------------------------------------------------------
173//
174// update the limits for energy, theta, phi and impact parameter
175//
176void MHMcRate::Boundaries(Float_t Energy, Float_t Theta,
177 Float_t Phi, Float_t Impact)
178{
179 // It updates the limit values
180
181 if(fThetaMax<Theta) fThetaMax=Theta;
182 if(fThetaMin>Theta) fThetaMin=Theta;
183
184 if(fPhiMax<Phi) fPhiMax=Phi;
185 if(fPhiMin>Phi) fPhiMin=Phi;
186
187 if(fImpactMax<Impact) fImpactMax=Impact;
188 if(fImpactMin>Impact) fImpactMin=Impact;
189
190 if(fEnergyMax<Energy) fEnergyMax=Energy;
191 if(fEnergyMin>Energy) fEnergyMin=Energy;
192
193}
194
195// --------------------------------------------------------------------------
196//
197// compute the trigger rate
198//
199void MHMcRate::CalcRate(Float_t trig, Float_t anal, Float_t simu)
200{
201 // It computes the trigger rate
202
203 // First one computes the rate of incident showers.
204 fShowRate=fFlux0/(fSpecIndex-1)*
205 (-pow(fEnergyMax,1-fSpecIndex)+pow(fEnergyMin,1-fSpecIndex));
206
207 if (fPartId!=1)
208 fShowRate=fShowRate*(fPhiMax-fPhiMin)*
209 (cos(fThetaMax)-cos(fThetaMin));
210
211 fShowRate=fShowRate*PI_NUMBER*(fImpactMax/100.0*fImpactMax/100.0-
212 fImpactMin/100.0*fImpactMin/100.0);
213
214 fShowRateError=sqrt(fShowRate);
215
216 // Then the trigger rate and its error is evaluated
217 if(fBackTrig<0){
218 fTrigRateError=sqrt((trig*fShowRate*fShowRate/(simu*simu))+
219 ((1.0-anal*160.0e-9)*
220 (1.0-anal*160.0e-9)*1/
221 (fBackSim*fBackSim*160.0e-9*fBackSim*160.0e-9)));
222 fBackTrig=0;
223 }
224 else
225 fTrigRateError=sqrt((trig*fShowRate*fShowRate/(simu*simu))+
226 ((1.0-anal*160.0e-9)*
227 (1.0-anal*160.0e-9)*fBackTrig/
228 (fBackSim*160.0e-9*fBackSim*160.0e-9)));
229
230 fTrigRate=trig*fShowRate/simu+
231 (1.0-anal*160.0e-9)*fBackTrig/
232 (fBackSim*160.0e-9);
233
234}
235
236// --------------------------------------------------------------------------
237//
238// print the trigger rate
239//
240void MHMcRate::Print()
241{
242 *fLog<<"Incident rate "<<fShowRate<<" Hz "<<endl;
243 *fLog<<endl<<"Trigger Rate "<<fTrigRate<<" +- "<<fTrigRateError<<" Hz"<<endl;
244
245}
246
247// --------------------------------------------------------------------------
248//
249// draw the trigger rate
250//
251void MHMcRate::Draw(Option_t* option)
252{
253 *fLog<<"To be iplemented"<<endl;
254}
Note: See TracBrowser for help on using the repository browser.