EventGeneratorListAssembler.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
7  University of Liverpool & STFC Rutherford Appleton Laboratory
8 */
9 //____________________________________________________________________________
10 
11 #include <sstream>
12 
20 #include "Framework/Utils/RunOpt.h"
21 
22 using std::ostringstream;
23 
24 using namespace genie;
25 
26 //___________________________________________________________________________
28 Algorithm("genie::EventGeneratorListAssembler")
29 {
30 
31 }
32 //___________________________________________________________________________
34 Algorithm("genie::EventGeneratorListAssembler", config)
35 {
36 
37 }
38 //___________________________________________________________________________
40 {
41 
42 }
43 //___________________________________________________________________________
45 {
46  SLOG("EvGenListAssembler", pNOTICE)
48  "Loading requested Event Generators", 0, '-');
49 
50  if ( RunOpt::Instance() -> EventGeneratorList() == "Default" ) {
51  AddTopRegistry( AlgConfigPool::Instance() -> TuneGeneratorList(), false ) ;
52 
53  SLOG("EvGenListAssembler", pNOTICE)
54  << "** Using Tune Generator List: " ;
55 
56  }
57 
58 
60 
61 // if (!fConfig) {
62 // SLOG("EvGenListAssembler", pFATAL)
63 // << "Cannot instantiate EventGeneratorList with no config.";
64 // gAbortingInErr = true;
65 // exit(-1);
66 // }
67 
68  int nproc = GetConfig().GetInt("NGenerators");
69  assert(nproc > 0);
70 
71  //-- Loop over the event generators for all requested processes
72  for(int ip = 0; ip < nproc; ip++) {
73  const EventGeneratorI * evgen = this->LoadGenerator(ip);
74  evgl->push_back(evgen);
75  }
76  return evgl;
77 }
78 //___________________________________________________________________________
80 {
81 
82 
83  ostringstream alg_key;
84  alg_key << "Generator-" << ip;
85 
86  const EventGeneratorI * evgen =
87  dynamic_cast<const EventGeneratorI *> (this->SubAlg(alg_key.str()));
88  assert(evgen);
89 
90  SLOG("EvGenListAssembler", pNOTICE)
91  << "** Loaded generator: " << evgen->Id().Key();
92 
93  return evgen;
94 }
95 //___________________________________________________________________________
96 
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
Defines the EventGeneratorI interface.
Algorithm abstract base class.
Definition: Algorithm.h:53
RgInt GetInt(RgKey key) const
Definition: Registry.cxx:467
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
static Config * config
Definition: config.cpp:1054
int AddTopRegistry(Registry *rp, bool owns=true)
add registry with top priority, also update ownership
Definition: Algorithm.cxx:625
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:97
static RunOpt * Instance(void)
Definition: RunOpt.cxx:54
const EventGeneratorI * LoadGenerator(int ip)
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
Definition: PrintUtils.cxx:164
A vector of EventGeneratorI objects.
#define pNOTICE
Definition: Messenger.h:61
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
Event Generation using GENIE, cosmics or single particles.
string Key(void) const
Definition: AlgId.h:46
static AlgConfigPool * Instance()
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:345