Public Member Functions | Private Member Functions | Private Attributes | List of all members
genie::flux::GCylindTH1Flux Class Reference

A generic GENIE flux driver. Generates a 'cylindrical' neutrino beam along the input direction, with the input transverse radius and centered at the input position. The energies are generated from the input energy spectrum (TH1D). Multiple neutrino species can be generated (you will need to supply an energy spectrum for each). More...

#include <GCylindTH1Flux.h>

Inheritance diagram for genie::flux::GCylindTH1Flux:
genie::GFluxI

Public Member Functions

 GCylindTH1Flux ()
 
 ~GCylindTH1Flux ()
 
void SetNuDirection (const TVector3 &direction)
 
void SetBeamSpot (const TVector3 &spot)
 
void SetTransverseRadius (double Rt)
 
void AddEnergySpectrum (int nu_pdgc, TH1D *spectrum)
 
void SetRtDependence (string rdep)
 
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...
 
- Public Member Functions inherited from genie::GFluxI
virtual ~GFluxI ()
 

Private Member Functions

void Initialize (void)
 
void CleanUp (void)
 
void ResetSelection (void)
 
void AddAllFluxes (void)
 
int SelectNeutrino (double Ev)
 
double GeneratePhi (void) const
 
double GenerateRt (void) const
 

Private Attributes

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...
 
vector< TH1D * > fSpectrum
 flux = f(Ev), 1/neutrino species More...
 
TH1D * fTotSpectrum
 combined flux = f(Ev) More...
 
TVector3 * fDirVec
 neutrino direction More...
 
TVector3 * fBeamSpot
 beam spot position More...
 
double fRt
 transverse size of neutrino beam More...
 
TF1 * fRtDep
 transverse radius dependence More...
 

Additional Inherited Members

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

Detailed Description

A generic GENIE flux driver. Generates a 'cylindrical' neutrino beam along the input direction, with the input transverse radius and centered at the input position. The energies are generated from the input energy spectrum (TH1D). Multiple neutrino species can be generated (you will need to supply an energy spectrum for each).

Author
Costas Andreopoulos <constantinos.andreopoulos cern.ch> University of Liverpool & STFC Rutherford Appleton Laboratory

July 4, 2005

Copyright (c) 2003-2020, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 43 of file GCylindTH1Flux.h.

Constructor & Destructor Documentation

GCylindTH1Flux::GCylindTH1Flux ( )

Definition at line 35 of file GCylindTH1Flux.cxx.

36 {
37  this->Initialize();
38 }
GCylindTH1Flux::~GCylindTH1Flux ( )

Definition at line 40 of file GCylindTH1Flux.cxx.

41 {
42  this->CleanUp();
43 }

Member Function Documentation

void GCylindTH1Flux::AddAllFluxes ( void  )
private

Definition at line 218 of file GCylindTH1Flux.cxx.

219 {
220  LOG("Flux", pNOTICE) << "Computing combined flux";
221 
222  if(fTotSpectrum) delete fTotSpectrum;
223 
224  vector<TH1D *>::const_iterator spectrum_iter;
225 
226  unsigned int inu=0;
227  for(spectrum_iter = fSpectrum.begin();
228  spectrum_iter != fSpectrum.end(); ++spectrum_iter) {
229  TH1D * spectrum = *spectrum_iter;
230 
231  if(inu==0) { fTotSpectrum = new TH1D(*spectrum); }
232  else { fTotSpectrum->Add(spectrum); }
233  inu++;
234  }
235 }
intermediate_table::const_iterator const_iterator
vector< TH1D * > fSpectrum
flux = f(Ev), 1/neutrino species
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
TH1D * fTotSpectrum
combined flux = f(Ev)
#define pNOTICE
Definition: Messenger.h:61
void GCylindTH1Flux::AddEnergySpectrum ( int  nu_pdgc,
TH1D *  spectrum 
)

Definition at line 183 of file GCylindTH1Flux.cxx.

