Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
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>

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)
 
EventRecordGenerateEvent (const TLorentzVector &nu4p)
 
const InteractionListInteractions (void) const
 
const EventGeneratorListEventGenerators (void) const
 
const EventGeneratorIFindGenerator (const Interaction *interaction) const
 
const SplineXSecSumSpline (void) const
 
const SplineXSecSpline (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

InitialStatefInitState
 initial state information for driver instance More...
 
EventRecordfCurrentRecord
 ptr to the event record being processed More...
 
EventGeneratorListfEvGenList
 all Event Generators available at this job More...
 
InteractionSelectorIfIntSelector
 interaction selector More...
 
InteractionGeneratorMapfIntGenMap
 interaction -> generator assosiative container More...
 
TBits * fUnphysEventMask
 controls whether unphysical events are returned More...
 
bool fUseSplines
 controls whether xsecs are computed or interpolated More...
 
SplinefXSecSumSpl
 sum{xsec(all interactions | this init state)} More...
 
unsigned int fNRecLevel
 recursive mode depth counter More...
 
string fEventGenList
 list of event generators loaded by this driver (what used to be the $GEVGL setting) More...
 

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 <constantinos.andreopoulos cern.ch> University of Liverpool & STFC Rutherford Appleton Laboratory

August 06, 2004

Copyright (c) 2003-2020, 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 ( )

Definition at line 57 of file GEVGDriver.cxx.

58 {
59  this->Init();
60 }
void Init(void)
Definition: GEVGDriver.cxx:67
GEVGDriver::~GEVGDriver ( )

Definition at line 62 of file GEVGDriver.cxx.

63 {
64  this->CleanUp();
65 }
void CleanUp(void)
Definition: GEVGDriver.cxx:121

Member Function Documentation

void GEVGDriver::AssertIsValidInitState ( void  ) const
private

Definition at line 698 of file GEVGDriver.cxx.

699 {
700  assert(fInitState);
701  int ppdgc = fInitState->ProbePdg();
702  bool isv = pdg::IsLepton(ppdgc) || pdg::IsDarkMatter(ppdgc) || pdg::IsAntiDarkMatter(ppdgc);
703  assert(isv);
704 }
bool IsDarkMatter(int pdgc)
Definition: PDGUtils.cxx:124
bool IsAntiDarkMatter(int pdgc)
Definition: PDGUtils.cxx:130
int ProbePdg(void) const
Definition: InitialState.h:64
InitialState * fInitState
initial state information for driver instance
Definition: GEVGDriver.h:118
bool IsLepton(int pdgc)
Definition: PDGUtils.cxx:83
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 }
string fEventGenList
list of event generators loaded by this driver (what used to be the $GEVGL setting) ...
Definition: GEVGDriver.h:127
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
EventGeneratorList * fEvGenList
all Event Generators available at this job
Definition: GEVGDriver.h:120
Assembles a list of all the EventGeneratorI subclasses that can be employed during a neutrino event g...
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 
173  this->AssertIsValidInitState();
174 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
InitialState * fInitState
initial state information for driver instance
Definition: GEVGDriver.h:118
void AssertIsValidInitState(void) const
Definition: GEVGDriver.cxx:698
Initial State information.
Definition: InitialState.h:48
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 
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 }
An Interaction -> EventGeneratorI associative container. The container is being built for the loaded ...
void BuildMap(const InitialState &init_state)
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
string AsString(void) const
#define pINFO
Definition: Messenger.h:62
InitialState * fInitState
initial state information for driver instance
Definition: GEVGDriver.h:118
InteractionGeneratorMap * fIntGenMap
interaction -> generator assosiative container
Definition: GEVGDriver.h:122
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
Definition: PrintUtils.cxx:164
void UseGeneratorList(const EventGeneratorList *list)
EventGeneratorList * fEvGenList
all Event Generators available at this job
Definition: GEVGDriver.h:120
#define pDEBUG
Definition: Messenger.h:63
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 }
InteractionSelectorI * fIntSelector
interaction selector
Definition: GEVGDriver.h:121
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
Algorithm * AdoptAlgorithm(const AlgId &algid) const
Definition: AlgFactory.cxx:116
Defines the InteractionSelectorI interface to be implemented by algorithms selecting interactions to ...
static AlgFactory * Instance()
Definition: AlgFactory.cxx:64
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39
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 }
InteractionSelectorI * fIntSelector
interaction selector
Definition: GEVGDriver.h:121
TBits * fUnphysEventMask
controls whether unphysical events are returned
Definition: GEVGDriver.h:123
InitialState * fInitState
initial state information for driver instance
Definition: GEVGDriver.h:118
Spline * fXSecSumSpl
sum{xsec(all interactions | this init state)}
Definition: GEVGDriver.h:125
InteractionGeneratorMap * fIntGenMap
interaction -> generator assosiative container
Definition: GEVGDriver.h:122
EventGeneratorList * fEvGenList
all Event Generators available at this job
Definition: GEVGDriver.h:120
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 }
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
Definition: Target.h:40
void Configure(int nu_pdgc, int Z, int A)
Definition: GEVGDriver.cxx:137
#define A
Definition: memgrp.cpp:38
Initial State information.
Definition: InitialState.h:48
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 ();
160  this -> BuildInteractionGeneratorMap ();
161  this -> BuildInteractionSelector ();
162 
163  LOG("GEVGDriver", pINFO) << "Done configuring. \n";
164 }
string fEventGenList
list of event generators loaded by this driver (what used to be the $GEVGL setting) ...
Definition: GEVGDriver.h:127
void BuildInteractionGeneratorMap(void)
Definition: GEVGDriver.cxx:189
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
string AsString(void) const
#define pINFO
Definition: Messenger.h:62
void BuildGeneratorList(void)
Definition: GEVGDriver.cxx:176
void BuildInteractionSelector(void)
Definition: GEVGDriver.cxx:208
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
Definition: PrintUtils.cxx:164
#define pNOTICE
Definition: Messenger.h:61
Initial State information.
Definition: InitialState.h:48
void BuildInitialState(const InitialState &init_state)
Definition: GEVGDriver.cxx:166
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
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();
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 = TMath::Max(0.001,evgen->ValidityContext().Emin());
614  double Emax = evgen->ValidityContext().Emax();
615 
616  // if the user set a maximum energy, create the spline up to this
617  // energy - otherwise use the upper limit of the validity range of
618  // the current generator
619  if ( emax > 0 ) {
620  if ( emax > Emax ) {
621  LOG("GEVGDriver", pWARN)
622  << "Refusing to exceed validity range: Emax = " << Emax;
623  }
624  emax = TMath::Min(emax,Emax); // don't exceed validity range
625  } else {
626  emax = Emax;
627  }
628 
629  assert( emax > Emin );
630 
631  // number of knots: use specified number. If not set, use 15 knots
632  // per decade. Don't use less than 30 knots.
633  if ( nknots < 0 ) {
634  nknots = (int) (15 * TMath::Log10(emax-Emin));
635  }
636  nknots = TMath::Max(nknots,30);
637 
638  // loop over all interactions that can be generated and ask the
639  // appropriate cross section algorithm to compute its cross section
640  for(intliter = ilst->begin(); intliter != ilst->end(); ++intliter) {
641 
642  // current interaction
643  Interaction * interaction = *intliter;
644  string code = interaction->AsString();
645 
646  SLOG("GEVGDriver", pINFO) << "Need xsec spline for " << code;
647 
648  // only create the spline if it does not already exists
649  bool spl_exists = xsl->SplineExists(alg, interaction);
650  if(!spl_exists) {
651  SLOG("GEVGDriver", pDEBUG)
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);
655  } else {
656  SLOG("GEVGDriver", pDEBUG) << "Spline was found";
657  }
658  } // loop over interaction that can be generated by this generator
659  delete ilst;
660  ilst = 0;
661  } // loop over event generators
662 
663  LOG("GEVGDriver", pINFO) << *xsl; // print list of splines
664 
665  fUseSplines = true;
666 }
Cross Section Calculation Interface.
intermediate_table::iterator iterator
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
bool SplineExists(const XSecAlgorithmI *alg, const Interaction *i) const
Defines the EventGeneratorI interface.
intermediate_table::const_iterator const_iterator
static XSecSplineList * Instance()
string AsString(void) const
virtual const GVldContext & ValidityContext(void) const =0
Summary information for an interaction.
Definition: Interaction.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
CodeOutputInterface * code
#define pINFO
Definition: Messenger.h:62
InitialState * fInitState
initial state information for driver instance
Definition: GEVGDriver.h:118
virtual InteractionList * CreateInteractionList(const InitialState &init) const =0
#define pWARN
Definition: Messenger.h:60
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:97
double Emax(void) const
Definition: GVldContext.h:46
void SetLogE(bool on)
set opt to build splines as f(E) or as f(logE)
A vector of Interaction objects.
double Emin(void) const
Definition: GVldContext.h:45
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
List of cross section vs energy splines.
Event Generation using GENIE, cosmics or single particles.
EventGeneratorList * fEvGenList
all Event Generators available at this job
Definition: GEVGDriver.h:120
string Key(void) const
Definition: AlgId.h:46
bool fUseSplines
controls whether xsecs are computed or interpolated
Definition: GEVGDriver.h:124
#define pDEBUG
Definition: Messenger.h:63
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 }
A numeric analysis tool class for interpolating 1-D functions.
Definition: Spline.h:46
#define pFATAL
Definition: Messenger.h:56
const double e
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
double XSecSum(const TLorentzVector &nup4)
Definition: GEVGDriver.cxx:373
#define pINFO
Definition: Messenger.h:62
Spline * fXSecSumSpl
sum{xsec(all interactions | this init state)}
Definition: GEVGDriver.h:125
E
Definition: 018_def.c:13
bool fUseSplines
controls whether xsecs are computed or interpolated
Definition: GEVGDriver.h:124
const EventGeneratorList* genie::GEVGDriver::EventGenerators ( void  ) const
inline

