CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
20 
24 
27 
32 
33 #include "CLHEP/Random/RandomEngine.h"
34 
35 // foward declarations
36 namespace edm {
37  class Event;
38 }
39 
40 namespace CLHEP {
41  class HepRandomEngine;
42 }
43 
44 namespace gen {
45 
47  public:
49  virtual ~BaseHadronizer() noexcept(false) {}
50 
51  // GenRunInfo and GenEvent passing
53  std::unique_ptr<HepMC::GenEvent> getGenEvent() { return std::move(genEvent_); }
54  std::unique_ptr<GenEventInfoProduct> getGenEventInfo() { return std::move(genEventInfo_); }
55  virtual std::unique_ptr<GenLumiInfoHeader> getGenLumiInfoHeader() const;
56  std::unique_ptr<lhef::LHEEvent> getLHEEvent() { return std::move(lheEvent_); }
57 
58  void resetEvent(std::unique_ptr<HepMC::GenEvent> event) { genEvent_ = std::move(event); }
59  void resetEventInfo(std::unique_ptr<GenEventInfoProduct> eventInfo) { genEventInfo_ = std::move(eventInfo); }
60 
61  // LHERunInfo and LHEEvent passing
62  const std::shared_ptr<lhef::LHERunInfo>& getLHERunInfo() const { return lheRunInfo_; }
63 
64  void setLHERunInfo(std::unique_ptr<lhef::LHERunInfo> runInfo) { lheRunInfo_ = std::move(runInfo); }
65  void setLHEEvent(std::unique_ptr<lhef::LHEEvent> event) { lheEvent_ = std::move(event); }
66 
67  // interface for accessing the EDM information from the hadronizer
69  edm::Event& getEDMEvent() const { return *edmEvent_; }
70  virtual bool select(HepMC::GenEvent*) const { return true; }
71 
72  void setRandomEngine(CLHEP::HepRandomEngine* v) { doSetRandomEngine(v); }
73 
74  std::vector<std::string> const& sharedResources() const { return doSharedResources(); }
75 
76  int randomIndex() const { return randomIndex_; }
79 
80  void randomizeIndex(edm::LuminosityBlock const& lumi, CLHEP::HepRandomEngine* rengine);
81  void generateLHE(edm::LuminosityBlock const& lumi, CLHEP::HepRandomEngine* rengine, unsigned int ncpu);
82  void cleanLHE();
83 
84  protected:
86  std::unique_ptr<HepMC::GenEvent>& event() { return genEvent_; }
87  std::unique_ptr<GenEventInfoProduct>& eventInfo() { return genEventInfo_; }
88 
89  lhef::LHEEvent* lheEvent() { return lheEvent_.get(); }
93 
94  private:
95  virtual void doSetRandomEngine(CLHEP::HepRandomEngine* v) {}
96 
97  virtual std::vector<std::string> const& doSharedResources() const { return theSharedResources; }
98 
100  std::unique_ptr<HepMC::GenEvent> genEvent_;
101  std::unique_ptr<GenEventInfoProduct> genEventInfo_;
102 
103  std::shared_ptr<lhef::LHERunInfo> lheRunInfo_;
104  std::unique_ptr<lhef::LHEEvent> lheEvent_;
105 
107 
108  static const std::vector<std::string> theSharedResources;
109 
110  std::vector<double> randomInitWeights_;
111  std::vector<std::string> randomInitConfigDescriptions_;
112  std::vector<std::string> gridpackPaths_;
113  };
114 
115 } // namespace gen
116 
117 #endif // gen_BaseHadronizer_h
virtual bool select(HepMC::GenEvent *) const
GenRunInfoProduct genRunInfo_
std::vector< double > randomInitWeights_
void setEDMEvent(edm::Event &event)
void generateLHE(edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine, unsigned int ncpu)
void setLHERunInfo(std::unique_ptr< lhef::LHERunInfo > runInfo)
BaseHadronizer(edm::ParameterSet const &ps)
edm::Event * edmEvent_
GenRunInfoProduct & getGenRunInfo()
std::unique_ptr< lhef::LHEEvent > getLHEEvent()
std::string lheFile_
const std::shared_ptr< lhef::LHERunInfo > & getLHERunInfo() const
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()
std::unique_ptr< GenEventInfoProduct > genEventInfo_
lhef::LHEEvent * lheEvent()
void setRandomEngine(CLHEP::HepRandomEngine *v)
const std::string & randomInitConfigDescription() const
std::shared_ptr< lhef::LHERunInfo > lheRunInfo_
void resetEvent(std::unique_ptr< HepMC::GenEvent > event)
def move
Definition: eostools.py:511
void setLHEEvent(std::unique_ptr< lhef::LHEEvent > event)
std::vector< std::string > const & sharedResources() const
std::vector< std::string > gridpackPaths_
void resetEventInfo(std::unique_ptr< GenEventInfoProduct > eventInfo)
list lumi
Definition: dqmdumpme.py:53
std::unique_ptr< HepMC::GenEvent > & event()
std::unique_ptr< HepMC::GenEvent > genEvent_
std::vector< std::string > randomInitConfigDescriptions_
lhef::LHERunInfo * lheRunInfo()
virtual std::unique_ptr< GenLumiInfoHeader > getGenLumiInfoHeader() const
virtual std::vector< std::string > const & doSharedResources() const
std::unique_ptr< GenEventInfoProduct > & eventInfo()
virtual void doSetRandomEngine(CLHEP::HepRandomEngine *v)
virtual ~BaseHadronizer() noexcept(false)
int randomIndex() const
const std::string & gridpackPath() const
static const std::vector< std::string > theSharedResources
edm::Event & getEDMEvent() const