184 {
185  LOG("Flux", pNOTICE) << "Adding flux spectrum for pdg = " << nu_pdgc;
186 
187  fPdgCList->push_back(nu_pdgc);
188 
189  bool accepted = (count(fPdgCList->begin(),fPdgCList->end(),nu_pdgc) == 1);
190  if(!accepted) {
191  LOG ("Flux", pWARN)
192  << "The pdg-code isn't recognized and the spectrum was ignored";
193  } else {
194  fSpectrum.push_back(spectrum);
195 
196  int nb = spectrum->GetNbinsX();
197  Axis_t max = spectrum->GetBinLowEdge(nb)+spectrum->GetBinWidth(nb);
198  fMaxEv = TMath::Max(fMaxEv, (double)max);
199 
200  LOG("Flux", pNOTICE)
201  << "Updating maximum energy of flux particles to: " << fMaxEv;
202 
203  this->AddAllFluxes(); // update combined flux
204  }
205 }
static constexpr double nb
Definition: Units.h:81
PDGCodeList * fPdgCList
list of neutrino pdg-codes
vector< TH1D * > fSpectrum
flux = f(Ev), 1/neutrino species
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
static int max(int a, int b)
#define pWARN
Definition: Messenger.h:60
#define pNOTICE
Definition: Messenger.h:61
void push_back(int pdg_code)
Definition: PDGCodeList.cxx:58
double fMaxEv
maximum energy
void GCylindTH1Flux::CleanUp ( void  )
private

Definition at line 145 of file GCylindTH1Flux.cxx.

146 {
147  LOG("Flux", pNOTICE) << "Cleaning up...";
148 
149  if (fDirVec ) delete fDirVec;
150  if (fBeamSpot ) delete fBeamSpot;
151  if (fPdgCList ) delete fPdgCList;
152  if (fTotSpectrum) delete fTotSpectrum;
153  if (fRtDep ) delete fRtDep;
154 
155  unsigned int nspectra = fSpectrum.size();
156  for(unsigned int i = 0; i < nspectra; i++) {
157  TH1D * spectrum = fSpectrum[i];
158  delete spectrum;
159  spectrum = 0;
160  }
161 }
PDGCodeList * fPdgCList
list of neutrino pdg-codes
TVector3 * fBeamSpot
beam spot position
vector< TH1D * > fSpectrum
flux = f(Ev), 1/neutrino species
TF1 * fRtDep
transverse radius dependence
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
TVector3 * fDirVec
neutrino direction
TH1D * fTotSpectrum
combined flux = f(Ev)
#define pNOTICE
Definition: Messenger.h:61
void GCylindTH1Flux::Clear ( Option_t *  opt)
virtual

reset state variables based on opt

Implements genie::GFluxI.

Definition at line 103 of file GCylindTH1Flux.cxx.

104 {
105 // Dummy clear method needed to conform to GFluxI interface
106 //
107  LOG("Flux", pERROR) <<
108  "No Clear(Option_t * opt) method implemented for opt: "<< opt;
109 }
#define pERROR
Definition: Messenger.h:59
opt
Definition: train.py:196
#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::GCylindTH1Flux::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 64 of file GCylindTH1Flux.h.

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

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

Implements genie::GFluxI.

Definition at line 57 of file GCylindTH1Flux.h.

57 { return *fPdgCList; }
PDGCodeList * fPdgCList
list of neutrino pdg-codes
bool GCylindTH1Flux::GenerateNext ( void  )
virtual

generate the next flux neutrino (return false in err)

Implements genie::GFluxI.

Definition at line 45 of file GCylindTH1Flux.cxx.

