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 
20 
24 
27 
32 
33 #include "CLHEP/Random/RandomEngine.h"
34 
35 
36 // foward declarations
37 namespace edm {
38  class Event;
39 }
40 
41 namespace CLHEP {
42  class HepRandomEngine;
43 }
44 
45 namespace gen {
46 
48  public:
49  BaseHadronizer( edm::ParameterSet const& ps );
51 
52  // GenRunInfo and GenEvent passing
53  GenRunInfoProduct &getGenRunInfo() { return genRunInfo_; }
54  std::unique_ptr<HepMC::GenEvent> getGenEvent() { return std::move(genEvent_); }
55  std::unique_ptr<GenEventInfoProduct> getGenEventInfo() { return std::move(genEventInfo_); }
56  virtual std::unique_ptr<GenLumiInfoHeader> getGenLumiInfoHeader() const;
57  std::unique_ptr<lhef::LHEEvent> getLHEEvent() { return std::move(lheEvent_);}
58 
59  void resetEvent(std::unique_ptr<HepMC::GenEvent> event) { genEvent_ = std::move(event); }
60  void resetEventInfo(std::unique_ptr<GenEventInfoProduct> eventInfo) { genEventInfo_ = std::move(eventInfo); }
61 
62  // LHERunInfo and LHEEvent passing
63  const std::shared_ptr<lhef::LHERunInfo> &getLHERunInfo() const { return lheRunInfo_; }
64 
65  void setLHERunInfo(std::unique_ptr<lhef::LHERunInfo> runInfo) { lheRunInfo_ = std::move(runInfo); }
66  void setLHEEvent(std::unique_ptr<lhef::LHEEvent> event) { lheEvent_ = std::move(event); }
67 
68  // interface for accessing the EDM information from the hadronizer
69  void setEDMEvent(edm::Event &event) { edmEvent_ = &event; }
70  edm::Event &getEDMEvent() const { return *edmEvent_; }
71  virtual bool select(HepMC::GenEvent*) const { return true;}
72 
73  void setRandomEngine(CLHEP::HepRandomEngine* v) { doSetRandomEngine(v); }
74 
75  std::vector<std::string> const& sharedResources() const { return doSharedResources(); }
76 
77  int randomIndex() const { return randomIndex_; }
78  const std::string &randomInitConfigDescription() const { return randomInitConfigDescriptions_[randomIndex_]; }
79  const std::string &gridpackPath() const { return gridpackPaths_[std::max(randomIndex_,0)]; }
80 
81  void randomizeIndex(edm::LuminosityBlock const& lumi, CLHEP::HepRandomEngine* rengine);
82  void generateLHE(edm::LuminosityBlock const& lumi, CLHEP::HepRandomEngine* rengine, unsigned int ncpu);
83  void cleanLHE();
84 
85  protected:
86  GenRunInfoProduct& runInfo() { return genRunInfo_; }
87  std::unique_ptr<HepMC::GenEvent>& event() { return genEvent_; }
88  std::unique_ptr<GenEventInfoProduct>& eventInfo() { return genEventInfo_; }
89 
90  lhef::LHEEvent* lheEvent() { return lheEvent_.get(); }
91  lhef::LHERunInfo *lheRunInfo() { return lheRunInfo_.get(); }
94 
95  private:
96 
97  virtual void doSetRandomEngine(CLHEP::HepRandomEngine* v) { }
98 
99  virtual std::vector<std::string> const& doSharedResources() const { return theSharedResources; }
100 
102  std::unique_ptr<HepMC::GenEvent> genEvent_;
103  std::unique_ptr<GenEventInfoProduct> genEventInfo_;
104 
105  std::shared_ptr<lhef::LHERunInfo> lheRunInfo_;
106  std::unique_ptr<lhef::LHEEvent> lheEvent_;
107 
109 
110  static const std::vector<std::string> theSharedResources;
111 
112  std::vector<double> randomInitWeights_;
113  std::vector<std::string> randomInitConfigDescriptions_;
114  std::vector<std::string> gridpackPaths_;
115 
116  };
117 
118 } // namespace gen
119 
120 #endif // gen_BaseHadronizer_h
virtual bool select(HepMC::GenEvent *) const
GenRunInfoProduct genRunInfo_
std::vector< double > randomInitWeights_
void setEDMEvent(edm::Event &event)
void setLHERunInfo(std::unique_ptr< lhef::LHERunInfo > runInfo)
edm::Event * edmEvent_
GenRunInfoProduct & getGenRunInfo()
std::unique_ptr< lhef::LHEEvent > getLHEEvent()
std::string lheFile_
const std::shared_ptr< lhef::LHERunInfo > & getLHERunInfo() const
virtual ~BaseHadronizer()(false)
std::unique_ptr< HepMC::GenEvent > getGenEvent()
std::unique_ptr< GenEventInfoProduct > getGenEventInfo()
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)
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)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::unique_ptr< HepMC::GenEvent > & event()
std::unique_ptr< HepMC::GenEvent > genEvent_
std::vector< std::string > randomInitConfigDescriptions_
lhef::LHERunInfo * lheRunInfo()
#define noexcept
virtual std::vector< std::string > const & doSharedResources() const
std::unique_ptr< GenEventInfoProduct > & eventInfo()
virtual void doSetRandomEngine(CLHEP::HepRandomEngine *v)
int randomIndex() const
HLT enums.
const std::string & gridpackPath() const
eventInfo
add run, event number and lumi section
static const std::vector< std::string > theSharedResources
def move(src, dest)
Definition: eostools.py:511
edm::Event & getEDMEvent() const
Definition: event.py:1