| 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 |
|
|---|
| 31 | ClassImp(MHMcRate);
|
|---|
| 32 |
|
|---|
| 33 | void 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 | //
|
|---|
| 63 | MHMcRate::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 | //
|
|---|
| 80 | MHMcRate::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 | //
|
|---|
| 98 | MHMcRate::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 | //
|
|---|
| 114 | void 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 | //
|
|---|
| 123 | void 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 | // update the limits for energy, theta, phi and impact parameter
|
|---|
| 132 | //
|
|---|
| 133 | void MHMcRate::UpdateBoundaries(Float_t energy, Float_t theta,
|
|---|
| 134 | Float_t phi, Float_t impact)
|
|---|
| 135 | {
|
|---|
| 136 | // It updates the limit values
|
|---|
| 137 |
|
|---|
| 138 | if (fThetaMax<theta) fThetaMax=theta;
|
|---|
| 139 | if (fThetaMin>theta) fThetaMin=theta;
|
|---|
| 140 |
|
|---|
| 141 | if (fPhiMax<phi) fPhiMax=phi;
|
|---|
| 142 | if (fPhiMin>phi) fPhiMin=phi;
|
|---|
| 143 |
|
|---|
| 144 | if (fImpactMax<impact) fImpactMax=impact;
|
|---|
| 145 | if (fImpactMin>impact) fImpactMin=impact;
|
|---|
| 146 |
|
|---|
| 147 | if (fEnergyMax<energy) fEnergyMax=energy;
|
|---|
| 148 | if (fEnergyMin>energy) fEnergyMin=energy;
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | // --------------------------------------------------------------------------
|
|---|
| 152 | //
|
|---|
| 153 | // compute the trigger rate and set the ReadyToSave bit
|
|---|
| 154 | //
|
|---|
| 155 | void 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 | SetReadyToSave();
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | // --------------------------------------------------------------------------
|
|---|
| 195 | //
|
|---|
| 196 | // print the trigger rate
|
|---|
| 197 | //
|
|---|
| 198 | void MHMcRate::Print(Option_t *) const
|
|---|
| 199 | {
|
|---|
| 200 | *fLog << all << "Incident rate " << fShowerRate << " Hz " << endl;
|
|---|
| 201 | *fLog << "Trigger Rate " << fTriggerRate << " +- " << fTriggerRateError << " Hz" << endl;
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | // --------------------------------------------------------------------------
|
|---|
| 205 | //
|
|---|
| 206 | // draw the trigger rate
|
|---|
| 207 | //
|
|---|
| 208 | void MHMcRate::Draw(Option_t *)
|
|---|
| 209 | {
|
|---|
| 210 | *fLog << all << dbginf << " - MHMcRate::Draw: To be iplemented" << endl;
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | TObject *MHMcRate::DrawClone(Option_t *) const
|
|---|
| 214 | {
|
|---|
| 215 | *fLog << all << dbginf << " - MHMcRate::DrawClone: To be iplemented" << endl;
|
|---|
| 216 | return NULL;
|
|---|
| 217 | }
|
|---|