GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
genie::flux::GPowerLawFlux Class Reference

A simple GENIE flux driver for neutrinos following a power law spectrum. Can handle a mix of neutrinos with their corresponding weight. More...

#include <GPowerLawFlux.h>

Inheritance diagram for genie::flux::GPowerLawFlux:
Inheritance graph
[legend]
Collaboration diagram for genie::flux::GPowerLawFlux:
Collaboration graph
[legend]

Public Member Functions

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

Private Member Functions

void CleanUp (void)
 

Private Attributes

double fSpectralIndex
 spectral index (E^{-alpha}) More...
 
double fMinEv
 minimum energy More...
 
double fMaxEv
 maximum energy More...
 
PDGCodeListfPdgCList
 list of neutrino pdg-codes More...
 
int fgPdgC
 running generated nu pdg-code More...
 
TLorentzVector fgP4
 running generated nu 4-momentum More...
 
TLorentzVector fgX4
 running generated nu 4-position More...
 
map< int, double > fProb
 cumulative probability of neutrino types More...
 
double fProbMax
 

Additional Inherited Members

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

Detailed Description

A simple GENIE flux driver for neutrinos following a power law spectrum. Can handle a mix of neutrinos with their corresponding weight.

Author
Alfonso Garcia <aagarciasoto km3net.de> IFIC
Created:
May 02, 2023
License:
Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 36 of file GPowerLawFlux.h.

Constructor & Destructor Documentation

GPowerLawFlux::GPowerLawFlux ( )

Definition at line 28 of file GPowerLawFlux.cxx.

28  :
29 GFluxI()
30 {
31  // default ctor for consistency with GFluxDriverFactory needs
32  // up to user to call Initialize() to set energy and flavor(s)
33 }
GPowerLawFlux::GPowerLawFlux ( double  alpha,
double  emin,
double  emax,
int  pdg 
)

Definition at line 35 of file GPowerLawFlux.cxx.

References Initialize().

35  :
36 GFluxI()
37 {
38  this->Initialize(alpha,emin,emax,pdg);
39 }
void Initialize(double alpha, double emin, double emax, int pdg)
GPowerLawFlux::GPowerLawFlux ( double  alpha,
double  emin,
double  emax,
const map< int, double > &  numap 
)

Definition at line 41 of file GPowerLawFlux.cxx.

References Initialize().

42  :
43 GFluxI()
44 {
45  this->Initialize(alpha,emin,emax,numap);
46 }
void Initialize(double alpha, double emin, double emax, int pdg)
GPowerLawFlux::~GPowerLawFlux ( )

Definition at line 48 of file GPowerLawFlux.cxx.

References CleanUp().

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

Member Function Documentation

void GPowerLawFlux::CleanUp ( void  )
private

Definition at line 144 of file GPowerLawFlux.cxx.

References fPdgCList, LOG, and pNOTICE.

Referenced by ~GPowerLawFlux().

145 {
146  LOG("Flux", pNOTICE) << "Cleaning up...";
147 
148  if (fPdgCList) delete fPdgCList;
149 }
PDGCodeList * fPdgCList
list of neutrino pdg-codes
Definition: GPowerLawFlux.h:77
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pNOTICE
Definition: Messenger.h:61
void GPowerLawFlux::Clear ( Option_t *  opt)
virtual

reset state variables based on opt

Implements genie::GFluxI.

Definition at line 87 of file GPowerLawFlux.cxx.

References LOG, and pERROR.

88 {
89 // Dummy clear method needed to conform to GFluxI interface
90 //
91  LOG("Flux", pERROR) <<
92  "No Clear(Option_t * opt) method implemented for opt: "<< opt;
93 }
#define pERROR
Definition: Messenger.h:59
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
bool genie::flux::GPowerLawFlux::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 52 of file GPowerLawFlux.h.

52 { return false; }
const PDGCodeList& genie::flux::GPowerLawFlux::FluxParticles ( void  )
inlinevirtual

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

Implements genie::GFluxI.

Definition at line 45 of file GPowerLawFlux.h.

References fPdgCList.

45 { return *fPdgCList; }
PDGCodeList * fPdgCList
list of neutrino pdg-codes
Definition: GPowerLawFlux.h:77
bool GPowerLawFlux::GenerateNext ( void  )
virtual

generate the next flux neutrino (return false in err)

Implements genie::GFluxI.

Definition at line 53 of file GPowerLawFlux.cxx.

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