Definition at line 80 of file GEVGDriver.h.

80 { return fEvGenList; }
EventGeneratorList * fEvGenList
all Event Generators available at this job
Definition: GEVGDriver.h:120
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 }
const EventGeneratorI * FindGenerator(const Interaction *in) const
Defines the EventGeneratorI interface.
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pWARN
Definition: Messenger.h:60
InteractionGeneratorMap * fIntGenMap
interaction -> generator assosiative container
Definition: GEVGDriver.h:122
Event Generation using GENIE, cosmics or single particles.
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";
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";
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 
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 
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 }
EventRecord * fCurrentRecord
ptr to the event record being processed
Definition: GEVGDriver.h:119
virtual void ProcessEventRecord(GHepRecord *event_rec) const =0
#define pERROR
Definition: Messenger.h:59
virtual Interaction * Summary(void) const
Definition: GHepRecord.cxx:91
const EventGeneratorI * FindGenerator(const Interaction *in) const
Defines the EventGeneratorI interface.
unsigned int fNRecLevel
recursive mode depth counter
Definition: GEVGDriver.h:126
InteractionSelectorI * fIntSelector
interaction selector
Definition: GEVGDriver.h:121
Summary information for an interaction.
Definition: Interaction.h:56
virtual bool Accept(void) const
Definition: GHepRecord.cxx:939
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
TBits * fUnphysEventMask
controls whether unphysical events are returned
Definition: GEVGDriver.h:123
#define pINFO
Definition: Messenger.h:62
InitialState * fInitState
initial state information for driver instance
Definition: GEVGDriver.h:118
#define pWARN
Definition: Messenger.h:60
static RunningThreadInfo * Instance(void)
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:97
virtual bool IsUnphysical(void) const
Definition: GHepRecord.h:119
void UpdateRunningThread(const EventGeneratorI *evg)
InteractionGeneratorMap * fIntGenMap
interaction -> generator assosiative container
Definition: GEVGDriver.h:122
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
Definition: PrintUtils.cxx:164
#define pNOTICE
Definition: Messenger.h:61
virtual EventRecord * SelectInteraction(const InteractionGeneratorMap *igmp, const TLorentzVector &p4) const =0
Define the InteractionSelectorI interface.
Event Generation using GENIE, cosmics or single particles.
void SetUnphysEventMask(const TBits &mask)
Definition: GHepRecord.cxx:930
Keep info on the event generation thread currently on charge. This is used so that event generation m...
string Key(void) const
Definition: AlgId.h:46
Initial State information.
Definition: InitialState.h:48
#define pDEBUG
Definition: Messenger.h:63
EventRecord * GenerateEvent(const TLorentzVector &nu4p)
Definition: GEVGDriver.cxx:228
static const unsigned int kRecursiveModeMaxDepth
Definition: Controls.h:29
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())
73  fCurrentRecord = 0;
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 }
EventRecord * fCurrentRecord
ptr to the event record being processed
Definition: GEVGDriver.h:119
string fEventGenList
list of event generators loaded by this driver (what used to be the $GEVGL setting) ...
Definition: GEVGDriver.h:127
unsigned int fNRecLevel
recursive mode depth counter
Definition: GEVGDriver.h:126
InteractionSelectorI * fIntSelector
interaction selector
Definition: GEVGDriver.h:121
static unsigned int NFlags(void)
Definition: GHepFlags.h:76
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
TBits * fUnphysEventMask
controls whether unphysical events are returned
Definition: GEVGDriver.h:123
InitialState * fInitState
initial state information for driver instance
Definition: GEVGDriver.h:118
Spline * fXSecSumSpl
sum{xsec(all interactions | this init state)}
Definition: GEVGDriver.h:125
InteractionGeneratorMap * fIntGenMap
interaction -> generator assosiative container
Definition: GEVGDriver.h:122
#define pNOTICE
Definition: Messenger.h:61
EventGeneratorList * fEvGenList
all Event Generators available at this job
Definition: GEVGDriver.h:120
bool fUseSplines
controls whether xsecs are computed or interpolated
Definition: GEVGDriver.h:124
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 
345  return &ilst;
346 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pWARN
Definition: Messenger.h:60
const InteractionList & GetInteractionList(void) const
InteractionGeneratorMap * fIntGenMap
interaction -> generator assosiative container
Definition: GEVGDriver.h:122
A vector of Interaction objects.
void GEVGDriver::Print ( ostream &  stream) const

