source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/simulation/lightsources/src/SimpleCrkCalculator.cc @ 117

Last change on this file since 117 was 117, checked in by moretto, 11 years ago

ESAF version compilable on mac OS

File size: 4.7 KB
Line 
1// ESAF : Euso Simulation and Analysis Framework
2// $Id: SimpleCrkCalculator.cc 2992 2011-09-28 10:22:44Z fenu $
3// Anne Stutz created Apr, 27 2004
4
5#include "SimpleCrkCalculator.hh"
6#include "EsafSpectrum.hh"
7#include "Atmosphere.hh"
8#include "Config.hh"
9#include "EConst.hh"
10
11using namespace sou;
12using namespace TMath;
13using EConst::FineStructureConst;
14using EConst::ElectronMassC2;
15
16ClassImp(SimpleCrkCalculator)
17
18//____________________________________________________________________________________________
19  SimpleCrkCalculator::SimpleCrkCalculator() : CrkCalculator() {
20    //
21    // ctor
22    //
23    ConfigFileParser* pConf = Config::Get()->GetCF("LightSource", "ShowerLightSource");       
24    fLambdaMin = (Int_t) pConf->GetNum("ShowerLightSource.fLambdaMin")*nm;
25    fLambdaMax = (Int_t) pConf->GetNum("ShowerLightSource.fLambdaMax")*nm;
26    fName = "simple";
27    Msg(EsafMsg::Info)<< "SimpleCrkCalculator built" << MsgDispatch;
28}
29
30//____________________________________________________________________________________________
31SimpleCrkCalculator::~SimpleCrkCalculator() {
32    //
33    // dtor
34    //
35
36}
37
38//____________________________________________________________________________________________
39Double_t SimpleCrkCalculator::GetCrkYield(const Double_t SC_alt, const Double_t SC_energy, Bool_t thr) const {
40    //
41    // get the yield of the Cerenkov emission for a fixed energy
42    // if thr == false, energy threshold of cerenkov production is not taken into account
43    //
44    Double_t CrkYield; 
45    // Get Atmosphere for Index
46    const Atmosphere* atmo = Atmosphere::Get();
47    Double_t delta = atmo->Index_Minus1(SC_alt);
48    // When Index is not implemented in the Atmosphere use the Corsika formula
49    if ( delta == 0) 
50        delta = 0.000283 * atmo->Air_Density( SC_alt )/atmo->Air_Density(0);
51
52    if(delta==0) throw runtime_error("Invalid Index in SimpleCrkCalculator");
53
54    // Cerenkov Yield
55    if ( (SC_energy > GetEnergyThreshold(SC_alt)) && thr) {
56        CrkYield = TwoPi() * FineStructureConst() * (2*delta - pow(ElectronMassC2()/SC_energy,2));
57        // wavelenght normalisation
58    }
59    else if(!thr) CrkYield = TwoPi() * FineStructureConst() * 2*delta * (1 - pow(GetEnergyThreshold(0.)/SC_energy,2));
60    else CrkYield=0.;
61    CrkYield = CrkYield * ( 1/fLambdaMin - 1/fLambdaMax );
62
63    return CrkYield;
64}
65
66//____________________________________________________________________________________________
67Double_t SimpleCrkCalculator::GetCrkYield(const Double_t SC_alt, TF12* EnergyDistribution) const {
68    //
69    // get the Cerenkov yield integrated on an energy distribution
70    //
71
72    Double_t CrkYield = 0.;
73
74    Double_t Emax = EnergyDistribution->GetXmax();  // unit to be fixed in shower
75    Double_t Emin = EnergyDistribution->GetXmin();
76    Double_t E = GetEnergyThreshold(SC_alt)/MeV;
77    Double_t dE = (Emax-E)/1000.;
78    Double_t IntSpec = EnergyDistribution->Integral(Emin,Emax);
79
80    while(true) {
81        CrkYield += GetCrkYield(SC_alt,E*MeV) * EnergyDistribution->Eval(E) * dE ; // unit to be fixed in shower
82        E += dE;
83        if(( Emax-Emin )<( E-Emin )) break;
84    }
85    CrkYield /= IntSpec;
86
87    return CrkYield;
88}
89
90//____________________________________________________________________________________________
91Double_t SimpleCrkCalculator::GetCrkYield(const Double_t SC_alt, const TH1F* ehisto) const {
92    //
93    // get the Cerenkov yield integrated on an energy histogram
94    //
95
96    Double_t CrkYield = 0.;
97
98    Double_t Int = ehisto->Integral();
99    if (Int == 0) return 0; 
100    for (Int_t i(0); i < ehisto->GetNbinsX(); i++) {
101        Double_t E = ehisto->GetBinCenter(i);
102        Double_t dE = ehisto->GetBinWidth(i); 
103        CrkYield +=GetCrkYield(SC_alt,E*MeV) * (ehisto->GetBinContent(i))/Int *dE ; 
104    }
105
106    return CrkYield;
107}
108
109//____________________________________________________________________________________________
110Double_t SimpleCrkCalculator::GetEnergyThreshold(const Double_t SC_alt) const {
111    //
112    // get the energy threshold for the cerenkov emission
113    //
114
115    // Get Atmosphere for Index
116    const Atmosphere* atmo = Atmosphere::Get();
117    Double_t delta = atmo->Index_Minus1(SC_alt);
118    // When Index is not implemented in the Atmosphere use the Corsika formula
119    if ( delta == 0) 
120        delta = 0.000283 * atmo->Air_Density( SC_alt )/atmo->Air_Density(0);
121   
122    return ElectronMassC2()/sqrt(2*delta);
123}
124
125
126//_________________________________________________________________________________
127EsafSpectrum* SimpleCrkCalculator::GetCrkSpectrum() const{
128    //
129    // get the wavelenght spectrum of the cerenkov emission
130    //
131
132    TFormula* cerenkov = new TFormula("cerenkov","1/(x*x)");
133    EsafSpectrum* CrkSpectrum = new EsafSpectrum(cerenkov,100,fLambdaMin,fLambdaMax);
134    delete cerenkov;
135    return CrkSpectrum;
136}
Note: See TracBrowser for help on using the repository browser.