GENIEGenerator
Loading...
Searching...
No Matches
GMonoEnergeticFlux.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Costas Andreopoulos <c.andreopoulos \at cern.ch>
7 University of Liverpool
8*/
9//____________________________________________________________________________
10
11#include <cassert>
12
19
22
23using namespace genie;
24using namespace genie::constants;
25using namespace genie::flux;
26
27//____________________________________________________________________________
29GFluxI()
30{
31 // default ctor for consistency with GFluxDriverFactory needs
32 // up to user to call Initialize() to set energy and flavor(s)
33}
34//____________________________________________________________________________
36GFluxI()
37{
38 this->Initialize(Ev,pdg);
39}
40//___________________________________________________________________________
42 double Ev, const map<int,double> & numap) :
43GFluxI()
44{
45 this->Initialize(Ev,numap);
46}
47//___________________________________________________________________________
52//___________________________________________________________________________
54{
56 double p = fProbMax * rnd->RndFlux().Rndm();
57
58 map<int,double>::const_iterator iter;
59 for(iter = fProb.begin(); iter != fProb.end(); ++iter) {
60 int nupdgc = iter->first;
61 double prob = iter->second;
62 if (p<prob) {
63 fgPdgC = nupdgc;
64 break;
65 }
66 }
67
68 LOG("Flux", pINFO)
69 << "Generated neutrino: "
70 << "\n pdg-code: " << fgPdgC
71 << "\n p4: " << utils::print::P4AsShortString(&fgP4)
72 << "\n x4: " << utils::print::X4AsString(&fgX4);
73
74 return true;
75}
76//___________________________________________________________________________
77void GMonoEnergeticFlux::Clear(Option_t * opt)
78{
79// Dummy clear method needed to conform to GFluxI interface
80//
81 LOG("Flux", pERROR) <<
82 "No Clear(Option_t * opt) method implemented for opt: "<< opt;
83}
84//___________________________________________________________________________
86{
87// Dummy implementation needed to conform to GFluxI interface
88//
89 LOG("Flux", pERROR) <<
90 "No GenerateWeighted(bool gen_weighted) method implemented for " <<
91 "gen_weighted: " << gen_weighted;
92}
93//___________________________________________________________________________
95{
96 map<int,double> numap;
97 numap.insert( map<int, double>::value_type(pdg, 1.) );
98
99 this->Initialize(Ev,numap);
100}
101//___________________________________________________________________________
102void GMonoEnergeticFlux::Initialize(double Ev, const map<int,double> & numap)
103{
104 LOG("Flux", pNOTICE) << "Initializing GMonoEnergeticFlux driver";
105
106 fMaxEv = Ev + 0.05;
107
109 fPdgCList->clear();
110
111 fProbMax = 0;
112 fProb.clear();
113
114 map<int,double>::const_iterator iter;
115 for(iter = numap.begin(); iter != numap.end(); ++iter) {
116 int nupdgc = iter->first;
117 double nuwgt = iter->second;
118
119 fPdgCList->push_back(nupdgc);
120
121 fProbMax+=nuwgt;
122 fProb.insert(map<int, double>::value_type(nupdgc,fProbMax));
123 }
124
125 fgPdgC = 0;
126 fgP4.SetPxPyPzE (0.,0.,Ev,Ev);
127 fgX4.SetXYZT (0.,0.,0.,0.);
128}
129//___________________________________________________________________________
131{
132 LOG("Flux", pNOTICE) << "Cleaning up...";
133
134 if (fPdgCList) delete fPdgCList;
135}
136//___________________________________________________________________________
137void GMonoEnergeticFlux::SetDirectionCos(double dx, double dy, double dz)
138{
139 TVector3 dircos1 = TVector3(dx,dy,dz).Unit();
140 LOG("Flux", pNOTICE) << "SetDirectionCos "
141 << utils::print::P3AsString(&dircos1);
142 double E = fgP4.E();
143 fgP4.SetVect(E*dircos1);
144
145}
146//___________________________________________________________________________
147void GMonoEnergeticFlux::SetRayOrigin(double x, double y, double z)
148{
149 TVector3 xyz(x,y,z);
150 LOG("Flux", pNOTICE) << "SetRayOrigin "
152 fgX4.SetVect(xyz);
153}
154//___________________________________________________________________________
155void GMonoEnergeticFlux::SetNuDirection(const TVector3 & direction)
156{
157 SetDirectionCos(direction.x(), direction.y(), direction.z());
158}
159//___________________________________________________________________________
160void GMonoEnergeticFlux::SetBeamSpot(const TVector3 & spot)
161{
162 SetRayOrigin(spot.x(), spot.y(), spot.z());
163}
164//___________________________________________________________________________
#define FLUXDRIVERREG4(_nsa, _nsb, _name, _fqname)
#define pNOTICE
Definition Messenger.h:61
#define pINFO
Definition Messenger.h:62
#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
A list of PDG codes.
Definition PDGCodeList.h:32
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition RandomGen.h:29
static RandomGen * Instance()
Access instance.
Definition RandomGen.cxx:74
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
Definition RandomGen.h:71
A simple GENIE flux driver for monoenergetic neutrinos along the z direction. Can handle a mix of neu...
TLorentzVector fgX4
running generated nu 4-position
bool GenerateNext(void)
generate the next flux neutrino (return false in err)
void SetNuDirection(const TVector3 &direction)
int fgPdgC
running generated nu pdg-code
void SetBeamSpot(const TVector3 &spot)
void Initialize(double Ev, int pdg)
TLorentzVector fgP4
running generated nu 4-momentum
void SetDirectionCos(double dx, double dy, double dz)
void Clear(Option_t *opt)
reset state variables based on opt
void SetRayOrigin(double x, double y, double z)
void GenerateWeighted(bool gen_weighted)
set whether to generate weighted or unweighted neutrinos
PDGCodeList * fPdgCList
list of neutrino pdg-codes
void Initialize(void)
Basic constants.
GENIE flux drivers.
Utilities for improving the code readability when using PDG codes.
string Vec3AsString(const TVector3 *vec)
string X4AsString(const TLorentzVector *x)
string P3AsString(const TVector3 *vec)
string P4AsShortString(const TLorentzVector *p)
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25