46 {
47  //-- Reset previously generated neutrino code / 4-p / 4-x
48  this->ResetSelection();
49 
50  //-- Generate an energy from the 'combined' spectrum histogram
51  // and compute the momentum vector
52  double Ev = (double) fTotSpectrum->GetRandom();
53 
54  TVector3 p3(*fDirVec); // momentum along the neutrino direction
55  p3.SetMag(Ev); // with |p|=Ev
56  // EDIT: Check if we're running with DM beam
58  double Md = PDGLibrary::Instance()->Find(kPdgDarkMatter)->Mass();
59  p3.SetMag(TMath::Sqrt(Ev*Ev - Md*Md));
60  }
61 
62  fgP4.SetPxPyPzE(p3.Px(), p3.Py(), p3.Pz(), Ev);
63 
64  //-- Select a neutrino species from the flux fractions at the
65  // selected energy
66  fgPdgC = (*fPdgCList)[this->SelectNeutrino(Ev)];
67 
68  //-- Compute neutrino 4-x
69 
70  if(fRt <= 0) {
71  fgX4.SetXYZT(0.,0.,0.,0.);
72  }
73  else {
74  // Create a vector (vec) that points to a random position at a disk
75  // of radius Rt passing through the origin, perpendicular to the
76  // input direction.
77  TVector3 vec0(*fDirVec); // vector along the input direction
78  TVector3 vec = vec0.Orthogonal(); // orthogonal vector
79 
80  double psi = this->GeneratePhi(); // rndm angle [0,2pi]
81  double Rt = this->GenerateRt(); // rndm R [0,Rtransverse]
82 
83  vec.Rotate(psi,vec0); // rotate around original vector
84  vec.SetMag(Rt); // set new norm
85 
86  // Set the neutrino position as beam_spot + vec
87  double x = fBeamSpot->X() + vec.X();
88  double y = fBeamSpot->Y() + vec.Y();
89  double z = fBeamSpot->Z() + vec.Z();
90 
91  fgX4.SetXYZT(x,y,z,0.);
92  }
93 
94  LOG("Flux", pINFO) << "Generated neutrino pdg-code: " << fgPdgC;
95  LOG("Flux", pINFO)
96  << "Generated neutrino p4: " << utils::print::P4AsShortString(&fgP4);
97  LOG("Flux", pINFO)
98  << "Generated neutrino x4: " << utils::print::X4AsString(&fgX4);
99 
100  return true;
101 }
string P4AsShortString(const TLorentzVector *p)
Definition: PrintUtils.cxx:45
PDGCodeList * fPdgCList
list of neutrino pdg-codes
const int kPdgDarkMatter
Definition: PDGCodes.h:218
TLorentzVector fgP4
running generated nu 4-momentum
bool ExistsInPDGCodeList(int pdg_code) const
TVector3 * fBeamSpot
beam spot position
TLorentzVector fgX4
running generated nu 4-position
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
const int kPdgAntiDarkMatter
Definition: PDGCodes.h:219
double GenerateRt(void) const
TVector3 * fDirVec
neutrino direction
int fgPdgC
running generated nu pdg-code
double fRt
transverse size of neutrino beam
#define pINFO
Definition: Messenger.h:62
double GeneratePhi(void) const
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:57
TH1D * fTotSpectrum
combined flux = f(Ev)
list x
Definition: train.py:276
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:75
string X4AsString(const TLorentzVector *x)
Definition: PrintUtils.cxx:57
double GCylindTH1Flux::GeneratePhi ( void  ) const
private

Definition at line 271 of file GCylindTH1Flux.cxx.

272 {
273  RandomGen * rnd = RandomGen::Instance();
274  double phi = 2.*kPi * rnd->RndFlux().Rndm(); // [0,2pi]
275  return phi;
276 }
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
Definition: RandomGen.h:71
static const double kPi
Definition: Constants.h:37
double GCylindTH1Flux::GenerateRt ( void  ) const
private

Definition at line 278 of file GCylindTH1Flux.cxx.

279 {
280  double Rt = fRtDep->GetRandom(); // rndm R [0,Rtransverse]
281  return Rt;
282 }
TF1 * fRtDep
transverse radius dependence
void GCylindTH1Flux::GenerateWeighted ( bool  gen_weighted)
virtual

set whether to generate weighted or unweighted neutrinos

Implements genie::GFluxI.

Definition at line 111 of file GCylindTH1Flux.cxx.

112 {
113 // Dummy implementation needed to conform to GFluxI interface
114 //
115  LOG("Flux", pERROR) <<
116  "No GenerateWeighted(bool gen_weighted) method implemented for " <<
117  "gen_weighted: " << gen_weighted;
118 }
#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::GCylindTH1Flux::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 65 of file GCylindTH1Flux.h.

65 { return -1; }
void GCylindTH1Flux::Initialize ( void  )
private

Definition at line 120 of file GCylindTH1Flux.cxx.

