CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/GeneratorInterface/LHEInterface/interface/LHERunInfo.h

Go to the documentation of this file.
00001 #ifndef GeneratorInterface_LHEInterface_LHERunInfo_h
00002 #define GeneratorInterface_LHEInterface_LHERunInfo_h
00003 
00004 #include <iostream>
00005 #include <memory>
00006 #include <vector>
00007 #include <string>
00008 
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 
00011 #include "SimDataFormats/GeneratorProducts/interface/LesHouches.h"
00012 #include "SimDataFormats/GeneratorProducts/interface/LHERunInfoProduct.h"
00013 
00014 #ifndef XERCES_CPP_NAMESPACE_QUALIFIER
00015 #       define UNDEF_XERCES_CPP_NAMESPACE_QUALIFIER
00016 #       define XERCES_CPP_NAMESPACE_QUALIFIER dummy::
00017 namespace dummy {
00018         class DOMNode;
00019         class DOMDocument;
00020 }
00021 #endif
00022 
00023 namespace lhef {
00024 
00025 class LHERunInfo {
00026     public:
00027         LHERunInfo(std::istream &in);
00028         LHERunInfo(const HEPRUP &heprup);
00029         LHERunInfo(const HEPRUP &heprup,
00030                    const std::vector<LHERunInfoProduct::Header> &headers,
00031                    const std::vector<std::string> &comments);
00032         LHERunInfo(const LHERunInfoProduct &product);
00033         ~LHERunInfo();
00034 
00035         class Header : public LHERunInfoProduct::Header {
00036             public:
00037                 Header();
00038                 Header(const std::string &tag);
00039                 Header(const Header &orig);
00040                 Header(const LHERunInfoProduct::Header &orig);
00041                 ~Header();
00042 
00043 #ifndef UNDEF_XERCES_CPP_NAMESPACE_QUALIFIER
00044                 const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
00045                                                         *getXMLNode() const;
00046 #endif
00047 
00048             private:
00049                 mutable XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *xmlDoc;
00050         };
00051 
00052         const HEPRUP *getHEPRUP() const { return &heprup; } 
00053 
00054         bool operator == (const LHERunInfo &other) const;
00055         inline bool operator != (const LHERunInfo &other) const
00056         { return !(*this == other); }
00057 
00058         const std::vector<Header> &getHeaders() const { return headers; }
00059         const std::vector<std::string> &getComments() const { return comments; }
00060 
00061         std::vector<std::string> findHeader(const std::string &tag) const;
00062 
00063         void addHeader(const Header &header) { headers.push_back(header); }
00064         void addComment(const std::string &line) { comments.push_back(line); }
00065 
00066         enum CountMode {
00067                 kTried = 0,
00068                 kSelected,
00069                 kKilled,
00070                 kAccepted
00071         };
00072 
00073         struct XSec {
00074                 XSec() : value(0.0), error(0.0) {}
00075 
00076                 double  value;
00077                 double  error;
00078         };
00079 
00080         void count(int process, CountMode count, double eventWeight = 1.0,
00081                    double brWeight = 1.0, double matchWeight = 1.0);
00082         XSec xsec() const;
00083         void statistics() const;
00084 
00085         std::pair<int, int> pdfSetTranslation() const;
00086 
00087     private:
00088         struct Counter {
00089                 Counter() : n(0), sum(0.0), sum2(0.0) {}
00090 
00091                 inline void add(double weight)
00092                 {
00093                         n++;
00094                         sum += weight;
00095                         sum2 += weight * weight;
00096                 }
00097 
00098                 unsigned int    n;
00099                 double          sum;
00100                 double          sum2;
00101         };
00102 
00103         struct Process {
00104                 int             process;
00105                 unsigned int    heprupIndex;
00106                 Counter         tried;
00107                 Counter         selected;
00108                 Counter         killed;
00109                 Counter         accepted;
00110                 Counter         acceptedBr;
00111 
00112                 inline bool operator < (const Process &other) const
00113                 { return process < other.process; }
00114                 inline bool operator < (int process) const
00115                 { return this->process < process; }
00116                 inline bool operator == (int process) const
00117                 { return this->process == process; }
00118         };
00119 
00120         void init();
00121 
00122         HEPRUP                          heprup;
00123         std::vector<Process>            processes;
00124         std::vector<Header>             headers;
00125         std::vector<std::string>        comments;
00126 };
00127 
00128 } // namespace lhef
00129 
00130 #ifdef UNDEF_XERCES_CPP_NAMESPACE_QUALIFIER
00131 #       undef XERCES_CPP_NAMESPACE_QUALIFIER
00132 #endif
00133 
00134 #endif // GeneratorRunInfo_LHEInterface_LHERunInfo_h