GENIEGenerator
Loading...
Searching...
No Matches
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:
[legend]
Collaboration diagram for genie::flux::GCylindTH1Flux:
[legend]

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 PDGCodeList & FluxParticles (void)
 declare list of flux neutrinos that can be generated (for init. purposes)
double MaxEnergy (void)
 declare the max flux neutrino energy that can be generated (for init. purposes)
bool GenerateNext (void)
 generate the next flux neutrino (return false in err)
int PdgCode (void)
 returns the flux neutrino pdg code
double Weight (void)
 returns the flux neutrino weight (if any)
const TLorentzVector & Momentum (void)
 returns the flux neutrino 4-momentum
const TLorentzVector & Position (void)
 returns the flux neutrino 4-position (note: expect SI rather than physical units)
bool End (void)
 true if no more flux nu's can be thrown (eg reaching end of beam sim ntuples)
long int Index (void)
 returns corresponding index for current flux neutrino (e.g. for a flux ntuple returns the current entry number)
void Clear (Option_t *opt)
 reset state variables based on opt
void GenerateWeighted (bool gen_weighted)
 set whether to generate weighted or unweighted neutrinos
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
PDGCodeList * fPdgCList
 list of neutrino pdg-codes
int fgPdgC
 running generated nu pdg-code
TLorentzVector fgP4
 running generated nu 4-momentum
TLorentzVector fgX4
 running generated nu 4-position
vector< TH1D * > fSpectrum
 flux = f(Ev), 1/neutrino species
TH1D * fTotSpectrum
 combined flux = f(Ev)
TVector3 * fDirVec
 neutrino direction
TVector3 * fBeamSpot
 beam spot position
double fRt
 transverse size of neutrino beam
TF1 * fRtDep
 transverse radius dependence

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 <c.andreopoulos \at cern.ch> University of Liverpool
Created:\n July 4, 2005
License:\n Copyright (c) 2003-2025, 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::GCylindTH1Flux ( )

Definition at line 35 of file GCylindTH1Flux.cxx.

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

References Initialize().

◆ ~GCylindTH1Flux()

GCylindTH1Flux::~GCylindTH1Flux ( )

Definition at line 40 of file GCylindTH1Flux.cxx.

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

References CleanUp().

Member Function Documentation

◆ AddAllFluxes()

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}
#define pNOTICE
Definition Messenger.h:61
#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)
vector< TH1D * > fSpectrum
flux = f(Ev), 1/neutrino species

References fSpectrum, fTotSpectrum, LOG, and pNOTICE.

Referenced by AddEnergySpectrum().

◆ AddEnergySpectrum()

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}
#define pWARN
Definition Messenger.h:60
double fMaxEv
maximum energy
PDGCodeList * fPdgCList
list of neutrino pdg-codes

References AddAllFluxes(), fMaxEv, fPdgCList, fSpectrum, LOG, pNOTICE, and pWARN.

Referenced by main().

◆ CleanUp()

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}
TVector3 * fDirVec
neutrino direction
TVector3 * fBeamSpot
beam spot position
TF1 * fRtDep
transverse radius dependence

References fBeamSpot, fDirVec, fPdgCList, fRtDep, fSpectrum, fTotSpectrum, LOG, and pNOTICE.

Referenced by ~GCylindTH1Flux().

◆ Clear()

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

References LOG, and pERROR.

◆ End()

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; }

◆ FluxParticles()

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; }

References fPdgCList.

◆ GenerateNext()

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
57 if (fPdgCList->ExistsInPDGCodeList(kPdgDarkMatter) || fPdgCList->ExistsInPDGCodeList(kPdgAntiDarkMatter)) {
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}
#define pINFO
Definition Messenger.h:62
static PDGLibrary * Instance(void)
TParticlePDG * Find(int pdgc, bool must_exist=true)
TLorentzVector fgP4
running generated nu 4-momentum
double fRt
transverse size of neutrino beam
int fgPdgC
running generated nu pdg-code
TLorentzVector fgX4
running generated nu 4-position
string X4AsString(const TLorentzVector *x)
string P4AsShortString(const TLorentzVector *p)
const int kPdgDarkMatter
Definition PDGCodes.h:218
const int kPdgAntiDarkMatter
Definition PDGCodes.h:219

