CMS 3D CMS Logo

BaseHadronizer.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 //
4 
5 // class BaseHadronizer meant as base class for hadronizers
6 // implements a few common methods concerning communication with the
7 // gen::HadronizerFilter<...> and gen::GeneratorFilter<...> templates,
8 // mostly memory management regarding the GenEvent pointers and such
9 
10 #ifndef gen_BaseHadronizer_h
11 #define gen_BaseHadronizer_h
12 
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 #include <memory>
18 
21 
26 
29 
34 
35 #include "CLHEP/Random/RandomEngine.h"
36 
37 // foward declarations
38 namespace edm {
39  class Event;
40 }
41 
42 namespace CLHEP {
43  class HepRandomEngine;
44 }
45 
46 namespace gen {
47 
49  public:
51  virtual ~BaseHadronizer() noexcept(false) {}
52 
53  // GenRunInfo and GenEvent passing
55  std::unique_ptr<HepMC::GenEvent> getGenEvent() { return std::move(genEvent_); }
56  std::unique_ptr<HepMC3::GenEvent> getGenEvent3() { return std::move(genEvent3_); }
57  std::unique_ptr<GenEventInfoProduct> getGenEventInfo() { return std::move(genEventInfo_); }
58  std::unique_ptr<GenEventInfoProduct3> getGenEventInfo3() { return std::move(genEventInfo3_); }
59  virtual std::unique_ptr<GenLumiInfoHeader> getGenLumiInfoHeader() const;
60  std::unique_ptr<lhef::LHEEvent> getLHEEvent() { return std::move(lheEvent_); }
61 
62  void resetEvent(std::unique_ptr<HepMC::GenEvent> event) { genEvent_ = std::move(event); }
63  void resetEvent3(std::unique_ptr<HepMC3::GenEvent> event3) { genEvent3_ = std::move(event3); }
64  void resetEventInfo(std::unique_ptr<GenEventInfoProduct> eventInfo) { genEventInfo_ = std::move(eventInfo); }
65  void resetEventInfo3(std::unique_ptr<GenEventInfoProduct3> eventInfo) { genEventInfo3_ = std::move(eventInfo); }
66 
67  // LHERunInfo and LHEEvent passing
68  const std::shared_ptr<lhef::LHERunInfo>& getLHERunInfo() const { return lheRunInfo_; }
69 
70  void setLHERunInfo(std::unique_ptr<lhef::LHERunInfo> runInfo) { lheRunInfo_ = std::move(runInfo); }
71  void setLHEEvent(std::unique_ptr<lhef::LHEEvent> event) { lheEvent_ = std::move(event); }
72 
73  // interface for accessing the EDM information from the hadronizer
75  edm::Event& getEDMEvent() const { return *edmEvent_; }
76  virtual bool select(HepMC::GenEvent*) const { return true; }
77 
78  void setRandomEngine(CLHEP::HepRandomEngine* v) { doSetRandomEngine(v); }
79 
80  std::vector<std::string> const& sharedResources() const { return doSharedResources(); }
81 
82  int randomIndex() const { return randomIndex_; }
85 
86  void randomizeIndex(edm::LuminosityBlock const& lumi, CLHEP::HepRandomEngine* rengine);
87  void generateLHE(edm::LuminosityBlock const& lumi, CLHEP::HepRandomEngine* rengine, unsigned int ncpu);
88  void cleanLHE();
89  unsigned int getVHepMC() { return ivhepmc; }
90 
91  protected:
92  unsigned int ivhepmc = 2;
94  std::unique_ptr<HepMC::GenEvent>& event() { return genEvent_; }
95  std::unique_ptr<GenEventInfoProduct>& eventInfo() { return genEventInfo_; }
96  //HepMC3:
97  std::unique_ptr<HepMC3::GenEvent>& event3() { return genEvent3_; }
98  std::unique_ptr<GenEventInfoProduct3>& eventInfo3() { return genEventInfo3_; }
99 
100  lhef::LHEEvent* lheEvent() { return lheEvent_.get(); }
104 
105  private:
106  virtual void doSetRandomEngine(CLHEP::HepRandomEngine* v) {}
107 
108  virtual std::vector<std::string> const& doSharedResources() const { return theSharedResources; }
109 
111  std::unique_ptr<HepMC::GenEvent> genEvent_;
112  std::unique_ptr<HepMC3::GenEvent> genEvent3_;
113  std::unique_ptr<GenEventInfoProduct> genEventInfo_;
114  std::unique_ptr<GenEventInfoProduct3> genEventInfo3_;
115 
116  std::shared_ptr<lhef::LHERunInfo> lheRunInfo_;
117  std::unique_ptr<lhef::LHEEvent> lheEvent_;
118 
120 
121  static const std::vector<std::string> theSharedResources;
122 
123  std::vector<double> randomInitWeights_;
124  std::vector<std::string> randomInitConfigDescriptions_;
125  std::vector<std::string> gridpackPaths_;
126  };
127 
128 } // namespace gen
129 
130 #endif // gen_BaseHadronizer_h
unsigned int getVHepMC()
GenRunInfoProduct genRunInfo_
const std::shared_ptr< lhef::LHERunInfo > & getLHERunInfo() const
std::vector< double > randomInitWeights_
void setEDMEvent(edm::Event &event)
void generateLHE(edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine, unsigned int ncpu)
const std::string & randomInitConfigDescription() const
void setLHERunInfo(std::unique_ptr< lhef::LHERunInfo > runInfo)
virtual std::unique_ptr< GenLumiInfoHeader > getGenLumiInfoHeader() const
BaseHadronizer(edm::ParameterSet const &ps)
const std::string & gridpackPath() const
edm::Event * edmEvent_
GenRunInfoProduct & getGenRunInfo()
std::unique_ptr< lhef::LHEEvent > getLHEEvent()
double v[5][pyjets_maxn]
std::unique_ptr< HepMC::GenEvent > getGenEvent()
std::unique_ptr< GenEventInfoProduct > getGenEventInfo()
void randomizeIndex(edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)
std::unique_ptr< lhef::LHEEvent > lheEvent_
GenRunInfoProduct & runInfo()
int randomIndex() const
std::unique_ptr< GenEventInfoProduct > genEventInfo_
edm::Event & getEDMEvent() const
lhef::LHEEvent * lheEvent()
virtual std::vector< std::string > const & doSharedResources() const
std::vector< std::string > const & sharedResources() const
void resetEvent3(std::unique_ptr< HepMC3::GenEvent > event3)
unsigned int ivhepmc
std::unique_ptr< HepMC3::GenEvent > getGenEvent3()
void setRandomEngine(CLHEP::HepRandomEngine *v)
std::shared_ptr< lhef::LHERunInfo > lheRunInfo_
void resetEvent(std::unique_ptr< HepMC::GenEvent > event)
void setLHEEvent(std::unique_ptr< lhef::LHEEvent > event)
std::vector< std::string > gridpackPaths_
std::unique_ptr< GenEventInfoProduct3 > & eventInfo3()
void resetEventInfo(std::unique_ptr< GenEventInfoProduct > eventInfo)
std::unique_ptr< HepMC::GenEvent > & event()
std::unique_ptr< HepMC::GenEvent > genEvent_
std::vector< std::string > randomInitConfigDescriptions_
lhef::LHERunInfo * lheRunInfo()
std::unique_ptr< GenEventInfoProduct3 > getGenEventInfo3()
std::unique_ptr< HepMC3::GenEvent > & event3()
std::unique_ptr< GenEventInfoProduct > & eventInfo()
std::unique_ptr< HepMC3::GenEvent > genEvent3_
virtual void doSetRandomEngine(CLHEP::HepRandomEngine *v)
virtual ~BaseHadronizer() noexcept(false)
HLT enums.
void resetEventInfo3(std::unique_ptr< GenEventInfoProduct3 > eventInfo)
virtual bool select(HepMC::GenEvent *) const
static const std::vector< std::string > theSharedResources
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< GenEventInfoProduct3 > genEventInfo3_
Definition: event.py:1