GENIEGenerator
Loading...
Searching...
No Matches
genie::GEVGDriver Class Reference

GENIE Event Generation Driver. A minimalist user interface object for generating neutrino interactions. Each such object is configured for a given initial state and it drives all relevant GENIE neutrino interaction physics simulation code for that state. To set-up MC jobs involving a multitude of possible initial states, including arbitrarily complex neutrino flux and detector geometry descriptions, see the GMCJDriver object. More...

#include <GEVGDriver.h>

Collaboration diagram for genie::GEVGDriver:
[legend]

Public Member Functions

 GEVGDriver ()
 ~GEVGDriver ()
void UseSplines (void)
void SetEventGeneratorList (string listname)
void SetUnphysEventMask (const TBits &mask)
void Configure (int nu_pdgc, int Z, int A)
void Configure (const InitialState &init_state)
EventRecord * GenerateEvent (const TLorentzVector &nu4p)
const InteractionList * Interactions (void) const
const EventGeneratorList * EventGenerators (void) const
const EventGeneratorI * FindGenerator (const Interaction *interaction) const
const Spline * XSecSumSpline (void) const
const Spline * XSecSpline (const Interaction *interaction) const
void CreateSplines (int nknots=-1, double emax=-1, bool inLogE=true)
double XSecSum (const TLorentzVector &nup4)
void CreateXSecSumSpline (int nk, double Emin, double Emax, bool inlogE=true)
Range1D_t ValidEnergyRange (void) const
void Reset (void)
void Print (ostream &stream) const

Private Member Functions

void Init (void)
void CleanUp (void)
void BuildInitialState (const InitialState &init_state)
void BuildGeneratorList (void)
void BuildInteractionGeneratorMap (void)
void BuildInteractionSelector (void)
void AssertIsValidInitState (void) const

Private Attributes

InitialState * fInitState
 initial state information for driver instance
EventRecord * fCurrentRecord
 ptr to the event record being processed
EventGeneratorList * fEvGenList
 all Event Generators available at this job
InteractionSelectorI * fIntSelector
 interaction selector
InteractionGeneratorMap * fIntGenMap
 interaction -> generator assosiative container
TBits * fUnphysEventMask
 controls whether unphysical events are returned
bool fUseSplines
 controls whether xsecs are computed or interpolated
Spline * fXSecSumSpl
 sum{xsec(all interactions | this init state)}
unsigned int fNRecLevel
 recursive mode depth counter
string fEventGenList
 list of event generators loaded by this driver (what used to be the $GEVGL setting)

Friends

ostream & operator<< (ostream &stream, const GEVGDriver &driver)

Detailed Description

GENIE Event Generation Driver. A minimalist user interface object for generating neutrino interactions. Each such object is configured for a given initial state and it drives all relevant GENIE neutrino interaction physics simulation code for that state. To set-up MC jobs involving a multitude of possible initial states, including arbitrarily complex neutrino flux and detector geometry descriptions, see the GMCJDriver object.

Author
Costas Andreopoulos <c.andreopoulos \at cern.ch> University of Liverpool
Created:\n August 06, 2004
License:\n Copyright (c) 2003-2025, The GENIE Collaboration
For the full text of the license visit http://copyright.genie-mc.org

Definition at line 54 of file GEVGDriver.h.

Constructor & Destructor Documentation

◆ GEVGDriver()

GEVGDriver::GEVGDriver ( )

Definition at line 57 of file GEVGDriver.cxx.

58{
59 this->Init();
60}

References Init().

Referenced by operator<<.

◆ ~GEVGDriver()

GEVGDriver::~GEVGDriver ( )

Definition at line 62 of file GEVGDriver.cxx.

63{
64 this->CleanUp();
65}

References CleanUp().

Member Function Documentation

◆ AssertIsValidInitState()

void GEVGDriver::AssertIsValidInitState ( void ) const
private

Definition at line 704 of file GEVGDriver.cxx.

705{
706 assert(fInitState);
707 int ppdgc = fInitState->ProbePdg();
708 bool isv = pdg::IsLepton(ppdgc) || pdg::IsDarkMatter(ppdgc) || pdg::IsAntiDarkMatter(ppdgc);
709 assert(isv);
710}
InitialState * fInitState
initial state information for driver instance
Definition GEVGDriver.h:118
bool IsLepton(int pdgc)
Definition PDGUtils.cxx:86
bool IsAntiDarkMatter(int pdgc)
Definition PDGUtils.cxx:133
bool IsDarkMatter(int pdgc)
Definition PDGUtils.cxx:127

References fInitState, genie::pdg::IsAntiDarkMatter(), genie::pdg::IsDarkMatter(), and genie::pdg::IsLepton().

Referenced by BuildInitialState().

◆ BuildGeneratorList()

void GEVGDriver::BuildGeneratorList ( void )
private

Load event generators. The list of event generators is named by fEventGenList.

Definition at line 176 of file GEVGDriver.cxx.

177{
178//! Load event generators.
179//! The list of event generators is named by fEventGenList.
180
181 LOG("GEVGDriver", pINFO)
182 << "Building the event generator list (specified list name: "
183 << fEventGenList << ")";
184
185 EventGeneratorListAssembler evglist_assembler(fEventGenList.c_str());
186 fEvGenList = evglist_assembler.AssembleGeneratorList();
187}
#define pINFO
Definition Messenger.h:62
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
string fEventGenList
list of event generators loaded by this driver (what used to be the $GEVGL setting)
Definition GEVGDriver.h:127
EventGeneratorList * fEvGenList
all Event Generators available at this job
Definition GEVGDriver.h:120

