43 using std::ostringstream;
45 using namespace genie;
87 fEventGenList =
"Default";
114 fUnphysEventMask->SetBitNumber(i,
true);
118 <<
" -> 0) : " << *fUnphysEventMask;
123 if (fUnphysEventMask)
delete fUnphysEventMask;
124 if (fInitState)
delete fInitState;
125 if (fEvGenList)
delete fEvGenList;
126 if (fIntSelector)
delete fIntSelector;
127 if (fIntGenMap)
delete fIntGenMap;
128 if (fXSecSumSpl)
delete fXSecSumSpl;
150 mesg <<
"Configuring event generation driver for initial state: `" 152 <<
"' using event generator list: `" 153 << fEventGenList <<
"'.";
158 this -> BuildInitialState (init_state);
159 this -> BuildGeneratorList ();
160 this -> BuildInteractionGeneratorMap ();
161 this -> BuildInteractionSelector ();
163 LOG(
"GEVGDriver",
pINFO) <<
"Done configuring. \n";
168 LOG(
"GEVGDriver",
pINFO) <<
"Setting the initial state";
170 if(fInitState)
delete fInitState;
173 this->AssertIsValidInitState();
182 <<
"Building the event generator list (specified list name: " 183 << fEventGenList <<
")";
195 <<
"Building the interaction -> generator associations...";
199 fIntGenMap->BuildMap(*fInitState);
201 string mesgh =
"Interaction -> Generator assignments for Initial State: ";
210 LOG(
"GEVGDriver",
pINFO) <<
"Building the interaction selector...";
214 if(fIntSelector)
delete fIntSelector;
216 algf->
AdoptAlgorithm(
"genie::PhysInteractionSelector",
"Default"));
221 *fUnphysEventMask =
mask;
225 <<
" -> 0) : " << *fUnphysEventMask;
231 LOG(
"GEVGDriver",
pINFO) <<
"Creating the initial state";
239 <<
"Selecting an Interaction & Bootstraping the EventRecord";
240 fCurrentRecord = fIntSelector->SelectInteraction(fIntGenMap, nu4p);
242 if(!fCurrentRecord) {
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";
285 fCurrentRecord->SetUnphysEventMask(*fUnphysEventMask);
294 bool unphys = fCurrentRecord->IsUnphysical();
296 LOG(
"GEVGDriver",
pINFO) <<
"Returning the current event!";
298 return fCurrentRecord;
300 LOG(
"GEVGDriver",
pWARN) <<
"An unphysical event was generated...";
302 bool accept = fCurrentRecord->Accept();
305 <<
"The generated unphysical event is accepted by the user";
307 return fCurrentRecord;
311 <<
"The generated unphysical event is rejected";
312 delete fCurrentRecord;
318 <<
"Attempting to regenerate the event...";
322 <<
"Could not produce a physical event after " 324 delete fCurrentRecord;
340 <<
"Interaction->Generator Map has not being built yet!";
351 <<
"Setting event generator list: " << listname;
353 fEventGenList = 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";
391 for(intliter = ilst.begin(); intliter != ilst.end(); ++intliter) {
399 <<
"Compute cross section for interaction: \n" <<
code;
403 fIntGenMap->FindGenerator(interaction)->CrossSectionAlg();
408 bool spline_exists = xssl->
SplineExists(xsec_alg, interaction);
409 if (spline_exists && fUseSplines) {
410 double E = nup4.Energy();
413 xsec = xsec_alg->
Integral(interaction);
415 xsec = TMath::Max(0., xsec);
420 <<
"\nInteraction = " << code
421 <<
"\nCross Section " 422 << (fUseSplines ?
"*interpolated*" :
"*computed*")
431 << pdglib->
Find(fInitState->ProbePdg())->GetName() <<
"+" 432 << pdglib->
Find(fInitState->Tgt().Pdg())->GetName() <<
"->X, " 433 <<
"E = " << nup4.Energy() <<
" GeV)" 434 << (fUseSplines ?
"*interpolated*" :
"*computed*")
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);
477 double xs = this->XSecSum(p4);
482 if (fXSecSumSpl)
delete fXSecSumSpl;
483 fXSecSumSpl =
new Spline(nk, E, xsec);
493 if (!fUseSplines)
return 0;
501 fIntGenMap->FindGenerator(interaction)->CrossSectionAlg();
539 for(intliter = ilst.begin(); intliter != ilst.end(); ++intliter) {
546 fIntGenMap->FindGenerator(interaction)->CrossSectionAlg();
550 bool spl_exists = xsl->
SplineExists(xsec_alg, interaction);
553 fUseSplines = fUseSplines && spl_exists;
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]");
594 for(evgliter = fEvGenList->begin();
595 evgliter != fEvGenList->end(); ++evgliter) {
599 <<
"Querying [" << evgen->
Id().
Key()
600 <<
"] for its InteractionList";
622 <<
"Refusing to exceed validity range: Emax = " << Emax;
624 emax = TMath::Min(emax,Emax);
629 assert( emax > Emin );
634 nknots = (
int) (15 * TMath::Log10(emax-Emin));
636 nknots = TMath::Max(nknots,30);
640 for(intliter = ilst->begin(); intliter != ilst->end(); ++intliter) {
646 SLOG(
"GEVGDriver",
pINFO) <<
"Need xsec spline for " <<
code;
652 <<
"The spline wasn't loaded at initialization. " 653 <<
"I can build it now but it might take a while...";
654 xsl->
CreateSpline(alg, interaction, nknots, Emin, emax);
656 SLOG(
"GEVGDriver",
pDEBUG) <<
"Spline was found";
681 for(evgliter = fEvGenList->begin();
682 evgliter != fEvGenList->end(); ++evgliter) {
691 E.
min = TMath::Min(E.
min, Emin);
692 E.
max = TMath::Max(E.
max, Emax);
701 int ppdgc = fInitState->ProbePdg();
709 <<
"\n\n *********************** GEVGDriver ***************************";
711 int ppdg = fInitState->ProbePdg();
712 int tgtpdg = fInitState->Tgt().Pdg();
714 stream <<
"\n |---o Probe PDG-code ......: " << ppdg;
715 stream <<
"\n |---o Target PDG-code .....: " << tgtpdg;
717 stream <<
"\n |---o Using cross section splines is turned " 719 stream <<
"\n |---o Unphysical event filter mask (" 722 stream <<
"\n *********************************************************\n";
Cross Section Calculation Interface.
void Print(ostream &stream) const
void CreateXSecSumSpline(int nk, double Emin, double Emax, bool inlogE=true)
void SetProbeP4(const TLorentzVector &P4)
THE MAIN GENIE PROJECT NAMESPACE
virtual void ProcessEventRecord(GHepRecord *event_rec) const =0
EventGeneratorList * AssembleGeneratorList()
void CreateSpline(const XSecAlgorithmI *alg, const Interaction *i, int nknots=-1, double e_min=-1, double e_max=-1)
Defines the InteractionListGeneratorI interface. Concrete implementations of this interface generate ...
virtual const InteractionListGeneratorI * IntListGenerator(void) const =0
A simple [min,max] interval for doubles.
const EventGeneratorI * FindGenerator(const Interaction *interaction) const
bool SplineExists(const XSecAlgorithmI *alg, const Interaction *i) const
A numeric analysis tool class for interpolating 1-D functions.
Defines the EventGeneratorI interface.
bool IsDarkMatter(int pdgc)
void BuildInteractionGeneratorMap(void)
static XSecSplineList * Instance()
double Evaluate(double x) const
string AsString(void) const
virtual const GVldContext & ValidityContext(void) const =0
Range1D_t ValidEnergyRange(void) const
string BoolAsIOString(bool b)
void GenerateEvent(string mesg)
Summary information for an interaction.
An Interaction -> EventGeneratorI associative container. The container is being built for the loaded ...
static unsigned int NFlags(void)
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
void SetEventGeneratorList(string listname)
bool IsAntiDarkMatter(int pdgc)
const InteractionList * Interactions(void) const
static constexpr double cm2
double XSecSum(const TLorentzVector &nup4)
virtual double Integral(const Interaction *i) const =0
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
string AsString(void) const
CodeOutputInterface * code
GENIE Event Generation Driver. A minimalist user interface object for generating neutrino interaction...
Algorithm * AdoptAlgorithm(const AlgId &algid) const
virtual InteractionList * CreateInteractionList(const InitialState &init) const =0
Misc GENIE control constants.
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
void BuildGeneratorList(void)
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Defines the InteractionSelectorI interface to be implemented by algorithms selecting interactions to ...
static RunningThreadInfo * Instance(void)
void BuildInteractionSelector(void)
virtual const AlgId & Id(void) const
Get algorithm ID.
static PDGLibrary * Instance(void)
static AlgFactory * Instance()
const Spline * XSecSpline(const Interaction *interaction) const
Singleton class to load & serve a TDatabasePDG.
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
void UpdateRunningThread(const EventGeneratorI *evg)
void Configure(string mesg)
void SetLogE(bool on)
set opt to build splines as f(E) or as f(logE)
void Configure(int nu_pdgc, int Z, int A)
A vector of Interaction objects.
InitialState * InitStatePtr(void) const
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
void CreateSplines(int nknots=-1, double emax=-1, bool inLogE=true)
TParticlePDG * Find(int pdgc, bool must_exist=true)
The GENIE Algorithm Factory.
void UseGeneratorList(const EventGeneratorList *list)
void SetUnphysEventMask(const TBits &mask)
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
const Spline * GetSpline(const XSecAlgorithmI *alg, const Interaction *i) const
List of cross section vs energy splines.
Event Generation using GENIE, cosmics or single particles.
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
Keep info on the event generation thread currently on charge. This is used so that event generation m...
void AssertIsValidInitState(void) const
Assembles a list of all the EventGeneratorI subclasses that can be employed during a neutrino event g...
Initial State information.
EventRecord * GenerateEvent(const TLorentzVector &nu4p)
void BuildInitialState(const InitialState &init_state)
static const unsigned int kRecursiveModeMaxDepth