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

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