GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GFluxBlender.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::flux::GFluxBlender
5 
6 \brief GENIE GFluxI adapter to allow flavor modification
7 
8  This adapter intervenes between the GENIE GMCJDriver class
9  (MC job driver) and a concrete GFluxI flux generator, to
10  allow user modification of the neutrino flavor. This
11  modification could be a fixed "swap" or an energy and/or
12  distance dependent (standard oscillations) one.
13 
14  Because the GMCJDriver only queries the flavor of a
15  generated neutrino once, prior to propagation through
16  the geometry, this approach is _not_ appropriate with
17  use of an oscillatory model in situations where the flavor
18  might change significantly over the scale of the geometry.
19  In such cases one would have to generate with a fixed flavor
20  (energy/distance independent) swap and reweight after the fact.
21 
22  Do not use this as a means of selecting only certain flavor
23  from flux generators that support other means (e.g. GNuMIFlux,
24  GSimpleNtpFlux which have SetFluxParticles(PDGCodeList)) as
25  those will be more efficient.
26 
27 \author Robert Hatcher <rhatcher \at fnal.gov>
28  Fermi National Accelerator Laboratory
29 
30 \created 2010/12/22
31 
32 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
33  for the full text of the license visit http://copyright.genie-mc.org
34 */
35 //____________________________________________________________________________
36 
37 #ifndef GENIE_FLUX_GFLUXBLENDER_H
38 #define GENIE_FLUX_GFLUXBLENDER_H
39 
40 #include <vector>
43 
44 namespace genie {
45 namespace flux {
46 
47  // forward declarations within namespace
48  class GFlavorMixerI;
49  class GNuMIFlux;
50  class GSimpleNtpFlux;
51 
52  class GFluxBlender : public GFluxI {
53 
54  public:
55 
56  GFluxBlender();
57  ~GFluxBlender();
58 
59  //
60  // implement the GFluxI interface:
61  // overriding real GFluxI methods:
62  // FluxParticles() [final list of flavor might be more than source]
63  // GenerateNext() [choose flavor during generation, avoid sterile]
64  //
65  const PDGCodeList & FluxParticles (void); ///< declare list of flux neutrinos that can be generated (for init. purposes)
66  double MaxEnergy (void) { return fRealGFluxI->MaxEnergy(); } ///< declare the max flux neutrino energy that can be generated (for init. purposes)
67  bool GenerateNext (void); ///< generate the next flux neutrino (return false in err)
68  int PdgCode (void) { return fPdgCMixed; } ///< returns the flux neutrino pdg code
69  double Weight (void) { return fRealGFluxI->Weight(); } ///< returns the flux neutrino weight (if any)
70  const TLorentzVector & Momentum (void) { return fRealGFluxI->Momentum(); } ///< returns the flux neutrino 4-momentum
71  const TLorentzVector & Position (void) { return fRealGFluxI->Position(); } ///< returns the flux neutrino 4-position (note: expect SI rather than physical units)
72  bool End (void) { return fRealGFluxI->End(); } ///< true if no more flux nu's can be thrown (eg reaching end of beam sim ntuples)
73  long int Index (void);
74  void Clear (Option_t * opt);
75  void GenerateWeighted (bool gen_weighted);
76 
77  //
78  // Additions to the GFluxI interface:
79  //
80  int PdgCodeGenerated (void) { return fPdgCGenerated; } ///< returns the flux neutrino original pdg code
81  double Energy (void) { return fEnergy; } //< returns the current neutrino's energy
82  double TravelDist (void) { return fDistance; } ///< returns the distance used in the flavor mixing
83  //
84  // For flux methods that report a distance from the point of origin
85  // to the chosen starting point for the ray use that distance
86  // (supported in GNuMIFlux and GSimpleNtpFlux).
87  // For other cases use a fixed travel distance (meters) set via:
88  //
89  void SetBaselineDist (double dist) { fBaselineDist = dist; }
90  double GetBaselineDist (void) { return fBaselineDist; }
91 
92  //
93  // Configuration:
94  //
95  GFluxI* AdoptFluxGenerator(GFluxI* generator); ///< return previous
96  GFlavorMixerI* AdoptFlavorMixer(GFlavorMixerI* mixer); ///< return previous
97  GFluxI* GetFluxGenerator() { return fRealGFluxI; } ///< access, not ownership
98  GFlavorMixerI* GetFlavorMixer() { return fFlavorMixer; } ///< access, not ownership
99 
100  void PrintConfig(void);
101  void PrintState(bool verbose=true);
102 
103  private:
104  int ChooseFlavor(int pdg_init, double energy, double dist);
105 
106  GFluxI* fRealGFluxI; ///< actual flux generator
107  GNuMIFlux* fGNuMIFlux; ///< ref to avoid repeat dynamic_cast
108  GSimpleNtpFlux* fGSimpleFlux; ///< ref to avoid repeat dynamic_cast
109 
110  GFlavorMixerI* fFlavorMixer; ///< flavor modification schema
111 
112  PDGCodeList fPDGListGenerator; ///< possible flavors from generator
113  PDGCodeList fPDGListMixed; ///< possible flavors after mixing
114  size_t fNPDGOut; ///< # of possible output flavors
115 
116  double fBaselineDist; ///< travel dist for mixing (if flux doesn't support GetDecayDist())
117 
118  double fEnergy; ///< current neutrino's energy
119  double fDistance; ///< current neutrino's travel distance
120  int fPdgCGenerated; ///< current neutrino's original flavor
121  int fPdgCMixed; ///< current neutrino's new flavor
122 
123  std::vector<double> fProb; ///< individual transition probs
124  std::vector<double> fSumProb; ///< cummulative probability
125  double fRndm; ///< random # used to make choice
126 
127  };
128 
129 } // namespace flux
130 } // namespace genie
131 #endif //GENIE_FLUX_GFLUXBLENDER_H
virtual double MaxEnergy(void)=0
declare the max flux neutrino energy that can be generated (for init. purposes)
bool End(void)
true if no more flux nu&#39;s can be thrown (eg reaching end of beam sim ntuples)
Definition: GFluxBlender.h:72
const TLorentzVector & Position(void)
returns the flux neutrino 4-position (note: expect SI rather than physical units) ...
Definition: GFluxBlender.h:71
double GetBaselineDist(void)
Definition: GFluxBlender.h:90
long int Index(void)
returns corresponding index for current flux neutrino (e.g. for a flux ntuple returns the current ent...
void Clear(Option_t *opt)
reset state variables based on opt
A GENIE flux driver using a simple ntuple format.
void GenerateWeighted(bool gen_weighted)
set whether to generate weighted or unweighted neutrinos
GSimpleNtpFlux * fGSimpleFlux
ref to avoid repeat dynamic_cast
Definition: GFluxBlender.h:108
virtual const TLorentzVector & Position(void)=0
returns the flux neutrino 4-position (note: expect SI rather than physical units) ...
void PrintState(bool verbose=true)
double fEnergy
current neutrino&#39;s energy
Definition: GFluxBlender.h:118
GFlavorMixerI * GetFlavorMixer()
access, not ownership
Definition: GFluxBlender.h:98
double fDistance
current neutrino&#39;s travel distance
Definition: GFluxBlender.h:119
int fPdgCMixed
current neutrino&#39;s new flavor
Definition: GFluxBlender.h:121
GFluxI * AdoptFluxGenerator(GFluxI *generator)
return previous
GFluxI * fRealGFluxI
actual flux generator
Definition: GFluxBlender.h:106
A list of PDG codes.
Definition: PDGCodeList.h:32
int fPdgCGenerated
current neutrino&#39;s original flavor
Definition: GFluxBlender.h:120
PDGCodeList fPDGListMixed
possible flavors after mixing
Definition: GFluxBlender.h:113
std::vector< double > fProb
individual transition probs
Definition: GFluxBlender.h:123
A GENIE flux driver encapsulating the NuMI neutrino flux. It reads-in the official GNUMI neutrino flu...
Definition: GNuMIFlux.h:217
double fRndm
random # used to make choice
Definition: GFluxBlender.h:125
bool GenerateNext(void)
generate the next flux neutrino (return false in err)
TRandom3 generator(0)
GFlavorMixerI * AdoptFlavorMixer(GFlavorMixerI *mixer)
return previous
GENIE interface for flavor modification.
Definition: GFlavorMixerI.h:42
const TLorentzVector & Momentum(void)
returns the flux neutrino 4-momentum
Definition: GFluxBlender.h:70
double fBaselineDist
travel dist for mixing (if flux doesn&#39;t support GetDecayDist())
Definition: GFluxBlender.h:116
size_t fNPDGOut
of possible output flavors
Definition: GFluxBlender.h:114
double Weight(void)
returns the flux neutrino weight (if any)
Definition: GFluxBlender.h:69
GNuMIFlux * fGNuMIFlux
ref to avoid repeat dynamic_cast
Definition: GFluxBlender.h:107
void SetBaselineDist(double dist)
Definition: GFluxBlender.h:89
GFluxI * GetFluxGenerator()
access, not ownership
Definition: GFluxBlender.h:97
int PdgCode(void)
returns the flux neutrino pdg code
Definition: GFluxBlender.h:68
int ChooseFlavor(int pdg_init, double energy, double dist)
virtual const TLorentzVector & Momentum(void)=0
returns the flux neutrino 4-momentum
virtual bool End(void)=0
true if no more flux nu&#39;s can be thrown (eg reaching end of beam sim ntuples)
virtual double Weight(void)=0
returns the flux neutrino weight (if any)
double MaxEnergy(void)
declare the max flux neutrino energy that can be generated (for init. purposes)
Definition: GFluxBlender.h:66
GFlavorMixerI * fFlavorMixer
flavor modification schema
Definition: GFluxBlender.h:110
const PDGCodeList & FluxParticles(void)
declare list of flux neutrinos that can be generated (for init. purposes)
GENIE GFluxI adapter to allow flavor modification.
Definition: GFluxBlender.h:52
int PdgCodeGenerated(void)
returns the flux neutrino original pdg code
Definition: GFluxBlender.h:80
std::vector< double > fSumProb
cummulative probability
Definition: GFluxBlender.h:124
PDGCodeList fPDGListGenerator
possible flavors from generator
Definition: GFluxBlender.h:112
double TravelDist(void)
returns the distance used in the flavor mixing
Definition: GFluxBlender.h:82
GENIE Interface for user-defined flux classes.
Definition: GFluxI.h:29