Definition at line 706 of file GEVGDriver.cxx.

707 {
708  stream
709  << "\n\n *********************** GEVGDriver ***************************";
710 
711  int ppdg = fInitState->ProbePdg();
712  int tgtpdg = fInitState->Tgt().Pdg();
713 
714  stream << "\n |---o Probe PDG-code ......: " << ppdg;
715  stream << "\n |---o Target PDG-code .....: " << tgtpdg;
716 
717  stream << "\n |---o Using cross section splines is turned "
719  stream << "\n |---o Unphysical event filter mask ("
720  << GHepFlags::NFlags() << "->0) = " << *fUnphysEventMask;
721 
722  stream << "\n *********************************************************\n";
723 }
int Pdg(void) const
Definition: Target.h:71
string BoolAsIOString(bool b)
Definition: PrintUtils.cxx:102
static unsigned int NFlags(void)
Definition: GHepFlags.h:76
TBits * fUnphysEventMask
controls whether unphysical events are returned
Definition: GEVGDriver.h:123
int ProbePdg(void) const
Definition: InitialState.h:64
InitialState * fInitState
initial state information for driver instance
Definition: GEVGDriver.h:118
const Target & Tgt(void) const
Definition: InitialState.h:66
bool fUseSplines
controls whether xsecs are computed or interpolated
Definition: GEVGDriver.h:124
void GEVGDriver::Reset ( void  )

