26 #include "Math/Minimizer.h"
27 #include "Math/Factory.h"
29 using namespace genie;
30 using namespace genie::controls;
31 using namespace genie::utils;
55 <<
"Generating kinematics uniformly over the allowed phase space";
74 double xsec_max = this->
MaxXSec(evrec);
85 double dn2 = n2max-n2min;
86 double dn3 = n3max-n3min;
93 double dn1 = n1max-n1min;
98 unsigned int iter = 0;
105 <<
"*** Could not select a valid y after "
106 << iter <<
" iterations";
109 exception.
SetReason(
"Couldn't select kinematics");
114 double n2 = n2min + dn2 * rnd->
RndKine().Rndm();
115 double n3 = n3min + dn3 * rnd->
RndKine().Rndm();
116 double n1 = n1min + dn1 * rnd->
RndKine().Rndm();
117 n1 = (n1>1.) ? n1-2. : n1;
123 LOG(
"HELeptonKinematics",
pDEBUG) <<
"Trying: n1 = " << n1 <<
", n2 = " << n2 <<
", n3 = " << n3;
130 double t = xsec_max * rnd->
RndKine().Rndm();
131 LOG(
"HELeptonKinematics",
pDEBUG) <<
"xsec= "<< xsec<<
", J= 1, Rnd= "<< t;
137 LOG(
"HELeptonKinematics",
pINFO) <<
"Selected: n1 = " << n1 <<
", n2 = " << n2 <<
", n3 = " << n3;
155 double dn1 = n1max-n1min;
156 double dn2 = n2max-n2min;
160 unsigned int iter = 0;
167 <<
"*** Could not select a valid y after "
168 << iter <<
" iterations";
171 exception.
SetReason(
"Couldn't select kinematics");
176 double n1 = n1min + dn1 * rnd->
RndKine().Rndm();
177 double n2 = n2min + dn2 * rnd->
RndKine().Rndm();
181 LOG(
"HELeptonKinematics",
pDEBUG) <<
"Trying: n1 = " << n1 <<
", n2 = " << n2;
188 double t = xsec_max * rnd->
RndKine().Rndm();
189 LOG(
"HELeptonKinematics",
pDEBUG) <<
"xsec= "<< xsec<<
", J= 1, Rnd= "<< t;
195 LOG(
"HELeptonKinematics",
pINFO) <<
"Selected: n1 = " << n1 <<
", n2 = " << n2;
221 double max_xsec = -1.0;
223 ROOT::Math::Minimizer * min = ROOT::Math::Factory::CreateMinimizer(
"Minuit");
229 min->SetFunction( f );
230 min->SetMaxFunctionCalls(10000);
231 min->SetTolerance(0.05);
233 min->SetFixedVariable ( 0,
"n1", 1.);
234 min->SetLimitedVariable ( 1,
"n2", 0., 0.01, 0., 1.);
235 min->SetLimitedVariable ( 2,
"n3", 0., 0.01, 0., 1.);
237 min->SetFixedVariable ( 0,
"n1", 1.);
238 min->SetLimitedVariable ( 1,
"n2", min->X()[1], 0.01, TMath::Max(0.,min->X()[1]-0.1), TMath::Min(1.,min->X()[1]+0.1));
239 min->SetLimitedVariable ( 2,
"n3", min->X()[2], 0.01, TMath::Max(0.,min->X()[2]-0.1), TMath::Min(1.,min->X()[2]+0.1));
244 SLOG(
"HELeptonKinematics",
pDEBUG) <<
"Minimum found -> n1: 1, n2: " << min->X()[1] <<
", n3: " << min->X()[2] <<
", xsec: " <<
fXSecModel->
XSec(interaction,
kPSn1n2n3fE);
247 min->SetFixedVariable ( 0,
"n1", -1.);
248 min->SetLimitedVariable ( 1,
"n2", 0., 0.01, 0., 1.);
249 min->SetLimitedVariable ( 2,
"n3", 0., 0.01, 0., 1.);
251 min->SetFixedVariable ( 0,
"n1", -1.);
252 min->SetLimitedVariable ( 1,
"n2", min->X()[1], 0.01, TMath::Max(0.,min->X()[1]-0.1), TMath::Min(1.,min->X()[1]+0.1));
253 min->SetLimitedVariable ( 2,
"n3", min->X()[2], 0.01, TMath::Max(0.,min->X()[2]-0.1), TMath::Min(1.,min->X()[2]+0.1));
257 SLOG(
"HELeptonKinematics",
pDEBUG) <<
"Minimum found -> n1: -1, n2: " << min->X()[1] <<
", n3: " << min->X()[2] <<
", xsec: " <<
fXSecModel->
XSec(interaction,
kPSn1n2n3fE);
263 const int Nscan = 100;
264 const int n1min = -1.;
265 const int n1max = 1.;
266 const int n2min = 0.;
267 const int n2max = 1.;
268 const double dn1 = (n1max-n1min)/(
double)Nscan;
269 const double dn2 = (n2max-n2min)/(
double)
274 for (
int i=0; i<Nscan; i++) {
275 double n1 = n1min + dn1*i;
276 for (
int j=0; j<Nscan; j++) {
277 double n2 = n2min + dn2*j;
281 if ( dxsec > max_xsec ) {
290 min->SetFunction( f );
291 min->SetMaxFunctionCalls(10000);
292 min->SetTolerance(0.05);
293 min->SetLimitedVariable ( 0,
"n1", scan_n1, 0.001, TMath::Max(-1.,scan_n1-0.1), TMath::Min(1.,scan_n1+0.1));
294 min->SetLimitedVariable ( 1,
"n2", scan_n2, 0.1, TMath::Max(-0.,scan_n2-0.1), TMath::Min(1.,scan_n2+0.1));
299 SLOG(
"HELeptonKinematics",
pDEBUG) <<
"Minimum found -> n1: " << min->X()[0] <<
", n2: " << min->X()[1];
308 SLOG(
"HELeptonKinematics",
pDEBUG) <<
"Max xsec in phase space = " << max_xsec;
bool fGenerateUniformly
uniform over allowed phase space + event weight?
HELeptonKinematicsGenerator()
virtual Interaction * Summary(void) const
static RandomGen * Instance()
Access instance.
Kinematics * KinePtr(void) const
double fSafetyFactor
ComputeMaxXSec -> ComputeMaxXSec * fSafetyFactor.
virtual void AssertXSecLimits(const Interaction *in, double xsec, double xsec_max) const
double fMaxXSecDiffTolerance
max{100*(xsec-maxxsec)/.5*(xsec+maxxsec)} if xsec>maxxsec
Defines the EventGeneratorI interface.
virtual double MaxXSec(GHepRecord *evrec, const int nkey=0) const
Abstract class. Provides a data caching mechanism for for concrete implementations of the EventRecord...
A singleton holding random number generator classes. All random number generation in GENIE should tak...
string AsString(void) const
const XSecAlgorithmI * fXSecModel
~HELeptonKinematicsGenerator()
Summary information for an interaction.
An exception thrown by EventRecordVisitorI when the normal processing sequence has to be disrupted (f...
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
virtual void Configure(const Registry &config)
void Configure(const Registry &config)
TRandom3 & RndKine(void) const
rnd number generator used by kinematics generators
void ProcessEventRecord(GHepRecord *event_rec) const
bool IsPhotonCoherent(void) const
virtual double XSec(const Interaction *i, KinePhaseSpace_t k=kPSfE) const =0
Compute the cross section for the input interaction.
void SetKV(KineVar_t kv, double value)
static RunningThreadInfo * Instance(void)
double Energy(const Interaction *in) const
void SwitchOnFastForward(void)
void SetReason(string reason)
virtual TBits * EventFlags(void) const
A registry. Provides the container for algorithm configuration parameters.
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
double ComputeMaxXSec(const Interaction *in) const
const InitialState & InitState(void) const
const ProcessInfo & ProcInfo(void) const
void ClearRunningValues(void)
bool GetParamDef(const RgKey &name, T &p, const T &def) const
const EventGeneratorI * RunningThread(void)
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
double ProbeE(RefFrame_t rf) const
GENIE's GHEP MC event record.
Keep info on the event generation thread currently on charge. This is used so that event generation m...
virtual void SetDiffXSec(double xsec, KinePhaseSpace_t ps)
Initial State information.