28 using std::ostringstream;
31 using namespace genie;
35 EventRecordVisitorI(), fSafetyFactor(1.), fNumOfSafetyFactors(-1), fNumOfInterpolatorTypes(-1)
41 EventRecordVisitorI(name), fSafetyFactor(1.), fNumOfSafetyFactors(-1), fNumOfInterpolatorTypes(-1)
47 EventRecordVisitorI(name, config), fSafetyFactor(1.), fNumOfSafetyFactors(-1), fNumOfInterpolatorTypes(-1)
60 <<
"Getting max. for the rejection method";
66 <<
"Attempting to find a cached max value";
71 <<
"Attempting to compute the max value";
82 LOG(
"Kinematics",
pINFO) <<
"max = " << xsec_max;
88 <<
"Can not generate event kinematics max_xsec<=0)";
98 exception.
SetReason(
"kinematics generation: max_xsec<=0");
106 const Interaction * interaction,
const int nkey)
const
112 double E = this->
Energy(interaction);
113 LOG(
"Kinematics",
pINFO) <<
"E = " << E;
117 <<
"Below minimum energy - Forcing explicit calculation";
130 <<
"\nInterpolated: max (E=" << E <<
") = " << spl_max_xsec;
134 <<
"Outside spline boundaries - Forcing explicit calculation";
140 double dE = TMath::Min(0.25, 0.05*E);
141 const map<double,double> & fmap = cb->
Map();
142 map<double,double>::const_iterator iter = fmap.lower_bound(E);
143 if(iter != fmap.end()) {
144 if(TMath::Abs(E - iter->first) < dE)
return iter->second;
191 const Interaction * interaction,
double max_xsec,
const int nkey)
const
194 <<
"Adding the computed max value to cache";
197 double E = this->
Energy(interaction);
199 if(max_xsec>0) cb->
AddValues(E,max_xsec);
202 if( cb->
Map().size() > 40 )
207 if( E < cb->Spl()->XMin() || E > cb->
Spl()->
XMax() ) {
225 const Interaction * interaction,
const int nkey)
const
233 string algkey = this->
Id().
Key();
234 string intkey = interaction->
AsString();
235 string key = cache->
CacheBranchKey(algkey, intkey, std::to_string(nkey));
241 LOG(
"Kinematics",
pINFO) <<
"No cache branch found";
242 LOG(
"Kinematics",
pINFO) <<
"Creating cache branch - key = " << key;
247 assert(cache_branch);
253 const Interaction * interaction,
double xsec,
double xsec_max)
const
259 double f = 200*(xsec-xsec_max)/(xsec_max+xsec);
262 <<
"xsec: (curr) = " << xsec
263 <<
" > (max) = " << xsec_max <<
"\n for " << *interaction;
265 <<
"*** Exceeding estimated maximum differential cross section";
269 <<
"xsec: (curr) = " << xsec
270 <<
" > (max) = " << xsec_max <<
"\n for " << *interaction;
272 <<
"*** The fractional deviation of " << f <<
" % was allowed";
279 <<
"Negative cross section for current kinematics!! \n" << *interaction;
virtual Interaction * Summary(void) const
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the 'Visito...
virtual void AssertXSecLimits(const Interaction *in, double xsec, double xsec_max) const
double fMaxXSecDiffTolerance
max{100*(xsec-maxxsec)/.5*(xsec+maxxsec)} if xsec>maxxsec
int fNumOfSafetyFactors
Number of given safety factors.
virtual double MaxXSec(GHepRecord *evrec, const int nkey=0) const
void CreateSpline(string type="TSpline3")
double Evaluate(double x) const
string AsString(void) const
void AddCacheBranch(string key, CacheBranchI *branch)
int fNumOfInterpolatorTypes
Number of given interpolators types.
virtual double ComputeMaxXSec(const Interaction *in) const =0
std::vector< double > vSafetyFactors
MaxXSec -> MaxXSec * fSafetyFactors[nkey].
Summary information for an interaction.
void AddValues(double x, double y)
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...
string CacheBranchKey(string k0, string k1="", string k2="") const
const UInt_t kISkipKinematicChk
if set, skip kinematic validity checks
CacheBranchI * FindCacheBranch(string key)
finding/adding cache branches
virtual const AlgId & Id(void) const
Get algorithm ID.
void SwitchOnFastForward(void)
const map< double, double > & Map(void) const
void SetReason(string reason)
virtual TBits * EventFlags(void) const
virtual CacheBranchFx * AccessCacheBranch(const Interaction *in, const int nkey=0) const
double fEMin
min E for which maxxsec is cached - forcing explicit calc.
virtual double Energy(const Interaction *in) const
virtual double FindMaxXSec(const Interaction *in, const int nkey=0) const
const InitialState & InitState(void) const
static Cache * Instance(void)
A simple cache branch storing the cached data in a TNtuple.
double ProbeE(RefFrame_t rf) const
GENIE's GHEP MC event record.
~KineGeneratorWithCache()
const UInt_t kISkipProcessChk
if set, skip process validity checks
virtual void SetDiffXSec(double xsec, KinePhaseSpace_t ps)
Initial State information.
std::vector< string > vInterpolatorTypes
Type of interpolator for each key in a branch.
virtual void CacheMaxXSec(const Interaction *in, double xsec, const int nkey=0) const