CMS 3D CMS Logo

LHEEvent.h
Go to the documentation of this file.
1 #ifndef GeneratorInterface_LHEInterface_LHEEvent_h
2 #define GeneratorInterface_LHEInterface_LHEEvent_h
3 
4 #include <iostream>
5 #include <utility>
6 #include <memory>
7 #include <vector>
8 #include <string>
9 
10 #include "HepMC/GenEvent.h"
11 #include "HepMC/GenVertex.h"
12 #include "HepMC/PdfInfo.h"
13 
15 
18 
20 
21 namespace lhef {
22 
23 class LHEEvent {
24  public:
25  LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo,
26  std::istream &in);
27  LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo,
28  const HEPEUP &hepeup);
29  LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo,
30  const HEPEUP &hepeup,
32  const std::vector<std::string> &comments);
33  LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo,
34  const LHEEventProduct &product);
35  ~LHEEvent();
36 
39 
40  const std::shared_ptr<LHERunInfo> &getRunInfo() const { return runInfo; }
41  const HEPEUP *getHEPEUP() const { return &hepeup; }
42  const HEPRUP *getHEPRUP() const { return runInfo->getHEPRUP(); }
43  const PDF *getPDF() const { return pdf.get(); }
44  const std::vector<std::string> &getComments() const { return comments; }
45  const int getReadAttempts() { return readAttemptCounter; }
46 
47  void addWeight(const WGT& wgt) { weights_.push_back(wgt); }
48  void setPDF(std::unique_ptr<PDF> pdf) { this->pdf = std::move(pdf); }
49 
50  double originalXWGTUP() const { return originalXWGTUP_; }
51  const std::vector<WGT>& weights() const { return weights_; }
52 
53  const std::vector<float> &scales() const { return scales_; }
54  void setScales(const std::vector<float> &scales) { scales_ = scales; }
55 
56  int npLO() const { return npLO_; }
57  int npNLO() const { return npNLO_; }
58 
59  void setNpLO(int n) { npLO_ = n; }
60  void setNpNLO(int n) { npNLO_ = n; }
61 
62  void addComment(const std::string &line) { comments.push_back(line); }
63 
64  static void removeParticle(lhef::HEPEUP &hepeup, int index);
65  void removeResonances(const std::vector<int> &ids);
66 
68  double weight = 1.0, double matchWeight = 1.0);
69 
70  void attempted() { readAttemptCounter++; return; }
71 
72  void fillPdfInfo(HepMC::PdfInfo *info) const;
73  void fillEventInfo(HepMC::GenEvent *hepmc) const;
74 
75  std::unique_ptr<HepMC::GenEvent> asHepMCEvent() const;
76 
77  static const HepMC::GenVertex *findSignalVertex(
78  const HepMC::GenEvent *event, bool status3 = true);
79 
80  static void fixHepMCEventTimeOrdering(HepMC::GenEvent *event);
81 
82  private:
83  static bool checkHepMCTree(const HepMC::GenEvent *event);
84  HepMC::GenParticle *makeHepMCParticle(unsigned int i) const;
85 
86  const std::shared_ptr<LHERunInfo> runInfo;
87 
89  std::unique_ptr<PDF> pdf;
90  std::vector<WGT> weights_;
91  std::vector<std::string> comments;
92  bool counted;
95  std::vector<float> scales_; //scale value used to exclude EWK-produced partons from matching
96  int npLO_; //number of partons for LO process (used to steer matching/merging)
97  int npNLO_; //number of partons for NLO process (used to steer matching/merging)
98 };
99 
100 } // namespace lhef
101 
102 #endif // GeneratorEvent_LHEInterface_LHEEvent_h
const PDF * getPDF() const
Definition: LHEEvent.h:43
HEPEUP hepeup
Definition: LHEEvent.h:88
static const TGPicture * info(bool iBackgroundIsBlack)
LHEEvent(const std::shared_ptr< LHERunInfo > &runInfo, std::istream &in)
Definition: LHEEvent.cc:36
int npLO() const
Definition: LHEEvent.h:56
void addWeight(const WGT &wgt)
Definition: LHEEvent.h:47
LHEEventProduct::WGT WGT
Definition: LHEEvent.h:38
std::vector< std::string > comments
Definition: LHEEvent.h:91
const HEPRUP * getHEPRUP() const
Definition: LHEEvent.h:42
void fillEventInfo(HepMC::GenEvent *hepmc) const
Definition: LHEEvent.cc:242
const std::shared_ptr< LHERunInfo > runInfo
Definition: LHEEvent.h:86
static void fixHepMCEventTimeOrdering(HepMC::GenEvent *event)
Definition: LHEEvent.cc:506
void removeResonances(const std::vector< int > &ids)
Definition: LHEEvent.cc:189
Definition: weight.py:1
void count(LHERunInfo::CountMode count, double weight=1.0, double matchWeight=1.0)
Definition: LHEEvent.cc:200
const int getReadAttempts()
Definition: LHEEvent.h:45
const HEPEUP * getHEPEUP() const
Definition: LHEEvent.h:41
int npNLO() const
Definition: LHEEvent.h:57
void attempted()
Definition: LHEEvent.h:70
int readAttemptCounter
Definition: LHEEvent.h:93
void addComment(const std::string &line)
Definition: LHEEvent.h:62
const std::vector< std::string > & getComments() const
Definition: LHEEvent.h:44
void setScales(const std::vector< float > &scales)
Definition: LHEEvent.h:54
HepMC::GenParticle * makeHepMCParticle(unsigned int i) const
Definition: LHEEvent.cc:380
static void removeParticle(lhef::HEPEUP &hepeup, int index)
Definition: LHEEvent.cc:149
void fillPdfInfo(HepMC::PdfInfo *info) const
Definition: LHEEvent.cc:214
std::unique_ptr< HepMC::GenEvent > asHepMCEvent() const
Definition: LHEEvent.cc:250
void setNpNLO(int n)
Definition: LHEEvent.h:60
LHEEventProduct::PDF PDF
Definition: LHEEvent.h:37
const std::vector< float > & scales() const
Definition: LHEEvent.h:53
static const HepMC::GenVertex * findSignalVertex(const HepMC::GenEvent *event, bool status3=true)
Definition: LHEEvent.cc:441
double originalXWGTUP() const
Definition: LHEEvent.h:50
std::vector< float > scales_
Definition: LHEEvent.h:95
std::unique_ptr< PDF > pdf
Definition: LHEEvent.h:89
void setPDF(std::unique_ptr< PDF > pdf)
Definition: LHEEvent.h:48
bool counted
Definition: LHEEvent.h:92
void setNpLO(int n)
Definition: LHEEvent.h:59
static bool checkHepMCTree(const HepMC::GenEvent *event)
Definition: LHEEvent.cc:397
const std::shared_ptr< LHERunInfo > & getRunInfo() const
Definition: LHEEvent.h:40
def move(src, dest)
Definition: eostools.py:511
const std::vector< WGT > & weights() const
Definition: LHEEvent.h:51
std::vector< WGT > weights_
Definition: LHEEvent.h:90
Definition: event.py:1
double originalXWGTUP_
Definition: LHEEvent.h:94