Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:14

0001 #ifndef GeneratorInterface_LHEInterface_LHEEvent_h
0002 #define GeneratorInterface_LHEInterface_LHEEvent_h
0003 
0004 #include <iostream>
0005 #include <utility>
0006 #include <memory>
0007 #include <vector>
0008 #include <string>
0009 
0010 #include "HepMC/GenEvent.h"
0011 #include "HepMC/GenVertex.h"
0012 #include "HepMC/PdfInfo.h"
0013 
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 
0016 #include "SimDataFormats/GeneratorProducts/interface/LesHouches.h"
0017 #include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h"
0018 
0019 #include "GeneratorInterface/LHEInterface/interface/LHERunInfo.h"
0020 
0021 namespace lhef {
0022 
0023   class LHEEvent {
0024   public:
0025     LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo, std::istream &in);
0026     LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo, const HEPEUP &hepeup);
0027     LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo,
0028              const HEPEUP &hepeup,
0029              const LHEEventProduct::PDF *pdf,
0030              const std::vector<std::string> &comments);
0031     LHEEvent(const std::shared_ptr<LHERunInfo> &runInfo, const LHEEventProduct &product);
0032     ~LHEEvent();
0033 
0034     typedef LHEEventProduct::PDF PDF;
0035     typedef LHEEventProduct::WGT WGT;
0036 
0037     const std::shared_ptr<LHERunInfo> &getRunInfo() const { return runInfo; }
0038     const HEPEUP *getHEPEUP() const { return &hepeup; }
0039     const HEPRUP *getHEPRUP() const { return runInfo->getHEPRUP(); }
0040     const PDF *getPDF() const { return pdf.get(); }
0041     const std::vector<std::string> &getComments() const { return comments; }
0042     const int getReadAttempts() { return readAttemptCounter; }
0043 
0044     void addWeight(const WGT &wgt) { weights_.push_back(wgt); }
0045     void setPDF(std::unique_ptr<PDF> pdf) { this->pdf = std::move(pdf); }
0046 
0047     double originalXWGTUP() const { return originalXWGTUP_; }
0048     const std::vector<WGT> &weights() const { return weights_; }
0049 
0050     const std::vector<float> &scales() const { return scales_; }
0051     void setScales(const std::vector<float> &scales) { scales_ = scales; }
0052 
0053     int npLO() const { return npLO_; }
0054     int npNLO() const { return npNLO_; }
0055 
0056     void setNpLO(int n) { npLO_ = n; }
0057     void setNpNLO(int n) { npNLO_ = n; }
0058 
0059     void addComment(const std::string &line) { comments.push_back(line); }
0060 
0061     static void removeParticle(lhef::HEPEUP &hepeup, int index);
0062     void removeResonances(const std::vector<int> &ids);
0063 
0064     void count(LHERunInfo::CountMode count, double weight = 1.0, double matchWeight = 1.0);
0065 
0066     void attempted() {
0067       readAttemptCounter++;
0068       return;
0069     }
0070 
0071     void fillPdfInfo(HepMC::PdfInfo *info) const;
0072     void fillEventInfo(HepMC::GenEvent *hepmc) const;
0073 
0074     std::unique_ptr<HepMC::GenEvent> asHepMCEvent() const;
0075 
0076     static const HepMC::GenVertex *findSignalVertex(const HepMC::GenEvent *event, bool status3 = true);
0077 
0078     static void fixHepMCEventTimeOrdering(HepMC::GenEvent *event);
0079 
0080   private:
0081     static bool checkHepMCTree(const HepMC::GenEvent *event);
0082     HepMC::GenParticle *makeHepMCParticle(unsigned int i) const;
0083 
0084     const std::shared_ptr<LHERunInfo> runInfo;
0085 
0086     HEPEUP hepeup;
0087     std::unique_ptr<PDF> pdf;
0088     std::vector<WGT> weights_;
0089     std::vector<std::string> comments;
0090     bool counted;
0091     int readAttemptCounter;
0092     double originalXWGTUP_;
0093     std::vector<float> scales_;  //scale value used to exclude EWK-produced partons from matching
0094     int npLO_;                   //number of partons for LO process (used to steer matching/merging)
0095     int npNLO_;                  //number of partons for NLO process (used to steer matching/merging)
0096   };
0097 
0098 }  // namespace lhef
0099 
0100 #endif  // GeneratorEvent_LHEInterface_LHEEvent_h