Definition at line 131 of file GEVGDriver.cxx.

132 {
133  this->CleanUp();
134  this->Init();
135 }
void Init(void)
Definition: GEVGDriver.cxx:67
void CleanUp(void)
Definition: GEVGDriver.cxx:121
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 }
string fEventGenList
list of event generators loaded by this driver (what used to be the $GEVGL setting) ...
Definition: GEVGDriver.h:127
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pNOTICE
Definition: Messenger.h:61
void GEVGDriver::SetUnphysEventMask ( const TBits &  mask)

Definition at line 219 of file GEVGDriver.cxx.

220 {
222 
223  LOG("GEVGDriver", pNOTICE)
224  << "Setting unphysical event mask (bits: " << GHepFlags::NFlags() - 1
225  << " -> 0) : " << *fUnphysEventMask;
226 }
static unsigned int NFlags(void)
Definition: GHepFlags.h:76
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
TBits * fUnphysEventMask
controls whether unphysical events are returned
Definition: GEVGDriver.h:123
#define pNOTICE
Definition: Messenger.h:61
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
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
536 
537  // Loop over all interactions & check that all splines have been loaded
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 }
Cross Section Calculation Interface.
const EventGeneratorI * FindGenerator(const Interaction *in) const
bool SplineExists(const XSecAlgorithmI *alg, const Interaction *i) const
intermediate_table::const_iterator const_iterator
static XSecSplineList * Instance()
string AsString(void) const
Summary information for an interaction.
Definition: Interaction.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pWARN
Definition: Messenger.h:60
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:97
const InteractionList & GetInteractionList(void) const
InteractionGeneratorMap * fIntGenMap
interaction -> generator assosiative container
Definition: GEVGDriver.h:122
A vector of Interaction objects.
List of cross section vs energy splines.
string Key(void) const
Definition: AlgId.h:46
bool fUseSplines
controls whether xsecs are computed or interpolated
Definition: GEVGDriver.h:124
Range1D_t GEVGDriver::ValidEnergyRange ( void  ) const