References genie::EventGeneratorListAssembler::AssembleGeneratorList(), fEventGenList, fEvGenList, LOG, and pINFO.

Referenced by Configure().

◆ BuildInitialState()

void GEVGDriver::BuildInitialState ( const InitialState & init_state)
private

Definition at line 166 of file GEVGDriver.cxx.

167{
168 LOG("GEVGDriver", pINFO) << "Setting the initial state";
169
170 if(fInitState) delete fInitState;
171 fInitState = new InitialState(init_state);
172
174}
void AssertIsValidInitState(void) const

References AssertIsValidInitState(), fInitState, LOG, and pINFO.

Referenced by Configure().

◆ BuildInteractionGeneratorMap()

void GEVGDriver::BuildInteractionGeneratorMap ( void )
private

Map each possible interaction, for the given initial state, to one of the generators loaded up

Definition at line 189 of file GEVGDriver.cxx.

190{
191//! Map each possible interaction, for the given initial state, to one
192//! of the generators loaded up
193
194 LOG("GEVGDriver", pINFO)
195 << "Building the interaction -> generator associations...";
196
197 fIntGenMap = new InteractionGeneratorMap;
198 fIntGenMap->UseGeneratorList(fEvGenList);
199 fIntGenMap->BuildMap(*fInitState);
200
201 string mesgh = "Interaction -> Generator assignments for Initial State: ";
202
203 LOG("GEVGDriver", pDEBUG)
204 << utils::print::PrintFramedMesg(mesgh + fInitState->AsString(), 0, '-')
205 << *fIntGenMap;
206}
#define pDEBUG
Definition Messenger.h:63
InteractionGeneratorMap * fIntGenMap
interaction -> generator assosiative container
Definition GEVGDriver.h:122
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f=' *')

References fEvGenList, fInitState, fIntGenMap, LOG, pDEBUG, pINFO, and genie::utils::print::PrintFramedMesg().

Referenced by Configure().

◆ BuildInteractionSelector()

void GEVGDriver::BuildInteractionSelector ( void )
private

Definition at line 208 of file GEVGDriver.cxx.

209{
210 LOG("GEVGDriver", pINFO) << "Building the interaction selector...";
211
212 AlgFactory * algf = AlgFactory::Instance();
213
214 if(fIntSelector) delete fIntSelector;
215 fIntSelector = dynamic_cast<InteractionSelectorI *> (
216 algf->AdoptAlgorithm("genie::PhysInteractionSelector","Default"));
217}
static AlgFactory * Instance()
Algorithm * AdoptAlgorithm(const AlgId &algid) const
InteractionSelectorI * fIntSelector
interaction selector
Definition GEVGDriver.h:121

References genie::AlgFactory::AdoptAlgorithm(), fIntSelector, genie::AlgFactory::Instance(), LOG, and pINFO.

Referenced by Configure().

◆ CleanUp()

void GEVGDriver::CleanUp ( void )
private

Definition at line 121 of file GEVGDriver.cxx.

122{
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;
129}
TBits * fUnphysEventMask
controls whether unphysical events are returned
Definition GEVGDriver.h:123
Spline * fXSecSumSpl
sum{xsec(all interactions | this init state)}
Definition GEVGDriver.h:125

References fEvGenList, fInitState, fIntGenMap, fIntSelector, fUnphysEventMask, and fXSecSumSpl.

Referenced by Reset(), and ~GEVGDriver().

◆ Configure() [1/2]

void GEVGDriver::Configure ( const InitialState & init_state)

Definition at line 145 of file GEVGDriver.cxx.

146{
147 InitialState init_state(is.TgtPdg(), is.ProbePdg()); // filter any other init state info
148
149 ostringstream mesg;
150 mesg << "Configuring event generation driver for initial state: `"
151 << init_state.AsString()
152 << "' using event generator list: `"
153 << fEventGenList << "'.";
154
155 LOG("GEVGDriver", pNOTICE)
156 << utils::print::PrintFramedMesg(mesg.str(), 0, '*');
157
158 this -> BuildInitialState (init_state);
159 this -> BuildGeneratorList ();
161 this -> BuildInteractionSelector ();
162
163 LOG("GEVGDriver", pINFO) << "Done configuring. \n";
164}
#define pNOTICE
Definition Messenger.h:61
void BuildGeneratorList(void)
void BuildInteractionGeneratorMap(void)
void BuildInteractionSelector(void)
void BuildInitialState(const InitialState &init_state)
string AsString(void) const

References genie::InitialState::AsString(), BuildGeneratorList(), BuildInitialState(), BuildInteractionGeneratorMap(), BuildInteractionSelector(), fEventGenList, LOG, pINFO, pNOTICE, genie::utils::print::PrintFramedMesg(), genie::InitialState::ProbePdg(), and genie::InitialState::TgtPdg().

◆ Configure() [2/2]

void GEVGDriver::Configure ( int nu_pdgc,
int Z,
int A )

Definition at line 137 of file GEVGDriver.cxx.

138{
139 Target target(Z, A);
140 InitialState init_state(target, nu_pdgc);
141
142 this->Configure(init_state);
143}
void Configure(int nu_pdgc, int Z, int A)

References Configure().

