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

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