Definition at line 668 of file GEVGDriver.cxx.

669 {
670 // loops over all loaded event generation threads, queries for the energy
671 // range at their validity context and builds the valid energy range for
672 // this driver
673 
674  Range1D_t E;
675  E.min = 9999;
676  E.max = -9999;
677 
678  EventGeneratorList::const_iterator evgliter; // event generator list iter
679 
680  // loop over all EventGenerator objects used in the current job
681  for(evgliter = fEvGenList->begin();
682  evgliter != fEvGenList->end(); ++evgliter) {
683  // current event generator
684  const EventGeneratorI * evgen = *evgliter;
685 
686  // Emin, Emax as declared in current generator's validity context
687  double Emin = TMath::Max(0.001,evgen->ValidityContext().Emin());
688  double Emax = evgen->ValidityContext().Emax();
689 
690  // combined Emin, Emax
691  E.min = TMath::Min(E.min, Emin);
692  E.max = TMath::Max(E.max, Emax);
693  }
694  assert(E.min<E.max && E.min>=0);
695  return E;
696 }
A simple [min,max] interval for doubles.
Definition: Range1.h:42
Defines the EventGeneratorI interface.
intermediate_table::const_iterator const_iterator
virtual const GVldContext & ValidityContext(void) const =0
double max
Definition: Range1.h:53
double Emax(void) const
Definition: GVldContext.h:46
E
Definition: 018_def.c:13
double Emin(void) const
Definition: GVldContext.h:45
double min
Definition: Range1.h:52
Event Generation using GENIE, cosmics or single particles.
EventGeneratorList * fEvGenList
all Event Generators available at this job
Definition: GEVGDriver.h:120
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
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 }
Cross Section Calculation Interface.
const EventGeneratorI * FindGenerator(const Interaction *in) const
A numeric analysis tool class for interpolating 1-D functions.
Definition: Spline.h:46
static XSecSplineList * Instance()
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
InteractionGeneratorMap * fIntGenMap
interaction -> generator assosiative container
Definition: GEVGDriver.h:122
const Spline * GetSpline(const XSecAlgorithmI *alg, const Interaction *i) const
List of cross section vs energy splines.
bool fUseSplines
controls whether xsecs are computed or interpolated
Definition: GEVGDriver.h:124
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
385 
386  // Get the list of all interactions that can be generated by this driver
388 
389  // Loop over all interactions & compute cross sections
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 }
Cross Section Calculation Interface.
void SetProbeP4(const TLorentzVector &P4)
const EventGeneratorI * FindGenerator(const Interaction *in) const
bool SplineExists(const XSecAlgorithmI *alg, const Interaction *i) const
int Pdg(void) const
Definition: Target.h:71
intermediate_table::const_iterator const_iterator
static XSecSplineList * Instance()
double Evaluate(double x) const
Definition: Spline.cxx:361
string AsString(void) const
Summary information for an interaction.
Definition: Interaction.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
static constexpr double cm2
Definition: Units.h:69
virtual double Integral(const Interaction *i) const =0
int ProbePdg(void) const
Definition: InitialState.h:64
CodeOutputInterface * code
#define pINFO
Definition: Messenger.h:62
InitialState * fInitState
initial state information for driver instance
Definition: GEVGDriver.h:118
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:57
Singleton class to load & serve a TDatabasePDG.
Definition: PDGLibrary.h:32
const InteractionList & GetInteractionList(void) const
InteractionGeneratorMap * fIntGenMap
interaction -> generator assosiative container
Definition: GEVGDriver.h:122
A vector of Interaction objects.
InitialState * InitStatePtr(void) const
Definition: Interaction.h:74
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:75
const Target & Tgt(void) const
Definition: InitialState.h:66
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
const Spline * GetSpline(const XSecAlgorithmI *alg, const Interaction *i) const
List of cross section vs energy splines.
bool fUseSplines
controls whether xsecs are computed or interpolated
Definition: GEVGDriver.h:124
#define pDEBUG
Definition: Messenger.h:63
const Spline* genie::GEVGDriver::XSecSumSpline ( void  ) const
inline

