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

#include <GAstroFlux.h>

Public Member Functions

 NuGenerator ()
 
 ~NuGenerator ()
 
bool SelectNuPdg (bool weighted, const map< int, double > &nupdgpdf, int &nupdg, double &wght)
 
bool SelectEnergy (bool weighted, TH1D &log10epdf, double log10emin, double log10emax, double &log10e, double &wght)
 
bool SelectOrigin (bool weighted, TH2D &opdf, double &phi, double &costheta, double &wght)
 

Detailed Description

Definition at line 199 of file GAstroFlux.h.

Constructor & Destructor Documentation

genie::flux::GAstroFlux::NuGenerator::NuGenerator ( )
inline

Definition at line 201 of file GAstroFlux.h.

201 {}
genie::flux::GAstroFlux::NuGenerator::~NuGenerator ( )
inline

Definition at line 202 of file GAstroFlux.h.

202 {}

Member Function Documentation

bool GAstroFlux::NuGenerator::SelectEnergy ( bool  weighted,
TH1D &  log10epdf,
double  log10emin,
double  log10emax,
double &  log10e,
double &  wght 
)

Definition at line 411 of file GAstroFlux.cxx.

References genie::RandomGen::Instance(), and genie::RandomGen::RndFlux().

414 {
415 // select neutrino energy
416 //
417 
418  log10E = -9999999;
419  wght = 0;
420 
421  if(log10Emax <= log10Emin) {
422  return false;
423  }
424 
425  // Generate weighted flux:
426  //
427  if(weighted) {
428  RandomGen * rnd = RandomGen::Instance();
429  log10E = log10Emin + (log10Emax-log10Emin) * rnd->RndFlux().Rndm();
430  wght = log10Epdf.GetBinContent(log10Epdf.FindBin(log10E));
431  }
432 
433  // Generate un-weighted flux:
434  //
435  else {
436  do {
437  log10E = log10Epdf.GetRandom();
438  }
439  while(log10E < log10Emin || log10E > log10Emax);
440  wght = 1.;
441  }
442 
443  return true;
444 }
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
bool GAstroFlux::NuGenerator::SelectNuPdg ( bool  weighted,
const map< int, double > &  nupdgpdf,
int &  nupdg,
double &  wght 
)

Definition at line 363 of file GAstroFlux.cxx.

References genie::RandomGen::Instance(), and genie::RandomGen::RndFlux().

366 {
367 // select neutrino species based on relative neutrino species populations
368 //
369  nupdg = 0;
370  wght = 0;
371 
372  if(nupdgpdf.size() == 0) {
373  return false;
374  }
375 
376  RandomGen * rnd = RandomGen::Instance();
377 
378  // Generate weighted flux:
379  //
380  if(weighted) {
381  unsigned int nnu = nupdgpdf.size();
382  unsigned int inu = rnd->RndFlux().Integer(nnu);
383  map<int,double>::const_iterator iter = nupdgpdf.begin();
384  advance(iter,inu);
385  nupdg = iter->first;
386  wght = iter->second;
387  }
388  // Generate un-weighted flux:
389  //
390  else {
391  double xsum = 0.;
392  double xrnd = rnd->RndFlux().Uniform();
393  map<int,double>::const_iterator iter = nupdgpdf.begin();
394  for( ; iter != nupdgpdf.end(); ++iter) {
395  xsum += iter->second;
396  if(xrnd < xsum) {
397  nupdg = iter->first;
398  break;
399  }
400  }
401  wght = 1.;
402  }
403 
404  if(nupdg==0) {
405  return false;
406  }
407 
408  return true;
409 }
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
bool GAstroFlux::NuGenerator::SelectOrigin ( bool  weighted,
TH2D &  opdf,
double &  phi,
double &  costheta,
double &  wght 
)

Definition at line 446 of file GAstroFlux.cxx.

References genie::RandomGen::Instance(), genie::constants::kPi, and genie::RandomGen::RndFlux().

449 {
450  wght = 0;
451  costheta = -999999;
452  phi = -999999;
453 
454  // Generate weighted flux:
455  //
456  if(weighted) {
457  RandomGen * rnd = RandomGen::Instance();
458  phi = 2.*kPi * rnd->RndFlux().Rndm();
459  costheta = -1. + 2.*rnd->RndFlux().Rndm();
460  wght = opdf.GetBinContent(opdf.FindBin(phi,costheta));
461  }
462 
463  // Generate un-weighted flux:
464  //
465  else {
466  opdf.GetRandom2(phi,costheta);
467  wght = 1.;
468  }
469 
470  return true;
471 }
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

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