EventGeneratorListAssembler.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2019, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab - January 25, 2004
9 
10  For the class documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13 
14 */
15 //____________________________________________________________________________
16 
17 #include <sstream>
18 
26 #include "Framework/Utils/RunOpt.h"
27 
28 using std::ostringstream;
29 
30 using namespace genie;
31 
32 //___________________________________________________________________________
34 Algorithm("genie::EventGeneratorListAssembler")
35 {
36 
37 }
38 //___________________________________________________________________________
40 Algorithm("genie::EventGeneratorListAssembler", config)
41 {
42 
43 }
44 //___________________________________________________________________________
46 {
47 
48 }
49 //___________________________________________________________________________
51 {
52  SLOG("EvGenListAssembler", pNOTICE)
54  "Loading requested Event Generators", 0, '-');
55 
56  if ( RunOpt::Instance() -> EventGeneratorList() == "Default" ) {
57  AddTopRegistry( AlgConfigPool::Instance() -> TuneGeneratorList(), false ) ;
58 
59  SLOG("EvGenListAssembler", pNOTICE)
60  << "** Using Tune Generator List: " ;
61 
62  }
63 
64 
66 
67 // if (!fConfig) {
68 // SLOG("EvGenListAssembler", pFATAL)
69 // << "Cannot instantiate EventGeneratorList with no config.";
70 // gAbortingInErr = true;
71 // exit(-1);
72 // }
73 
74  int nproc = GetConfig().GetInt("NGenerators");
75  assert(nproc > 0);
76 
77  //-- Loop over the event generators for all requested processes
78  for(int ip = 0; ip < nproc; ip++) {
79  const EventGeneratorI * evgen = this->LoadGenerator(ip);
80  evgl->push_back(evgen);
81  }
82  return evgl;
83 }
84 //___________________________________________________________________________
86 {
87 
88 
89  ostringstream alg_key;
90  alg_key << "Generator-" << ip;
91 
92  const EventGeneratorI * evgen =
93  dynamic_cast<const EventGeneratorI *> (this->SubAlg(alg_key.str()));
94  assert(evgen);
95 
96  SLOG("EvGenListAssembler", pNOTICE)
97  << "** Loaded generator: " << evgen->Id().Key();
98 
99  return evgen;
100 }
101 //___________________________________________________________________________
102 
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
Defines the EventGeneratorI interface.
Algorithm abstract base class.
Definition: Algorithm.h:54
Definition: config.py:1
TString ip
Definition: loadincs.C:5
RgInt GetInt(RgKey key) const
Definition: Registry.cxx:482
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:254
int AddTopRegistry(Registry *rp, bool owns=true)
add registry with top priority, also update ownership
Definition: Algorithm.cxx:585
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
static RunOpt * Instance(void)
Definition: RunOpt.cxx:62
const EventGeneratorI * LoadGenerator(int ip)
assert(nhit_max >=nhit_nbins)
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
Definition: PrintUtils.cxx:171
A vector of EventGeneratorI objects.
#define pNOTICE
Definition: Messenger.h:62
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:85
Module to generate only pions from cosmic rays.
string Key(void) const
Definition: AlgId.h:47
static AlgConfigPool * Instance()
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:353