121 {
122  LOG("Flux", pNOTICE) << "Initializing GCylindTH1Flux driver";
123 
124  fMaxEv = 0;
125  fPdgCList = new PDGCodeList;
126  fTotSpectrum = 0;
127  fDirVec = 0;
128  fBeamSpot = 0;
129  fRt =-1;
130  fRtDep = 0;
131 
132  this->ResetSelection();
133  this->SetRtDependence("x");
134  //eg, other example: this->SetRtDependence("pow(x,2)");
135 }
PDGCodeList * fPdgCList
list of neutrino pdg-codes
void SetRtDependence(string rdep)
TVector3 * fBeamSpot
beam spot position
A list of PDG codes.
Definition: PDGCodeList.h:32
TF1 * fRtDep
transverse radius dependence
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
TVector3 * fDirVec
neutrino direction
double fRt
transverse size of neutrino beam
TH1D * fTotSpectrum
combined flux = f(Ev)
#define pNOTICE
Definition: Messenger.h:61
double fMaxEv
maximum energy
double genie::flux::GCylindTH1Flux::MaxEnergy ( void  )
inlinevirtual

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

Implements genie::GFluxI.

Definition at line 58 of file GCylindTH1Flux.h.

58 { return fMaxEv; }
double fMaxEv
maximum energy
const TLorentzVector& genie::flux::GCylindTH1Flux::Momentum ( void  )
inlinevirtual

returns the flux neutrino 4-momentum

Implements genie::GFluxI.

Definition at line 62 of file GCylindTH1Flux.h.

62 { return fgP4; }
TLorentzVector fgP4
running generated nu 4-momentum
int genie::flux::GCylindTH1Flux::PdgCode ( void  )
inlinevirtual

returns the flux neutrino pdg code

Implements genie::GFluxI.

Definition at line 60 of file GCylindTH1Flux.h.

60 { return fgPdgC; }
int fgPdgC
running generated nu pdg-code
const TLorentzVector& genie::flux::GCylindTH1Flux::Position ( void  )
inlinevirtual

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

Implements genie::GFluxI.

Definition at line 63 of file GCylindTH1Flux.h.

63 { return fgX4; }
TLorentzVector fgX4
running generated nu 4-position
void GCylindTH1Flux::ResetSelection ( void  )
private

Definition at line 137 of file GCylindTH1Flux.cxx.

138 {
139 // initializing running neutrino pdg-code, 4-position, 4-momentum
140  fgPdgC = 0;
141  fgP4.SetPxPyPzE (0.,0.,0.,0.);
142  fgX4.SetXYZT (0.,0.,0.,0.);
143 }
TLorentzVector fgP4
running generated nu 4-momentum
TLorentzVector fgX4
running generated nu 4-position
int fgPdgC
running generated nu pdg-code
int GCylindTH1Flux::SelectNeutrino ( double  Ev)
private

Definition at line 237 of file GCylindTH1Flux.cxx.

238 {
239  const unsigned int n = fPdgCList->size();
240  double fraction[n];
241 
242  vector<TH1D *>::const_iterator spectrum_iter;
243 
244  unsigned int inu=0;
245  for(spectrum_iter = fSpectrum.begin();
246  spectrum_iter != fSpectrum.end(); ++spectrum_iter) {
247  TH1D * spectrum = *spectrum_iter;
248  fraction[inu++] = spectrum->GetBinContent(spectrum->FindBin(Ev));
249  }
250 
251  double sum = 0;
252  for(inu = 0; inu < n; inu++) {
253  sum += fraction[inu];
254  fraction[inu] = sum;
255  LOG("Flux", pDEBUG) << "SUM-FRACTION(0->" << inu <<") = " << sum;
256  }
257 
258  RandomGen * rnd = RandomGen::Instance();
259  double R = sum * rnd->RndFlux().Rndm();
260 
261  LOG("Flux", pDEBUG) << "R e [0,SUM] = " << R;
262 
263  for(inu = 0; inu < n; inu++) {if ( R < fraction[inu] ) return inu;}
264 
265  LOG("Flux", pERROR) << "Could not select a neutrino species";
266  assert(false);
267 
268  return -1;
269 }
#define pERROR
Definition: Messenger.h:59
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
PDGCodeList * fPdgCList
list of neutrino pdg-codes
intermediate_table::const_iterator const_iterator
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
vector< TH1D * > fSpectrum
flux = f(Ev), 1/neutrino species
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
std::void_t< T > n
size_t size
Definition: lodepng.cpp:55
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
Definition: RandomGen.h:71
#define pDEBUG
Definition: Messenger.h:63
void GCylindTH1Flux::SetBeamSpot ( const TVector3 &  spot)

