10 #include "Rivet/Run.hh" 11 #include "Rivet/AnalysisHandler.hh" 12 #include "Rivet/Analysis.hh" 16 using namespace Rivet;
20 : _isFirstEvent(
true),
25 _doFinalize(
pset.getParameter<
bool>(
"DoFinalize")),
26 _produceDQM(
pset.getParameter<
bool>(
"ProduceDQMOutput")),
29 usesResource(
"Rivet");
61 char*
cmsswbase = std::getenv(
"CMSSW_BASE");
62 char* cmsswrelease = std::getenv(
"CMSSW_RELEASE_BASE");
63 if (!std::getenv(
"RIVET_REF_PATH")) {
65 "/src/GeneratorInterface/RivetInterface/data:" +
string(cmsswrelease) +
66 "/src/GeneratorInterface/RivetInterface/data:.";
67 char* rivetrefCstr = strdup(rivetref.c_str());
68 setenv(
"RIVET_REF_PATH", rivetrefCstr, 1);
71 if (!std::getenv(
"RIVET_INFO_PATH")) {
73 "/src/GeneratorInterface/RivetInterface/data:" +
string(cmsswrelease) +
74 "/src/GeneratorInterface/RivetInterface/data:.";
75 char* rivetinfoCstr = strdup(rivetinfo.c_str());
76 setenv(
"RIVET_INFO_PATH", rivetinfoCstr, 1);
85 typedef std::vector<LHERunInfoProduct::Header>::const_iterator headers_const_iterator;
87 std::regex reg(
"<weight.*> ?(.*?) ?<\\/weight>");
90 std::vector<std::string>
lines = iter->lines();
91 for (
unsigned int iLine = 0; iLine <
lines.size(); iLine++) {
93 std::regex_search(
lines.at(iLine),
match, reg);
126 _cleanedWeightNames.push_back(std::regex_replace(wn, std::regex(
"[^A-Za-z\\d\\._=]"),
"_"));
136 std::unique_ptr<HepMC::GenEvent> tmpGenEvtPtr;
138 tmpGenEvtPtr = std::make_unique<HepMC::GenEvent>(*(evt->
GetEvent()));
141 HepMC::GenCrossSection xsec;
143 tmpGenEvtPtr->set_cross_section(xsec);
146 std::vector<double> mergedWeights;
147 for (
unsigned int i = 0;
i < tmpGenEvtPtr->weights().size();
i++) {
148 mergedWeights.push_back(tmpGenEvtPtr->weights()[
i]);
155 mergedWeights.push_back(tmpGenEvtPtr->weights()[0] * lheEventHandle->
weights().at(
i).wgt /
160 tmpGenEvtPtr->weights().clear();
164 myGenEvent = tmpGenEvtPtr.get();
210 using namespace YODA;
214 const string tmpdir =
"/RivetNormalizeTmp";
216 for (
const string& analysis :
analyses) {
221 TH1F
nevent(
"nEvt",
"n analyzed Events", 1, 0., 1.);
void analyze(const edm::Event &, const edm::EventSetup &) override
void endRun(const edm::Run &, const edm::EventSetup &) override
std::string _deselectMultiWeights
std::unique_ptr< Rivet::AnalysisHandler > _analysisHandler
double originalXWGTUP() const
headers_const_iterator headers_begin() const
void setCurrentFolder(std::string const &fullpath) override
std::vector< std::string > _cleanedWeightNames
std::string _setNominalWeightName
std::vector< std::string > _analysisNames
const edm::InputTag _lheLabel
headers_const_iterator headers_end() const
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
std::string _selectMultiWeights
bool getByLabel(std::string const &label, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
void beginRun(const edm::Run &, const edm::EventSetup &) override
RivetAnalyzer(const edm::ParameterSet &)
edm::EDGetTokenT< GenLumiInfoHeader > _genLumiInfoToken
const HepMC::GenEvent * GetEvent() const
edm::EDGetTokenT< edm::HepMCProduct > _hepmcCollection
edm::EDGetTokenT< LHERunInfoProduct > _lheRunInfoToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< std::string > _lheWeightNames
void endJob() override
List of registered analysis data objects.
edm::EDGetTokenT< LHEEventProduct > _LHECollection
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::vector< std::string > _weightNames
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
const std::vector< WGT > & weights() const
std::vector< MonitorElement * > _mes
~RivetAnalyzer() override