Referenced by Configure(), Configure(), GenerateEventsAtFixedInitState(), GetEventGenDriver(), main(), and genie::GMCJDriver::PopulateEventGenDriverPool().

◆ CreateSplines()

void GEVGDriver::CreateSplines ( int nknots = -1,
double emax = -1,
bool inLogE = true )

Definition at line 577 of file GEVGDriver.cxx.

578{
579// Creates all the cross section splines that are needed by this driver.
580// It will check for pre-loaded splines and it will skip the creation of the
581// splines it already finds loaded.
582
583 LOG("GEVGDriver", pINFO)
584 << "Creating (missing) splines with [UseLogE: "
585 << ((useLogE) ? "ON]" : "OFF]");
586 // Get the list of spline objects
587 XSecSplineList * xsl = XSecSplineList::Instance();
588 xsl->SetLogE(useLogE);
589
590 EventGeneratorList::const_iterator evgliter; // event generator list iter
591 InteractionList::iterator intliter; // interaction list iter
592
593 // loop over all EventGenerator objects used in the current job
594 for(evgliter = fEvGenList->begin();
595 evgliter != fEvGenList->end(); ++evgliter) {
596 // current event generator
597 const EventGeneratorI * evgen = *evgliter;
598 LOG("GEVGDriver", pINFO)
599 << "Querying [" << evgen->Id().Key()
600 << "] for its InteractionList";
601
602 // ask the event generator to produce a list of all interaction it can
603 // generate for the input initial state
604 const InteractionListGeneratorI * ilstgen = evgen->IntListGenerator();
605 InteractionList * ilst = ilstgen->CreateInteractionList(*fInitState);
606 if(!ilst) continue;
607
608 // total cross section algorithm used by the current EventGenerator
609 const XSecAlgorithmI * alg = evgen->CrossSectionAlg();
610
611 // get the energy range of the spline from the EventGenerator
612 // validity context
613 double Emin = evgen->ValidityContext().Emin() ;
614 xsl -> SetMinE( Emin ) ;
615
616 double valid_Emax = evgen->ValidityContext().Emax();
617
618 // if the user set a maximum energy, create the spline up to this
619 // energy - otherwise use the upper limit of the validity range of
620 // the current generator
621 if ( emax > 0 ) {
622 if ( emax > valid_Emax ) {
623 LOG("GEVGDriver", pWARN)
624 << "Refusing to exceed validity range: Emax = " << valid_Emax;
625 }
626 emax = TMath::Min(emax,valid_Emax); // don't exceed validity range
627 } else {
628 emax = valid_Emax;
629 }
630
631 assert( emax > Emin );
632
633 xsl -> SetMaxE( emax ) ;
634
635 // number of knots: use specified number. If not set, use 15 knots
636 // per decade. Don't use less than 30 knots.
637 if ( nknots < 0 ) {
638 nknots = (int) (15 * TMath::Log10(emax-Emin));
639 }
640 nknots = TMath::Max(nknots,30);
641
642 xsl -> SetNKnots( nknots ) ;
643
644 // loop over all interactions that can be generated and ask the
645 // appropriate cross section algorithm to compute its cross section
646 for(intliter = ilst->begin(); intliter != ilst->end(); ++intliter) {
647
648 // current interaction
649 Interaction * interaction = *intliter;
650 string code = interaction->AsString();
651
652 SLOG("GEVGDriver", pINFO) << "Need xsec spline for " << code;
653
654 // only create the spline if it does not already exists
655 bool spl_exists = xsl->SplineExists(alg, interaction);
656 if(!spl_exists) {
657 SLOG("GEVGDriver", pDEBUG)
658 << "The spline wasn't loaded at initialization. "
659 << "I can build it now but it might take a while...";
660 xsl->CreateSpline(alg, interaction) ;
661 } else {
662 SLOG("GEVGDriver", pDEBUG) << "Spline was found";
663 }
664 } // loop over interaction that can be generated by this generator
665 delete ilst;
666 ilst = 0;
667 } // loop over event generators
668
669 LOG("GEVGDriver", pINFO) << *xsl; // print list of splines
670
671 fUseSplines = true;
672}
#define pWARN
Definition Messenger.h:60
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition Messenger.h:84
string Key(void) const
Definition AlgId.h:46
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition Algorithm.h:98
virtual const InteractionListGeneratorI * IntListGenerator(void) const =0
virtual const GVldContext & ValidityContext(void) const =0
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
bool fUseSplines
controls whether xsecs are computed or interpolated
Definition GEVGDriver.h:124
double Emax(void) const
Definition GVldContext.h:46
double Emin(void) const
Definition GVldContext.h:45
virtual InteractionList * CreateInteractionList(const InitialState &init) const =0
string AsString(void) const
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
static XSecSplineList * Instance()
void CreateSpline(const XSecAlgorithmI *alg, const Interaction *i, int nknots=-1, double e_min=-1, double e_max=-1)

References genie::Interaction::AsString(), genie::InteractionListGeneratorI::CreateInteractionList(), genie::XSecSplineList::CreateSpline(), genie::EventGeneratorI::CrossSectionAlg(), genie::GVldContext::Emax(), genie::GVldContext::Emin(), fEvGenList, fInitState, fUseSplines, genie::Algorithm::Id(), genie::XSecSplineList::Instance(), genie::EventGeneratorI::IntListGenerator(), genie::AlgId::Key(), LOG, pDEBUG, pINFO, pWARN, genie::XSecSplineList::SetLogE(), SLOG, genie::XSecSplineList::SplineExists(), and genie::EventGeneratorI::ValidityContext().

