GENIEGenerator
Loading...
Searching...
No Matches
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"
Include dependency graph for gtestFluxSimple.cxx:

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

◆ createFluxNtuple()

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}
#define pINFO
Definition Messenger.h:62
#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
GENIE flux drivers.

References kNEvents, LOG, and pINFO.

Referenced by runGCylindTH1FluxDriver().

◆ main()

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)
hadnt Write("hadnt")

References LOG, pINFO, runGCylindTH1FluxDriver(), and Write().

◆ runGCylindTH1FluxDriver()

TNtuple * runGCylindTH1FluxDriver ( void )

Definition at line 57 of file gtestFluxSimple.cxx.

58{
59 LOG("test", pINFO) << "Creating GCylindTH1Flux flux driver";
60
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}
GENIE Interface for user-defined flux classes.
Definition GFluxI.h:29
A generic GENIE flux driver. Generates a 'cylindrical' neutrino beam along the input direction,...
TNtuple * createFluxNtuple(GFluxI *flux)
const int kPdgAntiNuMu
Definition PDGCodes.h:31
const int kPdgNuMu
Definition PDGCodes.h:30

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

Referenced by main().

Variable Documentation

◆ kNEvents

const unsigned int kNEvents = 10000

Definition at line 32 of file gtestFluxSimple.cxx.