Definition at line 87 of file GEVGDriver.h.

87 { return fXSecSumSpl; }
Spline * fXSecSumSpl
sum{xsec(all interactions | this init state)}
Definition: GEVGDriver.h:125

Friends And Related Function Documentation

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
Definition: GEVGDriver.cxx:706

Member Data Documentation

EventRecord* genie::GEVGDriver::fCurrentRecord
private

ptr to the event record being processed

Definition at line 119 of file GEVGDriver.h.

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.

EventGeneratorList* genie::GEVGDriver::fEvGenList
private

all Event Generators available at this job

Definition at line 120 of file GEVGDriver.h.

InitialState* genie::GEVGDriver::fInitState
private

initial state information for driver instance

Definition at line 118 of file GEVGDriver.h.

InteractionGeneratorMap* genie::GEVGDriver::fIntGenMap
private

interaction -> generator assosiative container

Definition at line 122 of file GEVGDriver.h.

InteractionSelectorI* genie::GEVGDriver::fIntSelector
private

interaction selector

Definition at line 121 of file GEVGDriver.h.

unsigned int genie::GEVGDriver::fNRecLevel
private

recursive mode depth counter

Definition at line 126 of file GEVGDriver.h.

TBits* genie::GEVGDriver::fUnphysEventMask
private

controls whether unphysical events are returned

Definition at line 123 of file GEVGDriver.h.

bool genie::GEVGDriver::fUseSplines
private

controls whether xsecs are computed or interpolated

Definition at line 124 of file GEVGDriver.h.

Spline* genie::GEVGDriver::fXSecSumSpl
private

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

Definition at line 125 of file GEVGDriver.h.


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