Referenced by genie::GMCJDriver::BootstrapXSecSplines(), GetEventGenDriver(), and main().

◆ CreateXSecSumSpline()

void GEVGDriver::CreateXSecSumSpline ( int nk,
double Emin,
double Emax,
bool inlogE = true )

Definition at line 440 of file GEVGDriver.cxx.

442{
443// This method creates a spline with the *total* cross section vs E (or logE)
444// for the initial state that this driver was configured with.
445// This spline is used, for example, by the GMCJDriver to select a target
446// material out of all the materials in a detector geometry (summing the
447// cross sections again and again proved to be expensive...)
448
449 LOG("GEVGDriver", pINFO)
450 << "Creating spline (sum-xsec = f(" << ((inlogE) ? "logE" : "E")
451 << ") in E = [" << Emin << ", " << Emax << "] using " << nk << " knots";
452
453 if(!fUseSplines) {
454 LOG("GEVGDriver", pFATAL) << "You haven't loaded any splines!! ";
455 }
456 assert(fUseSplines);
457 assert(Emin<Emax && Emin>0 && nk>2);
458
459 double logEmin=0, logEmax=0, dE=0;
460
461 double * E = new double[nk];
462 double * xsec = new double[nk];
463
464 if(inlogE) {
465 logEmin = TMath::Log(Emin);
466 logEmax = TMath::Log(Emax);
467 dE = (logEmax-logEmin)/(nk-1);
468 } else {
469 dE = (Emax-Emin)/(nk-1);
470 }
471
472 TLorentzVector p4(0,0,0,0);
473
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);
478
479 E[i] = e;
480 xsec[i] = xs;
481 }
482 if (fXSecSumSpl) delete fXSecSumSpl;
483 fXSecSumSpl = new Spline(nk, E, xsec);
484 delete [] E;
485 delete [] xsec;
486}
#define pFATAL
Definition Messenger.h:56
double XSecSum(const TLorentzVector &nup4)
const double e

References e, fUseSplines, fXSecSumSpl, LOG, pFATAL, pINFO, and XSecSum().

Referenced by genie::GMCJDriver::BootstrapXSecSplineSummation(), CalcTotalXSec(), and GetEventGenDriver().

◆ EventGenerators()

const EventGeneratorList * genie::GEVGDriver::EventGenerators ( void ) const
inline

Definition at line 80 of file GEVGDriver.h.

80{ return fEvGenList; }

References fEvGenList.

◆ FindGenerator()

const EventGeneratorI * GEVGDriver::FindGenerator ( const Interaction * interaction) const

Definition at line 357 of file GEVGDriver.cxx.

358{
359 if(!interaction) {
360 LOG("GEVGDriver", pWARN) << "Null interaction!!";
361 return 0;
362 }
363 if(!fIntGenMap) {
364 LOG("GEVGDriver", pWARN)
365 << "Interaction->Generator Map has not being built yet!";
366 return 0;
367 }
368
369 const EventGeneratorI * evgen = fIntGenMap->FindGenerator(interaction);
370 return evgen;
371}

References fIntGenMap, LOG, and pWARN.

Referenced by main().

◆ GenerateEvent()

EventRecord * GEVGDriver::GenerateEvent ( const TLorentzVector & nu4p)

Definition at line 228 of file GEVGDriver.cxx.

