Functions | Variables
gtestFluxSimple.cxx File Reference
#include <TFile.h>
#include <TNtuple.h>
#include <TSystem.h>
#include <TH1D.h>
#include <TF1.h>
#include "Tools/Flux/GCylindTH1Flux.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/ParticleData/PDGCodes.h"

Go to the source code of this file.

Functions

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

Variables

const unsigned int kNEvents = 10000
 

Function Documentation

TNtuple* createFluxNtuple ( GFluxI flux)

Definition at line 98 of file gtestFluxSimple.cxx.

99 {
100  TNtuple * fluxntp =
101  new TNtuple("fluxntp",
102  "flux data", "x:y:z:t:px:py:pz:E:pdgc");
103 
104  LOG("test", pINFO) << "Generating flux neutrinos";
105 
106  unsigned int ievent = 0;
107  while(ievent++ < kNEvents) {
108 
109  flux->GenerateNext();
110 
111  int pdgc = flux->PdgCode();
112  const TLorentzVector & x4 = flux->Position();
113  const TLorentzVector & p4 = flux->Momentum();
114 
115  fluxntp->Fill( x4.X(), x4.Y(), x4.Z(), x4.T(),
116  p4.Px(), p4.Py(), p4.Pz(), p4.E(), pdgc);
117  }
118  return fluxntp;
119 }
const unsigned int kNEvents
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
#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
int main ( int  ,
char **   
)

Definition at line 38 of file gtestFluxSimple.cxx.

39 {
40  LOG("test", pINFO) << "Running GCylindTH1Flux driver test";
41  TNtuple * ntcylh1f = runGCylindTH1FluxDriver();
42  ntcylh1f->SetTitle("GCylindTH1Flux driver data");
43 
44  LOG("test", pINFO) << "Saving flux ntuples";
45 
46  TFile f("./genie-flux-drivers.root","recreate");
47  ntcylh1f -> Write("ntcylh1f");
48  f.Close();
49 
50  delete ntcylh1f;
51 
52  LOG("test", pINFO) << "Done!";
53 
54  return 0;
55 }
TNtuple * runGCylindTH1FluxDriver(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
hadnt Write("hadnt")
TNtuple * runGCylindTH1FluxDriver ( void  )

Definition at line 57 of file gtestFluxSimple.cxx.

58 {
59  LOG("test", pINFO) << "Creating GCylindTH1Flux flux driver";
60 
61  GCylindTH1Flux * flux = new GCylindTH1Flux;
62 
63  LOG("test", pINFO) << "Setting configuration data";
64 
65  TF1 * f1 = new TF1("f1","1./x",0.5,5.0);
66  TH1D * spectrum1 = new TH1D("spectrum1","numu E", 20,0.5,5);
67  spectrum1->FillRandom("f1",100000);
68 
69  TF1 * f2 = new TF1("f2","x",0.5,5.0);
70  TH1D * spectrum2 = new TH1D("spectrum2","numubar E", 20,0.5,5);
71  spectrum2->FillRandom("f2",10000);
72 
73  TVector3 direction(0,0,1);
74  TVector3 beam_spot(0,0,-10);
75 
76  double Rtransverse = 0.5;
77 
78  LOG("test", pINFO) << "Configuring GCylindTH1Flux flux driver";
79 
80  flux -> SetNuDirection (direction);
81  flux -> SetBeamSpot (beam_spot);
82  flux -> SetTransverseRadius (Rtransverse);
83  flux -> AddEnergySpectrum (kPdgNuMu, spectrum1);
84  flux -> AddEnergySpectrum (kPdgAntiNuMu, spectrum2);
85 
86  LOG("test", pINFO) << "Creating flux ntuple";
87  GFluxI * fluxi = dynamic_cast<GFluxI*>(flux);
88 
89  TNtuple * fluxntp = createFluxNtuple(fluxi);
90 
91  delete f1;
92  delete f2;
93  delete flux;
94 
95  return fluxntp;
96 }
TNtuple * createFluxNtuple(GFluxI *flux)
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
A generic GENIE flux driver. Generates a &#39;cylindrical&#39; neutrino beam along the input direction...
#define pINFO
Definition: Messenger.h:62
const int kPdgAntiNuMu
Definition: PDGCodes.h:31
GENIE Interface for user-defined flux classes.
Definition: GFluxI.h:29

Variable Documentation

const unsigned int kNEvents = 10000

Definition at line 32 of file gtestFluxSimple.cxx.