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