229{
230 //-- Build initial state information from inputs
231 LOG("GEVGDriver", pINFO) << "Creating the initial state";
232 InitialState init_state(*fInitState);
233 init_state.SetProbeP4(nu4p);
234
235 //-- Select the interaction to be generated (amongst the entries of the
236 // InteractionList assembled by the EventGenerators) and bootstrap the
237 // event record
238 LOG("GEVGDriver", pINFO)
239 << "Selecting an Interaction & Bootstraping the EventRecord";
240 fCurrentRecord = fIntSelector->SelectInteraction(fIntGenMap, nu4p);
241
242 if(!fCurrentRecord) {
243 LOG("GEVGDriver", pWARN)
244 << "No interaction could be selected for: "
245 << init_state.AsString() << " at E = " << nu4p.E() << " GeV";
246 return 0;
247 }
248
249 //-- Get a ptr to the interaction summary
250 LOG("GEVGDriver", pDEBUG) << "Getting the selected interaction";
251 Interaction * interaction = fCurrentRecord->Summary();
252
253 //-- Find the appropriate concrete EventGeneratorI implementation
254 // for generating this event.
255 //
256 // The right EventGeneratorI will be selecting by iterating over the
257 // entries of the EventGeneratorList and compare the interaction
258 // against the ValidityContext declared by each EventGeneratorI
259 //
260 // (note: use of the 'Chain of Responsibility' Design Pattern)
261
262 LOG("GEVGDriver", pINFO) << "Finding an appropriate EventGenerator";
263
264 const EventGeneratorI * evgen = fIntGenMap->FindGenerator(interaction);
265 assert(evgen);
266
267 RunningThreadInfo * rtinfo = RunningThreadInfo::Instance();
268 rtinfo->UpdateRunningThread(evgen);
269
270 //-- Generate the selected event
271 //
272 // The selected EventGeneratorI subclass will start processing the
273 // event record (by sequentially asking each entry in its list of
274 // EventRecordVisitorI subclasses to visit and process the record).
275 // Most of the actual event generation takes place in this step.
276 //
277 // (note: use of the 'Visitor' Design Pattern)
278
279 string mesg = "Requesting from event generation thread: " +
280 evgen->Id().Key() + " to generate the selected interaction";
281
282 LOG("GEVGDriver", pNOTICE)
283 << utils::print::PrintFramedMesg(mesg,1,'=');
284
285 fCurrentRecord->SetUnphysEventMask(*fUnphysEventMask);
287
288 //-- Check the generated event flags. The default behaviour is
289 // to reject an unphysical event and enter in recursive mode
290 // and try to regenerate it. If an unphysical event mask has
291 // been set, error conditions may be ignored so that the
292 // requested classes of unphysical events can be passed-through.
293
294 bool unphys = fCurrentRecord->IsUnphysical();
295 if(!unphys) {
296 LOG("GEVGDriver", pINFO) << "Returning the current event!";
297 fNRecLevel = 0;
298 return fCurrentRecord; // The client 'adopts' the event record
299 } else {
300 LOG("GEVGDriver", pWARN) << "An unphysical event was generated...";
301 // Check whether the user wants to ignore the err
302 bool accept = fCurrentRecord->Accept();
303 if(accept) {
304 LOG("GEVGDriver", pWARN)
305 << "The generated unphysical event is accepted by the user";
306 fNRecLevel = 0;
307 return fCurrentRecord; // The client 'adopts' the event record
308
309 } else {
310 LOG("GEVGDriver", pWARN)
311 << "The generated unphysical event is rejected";
312 delete fCurrentRecord;
313 fCurrentRecord = 0;
314 fNRecLevel++; // increase the nested level counter
315
317 LOG("GEVGDriver", pWARN)
318 << "Attempting to regenerate the event...";
319 return this->GenerateEvent(nu4p);
320 } else {
321 LOG("GEVGDriver", pERROR)
322 << "Could not produce a physical event after "
323 << kRecursiveModeMaxDepth << " attempts!";
324 delete fCurrentRecord;
325 fCurrentRecord = 0;
326 fNRecLevel = 0;
327 return 0;
328// exit(1);
329 }
330 }
331 }
332}
#define pERROR
Definition Messenger.h:59
virtual void ProcessEventRecord(GHepRecord *event_rec) const =0
EventRecord * GenerateEvent(const TLorentzVector &nu4p)
EventRecord * fCurrentRecord
ptr to the event record being processed
Definition GEVGDriver.h:119
unsigned int fNRecLevel
recursive mode depth counter
Definition GEVGDriver.h:126
void UpdateRunningThread(const EventGeneratorI *evg)
static RunningThreadInfo * Instance(void)
static const unsigned int kRecursiveModeMaxDepth
Definition Controls.h:29

References genie::InitialState::AsString(), fCurrentRecord, fInitState, fIntGenMap, fIntSelector, fNRecLevel, fUnphysEventMask, GenerateEvent(), genie::Algorithm::Id(), genie::RunningThreadInfo::Instance(), genie::AlgId::Key(), genie::controls::kRecursiveModeMaxDepth, LOG, pDEBUG, pERROR, pINFO, pNOTICE, genie::utils::print::PrintFramedMesg(), genie::EventRecordVisitorI::ProcessEventRecord(), pWARN, genie::InitialState::SetProbeP4(), and genie::RunningThreadInfo::UpdateRunningThread().

Referenced by GenerateEvent(), GenerateEvent(), genie::GMCJDriver::GenerateEventKinematics(), and GenerateEventsAtFixedInitState().

◆ Init()

void GEVGDriver::Init ( void )
private

Definition at line 67 of file GEVGDriver.cxx.

68{
69 // initial state for which this driver is configured
70 fInitState = 0;
71
72 // current event record (ownership is transfered at GenerateEvent())
74
75 // list of Event Generator objects loaded into the driver
76 fEvGenList = 0;
77
78 // interaction selector
79 fIntSelector = 0;
80
81 // flag instructing the driver whether, for each interaction, to compute
82 // cross section by running their corresponding XSecAlgorithm or by
83 // evaluating their corresponding xsec spline
84 fUseSplines = false;
85
86 // set of event generators to be loaded by this driver
87 fEventGenList = "Default";
88
89 // 'depth' counter when entering a recursive mode to re-generate a failed/
90 // unphysical event - the driver is not allowed to go into arbitrarily large
91 // depths
92 fNRecLevel = 0;
93
94 // an "interaction" -> "generator" associative contained built for all
95 // simulated interactions (from the loaded Event Generators and for the
96 // input initial state)
97 fIntGenMap = 0;
98
99 // A spline describing the sum of all interaction cross sections given an
100 // initial state (the init state with which this driver was configured).
101 // Create it using the CreateXSecSumSpline() method
102 // The sum of all interaction cross sections is used, for example, by
103 // GMCJDriver for selecting an initial state.
104 fXSecSumSpl = 0;
105
106 // Default driver behaviour is to filter out unphysical events
107 // If needed, set the fUnphysEventMask bitfield to get pre-selected types of
108 // unphysical events (just set to 1 the bit you want ignored from the check).
109 // Be warned that the event record for unphysical events might be incomplete
110 // depending on the processing step that event generation was stopped.
111 fUnphysEventMask = new TBits(GHepFlags::NFlags());
112 //fUnphysEventMask->ResetAllBits(true);
113 for(unsigned int i = 0; i < GHepFlags::NFlags(); i++) {
114 fUnphysEventMask->SetBitNumber(i, true);
115 }
116 LOG("GEVGDriver", pNOTICE)
117 << "Initializing unphysical event mask (bits: " << GHepFlags::NFlags()-1
118 << " -> 0) : " << *fUnphysEventMask;
119}
static unsigned int NFlags(void)
Definition GHepFlags.h:76