54 {
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  double Ev = 0.;
69  if (fSpectralIndex==1) Ev = TMath::Exp(TMath::Log(fMinEv)+rnd->RndFlux().Rndm()*TMath::Log(fMaxEv/fMinEv));
70  else {
71  double pemin = TMath::Power(fMinEv, 1.-fSpectralIndex);
72  double pemax = TMath::Power(fMaxEv, 1.-fSpectralIndex);
73  Ev = TMath::Power(pemin+(pemax-pemin)*rnd->RndFlux().Rndm(),1./(1.-fSpectralIndex));
74  }
75 
76  fgP4.SetPxPyPzE (0.,0.,Ev,Ev);
77 
78  LOG("Flux", pINFO)
79  << "Generated neutrino: "
80  << "\n pdg-code: " << fgPdgC
81  << "\n p4: " << utils::print::P4AsShortString(&fgP4)
82  << "\n x4: " << utils::print::X4AsString(&fgX4);
83 
84  return true;
85 }
string P4AsShortString(const TLorentzVector *p)
Definition: PrintUtils.cxx:45
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
map< int, double > fProb
cumulative probability of neutrino types
Definition: GPowerLawFlux.h:81
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
double fSpectralIndex
spectral index (E^{-alpha})
Definition: GPowerLawFlux.h:74
TLorentzVector fgX4
running generated nu 4-position
Definition: GPowerLawFlux.h:80
double fMaxEv
maximum energy
Definition: GPowerLawFlux.h:76
#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
int fgPdgC
running generated nu pdg-code
Definition: GPowerLawFlux.h:78
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
Definition: RandomGen.h:71
string X4AsString(const TLorentzVector *x)
Definition: PrintUtils.cxx:57
double fMinEv
minimum energy
Definition: GPowerLawFlux.h:75
TLorentzVector fgP4
running generated nu 4-momentum
Definition: GPowerLawFlux.h:79
void GPowerLawFlux::GenerateWeighted ( bool  gen_weighted)
virtual

set whether to generate weighted or unweighted neutrinos

Implements genie::GFluxI.

Definition at line 95 of file GPowerLawFlux.cxx.

References LOG, and pERROR.

96 {
97 // Dummy implementation needed to conform to GFluxI interface
98 //
99  LOG("Flux", pERROR) <<
100  "No GenerateWeighted(bool gen_weighted) method implemented for " <<
101  "gen_weighted: " << gen_weighted;
102 }
#define pERROR
Definition: Messenger.h:59
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
long int genie::flux::GPowerLawFlux::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 53 of file GPowerLawFlux.h.

53 { return -1; }
void GPowerLawFlux::Initialize ( double  alpha,
double  emin,
double  emax,
int  pdg 
)

Definition at line 104 of file GPowerLawFlux.cxx.

Referenced by GPowerLawFlux().

105 {
106  map<int,double> numap;
107  numap.insert( map<int, double>::value_type(pdg, 1.) );
108 
109  this->Initialize(alpha,emin,emax,numap);
110 }
void Initialize(double alpha, double emin, double emax, int pdg)
void GPowerLawFlux::Initialize ( double  alpha,
double  emin,
double  emax,
const map< int, double > &  numap 
)

Definition at line 112 of file GPowerLawFlux.cxx.

References fgPdgC, fgX4, fMaxEv, fMinEv, fPdgCList, fProb, fProbMax, fSpectralIndex, LOG, pNOTICE, and genie::PDGCodeList::push_back().

113 {
114  LOG("Flux", pNOTICE) << "Initializing GPowerLawFlux driver";
115 
116  fSpectralIndex = alpha;
117  fMinEv = emin;
118  fMaxEv = emax;
119 
120  LOG("Flux", pNOTICE) << "Spectral Index : " << fSpectralIndex;
121  LOG("Flux", pNOTICE) << "Energy range : " << fMinEv << " , " << fMaxEv;
122 
123  fPdgCList = new PDGCodeList;
124  fPdgCList->clear();
125 
126  fProbMax = 0;
127  fProb.clear();
128 
129  map<int,double>::const_iterator iter;
130  for(iter = numap.begin(); iter != numap.end(); ++iter) {
131  int nupdgc = iter->first;
132  double nuwgt = iter->second;
133 
134  fPdgCList->push_back(nupdgc);
135 
136  fProbMax+=nuwgt;
137  fProb.insert(map<int, double>::value_type(nupdgc,fProbMax));
138  }
139 
140  fgPdgC = 0;
141  fgX4.SetXYZT (0.,0.,0.,0.);
142 }
map< int, double > fProb
cumulative probability of neutrino types
Definition: GPowerLawFlux.h:81
PDGCodeList * fPdgCList
list of neutrino pdg-codes
Definition: GPowerLawFlux.h:77
A list of PDG codes.
Definition: PDGCodeList.h:32
double fSpectralIndex
spectral index (E^{-alpha})
Definition: GPowerLawFlux.h:74
TLorentzVector fgX4
running generated nu 4-position
Definition: GPowerLawFlux.h:80
double fMaxEv
maximum energy
Definition: GPowerLawFlux.h:76
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
int fgPdgC
running generated nu pdg-code
Definition: GPowerLawFlux.h:78
#define pNOTICE
Definition: Messenger.h:61
double fMinEv
minimum energy
Definition: GPowerLawFlux.h:75
void push_back(int pdg_code)
Definition: PDGCodeList.cxx:58
double genie::flux::GPowerLawFlux::MaxEnergy ( void  )
inlinevirtual

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

Implements genie::GFluxI.

Definition at line 46 of file GPowerLawFlux.h.

References fMaxEv.

