GENIEGenerator
Loading...
Searching...
No Matches
GBGLRSAtmoFlux.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Christopher Backhouse <c.backhouse1@physics.ox.ac.uk>
7 Oxford University
8*/
9//____________________________________________________________________________
10
11#include <fstream>
12#include <cassert>
13
14#include <TH3D.h>
15#include <TMath.h>
16
20
23
24using std::ifstream;
25using std::ios;
26
27using namespace genie;
28using namespace genie::flux;
29using namespace genie::constants;
30
31//____________________________________________________________________________
34{
35 LOG("Flux", pNOTICE)
36 << "Instantiating the GENIE BGLRS atmospheric neutrino flux driver";
37
38 this->Initialize();
39 this->SetBinSizes();
40}
41//___________________________________________________________________________
46//___________________________________________________________________________
48{
49// Generate the correct cos(theta) and energy bin sizes.
50//
51// Zenith angle binning: the flux is given in 20 bins of
52// cos(zenith angle) from -1.0 to 1.0 (bin width = 0.1)
53//
54// Neutrino energy binning: the Bartol flux files are
55// provided in two pieces
56// (1) low energy piece (<10 GeV), solar min or max,
57// given in 40 log-spaced bins from 0.1 to 10 GeV
58// (20 bins per decade)
59// (2) high energy piece (>10 GeV), without solar effects,
60// given in 30 log-spaced bins from 10 to 1000 GeV
61// (10 bins per decade)
62
63 fPhiBins = new double [2];
64 fCosThetaBins = new double [kBGLRS3DNumCosThetaBins + 1];
66
67 fPhiBins[0] = 0;
68 fPhiBins[1] = 2.*kPi;
69
70 double dcostheta =
73
74 double logEmin = TMath::Log10(kBGLRS3DEvMin);
75 double dlogElow = 1.0 / (double) kBGLRS3DNumLogEvBinsPerDecadeLow;
76 double dlogEhigh = 1.0 / (double) kBGLRS3DNumLogEvBinsPerDecadeHigh;
77
78 double costheta = kBGLRS3DCosThetaMin;
79
80 for(unsigned int i=0; i<= kBGLRS3DNumCosThetaBins; i++) {
81 if( i==0 ) ; // do nothing
82 else costheta += dcostheta;
83 fCosThetaBins[i] = costheta;
85 LOG("Flux", pDEBUG)
86 << "FLUKA 3d flux: CosTheta bin " << i+1
87 << ": lower edge = " << fCosThetaBins[i];
88 } else {
89 LOG("Flux", pDEBUG)
90 << "FLUKA 3d flux: CosTheta bin " << kBGLRS3DNumCosThetaBins
91 << ": upper edge = " << fCosThetaBins[kBGLRS3DNumCosThetaBins];
92 }
93 }
94
95 double logE = logEmin;
96
97 for(unsigned int i=0; i<=kBGLRS3DNumLogEvBinsLow+kBGLRS3DNumLogEvBinsHigh; i++) {
98 if( i==0 ) ; // do nothing
99 else if( i<=kBGLRS3DNumLogEvBinsLow ) logE += dlogElow;
100 else logE += dlogEhigh;
101 fEnergyBins[i] = TMath::Power(10.0, logE);
103 LOG("Flux", pDEBUG)
104 << "FLUKA 3d flux: Energy bin " << i+1
105 << ": lower edge = " << fEnergyBins[i];
106 } else {
107 LOG("Flux", pDEBUG)
108 << "FLUKA 3d flux: Energy bin " << kBGLRS3DNumLogEvBinsLow+kBGLRS3DNumLogEvBinsHigh
110 }
111 }
112
113 fNumPhiBins = 1;
117}
118//___________________________________________________________________________
119bool GBGLRSAtmoFlux::FillFluxHisto(int nu_pdg, string filename)
120{
121 LOG("Flux", pNOTICE)
122 << "Loading BGLRS flux for neutrino: " << nu_pdg
123 << " from file: " << filename;
124
125 TH3D* histo = 0;
126 std::map<int,TH3D*>::iterator myMapEntry = fRawFluxHistoMap.find(nu_pdg);
127 if( myMapEntry != fRawFluxHistoMap.end() ){
128 histo = myMapEntry->second;
129 }
130 if(!histo) {
131 LOG("Flux", pERROR) << "Null flux histogram!";
132 return false;
133 }
134 ifstream flux_stream(filename.c_str(), ios::in);
135 if(!flux_stream) {
136 LOG("Flux", pERROR) << "Could not open file: " << filename;
137 return false;
138 }
139
140 int ibin;
141 double energy, costheta, flux;
142 double junkd; // throw away error estimates
143
144 double scale = 1.0; // 1.0 [m^2], OR 1.0e-4 [cm^2]
145
146 // throw away comment line
147 flux_stream.ignore(99999, '\n');
148
149 while ( !flux_stream.eof() ) {
150 flux = 0.0;
151 flux_stream >> energy >> costheta >> flux >> junkd >> junkd;
152 if( flux>0.0 ){
153 // Compensate for logarithmic units - dlogE=dE/E
154 // [Note: should do this explicitly using bin widths]
155 flux /= energy;
156 LOG("Flux", pINFO)
157 << "Flux[Ev = " << energy
158 << ", cos8 = " << costheta << "] = " << flux;
159 ibin = histo->FindBin( (Axis_t)energy, (Axis_t)costheta, (Axis_t)kPi );
160 histo->SetBinContent( ibin, (Stat_t)(scale*flux) );
161 }
162 }
163 return true;
164}
165//___________________________________________________________________________
#define FLUXDRIVERREG4(_nsa, _nsb, _name, _fqname)
#define pNOTICE
Definition Messenger.h:61
#define pINFO
Definition Messenger.h:62
#define pERROR
Definition Messenger.h:59
#define pDEBUG
Definition Messenger.h:63
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
map< int, TH3D * > fRawFluxHistoMap
flux = f(Ev,cos8,phi) for each neutrino species
Definition GAtmoFlux.h:155
unsigned int fNumEnergyBins
number of energy bins in input flux data files
Definition GAtmoFlux.h:145
double fMaxEv
maximum energy (in input flux files)
Definition GAtmoFlux.h:131
unsigned int fNumPhiBins
number of phi bins in input flux data files
Definition GAtmoFlux.h:143
double * fPhiBins
phi bins in input flux data files
Definition GAtmoFlux.h:146
double * fCosThetaBins
cos(theta) bins in input flux data files
Definition GAtmoFlux.h:147
unsigned int fNumCosThetaBins
number of cos(theta) bins in input flux data files
Definition GAtmoFlux.h:144
double * fEnergyBins
energy bins in input flux data files
Definition GAtmoFlux.h:148
A flux driver for the Bartol Atmospheric Neutrino Flux.
bool FillFluxHisto(int nu_pdg, string filename)
Basic constants.
GENIE flux drivers.
const double kBGLRS3DCosThetaMin
const unsigned int kBGLRS3DNumLogEvBinsPerDecadeHigh
const unsigned int kBGLRS3DNumCosThetaBins
const unsigned int kBGLRS3DNumLogEvBinsPerDecadeLow
const double kBGLRS3DEvMin
const unsigned int kBGLRS3DNumLogEvBinsHigh
const unsigned int kBGLRS3DNumLogEvBinsLow
const double kBGLRS3DCosThetaMax
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25