References fCurrentRecord, fEventGenList, fEvGenList, fInitState, fIntGenMap, fIntSelector, fNRecLevel, fUnphysEventMask, fUseSplines, fXSecSumSpl, LOG, genie::GHepFlags::NFlags(), and pNOTICE.

Referenced by GEVGDriver(), and Reset().

◆ Interactions()

const InteractionList * GEVGDriver::Interactions ( void ) const

Definition at line 334 of file GEVGDriver.cxx.

335{
336// Returns the list of all interactions that can be generated by this driver
337
338 if(!fIntGenMap) {
339 LOG("GEVGDriver", pWARN)
340 << "Interaction->Generator Map has not being built yet!";
341 return 0;
342 }
343
344 const InteractionList & ilst = fIntGenMap->GetInteractionList();
345 return &ilst;
346}

References fIntGenMap, LOG, and pWARN.

Referenced by main(), SaveGraphsToRootFile(), and SaveToPsFile().

◆ Print()

void GEVGDriver::Print ( ostream & stream) const

Definition at line 712 of file GEVGDriver.cxx.

713{
714 stream
715 << "\n\n *********************** GEVGDriver ***************************";
716
717 int ppdg = fInitState->ProbePdg();
718 int tgtpdg = fInitState->Tgt().Pdg();
719
720 stream << "\n |---o Probe PDG-code ......: " << ppdg;
721 stream << "\n |---o Target PDG-code .....: " << tgtpdg;
722
723 stream << "\n |---o Using cross section splines is turned "
725 stream << "\n |---o Unphysical event filter mask ("
726 << GHepFlags::NFlags() << "->0) = " << *fUnphysEventMask;
727
728 stream << "\n *********************************************************\n";
729}
string BoolAsIOString(bool b)

References genie::utils::print::BoolAsIOString(), fInitState, fUnphysEventMask, fUseSplines, and genie::GHepFlags::NFlags().

Referenced by operator<<.

◆ Reset()

void GEVGDriver::Reset ( void )

Definition at line 131 of file GEVGDriver.cxx.

132{
133 this->CleanUp();
134 this->Init();
135}

References CleanUp(), and Init().

◆ SetEventGeneratorList()

void GEVGDriver::SetEventGeneratorList ( string listname)

Definition at line 348 of file GEVGDriver.cxx.

349{
350 LOG("GEVGDriver", pNOTICE)
351 << "Setting event generator list: " << listname;
352
353 fEventGenList = listname;
354}

References fEventGenList, LOG, and pNOTICE.

Referenced by GenerateEventsAtFixedInitState(), GetEventGenDriver(), main(), and genie::GMCJDriver::PopulateEventGenDriverPool().

◆ SetUnphysEventMask()

void GEVGDriver::SetUnphysEventMask ( const TBits & mask)

Definition at line 219 of file GEVGDriver.cxx.

220{
221 *fUnphysEventMask = mask;
222
223 LOG("GEVGDriver", pNOTICE)
224 << "Setting unphysical event mask (bits: " << GHepFlags::NFlags() - 1
225 << " -> 0) : " << *fUnphysEventMask;
226}

References fUnphysEventMask, LOG, genie::GHepFlags::NFlags(), and pNOTICE.

Referenced by genie::GMCJDriver::GenerateEventKinematics(), and GenerateEventsAtFixedInitState().

◆ UseSplines()

void GEVGDriver::UseSplines ( void )

Definition at line 508 of file GEVGDriver.cxx.

509{
510// Instructs the driver to use cross section splines rather than computing
511// cross sections by integrating the differential cross section model which
512// can be very time-consuming.
513// **Note**
514// -- If you called GEVGDriver::CreateSplines() already the driver would
515// a) assume that you want to use them and b) would be assured that it
516// has all the splines it needs, so you do not need to call this method.
517// -- If you populated the XSecSplineList in another way without this driver
518// knowing about it, eg from an external XML file, do call this method
519// to let the driver know that you want to use the splines. However, note
520// that the driver would **explicitly check** that you have loaded all the
521// splines it needs. If not, then its fiery personality will take over and
522// it will refuse your request, reverting back to not using splines.
523
524 fUseSplines = true;
525
526 // Get the list of spline objects
527 // Should have been constructed at the job initialization
528 XSecSplineList * xsl = XSecSplineList::Instance();
529
530 // If the user wants to use splines, make sure that all the splines needed
531 // have been computed or loaded
532 if(fUseSplines) {
533
534 // Get the list of all interactions that can be generated by this driver
535 const InteractionList & ilst = fIntGenMap->GetInteractionList();
536
537 // Loop over all interactions & check that all splines have been loaded
538 InteractionList::const_iterator intliter;
539 for(intliter = ilst.begin(); intliter != ilst.end(); ++intliter) {
540
541 // current interaction
542 Interaction * interaction = *intliter;
543
544 // corresponding cross section algorithm
545 const XSecAlgorithmI * xsec_alg =
546 fIntGenMap->FindGenerator(interaction)->CrossSectionAlg();
547 assert(xsec_alg);
548
549 // spline exists in spline list?
550 bool spl_exists = xsl->SplineExists(xsec_alg, interaction);
551
552 // update the 'use splines' flag
553 fUseSplines = fUseSplines && spl_exists;
554
555 if(!spl_exists) {
556 if(!xsec_alg) {
557 LOG("GEVGDriver", pWARN)
558 << "Null cross-section algorithm! Can not load cross-section spline.";
559 return;
560 }
561 if(!interaction) {
562 LOG("GEVGDriver", pWARN)
563 << "Null interaction! Can not load cross-section spline.";
564 return;
565 }
566 LOG("GEVGDriver", pWARN)
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";
571 return;
572 }
573 } // loop over interaction list
574 }//use-splines?
575}

