GENIEGenerator
Loading...
Searching...
No Matches
genie::flux::GMonoEnergeticFlux Class Reference

A simple GENIE flux driver for monoenergetic neutrinos along the z direction. Can handle a mix of neutrinos with their corresponding weight. This trivial flux driver was added in so that single energy neutrinos can be easily used with the event generation driver that can handle a target mix or detailed geometries. More...

#include <GMonoEnergeticFlux.h>

Inheritance diagram for genie::flux::GMonoEnergeticFlux:
[legend]
Collaboration diagram for genie::flux::GMonoEnergeticFlux:
[legend]

Public Member Functions

 GMonoEnergeticFlux ()
 GMonoEnergeticFlux (double Ev, int pdg)
 GMonoEnergeticFlux (double Ev, const map< int, double > &numap)
 ~GMonoEnergeticFlux ()
const PDGCodeList & FluxParticles (void)
 declare list of flux neutrinos that can be generated (for init. purposes)
double MaxEnergy (void)
 declare the max flux neutrino energy that can be generated (for init. purposes)
bool GenerateNext (void)
 generate the next flux neutrino (return false in err)
int PdgCode (void)
 returns the flux neutrino pdg code
double Weight (void)
 returns the flux neutrino weight (if any)
const TLorentzVector & Momentum (void)
 returns the flux neutrino 4-momentum
const TLorentzVector & Position (void)
 returns the flux neutrino 4-position (note: expect SI rather than physical units)
bool End (void)
 true if no more flux nu's can be thrown (eg reaching end of beam sim ntuples)
long int Index (void)
 returns corresponding index for current flux neutrino (e.g. for a flux ntuple returns the current entry number)
void Clear (Option_t *opt)
 reset state variables based on opt
void GenerateWeighted (bool gen_weighted)
 set whether to generate weighted or unweighted neutrinos
void SetDirectionCos (double dx, double dy, double dz)
void SetRayOrigin (double x, double y, double z)
void SetNuDirection (const TVector3 &direction)
void SetBeamSpot (const TVector3 &spot)
void Initialize (double Ev, int pdg)
void Initialize (double Ev, const map< int, double > &numap)
Public Member Functions inherited from genie::GFluxI
virtual ~GFluxI ()

Private Member Functions

void CleanUp (void)

Private Attributes

double fMaxEv
 maximum energy
PDGCodeList * fPdgCList
 list of neutrino pdg-codes
int fgPdgC
 running generated nu pdg-code
TLorentzVector fgP4
 running generated nu 4-momentum
TLorentzVector fgX4
 running generated nu 4-position
map< int, double > fProb
double fProbMax

Additional Inherited Members

Protected Member Functions inherited from genie::GFluxI
 GFluxI ()

Detailed Description

A simple GENIE flux driver for monoenergetic neutrinos along the z direction. Can handle a mix of neutrinos with their corresponding weight. This trivial flux driver was added in so that single energy neutrinos can be easily used with the event generation driver that can handle a target mix or detailed geometries.

Author
Costas Andreopoulos <c.andreopoulos \at cern.ch> University of Liverpool
Created:\n Feb 08, 2008
License:\n Copyright (c) 2003-2025, The GENIE Collaboration
For the full text of the license visit http://copyright.genie-mc.org

Definition at line 38 of file GMonoEnergeticFlux.h.

Constructor & Destructor Documentation

◆ GMonoEnergeticFlux() [1/3]

GMonoEnergeticFlux::GMonoEnergeticFlux ( )

Definition at line 28 of file GMonoEnergeticFlux.cxx.

28 :
29GFluxI()
30{
31 // default ctor for consistency with GFluxDriverFactory needs
32 // up to user to call Initialize() to set energy and flavor(s)
33}

References genie::GFluxI::GFluxI().

◆ GMonoEnergeticFlux() [2/3]

GMonoEnergeticFlux::GMonoEnergeticFlux ( double Ev,
int pdg )

Definition at line 35 of file GMonoEnergeticFlux.cxx.

