Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:42

0001 #ifndef SimDataFormats_GeneratorProducts_LHEEventProduct_h
0002 #define SimDataFormats_GeneratorProducts_LHEEventProduct_h
0003 
0004 #include <memory>
0005 #include <vector>
0006 #include <string>
0007 
0008 #include "SimDataFormats/GeneratorProducts/interface/LesHouches.h"
0009 #include "SimDataFormats/GeneratorProducts/interface/PdfInfo.h"
0010 #include "SimDataFormats/GeneratorProducts/interface/WeightsInfo.h"
0011 
0012 class LHEEventProduct {
0013 public:
0014   typedef gen::PdfInfo PDF;
0015   typedef gen::WeightsInfo WGT;
0016 
0017   typedef std::vector<std::string>::const_iterator comments_const_iterator;
0018   typedef std::vector<std::string>::size_type size_type;
0019 
0020   LHEEventProduct() {}
0021   LHEEventProduct(const lhef::HEPEUP &hepeup) : hepeup_(hepeup), originalXWGTUP_(0) {}
0022   LHEEventProduct(const lhef::HEPEUP &hepeup, const double originalXWGTUP)
0023       : hepeup_(hepeup), originalXWGTUP_(originalXWGTUP) {}
0024   LHEEventProduct(LHEEventProduct &&other) = default;
0025 
0026   LHEEventProduct &operator=(LHEEventProduct &&other) = default;
0027 
0028   ~LHEEventProduct() = default;
0029 
0030   void setPDF(const PDF &pdf) { pdf_ = std::make_unique<PDF>(pdf); }
0031   void addWeight(const WGT &wgt) { weights_.push_back(wgt); }
0032   void addComment(const std::string &line) { comments_.push_back(line); }
0033 
0034   double originalXWGTUP() const { return originalXWGTUP_; }
0035   const std::vector<WGT> &weights() const { return weights_; }
0036 
0037   const std::vector<float> &scales() const { return scales_; }
0038   void setScales(const std::vector<float> &scales) { scales_ = scales; }
0039 
0040   int npLO() const { return npLO_; }
0041   int npNLO() const { return npNLO_; }
0042   int evtnum() const { return evtnum_; }
0043 
0044   void setNpLO(int n) { npLO_ = n; }
0045   void setNpNLO(int n) { npNLO_ = n; }
0046   void setEvtNum(int n) { evtnum_ = n; }
0047 
0048   const lhef::HEPEUP &hepeup() const { return hepeup_; }
0049   const PDF *pdf() const { return pdf_.get(); }
0050 
0051   size_type comments_size() const { return comments_.size(); }
0052   comments_const_iterator comments_begin() const { return comments_.begin(); }
0053   comments_const_iterator comments_end() const { return comments_.end(); }
0054 
0055   const char *getComment(unsigned i) const {
0056     if (comments_.empty() || i >= comments_.size())
0057       return "";
0058     else
0059       return (const char *)comments_[i].c_str();
0060   }
0061 
0062   class const_iterator {
0063   public:
0064     typedef std::forward_iterator_tag iterator_category;
0065     typedef std::string value_type;
0066     typedef std::ptrdiff_t difference_type;
0067     typedef std::string *pointer;
0068     typedef std::string &reference;
0069 
0070     const_iterator() : line(npos) {}
0071     ~const_iterator() {}
0072 
0073     inline bool operator==(const const_iterator &other) const { return line == other.line; }
0074     inline bool operator!=(const const_iterator &other) const { return !operator==(other); }
0075 
0076     inline const_iterator &operator++() {
0077       next();
0078       return *this;
0079     }
0080     inline const_iterator operator++(int dummy) {
0081       const_iterator orig = *this;
0082       next();
0083       return orig;
0084     }
0085 
0086     const std::string &operator*() const { return tmp; }
0087     const std::string *operator->() const { return &tmp; }
0088 
0089   private:
0090     friend class LHEEventProduct;
0091 
0092     void next();
0093 
0094     const LHEEventProduct *event;
0095     unsigned int line;
0096     std::string tmp;
0097 
0098     static const unsigned int npos = 99999;
0099   };
0100 
0101   const_iterator begin() const;
0102   inline const_iterator end() const { return const_iterator(); }
0103 
0104 private:
0105   lhef::HEPEUP hepeup_;
0106   std::vector<std::string> comments_;
0107   std::unique_ptr<PDF> pdf_;
0108   std::vector<WGT> weights_;
0109   double originalXWGTUP_;
0110   std::vector<float> scales_;  //scale value used to exclude EWK-produced partons from matching
0111   int npLO_;                   //number of partons for LO process (used to steer matching/merging)
0112   int npNLO_;                  //number of partons for NLO process (used to steer matching/merging)
0113   int evtnum_;  //The number of the event (needed to ensure the correct LHE events are saved for MG +Herwig)
0114 };
0115 
0116 #endif  // GeneratorEvent_LHEInterface_LHEEventProduct_h