46 { return fMaxEv; }
double fMaxEv
maximum energy
Definition: GPowerLawFlux.h:76
const TLorentzVector& genie::flux::GPowerLawFlux::Momentum ( void  )
inlinevirtual

returns the flux neutrino 4-momentum

Implements genie::GFluxI.

Definition at line 50 of file GPowerLawFlux.h.

References fgP4.

50 { return fgP4; }
TLorentzVector fgP4
running generated nu 4-momentum
Definition: GPowerLawFlux.h:79
int genie::flux::GPowerLawFlux::PdgCode ( void  )
inlinevirtual

returns the flux neutrino pdg code

Implements genie::GFluxI.

Definition at line 48 of file GPowerLawFlux.h.

References fgPdgC.

48 { return fgPdgC; }
int fgPdgC
running generated nu pdg-code
Definition: GPowerLawFlux.h:78
const TLorentzVector& genie::flux::GPowerLawFlux::Position ( void  )
inlinevirtual

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

Implements genie::GFluxI.

Definition at line 51 of file GPowerLawFlux.h.

References fgX4.

51 { return fgX4; }
TLorentzVector fgX4
running generated nu 4-position
Definition: GPowerLawFlux.h:80
void GPowerLawFlux::SetBeamSpot ( const TVector3 &  spot)

Definition at line 174 of file GPowerLawFlux.cxx.

References SetRayOrigin().

175 {
176  SetRayOrigin(spot.x(), spot.y(), spot.z());
177 }
void SetRayOrigin(double x, double y, double z)
void GPowerLawFlux::SetDirectionCos ( double  dx,
double  dy,
double  dz 
)

Definition at line 151 of file GPowerLawFlux.cxx.

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

Referenced by SetNuDirection().

152 {
153  TVector3 dircos1 = TVector3(dx,dy,dz).Unit();
154  LOG("Flux", pNOTICE) << "SetDirectionCos "
155  << utils::print::P3AsString(&dircos1);
156  double E = fgP4.E();
157  fgP4.SetVect(E*dircos1);
158 
159 }
string P3AsString(const TVector3 *vec)
Definition: PrintUtils.cxx:69
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pNOTICE
Definition: Messenger.h:61
TLorentzVector fgP4
running generated nu 4-momentum
Definition: GPowerLawFlux.h:79
void GPowerLawFlux::SetNuDirection ( const TVector3 &  direction)

Definition at line 169 of file GPowerLawFlux.cxx.

References SetDirectionCos().

170 {
171  SetDirectionCos(direction.x(), direction.y(), direction.z());
172 }
void SetDirectionCos(double dx, double dy, double dz)
void GPowerLawFlux::SetRayOrigin ( double  x,
double  y,
double  z 
)

Definition at line 161 of file GPowerLawFlux.cxx.

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

Referenced by SetBeamSpot().

162 {
163  TVector3 xyz(x,y,z);
164  LOG("Flux", pNOTICE) << "SetRayOrigin "
166  fgX4.SetVect(xyz);
167 }
TLorentzVector fgX4
running generated nu 4-position
Definition: GPowerLawFlux.h:80
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pNOTICE
Definition: Messenger.h:61
string Vec3AsString(const TVector3 *vec)
Definition: PrintUtils.cxx:80
double genie::flux::GPowerLawFlux::Weight ( void  )
inlinevirtual

returns the flux neutrino weight (if any)

Implements genie::GFluxI.

Definition at line 49 of file GPowerLawFlux.h.

49 { return 1.0; }

Member Data Documentation

TLorentzVector genie::flux::GPowerLawFlux::fgP4
private

running generated nu 4-momentum

Definition at line 79 of file GPowerLawFlux.h.

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

int genie::flux::GPowerLawFlux::fgPdgC
private

running generated nu pdg-code

Definition at line 78 of file GPowerLawFlux.h.

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

TLorentzVector genie::flux::GPowerLawFlux::fgX4
private

running generated nu 4-position

Definition at line 80 of file GPowerLawFlux.h.

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

double genie::flux::GPowerLawFlux::fMaxEv
private

maximum energy

Definition at line 76 of file GPowerLawFlux.h.

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

double genie::flux::GPowerLawFlux::fMinEv
private

minimum energy

Definition at line 75 of file GPowerLawFlux.h.

Referenced by GenerateNext(), and Initialize().

PDGCodeList* genie::flux::GPowerLawFlux::fPdgCList
private

list of neutrino pdg-codes

Definition at line 77 of file GPowerLawFlux.h.

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

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

cumulative probability of neutrino types

Definition at line 81 of file GPowerLawFlux.h.

Referenced by GenerateNext(), and Initialize().

double genie::flux::GPowerLawFlux::fProbMax
private

Definition at line 82 of file GPowerLawFlux.h.

Referenced by GenerateNext(), and Initialize().

double genie::flux::GPowerLawFlux::fSpectralIndex
private

spectral index (E^{-alpha})

Definition at line 74 of file GPowerLawFlux.h.

Referenced by GenerateNext(), and Initialize().


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