Definition at line 169 of file GCylindTH1Flux.cxx.

170 {
171  if(fBeamSpot) delete fBeamSpot;
172  fBeamSpot = new TVector3(spot);
173 }
TVector3 * fBeamSpot
beam spot position
void GCylindTH1Flux::SetNuDirection ( const TVector3 &  direction)

Definition at line 163 of file GCylindTH1Flux.cxx.

164 {
165  if(fDirVec) delete fDirVec;
166  fDirVec = new TVector3(direction);
167 }
TVector3 * fDirVec
neutrino direction
void GCylindTH1Flux::SetRtDependence ( string  rdep)

Definition at line 207 of file GCylindTH1Flux.cxx.

208 {
209 // Set the (functional form of) Rt dependence as string, eg "x*x+sin(x)"
210 // You do not need to set this method. The default behaviour is to generate
211 // flux neutrinos uniformly over the area of the cylinder's cross section.
212 
213  if(fRtDep) delete fRtDep;
214 
215  fRtDep = new TF1("rdep", rdep.c_str(), 0,fRt);
216 }
TF1 * fRtDep
transverse radius dependence
double fRt
transverse size of neutrino beam
void GCylindTH1Flux::SetTransverseRadius ( double  Rt)

Definition at line 175 of file GCylindTH1Flux.cxx.

176 {
177  LOG ("Flux", pNOTICE) << "Setting R[transverse] = " << Rt;
178  fRt = Rt;
179 
180  if(fRtDep) fRtDep->SetRange(0,Rt);
181 }
TF1 * fRtDep
transverse radius dependence
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
double fRt
transverse size of neutrino beam
#define pNOTICE
Definition: Messenger.h:61
double genie::flux::GCylindTH1Flux::Weight ( void  )
inlinevirtual

returns the flux neutrino weight (if any)

Implements genie::GFluxI.

Definition at line 61 of file GCylindTH1Flux.h.

61 { return 1.0; }

Member Data Documentation

TVector3* genie::flux::GCylindTH1Flux::fBeamSpot
private

beam spot position

Definition at line 89 of file GCylindTH1Flux.h.

TVector3* genie::flux::GCylindTH1Flux::fDirVec
private

neutrino direction

Definition at line 88 of file GCylindTH1Flux.h.

TLorentzVector genie::flux::GCylindTH1Flux::fgP4
private

running generated nu 4-momentum

Definition at line 84 of file GCylindTH1Flux.h.

int genie::flux::GCylindTH1Flux::fgPdgC
private

running generated nu pdg-code

Definition at line 83 of file GCylindTH1Flux.h.

TLorentzVector genie::flux::GCylindTH1Flux::fgX4
private

running generated nu 4-position

Definition at line 85 of file GCylindTH1Flux.h.

double genie::flux::GCylindTH1Flux::fMaxEv
private

maximum energy

Definition at line 81 of file GCylindTH1Flux.h.

PDGCodeList* genie::flux::GCylindTH1Flux::fPdgCList
private

list of neutrino pdg-codes

Definition at line 82 of file GCylindTH1Flux.h.

double genie::flux::GCylindTH1Flux::fRt
private

transverse size of neutrino beam

Definition at line 90 of file GCylindTH1Flux.h.

TF1* genie::flux::GCylindTH1Flux::fRtDep
private

transverse radius dependence

Definition at line 91 of file GCylindTH1Flux.h.

vector<TH1D *> genie::flux::GCylindTH1Flux::fSpectrum
private

flux = f(Ev), 1/neutrino species

Definition at line 86 of file GCylindTH1Flux.h.

TH1D* genie::flux::GCylindTH1Flux::fTotSpectrum
private

combined flux = f(Ev)

Definition at line 87 of file GCylindTH1Flux.h.


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