GAtmoFlux.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::flux::GAtmoFlux
5 
6 \brief A base class for the FLUKA, BGLRS and ATMNC atmo. nu. flux drivers.
7  The driver depends on data files provided by the atmospheric neutrino
8  flux simulation authors in order to determine the angular and energy
9  dependence for each neutrino species.
10  The position of each flux neutrino [going towards a detector centered
11  at (0,0,0)] is generated uniformly on a plane that is perpendicular
12  to a sphere of radius Rl at the point that is determined by the
13  generated neutrino direction (theta,phi). The size of the area of
14  that plane, where flux neutrinos are generated, is determined by the
15  transverse radius Rt. You can tweak Rl, Rt to match the size of your
16  detector.
17  Initially, neutrino coordinates are generated in a default detector
18  coordinate system (Topocentric Horizontal Coordinate -THZ-):
19  +z: Points towards the local zenith.
20  +x: On same plane as local meridian, pointing south.
21  +y: As needed to make a right-handed coordinate system.
22  origin: detector centre
23  Alternative user-defined topocentric systems can
24  be defined by specifying the appropriate rotation from THZ.
25  The driver allows minimum and maximum energy cuts.
26  Also it provides the options to generate wither unweighted or weighted
27  flux neutrinos (the latter giving smoother distributions at the tails).
28 
29 \author Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
30  University of Liverpool & STFC Rutherford Appleton Lab
31 
32 \created January 26, 2008
33 
34 \cpright Copyright (c) 2003-2019, The GENIE Collaboration
35  For the full text of the license visit http://copyright.genie-mc.org
36  or see $GENIE/LICENSE
37 */
38 //____________________________________________________________________________
39 
40 #ifndef _GATMO_FLUX_H_
41 #define _GATMO_FLUX_H_
42 
43 #include <string>
44 #include <map>
45 #include <vector>
46 
47 #include <TLorentzVector.h>
48 #include <TRotation.h>
49 
51 
52 class TH3D;
53 
54 using std::string;
55 using std::map;
56 using std::vector;
57 
58 namespace genie {
59 namespace flux {
60 
61 class GAtmoFlux: public GFluxI {
62 
63 public :
64  virtual ~GAtmoFlux();
65 
66  // methods implementing the GENIE GFluxI interface
67  virtual const PDGCodeList & FluxParticles (void) { return *fPdgCList; }
68  virtual double MaxEnergy (void);
69  virtual bool GenerateNext (void);
70  virtual int PdgCode (void) { return fgPdgC; }
71  virtual double Weight (void) { return fWeight; }
72  virtual const TLorentzVector & Momentum (void) { return fgP4; }
73  virtual const TLorentzVector & Position (void) { return fgX4; }
74  virtual bool End (void) { return false; }
75  virtual long int Index (void) { return -1; }
76  virtual void Clear (Option_t * opt);
77  virtual void GenerateWeighted (bool gen_weighted);
78 
79  // get neutrino energy/direction of generated events
80  double Enu (void) { return fgP4.Energy(); }
81  double Energy (void) { return fgP4.Energy(); }
82  double CosTheta (void) { return -fgP4.Pz()/fgP4.Energy(); }
83  double CosZenith (void) { return -fgP4.Pz()/fgP4.Energy(); }
84 
85  // methods specific to the atmospheric flux drivers
86  long int NFluxNeutrinos (void) const; ///< Number of flux nu's generated. Not the same as the number of nu's thrown towards the geometry (if there are cuts).
87  void ForceMinEnergy (double emin);
88  void ForceMaxEnergy (double emax);
89  void SetSpectralIndex (double index);
90  void SetRadii (double Rlongitudinal, double Rtransverse);
91  void SetUserCoordSystem (TRotation & rotation); ///< Rotation: Topocentric Horizontal -> User-defined Topocentric Coord System.
92  void AddFluxFile (int neutrino_pdg, string filename);
93  void AddFluxFile (string filename);
94  bool LoadFluxData (void);
95 
96  TH3D* GetFluxHistogram (int flavour);
97  double GetFlux (int flavour);
98  double GetFlux (int flavour, double energy);
99  double GetFlux (int flavour, double energy, double costh);
100  double GetFlux (int flavour, double energy, double costh, double phi);
101 
102 protected:
103 
104  // abstract class, ctor hidden
105  GAtmoFlux();
106 
107  // protected methods
108  bool GenerateNext_1try (void);
109  void Initialize (void);
110  void CleanUp (void);
111  void ResetSelection (void);
112  double MinEnergy (void) { return fMinEvCut; }
113  TH3D * CreateFluxHisto (string name, string title);
114  void ZeroFluxHisto (TH3D * hist);
115  void AddAllFluxes (void);
116  int SelectNeutrino (double Ev, double costheta, double phi);
117  TH3D* CreateNormalisedFluxHisto ( TH3D* hist); // normalise flux files
118 
119  // pure virtual methods; to be implemented by concrete flux drivers
120  virtual bool FillFluxHisto (int nu_pdg, string filename) = 0;
121 
122  // protected data members
123  double fMaxEv; ///< maximum energy (in input flux files)
124  PDGCodeList * fPdgCList; ///< input list of neutrino pdg-codes
125  int fgPdgC; ///< current generated nu pdg-code
126  TLorentzVector fgP4; ///< current generated nu 4-momentum
127  TLorentzVector fgX4; ///< current generated nu 4-position
128  double fWeight; ///< current generated nu weight
129  long int fNNeutrinos; ///< number of flux neutrinos thrown so far
130  double fMaxEvCut; ///< user-defined cut: maximum energy
131  double fMinEvCut; ///< user-defined cut: minimum energy
132  double fRl; ///< defining flux neutrino generation surface: longitudinal radius
133  double fRt; ///< defining flux neutrino generation surface: transverse radius
134  TRotation fRotTHz2User; ///< coord. system rotation: THZ -> Topocentric user-defined
135  unsigned int fNumPhiBins; ///< number of phi bins in input flux data files
136  unsigned int fNumCosThetaBins; ///< number of cos(theta) bins in input flux data files
137  unsigned int fNumEnergyBins; ///< number of energy bins in input flux data files
138  double * fPhiBins; ///< phi bins in input flux data files
139  double * fCosThetaBins; ///< cos(theta) bins in input flux data files
140  double * fEnergyBins; ///< energy bins in input flux data files
141  bool fGenWeighted; ///< generate a weighted or unweighted flux?
142  double fSpectralIndex; ///< power law function used for weighted flux
143  bool fInitialized; ///< flag to check that initialization is run
144  TH3D * fTotalFluxHisto; ///< flux = f(Ev,cos8,phi) summed over neutrino species
145  double fTotalFluxHistoIntg; ///< fFluxSum2D integral
146  map<int, TH3D*> fFluxHistoMap; ///< flux = f(Ev,cos8,phi) for each neutrino species
147  map<int, TH3D*> fRawFluxHistoMap; ///< flux = f(Ev,cos8,phi) for each neutrino species
148  vector<int> fFluxFlavour; ///< input flux file for each neutrino species
149  vector<string> fFluxFile; ///< input flux file for each neutrino species
150 };
151 
152 } // flux namespace
153 } // genie namespace
154 
155 #endif // _GATMO_FLUX_H_
156 
int SelectNeutrino(double Ev, double costheta, double phi)
Definition: GAtmoFlux.cxx:603
int fgPdgC
current generated nu pdg-code
Definition: GAtmoFlux.h:125
vector< int > fFluxFlavour
input flux file for each neutrino species
Definition: GAtmoFlux.h:148
double CosZenith(void)
Definition: GAtmoFlux.h:83
const XML_Char * name
Definition: expat.h:151
map< int, TH3D * > fFluxHistoMap
flux = f(Ev,cos8,phi) for each neutrino species
Definition: GAtmoFlux.h:146
double * fPhiBins
phi bins in input flux data files
Definition: GAtmoFlux.h:138
vector< string > fFluxFile
input flux file for each neutrino species
Definition: GAtmoFlux.h:149
unsigned int fNumEnergyBins
number of energy bins in input flux data files
Definition: GAtmoFlux.h:137
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
unsigned int fNumCosThetaBins
number of cos(theta) bins in input flux data files
Definition: GAtmoFlux.h:136
TH3D * CreateNormalisedFluxHisto(TH3D *hist)
Definition: GAtmoFlux.cxx:520
double Enu(void)
Definition: GAtmoFlux.h:80
double fSpectralIndex
power law function used for weighted flux
Definition: GAtmoFlux.h:142
TH3D * GetFluxHistogram(int flavour)
Definition: GAtmoFlux.cxx:651
long int NFluxNeutrinos(void) const
Number of flux nu&#39;s generated. Not the same as the number of nu&#39;s thrown towards the geometry (if the...
Definition: GAtmoFlux.cxx:265
long int fNNeutrinos
number of flux neutrinos thrown so far
Definition: GAtmoFlux.h:129
string filename
Definition: shutoffs.py:106
void SetRadii(double Rlongitudinal, double Rtransverse)
Definition: GAtmoFlux.cxx:412
double fRl
defining flux neutrino generation surface: longitudinal radius
Definition: GAtmoFlux.h:132
bool fInitialized
flag to check that initialization is run
Definition: GAtmoFlux.h:143
double GetFlux(int flavour)
Definition: GAtmoFlux.cxx:662
virtual void GenerateWeighted(bool gen_weighted)
set whether to generate weighted or unweighted neutrinos
Definition: GAtmoFlux.cxx:289
Loaders::FluxType flux
TRotation fRotTHz2User
coord. system rotation: THZ -> Topocentric user-defined
Definition: GAtmoFlux.h:134
A list of PDG codes.
Definition: PDGCodeList.h:33
const double emin
double fMinEvCut
user-defined cut: minimum energy
Definition: GAtmoFlux.h:131
double fMaxEvCut
user-defined cut: maximum energy
Definition: GAtmoFlux.h:130
void ForceMaxEnergy(double emax)
Definition: GAtmoFlux.cxx:276
double fTotalFluxHistoIntg
fFluxSum2D integral
Definition: GAtmoFlux.h:145
virtual double Weight(void)
returns the flux neutrino weight (if any)
Definition: GAtmoFlux.h:71
const double emax
virtual bool FillFluxHisto(int nu_pdg, string filename)=0
double energy
Definition: plottest35.C:25
void SetSpectralIndex(double index)
Definition: GAtmoFlux.cxx:294
double Energy(void)
Definition: GAtmoFlux.h:81
bool fGenWeighted
generate a weighted or unweighted flux?
Definition: GAtmoFlux.h:141
double * fCosThetaBins
cos(theta) bins in input flux data files
Definition: GAtmoFlux.h:139
unsigned int fNumPhiBins
number of phi bins in input flux data files
Definition: GAtmoFlux.h:135
double * fEnergyBins
energy bins in input flux data files
Definition: GAtmoFlux.h:140
virtual double MaxEnergy(void)
declare the max flux neutrino energy that can be generated (for init. purposes)
Definition: GAtmoFlux.cxx:87
double MinEnergy(void)
Definition: GAtmoFlux.h:112
virtual const TLorentzVector & Momentum(void)
returns the flux neutrino 4-momentum
Definition: GAtmoFlux.h:72
void SetUserCoordSystem(TRotation &rotation)
Rotation: Topocentric Horizontal -> User-defined Topocentric Coord System.
Definition: GAtmoFlux.cxx:306
virtual long int Index(void)
returns corresponding index for current flux neutrino (e.g. for a flux ntuple returns the current ent...
Definition: GAtmoFlux.h:75
virtual bool GenerateNext(void)
generate the next flux neutrino (return false in err)
Definition: GAtmoFlux.cxx:92
TLorentzVector fgP4
current generated nu 4-momentum
Definition: GAtmoFlux.h:126
virtual const PDGCodeList & FluxParticles(void)
declare list of flux neutrinos that can be generated (for init. purposes)
Definition: GAtmoFlux.h:67
void ZeroFluxHisto(TH3D *hist)
Definition: GAtmoFlux.cxx:567
map< int, TH3D * > fRawFluxHistoMap
flux = f(Ev,cos8,phi) for each neutrino species
Definition: GAtmoFlux.h:147
double fRt
defining flux neutrino generation surface: transverse radius
Definition: GAtmoFlux.h:133
void AddFluxFile(int neutrino_pdg, string filename)
Definition: GAtmoFlux.cxx:421
virtual const TLorentzVector & Position(void)
returns the flux neutrino 4-position (note: expect SI rather than physical units) ...
Definition: GAtmoFlux.h:73
TH3D * fTotalFluxHisto
flux = f(Ev,cos8,phi) summed over neutrino species
Definition: GAtmoFlux.h:144
TH3D * CreateFluxHisto(string name, string title)
Definition: GAtmoFlux.cxx:592
void ResetSelection(void)
Definition: GAtmoFlux.cxx:369
virtual void Clear(Option_t *opt)
reset state variables based on opt
Definition: GAtmoFlux.cxx:282
PDGCodeList * fPdgCList
input list of neutrino pdg-codes
Definition: GAtmoFlux.h:124
bool GenerateNext_1try(void)
Definition: GAtmoFlux.cxx:114
A base class for the FLUKA, BGLRS and ATMNC atmo. nu. flux drivers. The driver depends on data files ...
Definition: GAtmoFlux.h:61
void ForceMinEnergy(double emin)
Definition: GAtmoFlux.cxx:270
double fMaxEv
maximum energy (in input flux files)
Definition: GAtmoFlux.h:123
TLorentzVector fgX4
current generated nu 4-position
Definition: GAtmoFlux.h:127
virtual bool End(void)
true if no more flux nu&#39;s can be thrown (eg reaching end of beam sim ntuples)
Definition: GAtmoFlux.h:74
double CosTheta(void)
Definition: GAtmoFlux.h:82
double fWeight
current generated nu weight
Definition: GAtmoFlux.h:128
GENIE Interface for user-defined flux classes.
Definition: GFluxI.h:37
virtual int PdgCode(void)
returns the flux neutrino pdg code
Definition: GAtmoFlux.h:70
enum BeamMode string