References genie::Interaction::AsString(), fIntGenMap, fUseSplines, genie::Algorithm::Id(), genie::XSecSplineList::Instance(), genie::AlgId::Key(), LOG, pWARN, and genie::XSecSplineList::SplineExists().

Referenced by Configure(), and genie::GMCJDriver::PopulateEventGenDriverPool().

◆ ValidEnergyRange()

Range1D_t GEVGDriver::ValidEnergyRange ( void ) const

Definition at line 674 of file GEVGDriver.cxx.

675{
676// loops over all loaded event generation threads, queries for the energy
677// range at their validity context and builds the valid energy range for
678// this driver
679
680 Range1D_t E;
681 E.min = 9999;
682 E.max = -9999;
683
684 EventGeneratorList::const_iterator evgliter; // event generator list iter
685
686 // loop over all EventGenerator objects used in the current job
687 for(evgliter = fEvGenList->begin();
688 evgliter != fEvGenList->end(); ++evgliter) {
689 // current event generator
690 const EventGeneratorI * evgen = *evgliter;
691
692 // Emin, Emax as declared in current generator's validity context
693 double Emin = TMath::Max(0.001,evgen->ValidityContext().Emin());
694 double Emax = evgen->ValidityContext().Emax();
695
696 // combined Emin, Emax
697 E.min = TMath::Min(E.min, Emin);
698 E.max = TMath::Max(E.max, Emax);
699 }
700 assert(E.min<E.max && E.min>=0);
701 return E;
702}

References genie::GVldContext::Emax(), genie::GVldContext::Emin(), fEvGenList, genie::Range1D_t::max, genie::Range1D_t::min, and genie::EventGeneratorI::ValidityContext().

Referenced by genie::GMCJDriver::BootstrapXSecSplineSummation().

◆ XSecSpline()

const Spline * GEVGDriver::XSecSpline ( const Interaction * interaction) const

Definition at line 488 of file GEVGDriver.cxx.

489{
490// Returns the cross section spline for the input interaction as was
491// computed from the cross section model associated with that interaction.
492
493 if (!fUseSplines) return 0;
494
495 // Get the list of spline objects
496 // Should have been constructed at the job initialization
497 XSecSplineList * xssl = XSecSplineList::Instance();
498
499 // get corresponding cross section algorithm for the input interaction
500 const XSecAlgorithmI * xsec_alg =
501 fIntGenMap->FindGenerator(interaction)->CrossSectionAlg();
502 assert(xsec_alg);
503
504 const Spline * spl = xssl->GetSpline(xsec_alg,interaction);
505 return spl;
506}
const Spline * GetSpline(const XSecAlgorithmI *alg, const Interaction *i) const

References fIntGenMap, fUseSplines, genie::XSecSplineList::GetSpline(), and genie::XSecSplineList::Instance().

Referenced by SaveGraphsToRootFile(), and SaveToPsFile().

◆ XSecSum()

double GEVGDriver::XSecSum ( const TLorentzVector & nup4)

Definition at line 373 of file GEVGDriver.cxx.

374{
375// Computes the sum of the cross sections for all the interactions that can
376// be simulated for the given initial state and for the input neutrino energy
377//
378 LOG("GEVGDriver", pDEBUG) << "Computing the cross section sum";
379
380 double xsec_sum = 0;
381
382 // Get the list of spline objects
383 // Should have been constructed at the job initialization
384 XSecSplineList * xssl = XSecSplineList::Instance();
385
386 // Get the list of all interactions that can be generated by this driver
387 const InteractionList & ilst = fIntGenMap->GetInteractionList();
388
389 // Loop over all interactions & compute cross sections
390 InteractionList::const_iterator intliter;
391 for(intliter = ilst.begin(); intliter != ilst.end(); ++intliter) {
392
393 // get current interaction
394 Interaction * interaction = new Interaction(**intliter);
395 interaction->InitStatePtr()->SetProbeP4(nup4);
396
397 string code = interaction->AsString();
398 SLOG("GEVGDriver", pDEBUG)
399 << "Compute cross section for interaction: \n" << code;
400
401 // get corresponding cross section algorithm
402 const XSecAlgorithmI * xsec_alg =
403 fIntGenMap->FindGenerator(interaction)->CrossSectionAlg();
404 assert(xsec_alg);
405
406 // compute (or evaluate) the cross section
407 double xsec = 0;
408 bool spline_exists = xssl->SplineExists(xsec_alg, interaction);
409 if (spline_exists && fUseSplines) {
410 double E = nup4.Energy();
411 xsec = xssl->GetSpline(xsec_alg,interaction)->Evaluate(E);
412 } else
413 xsec = xsec_alg->Integral(interaction);
414
415 xsec = TMath::Max(0., xsec);
416
417 // sum-up and report
418 xsec_sum += xsec;
419 LOG("GEVGDriver", pDEBUG)
420 << "\nInteraction = " << code
421 << "\nCross Section "
422 << (fUseSplines ? "*interpolated*" : "*computed*")
423 << " = " << (xsec/units::cm2) << " cm2";
424
425 delete interaction;
426 } // loop over event generators
427
428 PDGLibrary * pdglib = PDGLibrary::Instance();
429 LOG("GEVGDriver", pINFO)
430 << "SumXSec("
431 << pdglib->Find(fInitState->ProbePdg())->GetName() << "+"
432 << pdglib->Find(fInitState->Tgt().Pdg())->GetName() << "->X, "
433 << "E = " << nup4.Energy() << " GeV)"
434 << (fUseSplines ? "*interpolated*" : "*computed*")
435 << " = " << (xsec_sum/units::cm2) << " cm2";
436
437 return xsec_sum;
438}
void SetProbeP4(const TLorentzVector &P4)
InitialState * InitStatePtr(void) const
Definition Interaction.h:74
static PDGLibrary * Instance(void)
TParticlePDG * Find(int pdgc, bool must_exist=true)
double Evaluate(double x) const
Definition Spline.cxx:363
virtual double Integral(const Interaction *i) const =0
static constexpr double cm2
Definition Units.h:69