35 :
36GFluxI()
37{
38 this->Initialize(Ev,pdg);
39}
void Initialize(void)

References genie::GFluxI::GFluxI(), and Initialize().

◆ GMonoEnergeticFlux() [3/3]

GMonoEnergeticFlux::GMonoEnergeticFlux ( double Ev,
const map< int, double > & numap )

Definition at line 41 of file GMonoEnergeticFlux.cxx.

42 :
43GFluxI()
44{
45 this->Initialize(Ev,numap);
46}

References genie::GFluxI::GFluxI(), and Initialize().

◆ ~GMonoEnergeticFlux()

GMonoEnergeticFlux::~GMonoEnergeticFlux ( )

Definition at line 48 of file GMonoEnergeticFlux.cxx.

49{
50 this->CleanUp();
51}

References CleanUp().

Member Function Documentation

◆ CleanUp()

void GMonoEnergeticFlux::CleanUp ( void )
private

Definition at line 130 of file GMonoEnergeticFlux.cxx.

131{
132 LOG("Flux", pNOTICE) << "Cleaning up...";
133
134 if (fPdgCList) delete fPdgCList;
135}
#define pNOTICE
Definition Messenger.h:61
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
PDGCodeList * fPdgCList
list of neutrino pdg-codes

References fPdgCList, LOG, and pNOTICE.

Referenced by ~GMonoEnergeticFlux().

◆ Clear()

void GMonoEnergeticFlux::Clear ( Option_t * opt)
virtual

reset state variables based on opt

Implements genie::GFluxI.

Definition at line 77 of file GMonoEnergeticFlux.cxx.

78{
79// Dummy clear method needed to conform to GFluxI interface
80//
81 LOG("Flux", pERROR) <<
82 "No Clear(Option_t * opt) method implemented for opt: "<< opt;
83}
#define pERROR
Definition Messenger.h:59

References LOG, and pERROR.

◆ End()

bool genie::flux::GMonoEnergeticFlux::End ( void )
inlinevirtual

true if no more flux nu's can be thrown (eg reaching end of beam sim ntuples)

Implements genie::GFluxI.

Definition at line 54 of file GMonoEnergeticFlux.h.

54{ return false; }

◆ FluxParticles()

const PDGCodeList & genie::flux::GMonoEnergeticFlux::FluxParticles ( void )
inlinevirtual

declare list of flux neutrinos that can be generated (for init. purposes)

Implements genie::GFluxI.

Definition at line 47 of file GMonoEnergeticFlux.h.

47{ return *fPdgCList; }

References fPdgCList.

◆ GenerateNext()

bool GMonoEnergeticFlux::GenerateNext ( void )
virtual

generate the next flux neutrino (return false in err)

Implements genie::GFluxI.

Definition at line 53 of file GMonoEnergeticFlux.cxx.

54{
55 RandomGen * rnd = RandomGen::Instance();
56 double p = fProbMax * rnd->RndFlux().Rndm();
57
58 map<int,double>::const_iterator iter;
59 for(iter = fProb.begin(); iter != fProb.end(); ++iter) {
60 int nupdgc = iter->first;
61 double prob = iter->second;
62 if (p<prob) {
63 fgPdgC = nupdgc;
64 break;
65 }
66 }
67
68 LOG("Flux", pINFO)
69 << "Generated neutrino: "
70 << "\n pdg-code: " << fgPdgC
71 << "\n p4: " << utils::print::P4AsShortString(&fgP4)
72 << "\n x4: " << utils::print::X4AsString(&fgX4);
73
74 return true;
75}
#define pINFO
Definition Messenger.h:62
static RandomGen * Instance()
Access instance.
Definition RandomGen.cxx:74
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
Definition RandomGen.h:71
TLorentzVector fgX4
running generated nu 4-position
int fgPdgC
running generated nu pdg-code
TLorentzVector fgP4
running generated nu 4-momentum
string X4AsString(const TLorentzVector *x)
string P4AsShortString(const TLorentzVector *p)

