14#include <Math/IFunction.h>
15#include <Math/GSLMinimizer1D.h>
16#include <Math/BrentMinimizer1D.h>
80 assert(Q2.min > 0. && Q2.min < Q2.max);
81 const InitialState & init_state = interaction -> InitState();
83 const double Q2min = Q2.min;
84 const double Q2max = Q2.max;
85 const double dQ2 = Q2max - Q2min;
98 <<
"Option to generate kinematics uniformly not supported";
125 ROOT::Math::IBaseFunctionOneDim * xsec_func =
127 ROOT::Math::BrentMinimizer1D minimizer;
128 minimizer.SetFunction(*xsec_func,Q2min,Q2max);
129 minimizer.Minimize(1000,1,1E-5);
130 double Q2_for_xsec_max = minimizer.XMinimum();
135 <<
"Maximizing dsig(Q2;E = " << E <<
"GeV)/dQ2 gave a value of "
136 << xsec_max/(
units::cm2) <<
" cm2/GeV^2 at Q2 = "
137 << Q2_for_xsec_max <<
" GeV^2";
140 unsigned int iter = 0;
145 <<
"*** Could not select a valid Q2 after " << iter <<
" iterations";
146 event->EventFlags()->SetBitNumber(
kKineGenErr,
true);
148 exception.
SetReason(
"Couldn't select kinematics");
160 if(gxsec > xsec_max) {
161 double frac = TMath::Abs(gxsec-xsec_max)/xsec_max;
164 <<
"Current computed cross-section (" << gxsec/(
units::cm2)
165 <<
" cm2/GeV^2) exceeds the maximum cross-section ("
166 << xsec_max/(
units::cm2) <<
" beyond the specified tolerance";
174 <<
"dxsec/dQ2 = " << gxsec/(
units::cm2) <<
" cm2/GeV^2"
175 <<
"J = 1, rnd = " << t;
176 bool accept = (t<gxsec);
181 LOG(
"CEvNS",
pNOTICE) <<
"Selected Q2 = " <<
gQ2 <<
" GeV^2";
192 event->SetDiffXSec(gxsec,
kPSQ2fE);
200 int target_pdgc = target->
Pdg();
203 double Ev = probe->
E();
204 double Q2 =
event->Summary()->Kine().Q2(
true);
206 const TLorentzVector & vtx = *(probe->
X4());
207 TLorentzVector x4l(vtx);
211 double y = Q2/(2*M*Ev);
212 double El = (1-y)*Ev;
215 <<
"Final state neutrino energy: E = " << El <<
" GeV";
221 double plp = El - 0.5*(Q2+ml2)/Ev;
222 double plt = TMath::Sqrt(TMath::Max(0.,El*El-plp*plp-ml2));
225 <<
"Final state neutrino momentum components: |p//| = "
226 << plp <<
" GeV, [pT] = " << plt <<
" GeV";
230 double phi = 2*
kPi * rnd->
RndLep().Rndm();
231 double pltx = plt * TMath::Cos(phi);
232 double plty = plt * TMath::Sin(phi);
235 TVector3 unit_nudir = probe->
P4()->Vect().Unit();
239 TVector3 p3l(pltx,plty,plp);
240 p3l.RotateUz(unit_nudir);
243 TLorentzVector p4l(p3l,El);
252 event->Summary()->KinePtr()->SetFSLeptonP4(p4l);
261 const TLorentzVector & p4probe = * ( probe -> P4() );
262 const TLorentzVector & p4target = * ( target -> P4() );
263 const TLorentzVector & p4fsl = * ( fsl -> P4() );
265 const TLorentzVector & p4recoil = p4probe + p4target - p4fsl;
270 const TLorentzVector & vtx = *(probe->
X4());
276 -1,-1,-1, p4recoil, vtx);
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
virtual void Configure(const Registry &config)
bool GetParamDef(const RgKey &name, T &p, const T &def) const
void AddFinalStateNeutrino(GHepRecord *event) const
void AddRecoilNucleus(GHepRecord *event) const
void GenerateKinematics(GHepRecord *event) const
const XSecAlgorithmI * fXSecModel
void ProcessEventRecord(GHepRecord *event) const
double fMaxXSecDiffTolerance
void Configure(const Registry &config)
Defines the EventGeneratorI interface.
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
STDHEP-like event record entry that can fit a particle or a nucleus.
const TLorentzVector * P4(void) const
const TLorentzVector * X4(void) const
double E(void) const
Get energy.
int FirstDaughter(void) const
GENIE's GHEP MC event record.
virtual int ProbePosition(void) const
virtual GHepParticle * TargetNucleus(void) const
virtual int TargetNucleusPosition(void) const
Initial State information.
double ProbeE(RefFrame_t rf) const
Summary information for an interaction.
const KPhaseSpace & PhaseSpace(void) const
Kinematics * KinePtr(void) const
Range1D_t Q2Lim(void) const
Q2 limits.
void SetQ2(double Q2, bool selected=false)
void ClearRunningValues(void)
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 & RndLep(void) const
rnd number generator used by final state primary lepton generators
TRandom3 & RndKine(void) const
rnd number generator used by kinematics generators
A simple [min,max] interval for doubles.
A registry. Provides the container for algorithm configuration parameters.
Keep info on the event generation thread currently on charge. This is used so that event generation m...
static RunningThreadInfo * Instance(void)
const EventGeneratorI * RunningThread(void)
An exception thrown by EventRecordVisitorI when the normal processing sequence has to be disrupted (f...
void SwitchOnFastForward(void)
void SetReason(string reason)
Misc GENIE control constants.
static const unsigned int kRjMaxIterations
static constexpr double cm2
Simple functions for loading and reading nucleus dependent keys from config files.
string P4AsString(const TLorentzVector *p)
Root of GENIE utility namespaces.
THE MAIN GENIE PROJECT NAMESPACE
const UInt_t kISkipKinematicChk
if set, skip kinematic validity checks
const UInt_t kISkipProcessChk
if set, skip process validity checks