References genie::Interaction::AsString(), genie::units::cm2, genie::Spline::Evaluate(), genie::PDGLibrary::Find(), fInitState, fIntGenMap, fUseSplines, genie::XSecSplineList::GetSpline(), genie::Interaction::InitStatePtr(), genie::PDGLibrary::Instance(), genie::XSecSplineList::Instance(), genie::XSecAlgorithmI::Integral(), LOG, pDEBUG, pINFO, genie::InitialState::SetProbeP4(), SLOG, and genie::XSecSplineList::SplineExists().

Referenced by CreateXSecSumSpline().

◆ XSecSumSpline()

const Spline * genie::GEVGDriver::XSecSumSpline ( void ) const
inline

◆ operator<<

ostream & operator<< ( ostream & stream,
const GEVGDriver & driver )
friend

Definition at line 50 of file GEVGDriver.cxx.

51 {
52 driver.Print(stream);
53 return stream;
54 }
void Print(ostream &stream) const

References GEVGDriver(), and Print().

Member Data Documentation

◆ fCurrentRecord

EventRecord* genie::GEVGDriver::fCurrentRecord
private

ptr to the event record being processed

Definition at line 119 of file GEVGDriver.h.

Referenced by GenerateEvent(), and Init().

◆ fEventGenList

string genie::GEVGDriver::fEventGenList
private

list of event generators loaded by this driver (what used to be the $GEVGL setting)

Definition at line 127 of file GEVGDriver.h.

Referenced by BuildGeneratorList(), Configure(), Init(), and SetEventGeneratorList().

◆ fEvGenList

EventGeneratorList* genie::GEVGDriver::fEvGenList
private

all Event Generators available at this job

Definition at line 120 of file GEVGDriver.h.

Referenced by BuildGeneratorList(), BuildInteractionGeneratorMap(), CleanUp(), CreateSplines(), EventGenerators(), Init(), and ValidEnergyRange().

◆ fInitState

InitialState* genie::GEVGDriver::fInitState
private

initial state information for driver instance

Definition at line 118 of file GEVGDriver.h.

Referenced by AssertIsValidInitState(), BuildInitialState(), BuildInteractionGeneratorMap(), CleanUp(), CreateSplines(), GenerateEvent(), Init(), Print(), and XSecSum().

◆ fIntGenMap

InteractionGeneratorMap* genie::GEVGDriver::fIntGenMap
private

interaction -> generator assosiative container

Definition at line 122 of file GEVGDriver.h.

Referenced by BuildInteractionGeneratorMap(), CleanUp(), FindGenerator(), GenerateEvent(), Init(), Interactions(), UseSplines(), XSecSpline(), and XSecSum().

◆ fIntSelector

InteractionSelectorI* genie::GEVGDriver::fIntSelector
private

interaction selector

Definition at line 121 of file GEVGDriver.h.

Referenced by BuildInteractionSelector(), CleanUp(), GenerateEvent(), and Init().

◆ fNRecLevel

unsigned int genie::GEVGDriver::fNRecLevel
private

recursive mode depth counter

Definition at line 126 of file GEVGDriver.h.

Referenced by GenerateEvent(), and Init().

◆ fUnphysEventMask

TBits* genie::GEVGDriver::fUnphysEventMask
private

controls whether unphysical events are returned

Definition at line 123 of file GEVGDriver.h.

Referenced by CleanUp(), GenerateEvent(), Init(), Print(), and SetUnphysEventMask().

◆ fUseSplines

bool genie::GEVGDriver::fUseSplines
private

controls whether xsecs are computed or interpolated

Definition at line 124 of file GEVGDriver.h.

Referenced by CreateSplines(), CreateXSecSumSpline(), Init(), Print(), UseSplines(), XSecSpline(), and XSecSum().

◆ fXSecSumSpl

Spline* genie::GEVGDriver::fXSecSumSpl
private

sum{xsec(all interactions | this init state)}

Definition at line 125 of file GEVGDriver.h.

Referenced by CleanUp(), CreateXSecSumSpline(), Init(), and XSecSumSpline().


The documentation for this class was generated from the following files: