GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions | Variables
gtestFluxAtmo.cxx File Reference
#include <TFile.h>
#include <TNtuple.h>
#include <TSystem.h>
#include <TH1D.h>
#include <TF1.h>
#include "Tools/Flux/GFLUKAAtmoFlux.h"
#include "Tools/Flux/GBGLRSAtmoFlux.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/ParticleData/PDGCodes.h"
Include dependency graph for gtestFluxAtmo.cxx:

Go to the source code of this file.

Functions

TNtuple * runGFlukaAtmo3DFluxDriver (void)
 
TNtuple * runGBartolAtmoFluxDriver (void)
 
TNtuple * createFluxNtuple (GFluxI *flux)
 
int main (int, char **)
 

Variables

const unsigned int kNEvents = 100000
 

Function Documentation

TNtuple * createFluxNtuple ( GFluxI flux)

Definition at line 120 of file gtestFluxAtmo.cxx.

References genie::GFluxI::GenerateNext(), kNEvents, LOG, genie::GFluxI::Momentum(), genie::GFluxI::PdgCode(), pINFO, genie::GFluxI::Position(), and genie::GFluxI::Weight().

Referenced by runGBartolAtmoFluxDriver(), runGCylindTH1FluxDriver(), and runGFlukaAtmo3DFluxDriver().

121 {
122  TNtuple * fluxntp =
123  new TNtuple("fluxntp", "flux", "x:y:z:t:px:py:pz:E:pdgc:wght");
124 
125  LOG("test", pINFO) << "Generating flux neutrinos";
126 
127  unsigned int ievent = 0;
128  while(ievent++ < kNEvents) {
129  LOG("test", pINFO) << "Event number: " << ievent;
130  flux->GenerateNext();
131  int pdgc = flux->PdgCode();
132  double wght = flux->Weight();
133  const TLorentzVector & x4 = flux->Position();
134  const TLorentzVector & p4 = flux->Momentum();
135  fluxntp->Fill(
136  x4.X(), x4.Y(), x4.Z(), x4.T(),
137  p4.Px(), p4.Py(), p4.Pz(), p4.E(), pdgc, wght);
138  }
139  return fluxntp;
140 }
virtual const TLorentzVector & Position(void)=0
returns the flux neutrino 4-position (note: expect SI rather than physical units) ...
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
const unsigned int kNEvents
#define pINFO
Definition: Messenger.h:62
virtual bool GenerateNext(void)=0
generate the next flux neutrino (return false in err)
virtual int PdgCode(void)=0
returns the flux neutrino pdg code
virtual const TLorentzVector & Momentum(void)=0
returns the flux neutrino 4-momentum
virtual double Weight(void)=0
returns the flux neutrino weight (if any)
int main ( int  ,
char **   
)

Definition at line 40 of file gtestFluxAtmo.cxx.

References LOG, pINFO, runGBartolAtmoFluxDriver(), runGFlukaAtmo3DFluxDriver(), and Write().

41 {
42  LOG("test", pINFO) << "Running GFlukaAtmo3DFlux driver test";
43  TNtuple * ntfluka = runGFlukaAtmo3DFluxDriver();
44  ntfluka->SetTitle("GFlukaAtmo3DFlux driver data");
45 
46  LOG("test", pINFO) << "Running GBartolAtmoFlux driver test";
47  TNtuple * ntbartol = runGBartolAtmoFluxDriver();
48  ntbartol->SetTitle("GBartolAtmoFlux driver data");
49 
50  LOG("test", pINFO) << "Saving flux ntuples";
51 
52  TFile f("./genie-flux-drivers.root","recreate");
53  ntfluka -> Write("ntfluka");
54  ntbartol -> Write("ntbartol");
55  f.Close();
56 
57  LOG("test", pINFO) << "Done!";
58 
59  return 0;
60 }
TNtuple * runGFlukaAtmo3DFluxDriver(void)
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
TNtuple * runGBartolAtmoFluxDriver(void)
hadnt Write("hadnt")
TNtuple * runGBartolAtmoFluxDriver ( void  )

Definition at line 93 of file gtestFluxAtmo.cxx.

References createFluxNtuple(), genie::kPdgAntiNuE, genie::kPdgAntiNuMu, genie::kPdgNuE, genie::kPdgNuMu, LOG, and pINFO.

Referenced by main().

94 {
95  string base_dir =
96  (gSystem->Getenv("GFLUX_BGLRS3DATMO") ?
97  gSystem->Getenv("GFLUX_BGLRS3DATMO") : ".");
98 
99  double Rlongitudinal = 1000.; //m
100  double Rtransverse = 100.; //m
101 
102  GBGLRSAtmoFlux * flux = new GBGLRSAtmoFlux;
103 
104  flux -> AddFluxFile ( kPdgNuMu, base_dir + "/f210_3_z.kam_num" );
105  flux -> AddFluxFile ( kPdgAntiNuMu, base_dir + "/f210_3_z.kam_nbm" );
106  flux -> AddFluxFile ( kPdgNuE, base_dir + "/f210_3_z.kam_nue" );
107  flux -> AddFluxFile ( kPdgAntiNuE, base_dir + "/f210_3_z.kam_nbe" );
108  flux -> SetRadii(Rlongitudinal, Rtransverse);
109  flux -> LoadFluxData();
110  flux -> GenerateWeighted(true);
111 //flux -> ForceMaxEnergy(300);
112 
113  LOG("test", pINFO) << "Generating events";
114  TNtuple * fluxntp = createFluxNtuple(dynamic_cast<GFluxI*>(flux));
115  delete flux;
116 
117  return fluxntp;
118 }
const int kPdgNuE
Definition: PDGCodes.h:28
const int kPdgAntiNuE
Definition: PDGCodes.h:29
const int kPdgNuMu
Definition: PDGCodes.h:30
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
TNtuple * createFluxNtuple(GFluxI *flux)
const int kPdgAntiNuMu
Definition: PDGCodes.h:31
A flux driver for the Bartol Atmospheric Neutrino Flux.
TNtuple * runGFlukaAtmo3DFluxDriver ( void  )

Definition at line 62 of file gtestFluxAtmo.cxx.

References createFluxNtuple(), genie::kPdgAntiNuE, genie::kPdgAntiNuMu, genie::kPdgNuE, genie::kPdgNuMu, LOG, and pINFO.

Referenced by main().

63 {
64  string base_dir =
65  (gSystem->Getenv("GFLUX_FLUKA3DATMO") ?
66  gSystem->Getenv("GFLUX_FLUKA3DATMO") : ".");
67 
68  double Rlongitudinal = 1000.; //m
69  double Rtransverse = 100.; //m
70 
71  GFLUKAAtmoFlux * flux = new GFLUKAAtmoFlux;
72 
73  LOG("test", pINFO) << base_dir + "/sdave_numu07.dat";
74  LOG("test", pINFO) << base_dir + "/sdave_anumu07.dat";
75  LOG("test", pINFO) << base_dir + "/sdave_nue07.dat";
76  LOG("test", pINFO) << base_dir + "/sdave_anue07.dat";
77 
78 
79  flux -> AddFluxFile ( kPdgNuMu, base_dir + "/sdave_numu07.dat" );
80  flux -> AddFluxFile ( kPdgAntiNuMu, base_dir + "/sdave_anumu07.dat" );
81  flux -> AddFluxFile ( kPdgNuE, base_dir + "/sdave_nue07.dat" );
82  flux -> AddFluxFile ( kPdgAntiNuE, base_dir + "/sdave_anue07.dat" );
83  flux -> SetRadii(Rlongitudinal, Rtransverse);
84  flux -> LoadFluxData();
85  flux -> GenerateWeighted(true);
86 //flux -> ForceMaxEnergy(3);
87 
88  LOG("test", pINFO) << "Generating events";
89  TNtuple * fluxntp = createFluxNtuple(dynamic_cast<GFluxI*>(flux));
90  return fluxntp;
91 }
const int kPdgNuE
Definition: PDGCodes.h:28
const int kPdgAntiNuE
Definition: PDGCodes.h:29
const int kPdgNuMu
Definition: PDGCodes.h:30
A flux driver for the FLUKA 3-D Atmospheric Neutrino Flux.
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
TNtuple * createFluxNtuple(GFluxI *flux)
const int kPdgAntiNuMu
Definition: PDGCodes.h:31

Variable Documentation

const unsigned int kNEvents = 100000

Definition at line 33 of file gtestFluxAtmo.cxx.