References fgP4, fgPdgC, fgX4, fProb, fProbMax, genie::RandomGen::Instance(), LOG, genie::utils::print::P4AsShortString(), pINFO, genie::RandomGen::RndFlux(), and genie::utils::print::X4AsString().

◆ GenerateWeighted()

void GMonoEnergeticFlux::GenerateWeighted ( bool gen_weighted)
virtual

set whether to generate weighted or unweighted neutrinos

Implements genie::GFluxI.

Definition at line 85 of file GMonoEnergeticFlux.cxx.

86{
87// Dummy implementation needed to conform to GFluxI interface
88//
89 LOG("Flux", pERROR) <<
90 "No GenerateWeighted(bool gen_weighted) method implemented for " <<
91 "gen_weighted: " << gen_weighted;
92}

References LOG, and pERROR.

◆ Index()

long int genie::flux::GMonoEnergeticFlux::Index ( void )
inlinevirtual

returns corresponding index for current flux neutrino (e.g. for a flux ntuple returns the current entry number)

Implements genie::GFluxI.

Definition at line 55 of file GMonoEnergeticFlux.h.

55{ return -1; }

◆ Initialize() [1/2]

void GMonoEnergeticFlux::Initialize ( double Ev,
const map< int, double > & numap )

Definition at line 102 of file GMonoEnergeticFlux.cxx.

103{
104 LOG("Flux", pNOTICE) << "Initializing GMonoEnergeticFlux driver";
105
106 fMaxEv = Ev + 0.05;
107
108 fPdgCList = new PDGCodeList;
109 fPdgCList->clear();
110
111 fProbMax = 0;
112 fProb.clear();
113
114 map<int,double>::const_iterator iter;
115 for(iter = numap.begin(); iter != numap.end(); ++iter) {
116 int nupdgc = iter->first;
117 double nuwgt = iter->second;
118
119 fPdgCList->push_back(nupdgc);
120
121 fProbMax+=nuwgt;
122 fProb.insert(map<int, double>::value_type(nupdgc,fProbMax));
123 }
124
125 fgPdgC = 0;
126 fgP4.SetPxPyPzE (0.,0.,Ev,Ev);
127 fgX4.SetXYZT (0.,0.,0.,0.);
128}

References fgP4, fgPdgC, fgX4, fMaxEv, fPdgCList, fProb, fProbMax, LOG, and pNOTICE.

◆ Initialize() [2/2]

void GMonoEnergeticFlux::Initialize ( double Ev,
int pdg )

Definition at line 94 of file GMonoEnergeticFlux.cxx.

95{
96 map<int,double> numap;
97 numap.insert( map<int, double>::value_type(pdg, 1.) );
98
99 this->Initialize(Ev,numap);
100}

References Initialize().

◆ MaxEnergy()

double genie::flux::GMonoEnergeticFlux::MaxEnergy ( void )
inlinevirtual

declare the max flux neutrino energy that can be generated (for init. purposes)

Implements genie::GFluxI.

Definition at line 48 of file GMonoEnergeticFlux.h.

48{ return fMaxEv; }

References fMaxEv.

◆ Momentum()

const TLorentzVector & genie::flux::GMonoEnergeticFlux::Momentum ( void )
inlinevirtual

returns the flux neutrino 4-momentum

Implements genie::GFluxI.

Definition at line 52 of file GMonoEnergeticFlux.h.

52{ return fgP4; }

References fgP4.

◆ PdgCode()

int genie::flux::GMonoEnergeticFlux::PdgCode ( void )
inlinevirtual

returns the flux neutrino pdg code

Implements genie::GFluxI.

Definition at line 50 of file GMonoEnergeticFlux.h.

50{ return fgPdgC; }

References fgPdgC.

◆ Position()

const TLorentzVector & genie::flux::GMonoEnergeticFlux::Position ( void )
inlinevirtual

returns the flux neutrino 4-position (note: expect SI rather than physical units)

Implements genie::GFluxI.

Definition at line 53 of file GMonoEnergeticFlux.h.

53{ return fgX4; }

References fgX4.

◆ SetBeamSpot()