References fBeamSpot, fDirVec, fgP4, fgPdgC, fgX4, genie::PDGLibrary::Find(), fPdgCList, fRt, fTotSpectrum, GeneratePhi(), GenerateRt(), genie::PDGLibrary::Instance(), genie::kPdgAntiDarkMatter, genie::kPdgDarkMatter, LOG, genie::utils::print::P4AsShortString(), pINFO, ResetSelection(), SelectNeutrino(), and genie::utils::print::X4AsString().

◆ GeneratePhi()

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:74
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
Definition RandomGen.h:71

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

Referenced by GenerateNext().

◆ GenerateRt()

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}

References fRtDep.

Referenced by GenerateNext().

◆ GenerateWeighted()

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}

References LOG, and pERROR.

◆ Index()

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; }

◆ Initialize()

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}
void SetRtDependence(string rdep)

References fBeamSpot, fDirVec, fMaxEv, fPdgCList, fRt, fRtDep, fTotSpectrum, LOG, pNOTICE, ResetSelection(), and SetRtDependence().

Referenced by GCylindTH1Flux().

◆ MaxEnergy()

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; }

References fMaxEv.

◆ Momentum()

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; }

References fgP4.

◆ PdgCode()

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; }

References fgPdgC.

◆ Position()

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; }

References fgX4.

◆ ResetSelection()

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}

References fgP4, fgPdgC, and fgX4.

Referenced by GenerateNext(), and Initialize().

◆ SelectNeutrino()

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 pDEBUG
Definition Messenger.h:63

References fPdgCList, fSpectrum, genie::RandomGen::Instance(), LOG, pDEBUG, pERROR, and genie::RandomGen::RndFlux().

Referenced by GenerateNext().

◆ SetBeamSpot()

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}

References fBeamSpot.

Referenced by main().

◆ SetNuDirection()

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}

References fDirVec.

Referenced by main().

◆ SetRtDependence()

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}

References fRt, and fRtDep.

Referenced by Initialize().

◆ SetTransverseRadius()

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}

References fRt, fRtDep, LOG, and pNOTICE.

Referenced by main().

◆ Weight()

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

◆ fBeamSpot

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

beam spot position

Definition at line 89 of file GCylindTH1Flux.h.

Referenced by CleanUp(), GenerateNext(), Initialize(), and SetBeamSpot().

◆ fDirVec

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

neutrino direction

Definition at line 88 of file GCylindTH1Flux.h.

Referenced by CleanUp(), GenerateNext(), Initialize(), and SetNuDirection().

◆ fgP4

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

running generated nu 4-momentum

Definition at line 84 of file GCylindTH1Flux.h.

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

◆ fgPdgC

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

running generated nu pdg-code

Definition at line 83 of file GCylindTH1Flux.h.

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

◆ fgX4

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

running generated nu 4-position

Definition at line 85 of file GCylindTH1Flux.h.

Referenced by GenerateNext(), Position(), and ResetSelection().

◆ fMaxEv

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

maximum energy

Definition at line 81 of file GCylindTH1Flux.h.

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

◆ fPdgCList

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

list of neutrino pdg-codes

Definition at line 82 of file GCylindTH1Flux.h.

Referenced by AddEnergySpectrum(), CleanUp(), FluxParticles(), GenerateNext(), Initialize(), and SelectNeutrino().

◆ fRt

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

transverse size of neutrino beam

Definition at line 90 of file GCylindTH1Flux.h.

Referenced by GenerateNext(), Initialize(), SetRtDependence(), and SetTransverseRadius().

◆ fRtDep

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

transverse radius dependence

Definition at line 91 of file GCylindTH1Flux.h.

Referenced by CleanUp(), GenerateRt(), Initialize(), SetRtDependence(), and SetTransverseRadius().

◆ fSpectrum

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

flux = f(Ev), 1/neutrino species

Definition at line 86 of file GCylindTH1Flux.h.

Referenced by AddAllFluxes(), AddEnergySpectrum(), CleanUp(), and SelectNeutrino().

◆ fTotSpectrum

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

combined flux = f(Ev)

Definition at line 87 of file GCylindTH1Flux.h.

Referenced by AddAllFluxes(), CleanUp(), GenerateNext(), and Initialize().


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