59 const TLorentzVector & p4 = this->
Momentum();
60 double E = p4.Energy();
63 double wght = this->
Weight();
65 bool accept = (E<=Emax && E>=Emin && wght>0);
66 if(accept)
return true;
100 double emin = TMath::Power(
fEnergyBins[0],1.0-alpha);
102 Ev = TMath::Power(emin+(emax-emin)*rnd->
RndFlux().Rndm(),1.0/(1.0-alpha));
103 costheta = -1+2*rnd->
RndFlux().Rndm();
107 unsigned int inu = rnd->
RndFlux().Integer(nnu);
108 nu_pdg = (*fPdgCList)[inu];
114 double flux = this->
GetFlux(nu_pdg, Ev, costheta, phi);
119 weight =
flux*TMath::Power(Ev,alpha);
127 Axis_t ax = 0, ay = 0, az = 0;
130 costheta = (double)ay;
137 double sintheta = TMath::Sqrt(1-costheta*costheta);
138 double cosphi = TMath::Cos(phi);
139 double sinphi = TMath::Sin(phi);
149 double pz = -1.* Ev * costheta;
150 double py = -1.* Ev * sintheta * sinphi;
151 double px = -1.* Ev * sintheta * cosphi;
163 y +=
fRl * sintheta * sinphi;
164 x +=
fRl * sintheta * cosphi;
171 TVector3 tx3(x, y, z );
172 TVector3 tp3(px,py,pz);
191 TVector3 dvec1 = vec.Orthogonal();
192 TVector3 dvec2 = dvec1;
193 dvec2.Rotate(-
kPi/2.0,vec);
196 double random = rnd->
RndFlux().Rndm();
197 dvec1.SetMag(TMath::Sqrt(random)*
fRt*TMath::Cos(psi));
198 dvec2.SetMag(TMath::Sqrt(random)*
fRt*TMath::Sin(psi));
199 x += dvec1.X() + dvec2.X();
200 y += dvec1.Y() + dvec2.Y();
201 z += dvec1.Z() + dvec2.Z();
206 fgP4.SetPxPyPzE(px, py, pz, Ev);
207 fgX4.SetXYZT (x, y, z, 0.);
214 <<
"Generated neutrino: "
215 <<
"\n pdg-code: " <<
fgPdgC
229 emin = TMath::Max(0., emin);
235 emax = TMath::Max(0., emax);
243 LOG(
"Flux",
pERROR) <<
"No clear method implemented for option:"<< opt;
257 LOG(
"Flux",
pWARN) <<
"Warning: cannot use a spectral index of unity";
260 LOG(
"Flux",
pNOTICE) <<
"Using Spectral Index = " << index;
270 LOG(
"Flux",
pNOTICE) <<
"Initializing atmospheric flux driver";
284 bool allow_dup =
false;
331 fgP4.SetPxPyPzE (0.,0.,0.,0.);
332 fgX4.SetXYZT (0.,0.,0.,0.);
342 TH3D * flux_histogram = rawiter->second;
344 delete flux_histogram;
352 TH3D * flux_histogram = iter->second;
354 delete flux_histogram;
371 LOG (
"Flux",
pNOTICE) <<
"Setting R[longitudinal] = " << Rlongitudinal;
372 LOG (
"Flux",
pNOTICE) <<
"Setting R[transverse] = " << Rtransverse;
397 std::ifstream f(filename.c_str());
399 LOG(
"Flux",
pFATAL) <<
"Flux file does not exist "<<filename;
407 <<
"Input particle code: " << nu_pdg <<
" not a neutrino!";
420 std::ifstream f(filename.c_str());
422 LOG(
"Flux",
pFATAL) <<
"Flux file does not exist "<<filename;
441 <<
"Loading atmospheric neutrino flux simulation data";
446 bool loading_status =
true;
453 LOG(
"Flux",
pNOTICE) <<
"Loading data for: " << pname;
466 loading_status = loading_status && loaded;
470 <<
"Error loading atmospheric neutrino flux simulation data from " << filename;
478 int nu_pdg = hist_iter->first;
479 TH3D* hist = hist_iter->second;
482 fFluxHistoMap.insert( map<int,TH3D*>::value_type(nu_pdg,hnorm) );
487 <<
"Atmospheric neutrino flux simulation data loaded!";
493 <<
"Error loading atmospheric neutrino flux simulation data";
505 TString histname = hist->GetName();
506 histname.Append(
"_IntegratedFlux");
509 TH3D* hist_intg = (TH3D*)(hist->Clone(histname.Data()));
513 Double_t dN_dEdS = 0.0;
518 for(Int_t e_bin = 1; e_bin <= hist->GetXaxis()->GetNbins(); e_bin++)
520 for(Int_t c_bin = 1; c_bin <= hist->GetYaxis()->GetNbins(); c_bin++)
522 for(Int_t p_bin = 1; p_bin <= hist->GetZaxis()->GetNbins(); p_bin++)
524 dN_dEdS = hist->GetBinContent(e_bin,c_bin,p_bin);
526 dE = hist->GetXaxis()->GetBinUpEdge(e_bin)
527 - hist->GetXaxis()->GetBinLowEdge(e_bin);
529 dS = ( hist->GetZaxis()->GetBinUpEdge(p_bin)
530 - hist->GetZaxis()->GetBinLowEdge(p_bin) )
531 * ( hist->GetYaxis()->GetBinUpEdge(c_bin)
532 - hist->GetYaxis()->GetBinLowEdge(c_bin) );
536 hist_intg->SetBinContent(e_bin,c_bin,p_bin,dN);
546 LOG(
"Flux",
pDEBUG) <<
"Forcing flux histogram contents to 0";
554 <<
"Computing combined flux & flux normalization factor";
562 TH3D * flux_histogram = it->second;
571 LOG(
"Flux",
pNOTICE) <<
"Instantiating histogram: [" << name <<
"]";
572 TH3D * hist =
new TH3D(
573 name.c_str(), title.c_str(),
587 double *
flux =
new double[n];
592 TH3D * flux_histogram = it->second;
593 int ibin = flux_histogram->FindBin(Ev,costheta,phi);
594 flux[i] = flux_histogram->GetBinContent(ibin);
602 <<
"Sum{Flux(0->" << i <<
")} = " <<
flux[i];
606 double R = flux_sum * rnd->
RndFlux().Rndm();
613 int selected_pdg = (*fPdgCList)[i];
615 <<
"Selected neutrino PDG code = " << selected_pdg;
621 LOG(
"Flux",
pERROR) <<
"Could not select a neutrino species!";
634 histogram = it->second;
643 map<int,TH3D*>::iterator rawiter;
647 TH3D *
h = rawiter->second;
649 flux +=
h->Integral(
"width");
650 LOG(
"Flux",
pDEBUG) <<
"Total flux for " << rawiter->first <<
" equals " <<
h->Integral(
"width") <<
".";
662 map<int,TH3D*>::iterator rawiter;
663 int e_min_bin, e_max_bin;
670 LOG(
"Flux",
pFATAL) <<
"Emax = " << Emax <<
" is less than Emin = " << Emin;
676 TH3D *
h = rawiter->second;
681 e_min_bin =
h->GetXaxis()->FindBin(Emin);
682 e_max_bin =
h->GetXaxis()->FindBin(Emax);
684 if (e_min_bin >
h->GetXaxis()->GetNbins()) {
687 }
else if (e_min_bin == e_max_bin) {
691 flux +=
h->Integral(e_min_bin,e_min_bin,1,
h->GetYaxis()->GetNbins(),1,
h->GetZaxis()->GetNbins(),
"width")*(Emax - Emin)/(
h->GetXaxis()->GetBinUpEdge(e_min_bin)-
h->GetXaxis()->GetBinLowEdge(e_min_bin));
696 flux +=
h->Integral(e_min_bin,e_min_bin,1,
h->GetYaxis()->GetNbins(),1,
h->GetZaxis()->GetNbins(),
"width")*(
h->GetXaxis()->GetBinUpEdge(e_min_bin) - Emin)/(
h->GetXaxis()->GetBinUpEdge(e_min_bin)-
h->GetXaxis()->GetBinLowEdge(e_min_bin));
699 if (e_min_bin < h->GetXaxis()->GetNbins())
700 flux +=
h->Integral(e_min_bin+1,e_max_bin-1,1,
h->GetYaxis()->GetNbins(),1,
h->GetZaxis()->GetNbins(),
"width");
702 if (e_max_bin <= h->GetXaxis()->GetNbins())
703 flux +=
h->Integral(e_max_bin,e_max_bin,1,
h->GetYaxis()->GetNbins(),1,
h->GetZaxis()->GetNbins(),
"width")*(Emax -
h->GetXaxis()->GetBinLowEdge(e_max_bin))/(
h->GetXaxis()->GetBinUpEdge(e_max_bin)-
h->GetXaxis()->GetBinLowEdge(e_max_bin));
714 if(!flux_hist)
return 0.0;
717 Double_t dN_dEdS = 0.0;
721 for(Int_t e_bin = 1; e_bin <= flux_hist->GetXaxis()->GetNbins(); e_bin++)
723 for(Int_t c_bin = 1; c_bin <= flux_hist->GetYaxis()->GetNbins(); c_bin++)
725 for( Int_t p_bin = 1; p_bin <= flux_hist->GetZaxis()->GetNbins(); p_bin++)
727 dN_dEdS = flux_hist->GetBinContent(e_bin,c_bin,p_bin);
729 dE = flux_hist->GetXaxis()->GetBinUpEdge(e_bin)
730 - flux_hist->GetXaxis()->GetBinLowEdge(e_bin);
732 dS = ( flux_hist->GetZaxis()->GetBinUpEdge(p_bin)
733 - flux_hist->GetZaxis()->GetBinLowEdge(p_bin) )
734 * ( flux_hist->GetYaxis()->GetBinUpEdge(c_bin)
735 - flux_hist->GetYaxis()->GetBinLowEdge(c_bin) );
737 flux += dN_dEdS*dE*dS;
748 if(!flux_hist)
return 0.0;
751 Double_t dN_dEdS = 0.0;
754 Int_t e_bin = flux_hist->GetXaxis()->FindBin(energy);
756 for(Int_t c_bin = 1; c_bin <= flux_hist->GetYaxis()->GetNbins(); c_bin++)
758 for( Int_t p_bin = 1; p_bin <= flux_hist->GetZaxis()->GetNbins(); p_bin++)
760 dN_dEdS = flux_hist->GetBinContent(e_bin,c_bin,p_bin);
762 dS = ( flux_hist->GetZaxis()->GetBinUpEdge(p_bin)
763 - flux_hist->GetZaxis()->GetBinLowEdge(p_bin) )
764 * ( flux_hist->GetYaxis()->GetBinUpEdge(c_bin)
765 - flux_hist->GetYaxis()->GetBinLowEdge(c_bin) );
777 if(!flux_hist)
return 0.0;
780 Double_t dN_dEdS = 0.0;
783 Int_t e_bin = flux_hist->GetXaxis()->FindBin(energy);
784 Int_t c_bin = flux_hist->GetYaxis()->FindBin(costh);
786 for( Int_t p_bin = 1; p_bin <= flux_hist->GetZaxis()->GetNbins(); p_bin++)
788 dN_dEdS = flux_hist->GetBinContent(e_bin,c_bin,p_bin);
790 dS = ( flux_hist->GetZaxis()->GetBinUpEdge(p_bin)
791 - flux_hist->GetZaxis()->GetBinLowEdge(p_bin) );
802 if(!flux_hist)
return 0.0;
804 Int_t e_bin = flux_hist->GetXaxis()->FindBin(energy);
805 Int_t c_bin = flux_hist->GetYaxis()->FindBin(costh);
806 Int_t p_bin = flux_hist->GetZaxis()->FindBin(phi);
808 Double_t
flux = flux_hist->GetBinContent(e_bin,c_bin,p_bin);
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils.
Is a concrete implementation of the QELFormFactorsModelI: Form Factors for Quasi Elastic CC vN Delta ...
static PDGLibrary * Instance(void)
TParticlePDG * Find(int pdgc, bool must_exist=true)
A singleton holding random number generator classes. All random number generation in GENIE should tak...
static RandomGen * Instance()
Access instance.
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
TH3D * CreateNormalisedFluxHisto(TH3D *hist)
map< int, TH3D * > fRawFluxHistoMap
flux = f(Ev,cos8,phi) for each neutrino species
bool fInitialized
flag to check that initialization is run
void AddFluxFile(int neutrino_pdg, string filename)
int fgPdgC
current generated nu pdg-code
bool GenerateNext_1try(void)
double fRl
defining flux neutrino generation surface: longitudinal radius
virtual bool GenerateNext(void)
generate the next flux neutrino (return false in err)
double fWeight
current generated nu weight
TH3D * CreateFluxHisto(string name, string title)
void ForceMaxEnergy(double emax)
double GetTransverseRadius(void)
double GetTotalFlux(void)
PDGCodeList * fPdgCList
input list of neutrino pdg-codes
double fMaxEvCut
user-defined cut: maximum energy
vector< string > fFluxFile
input flux file for each neutrino species
double GetTotalFluxInEnergyRange(void)
TH3D * GetFluxHistogram(int flavour)
TH3D * fTotalFluxHisto
flux = f(Ev,cos8,phi) summed over neutrino species
virtual void Clear(Option_t *opt)
reset state variables based on opt
virtual const TLorentzVector & Momentum(void)
returns the flux neutrino 4-momentum
double GetFluxSurfaceArea(void)
unsigned int fNumEnergyBins
number of energy bins in input flux data files
vector< int > fFluxFlavour
input flux file for each neutrino species
void ForceMinEnergy(double emin)
long int NFluxNeutrinos(void) const
Number of flux nu's generated. Not the same as the number of nu's thrown towards the geometry (if the...
virtual void GenerateWeighted(bool gen_weighted)
set whether to generate weighted or unweighted neutrinos
void ZeroFluxHisto(TH3D *hist)
double fMaxEv
maximum energy (in input flux files)
bool fGenWeighted
generate a weighted or unweighted flux?
double fMinEvCut
user-defined cut: minimum energy
void ResetSelection(void)
double fTotalFluxHistoIntg
fFluxSum2D integral
unsigned int fNumPhiBins
number of phi bins in input flux data files
void SetRadii(double Rlongitudinal, double Rtransverse)
TLorentzVector fgX4
current generated nu 4-position
void SetUserCoordSystem(TRotation &rotation)
Rotation: Topocentric Horizontal -> User-defined Topocentric Coord System.
TRotation fRotTHz2User
coord. system rotation: THZ -> Topocentric user-defined
double * fPhiBins
phi bins in input flux data files
virtual bool FillFluxHisto(int nu_pdg, string filename)=0
map< int, TH3D * > fFluxHistoMap
flux = f(Ev,cos8,phi) for each neutrino species
double * fCosThetaBins
cos(theta) bins in input flux data files
unsigned int fNumCosThetaBins
number of cos(theta) bins in input flux data files
virtual double Weight(void)
returns the flux neutrino weight (if any)
int SelectNeutrino(double Ev, double costheta, double phi)
double * fEnergyBins
energy bins in input flux data files
TLorentzVector fgP4
current generated nu 4-momentum
double GetLongitudinalRadius(void)
void SetSpectralIndex(double index)
double GetFlux(int flavour)
long int fNNeutrinos
number of flux neutrinos thrown so far
double fSpectralIndex
power law function used for weighted flux
virtual double MaxEnergy(void)
declare the max flux neutrino energy that can be generated (for init. purposes)
double fRt
defining flux neutrino generation surface: transverse radius
GAtmoFlux * GetFlux(void)
bool IsNeutrino(int pdgc)
bool IsAntiNeutrino(int pdgc)
string X4AsString(const TLorentzVector *x)
string P4AsShortString(const TLorentzVector *p)
THE MAIN GENIE PROJECT NAMESPACE