void GMonoEnergeticFlux::SetBeamSpot ( const TVector3 & spot)

Definition at line 160 of file GMonoEnergeticFlux.cxx.

161{
162 SetRayOrigin(spot.x(), spot.y(), spot.z());
163}
void SetRayOrigin(double x, double y, double z)

References SetRayOrigin().

◆ SetDirectionCos()

void GMonoEnergeticFlux::SetDirectionCos ( double dx,
double dy,
double dz )

Definition at line 137 of file GMonoEnergeticFlux.cxx.

138{
139 TVector3 dircos1 = TVector3(dx,dy,dz).Unit();
140 LOG("Flux", pNOTICE) << "SetDirectionCos "
141 << utils::print::P3AsString(&dircos1);
142 double E = fgP4.E();
143 fgP4.SetVect(E*dircos1);
144
145}
string P3AsString(const TVector3 *vec)

References fgP4, LOG, genie::utils::print::P3AsString(), and pNOTICE.

Referenced by SetNuDirection().

◆ SetNuDirection()

void GMonoEnergeticFlux::SetNuDirection ( const TVector3 & direction)

Definition at line 155 of file GMonoEnergeticFlux.cxx.

156{
157 SetDirectionCos(direction.x(), direction.y(), direction.z());
158}
void SetDirectionCos(double dx, double dy, double dz)

References SetDirectionCos().

◆ SetRayOrigin()

void GMonoEnergeticFlux::SetRayOrigin ( double x,
double y,
double z )

Definition at line 147 of file GMonoEnergeticFlux.cxx.

148{
149 TVector3 xyz(x,y,z);
150 LOG("Flux", pNOTICE) << "SetRayOrigin "
152 fgX4.SetVect(xyz);
153}
string Vec3AsString(const TVector3 *vec)

References fgX4, LOG, pNOTICE, and genie::utils::print::Vec3AsString().

Referenced by SetBeamSpot().

◆ Weight()

double genie::flux::GMonoEnergeticFlux::Weight ( void )
inlinevirtual

returns the flux neutrino weight (if any)

Implements genie::GFluxI.

Definition at line 51 of file GMonoEnergeticFlux.h.

51{ return 1.0; }

Member Data Documentation

◆ fgP4

TLorentzVector genie::flux::GMonoEnergeticFlux::fgP4
private

running generated nu 4-momentum

Definition at line 79 of file GMonoEnergeticFlux.h.

Referenced by GenerateNext(), Initialize(), Momentum(), and SetDirectionCos().

◆ fgPdgC

int genie::flux::GMonoEnergeticFlux::fgPdgC
private

running generated nu pdg-code

Definition at line 78 of file GMonoEnergeticFlux.h.

Referenced by GenerateNext(), Initialize(), and PdgCode().

◆ fgX4

TLorentzVector genie::flux::GMonoEnergeticFlux::fgX4
private

running generated nu 4-position

Definition at line 80 of file GMonoEnergeticFlux.h.

Referenced by GenerateNext(), Initialize(), Position(), and SetRayOrigin().

◆ fMaxEv

double genie::flux::GMonoEnergeticFlux::fMaxEv
private

maximum energy

Definition at line 76 of file GMonoEnergeticFlux.h.

Referenced by Initialize(), and MaxEnergy().

◆ fPdgCList

PDGCodeList* genie::flux::GMonoEnergeticFlux::fPdgCList
private

list of neutrino pdg-codes

Definition at line 77 of file GMonoEnergeticFlux.h.

Referenced by CleanUp(), FluxParticles(), and Initialize().

◆ fProb

map<int, double> genie::flux::GMonoEnergeticFlux::fProb
private

Definition at line 81 of file GMonoEnergeticFlux.h.

Referenced by GenerateNext(), and Initialize().

◆ fProbMax

double genie::flux::GMonoEnergeticFlux::fProbMax
private

Definition at line 82 of file GMonoEnergeticFlux.h.

Referenced by GenerateNext(), and Initialize().


The documentation for this class was generated from the following files: