43using std::ostringstream;
150 mesg <<
"Configuring event generation driver for initial state: `"
152 <<
"' using event generator list: `"
163 LOG(
"GEVGDriver",
pINFO) <<
"Done configuring. \n";
168 LOG(
"GEVGDriver",
pINFO) <<
"Setting the initial state";
182 <<
"Building the event generator list (specified list name: "
195 <<
"Building the interaction -> generator associations...";
201 string mesgh =
"Interaction -> Generator assignments for Initial State: ";
210 LOG(
"GEVGDriver",
pINFO) <<
"Building the interaction selector...";
216 algf->
AdoptAlgorithm(
"genie::PhysInteractionSelector",
"Default"));
231 LOG(
"GEVGDriver",
pINFO) <<
"Creating the initial state";
239 <<
"Selecting an Interaction & Bootstraping the EventRecord";
244 <<
"No interaction could be selected for: "
245 << init_state.
AsString() <<
" at E = " << nu4p.E() <<
" GeV";
250 LOG(
"GEVGDriver",
pDEBUG) <<
"Getting the selected interaction";
262 LOG(
"GEVGDriver",
pINFO) <<
"Finding an appropriate EventGenerator";
279 string mesg =
"Requesting from event generation thread: " +
280 evgen->
Id().
Key() +
" to generate the selected interaction";
296 LOG(
"GEVGDriver",
pINFO) <<
"Returning the current event!";
300 LOG(
"GEVGDriver",
pWARN) <<
"An unphysical event was generated...";
305 <<
"The generated unphysical event is accepted by the user";
311 <<
"The generated unphysical event is rejected";
318 <<
"Attempting to regenerate the event...";
322 <<
"Could not produce a physical event after "
340 <<
"Interaction->Generator Map has not being built yet!";
351 <<
"Setting event generator list: " << listname;
360 LOG(
"GEVGDriver",
pWARN) <<
"Null interaction!!";
365 <<
"Interaction->Generator Map has not being built yet!";
378 LOG(
"GEVGDriver",
pDEBUG) <<
"Computing the cross section sum";
390 InteractionList::const_iterator intliter;
391 for(intliter = ilst.begin(); intliter != ilst.end(); ++intliter) {
397 string code = interaction->
AsString();
399 <<
"Compute cross section for interaction: \n" << code;
403 fIntGenMap->FindGenerator(interaction)->CrossSectionAlg();
408 bool spline_exists = xssl->
SplineExists(xsec_alg, interaction);
410 double E = nup4.Energy();
413 xsec = xsec_alg->
Integral(interaction);
415 xsec = TMath::Max(0., xsec);
420 <<
"\nInteraction = " << code
421 <<
"\nCross Section "
433 <<
"E = " << nup4.Energy() <<
" GeV)"
441 int nk,
double Emin,
double Emax,
bool inlogE)
450 <<
"Creating spline (sum-xsec = f(" << ((inlogE) ?
"logE" :
"E")
451 <<
") in E = [" << Emin <<
", " << Emax <<
"] using " << nk <<
" knots";
454 LOG(
"GEVGDriver",
pFATAL) <<
"You haven't loaded any splines!! ";
457 assert(Emin<Emax && Emin>0 && nk>2);
459 double logEmin=0, logEmax=0, dE=0;
461 double * E =
new double[nk];
462 double * xsec =
new double[nk];
465 logEmin = TMath::Log(Emin);
466 logEmax = TMath::Log(Emax);
467 dE = (logEmax-logEmin)/(nk-1);
469 dE = (Emax-Emin)/(nk-1);
472 TLorentzVector p4(0,0,0,0);
474 for(
int i=0; i<nk; i++) {
475 double e = (inlogE) ? TMath::Exp(logEmin + i*dE) : Emin + i*dE;
476 p4.SetPxPyPzE(0.,0.,
e,
e);
501 fIntGenMap->FindGenerator(interaction)->CrossSectionAlg();
538 InteractionList::const_iterator intliter;
539 for(intliter = ilst.begin(); intliter != ilst.end(); ++intliter) {
546 fIntGenMap->FindGenerator(interaction)->CrossSectionAlg();
550 bool spl_exists = xsl->
SplineExists(xsec_alg, interaction);
558 <<
"Null cross-section algorithm! Can not load cross-section spline.";
563 <<
"Null interaction! Can not load cross-section spline.";
567 <<
"*** At least a spline (algorithm: "
568 << xsec_alg->
Id().
Key() <<
", interaction: "
569 << interaction->
AsString() <<
" doesn't exist. "
570 <<
"Reverting back to not using splines";
584 <<
"Creating (missing) splines with [UseLogE: "
585 << ((useLogE) ?
"ON]" :
"OFF]");
590 EventGeneratorList::const_iterator evgliter;
591 InteractionList::iterator intliter;
599 <<
"Querying [" << evgen->
Id().
Key()
600 <<
"] for its InteractionList";
614 xsl -> SetMinE( Emin ) ;
622 if ( emax > valid_Emax ) {
624 <<
"Refusing to exceed validity range: Emax = " << valid_Emax;
626 emax = TMath::Min(emax,valid_Emax);
631 assert( emax > Emin );
633 xsl -> SetMaxE( emax ) ;
638 nknots = (int) (15 * TMath::Log10(emax-Emin));
640 nknots = TMath::Max(nknots,30);
642 xsl -> SetNKnots( nknots ) ;
646 for(intliter = ilst->begin(); intliter != ilst->end(); ++intliter) {
650 string code = interaction->
AsString();
652 SLOG(
"GEVGDriver",
pINFO) <<
"Need xsec spline for " << code;
658 <<
"The spline wasn't loaded at initialization. "
659 <<
"I can build it now but it might take a while...";
662 SLOG(
"GEVGDriver",
pDEBUG) <<
"Spline was found";
684 EventGeneratorList::const_iterator evgliter;
697 E.
min = TMath::Min(E.
min, Emin);
698 E.
max = TMath::Max(E.
max, Emax);
715 <<
"\n\n *********************** GEVGDriver ***************************";
720 stream <<
"\n |---o Probe PDG-code ......: " << ppdg;
721 stream <<
"\n |---o Target PDG-code .....: " << tgtpdg;
723 stream <<
"\n |---o Using cross section splines is turned "
725 stream <<
"\n |---o Unphysical event filter mask ("
728 stream <<
"\n *********************************************************\n";
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils.
The GENIE Algorithm Factory.
static AlgFactory * Instance()
Algorithm * AdoptAlgorithm(const AlgId &algid) const
virtual const AlgId & Id(void) const
Get algorithm ID.
Defines the EventGeneratorI interface.
virtual const InteractionListGeneratorI * IntListGenerator(void) const =0
virtual const GVldContext & ValidityContext(void) const =0
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
Assembles a list of all the EventGeneratorI subclasses that can be employed during a neutrino event g...
EventGeneratorList * AssembleGeneratorList()
virtual void ProcessEventRecord(GHepRecord *event_rec) const =0
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
void AssertIsValidInitState(void) const
const Spline * XSecSpline(const Interaction *interaction) const
void SetUnphysEventMask(const TBits &mask)
void Configure(int nu_pdgc, int Z, int A)
string fEventGenList
list of event generators loaded by this driver (what used to be the $GEVGL setting)
EventGeneratorList * fEvGenList
all Event Generators available at this job
void CreateSplines(int nknots=-1, double emax=-1, bool inLogE=true)
InitialState * fInitState
initial state information for driver instance
void BuildGeneratorList(void)
TBits * fUnphysEventMask
controls whether unphysical events are returned
const InteractionList * Interactions(void) const
bool fUseSplines
controls whether xsecs are computed or interpolated
double XSecSum(const TLorentzVector &nup4)
InteractionGeneratorMap * fIntGenMap
interaction -> generator assosiative container
Spline * fXSecSumSpl
sum{xsec(all interactions | this init state)}
EventRecord * GenerateEvent(const TLorentzVector &nu4p)
EventRecord * fCurrentRecord
ptr to the event record being processed
void CreateXSecSumSpline(int nk, double Emin, double Emax, bool inlogE=true)
void BuildInteractionGeneratorMap(void)
unsigned int fNRecLevel
recursive mode depth counter
void BuildInteractionSelector(void)
void BuildInitialState(const InitialState &init_state)
InteractionSelectorI * fIntSelector
interaction selector
void SetEventGeneratorList(string listname)
Range1D_t ValidEnergyRange(void) const
void Print(ostream &stream) const
const EventGeneratorI * FindGenerator(const Interaction *interaction) const
static unsigned int NFlags(void)
Initial State information.
string AsString(void) const
void SetProbeP4(const TLorentzVector &P4)
An Interaction -> EventGeneratorI associative container. The container is being built for the loaded ...
Defines the InteractionListGeneratorI interface. Concrete implementations of this interface generate ...
virtual InteractionList * CreateInteractionList(const InitialState &init) const =0
A vector of Interaction objects.
Defines the InteractionSelectorI interface to be implemented by algorithms selecting interactions to ...
Summary information for an interaction.
string AsString(void) const
InitialState * InitStatePtr(void) const
Singleton class to load & serve a TDatabasePDG.
static PDGLibrary * Instance(void)
TParticlePDG * Find(int pdgc, bool must_exist=true)
A simple [min,max] interval for doubles.
Keep info on the event generation thread currently on charge. This is used so that event generation m...
void UpdateRunningThread(const EventGeneratorI *evg)
static RunningThreadInfo * Instance(void)
A numeric analysis tool class for interpolating 1-D functions.
double Evaluate(double x) const
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
Cross Section Calculation Interface.
virtual double Integral(const Interaction *i) const =0
List of cross section vs energy splines.
void SetLogE(bool on)
set opt to build splines as f(E) or as f(logE)
bool SplineExists(const XSecAlgorithmI *alg, const Interaction *i) const
const Spline * GetSpline(const XSecAlgorithmI *alg, const Interaction *i) const
static XSecSplineList * Instance()
void CreateSpline(const XSecAlgorithmI *alg, const Interaction *i, int nknots=-1, double e_min=-1, double e_max=-1)
Misc GENIE control constants.
static const unsigned int kRecursiveModeMaxDepth
bool IsAntiDarkMatter(int pdgc)
bool IsDarkMatter(int pdgc)
static constexpr double cm2
string BoolAsIOString(bool b)
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f=' *')
THE MAIN GENIE PROJECT NAMESPACE
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)