Public Member Functions | List of all members
genie::flux::GAstroFlux::NuGenerator Class Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/genie/v3_00_06_p01/Linux64bit+2.6-2.12-e17-debug/GENIE-Generator/src/Tools/Flux/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 202 of file GAstroFlux.h.

Constructor & Destructor Documentation

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

Definition at line 204 of file GAstroFlux.h.

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

Definition at line 205 of file GAstroFlux.h.

References SelectEnergy(), SelectNuPdg(), and SelectOrigin().

205 {}

Member Function Documentation

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

Definition at line 423 of file GAstroFlux.cxx.

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

Referenced by ~NuGenerator().

426 {
427 // select neutrino energy
428 //
429 
430  log10E = -9999999;
431  wght = 0;
432 
433  if(log10Emax <= log10Emin) {
434  return false;
435  }
436 
437  // Generate weighted flux:
438  //
439  if(weighted) {
441  log10E = log10Emin + (log10Emax-log10Emin) * rnd->RndFlux().Rndm();
442  wght = log10Epdf.GetBinContent(log10Epdf.FindBin(log10E));
443  }
444 
445  // Generate un-weighted flux:
446  //
447  else {
448  do {
449  log10E = log10Epdf.GetRandom();
450  }
451  while(log10E < log10Emin || log10E > log10Emax);
452  wght = 1.;
453  }
454 
455  return true;
456 }
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:79
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:30
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
Definition: RandomGen.h:72
bool GAstroFlux::NuGenerator::SelectNuPdg ( bool  weighted,
const map< int, double > &  nupdgpdf,
int nupdg,
double &  wght 
)

Definition at line 375 of file GAstroFlux.cxx.

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

Referenced by ~NuGenerator().

378 {
379 // select neutrino species based on relative neutrino species populations
380 //
381  nupdg = 0;
382  wght = 0;
383 
384  if(nupdgpdf.size() == 0) {
385  return false;
386  }
387 
389 
390  // Generate weighted flux:
391  //
392  if(weighted) {
393  unsigned int nnu = nupdgpdf.size();
394  unsigned int inu = rnd->RndFlux().Integer(nnu);
395  map<int,double>::const_iterator iter = nupdgpdf.begin();
396  advance(iter,inu);
397  nupdg = iter->first;
398  wght = iter->second;
399  }
400  // Generate un-weighted flux:
401  //
402  else {
403  double xsum = 0.;
404  double xrnd = rnd->RndFlux().Uniform();
405  map<int,double>::const_iterator iter = nupdgpdf.begin();
406  for( ; iter != nupdgpdf.end(); ++iter) {
407  xsum += iter->second;
408  if(xrnd < xsum) {
409  nupdg = iter->first;
410  break;
411  }
412  }
413  wght = 1.;
414  }
415 
416  if(nupdg==0) {
417  return false;
418  }
419 
420  return true;
421 }
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:79
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:30
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
Definition: RandomGen.h:72
bool GAstroFlux::NuGenerator::SelectOrigin ( bool  weighted,
TH2D &  opdf,
double &  phi,
double &  costheta,
double &  wght 
)

Definition at line 458 of file GAstroFlux.cxx.

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

Referenced by ~NuGenerator().

461 {
462  wght = 0;
463  costheta = -999999;
464  phi = -999999;
465 
466  // Generate weighted flux:
467  //
468  if(weighted) {
470  phi = 2.*kPi * rnd->RndFlux().Rndm();
471  costheta = -1. + 2.*rnd->RndFlux().Rndm();
472  wght = opdf.GetBinContent(opdf.FindBin(phi,costheta));
473  }
474 
475  // Generate un-weighted flux:
476  //
477  else {
478  opdf.GetRandom2(phi,costheta);
479  wght = 1.;
480  }
481 
482  return true;
483 }
const double kPi
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:79
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:30
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
Definition: RandomGen.h:72

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