source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/common/atmosphere/src/LinsleyAtmosphereData.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: 3.4 KB
Line 
1// ESAF : Euso Simulation and Analysis Framework
2// $Id: LinsleyAtmosphereData.cc 2679 2006-05-03 08:28:58Z moreggia $
3// Sylvain Moreggia created May, 17 2004
4
5#include "LinsleyAtmosphereData.hh"
6#include "NumbersFileParser.hh"
7#include <math.h>
8
9using namespace sou;
10
11ClassImp(LinsleyAtmosphereData)
12
13//_____________________________________________________________________________
14LinsleyAtmosphereData::LinsleyAtmosphereData() : AtmosphereData() {
15    //
16    // ctor
17    //
18    fNb = (Int_t)Conf()->GetNum("LinsleyAtmosphereData.fNb");
19    fName = Conf()->GetStr("LinsleyAtmosphereData.fName");
20
21    fBottom = new Double_t[fNb];
22    fA = new Double_t[fNb];
23    fB = new Double_t[fNb];
24    fC = new Double_t[fNb];
25    if(!(fBottom && fA && fB && fC)) Msg(EsafMsg::Panic) <<"Pb for memory allocation in LinsleyAtmosphereData ctor"<<MsgDispatch;
26    ParamTables();
27    SetTables();
28}
29
30//_____________________________________________________________________________
31LinsleyAtmosphereData::LinsleyAtmosphereData(const Int_t&, const vector<Double_t>&, const Int_t&)
32    : AtmosphereData() {
33    //
34    // ctor
35    //
36    fBottom = 0;
37    fA      = 0;
38    fB      = 0;
39    fC      = 0;
40}
41
42//_____________________________________________________________________________
43LinsleyAtmosphereData::~LinsleyAtmosphereData() {
44    //
45    // dtor
46    //
47}
48
49//_____________________________________________________________________________
50void LinsleyAtmosphereData::ParamTables() {
51    //
52    // fill data members (tables)
53    //
54    string fn = fName + ".data";
55    NumbersFileParser nf("config/Atmosphere/LinsleyData/" + fn, fNb);
56    Msg(EsafMsg::Info)<< "  Linsley Atmosphere - config :" << fName << MsgDispatch;
57
58    vector<Double_t> param;
59    for(Int_t i=0; i<fNb; i++) {
60        param = nf.GetCol(i);
61        fBottom[i] = param[0]*km;
62        fA[i] = param[2]*g/cm2;
63        fB[i] = param[3]*g/cm2;
64        fC[i] = param[4]*cm;
65    }
66}
67
68//_____________________________________________________________________________
69void LinsleyAtmosphereData::SetTables() {
70    //
71    // fill data members (tables)
72    //
73    Int_t fNbL=100;
74    fAltitudeTable = new Double_t[fNbL];
75    fAir_DensityTable = new Double_t[fNbL];
76   
77    for(Int_t j=0; j<fNbL; j++){
78      Double_t h = Double_t(j);
79      fAltitudeTable[j] = h*km;
80      for(Int_t i=0; i<fNb; i++) {
81        if(fBottom[i]/km <= h && h < fBottom[i+1]/km) {
82          fAir_DensityTable[j]= fB[i]/fC[i] * exp(-h*km/fC[i]); }
83
84      }
85    }
86    string atmod = "linsley";
87    Msg(EsafMsg::Warning)<< "<SetTables> GetDefault() and WriteUserModelFile() disabled in LinseyAtmosphere mode" << MsgDispatch;
88    //GetDefault(atmod,fNbL);
89    //WriteUserModelFile(fNbL);   // interface with Lowtran needs to be fixed
90#ifdef DEBUG
91    //DebugPlots(fNbL);   
92#endif
93}
94
95//_____________________________________________________________________________
96Double_t LinsleyAtmosphereData::DensityParametrization(Double_t h) const {
97    //
98    // Linsley parametrization
99    //
100    Int_t i;
101    if(h < -kAltitudeTolerance)  {
102        Msg(EsafMsg::Warning) << "Negative altitude in LinsleyAtmosphereData, h = "<<h << MsgDispatch;
103        Msg(EsafMsg::Warning) << "ZERO density returned"<< MsgDispatch;
104        return 0.;
105    }
106    if(h < 0) h = 0.;
107   
108    if(fName == "Uniform") {
109        if(h < fBottom[1]) return fB[0] / fC[0];
110        else return fB[1] / fC[1];
111    }
112   
113    for(i=0; i<fNb-1; i++) {
114        if(h < fBottom[i+1]) return fB[i]/fC[i] * exp(-h/fC[i]);
115    }
116    return fB[i]/fC[i];
117}
118
119
120
121
122
123
124
Note: See TracBrowser for help on using the repository browser.