11 #include "Rivet/AnalysisHandler.hh"
12 #include "Rivet/Analysis.hh"
20 using namespace Rivet;
26 _outFileName(pset.getParameter<std::
string>(
"OutputFile")),
29 _doFinalize(pset.getParameter<bool>(
"DoFinalize")),
30 _produceDQM(pset.getParameter<bool>(
"ProduceDQMOutput"))
33 std::vector<std::string> analysisNames = pset.
getParameter<std::vector<std::string> >(
"AnalysisNames");
38 if (_useExternalWeight) {
39 if (!pset.
exists(
"GenEventInfoCollection")){
40 throw cms::Exception(
"RivetAnalyzer") <<
"when using an external event weight you have to specify the GenEventInfoProduct collection from which the weight has to be taken " ;
49 const std::set< AnaHandle, CmpAnaHandle > & analyses =
_analysisHandler.analyses();
51 std::set< AnaHandle, CmpAnaHandle >::const_iterator ibeg = analyses.begin();
52 std::set< AnaHandle, CmpAnaHandle >::const_iterator iend = analyses.end();
53 std::set< AnaHandle, CmpAnaHandle >::const_iterator iana;
54 double xsection = -1.;
56 for (iana = ibeg; iana != iend; ++iana){
57 if ((*iana)->needsCrossSection())
58 (*iana)->setCrossSection(xsection);
74 char * cmsswbase = getenv(
"CMSSW_BASE");
75 char * cmsswrelease = getenv(
"CMSSW_RELEASE_BASE");
77 rivetref =
"RIVET_REF_PATH=" +
string(cmsswbase) +
"/src/GeneratorInterface/RivetInterface/data:" +
string(cmsswrelease) +
"/src/GeneratorInterface/RivetInterface/data";
78 rivetinfo =
"RIVET_INFO_PATH=" +
string(cmsswbase) +
"/src/GeneratorInterface/RivetInterface/data:" +
string(cmsswrelease) +
"/src/GeneratorInterface/RivetInterface/data";
79 putenv(strdup(rivetref.c_str()));
80 putenv(strdup(rivetinfo.c_str()));
94 const HepMC::GenEvent *myGenEvent = evt->GetEvent();
97 HepMC::GenEvent * tmpGenEvtPtr =
new HepMC::GenEvent( *(evt->GetEvent()) );
98 if (tmpGenEvtPtr->weights().size() == 0) {
99 throw cms::Exception(
"RivetAnalyzer") <<
"Original weight container has 0 size ";
101 if (tmpGenEvtPtr->weights().size() > 1) {
102 edm::LogWarning(
"RivetAnalyzer") <<
"Original event weight size is " << tmpGenEvtPtr->weights().size() <<
". Will change only the first one ";
106 tmpGenEvtPtr->weights()[0] = genEventInfoProduct->weight();
107 myGenEvent = tmpGenEvtPtr;
155 using namespace YODA;
159 const string tmpdir =
"/RivetNormalizeTmp";
161 foreach (
const string& analysis, analyses) {
163 dbe->setCurrentFolder((
"Rivet/"+analysis).c_str());
166 TH1F
nevent(
"nEvt",
"n analyzed Events", 1, 0., 1.);
168 _mes.push_back(
dbe->book1D(
"nEvt",&nevent));
T getParameter(std::string const &) const
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
virtual void endRun(const edm::Run &, const edm::EventSetup &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
#define DEFINE_FWK_MODULE(type)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
edm::InputTag _hepmcCollection
Rivet::AnalysisHandler _analysisHandler
RivetAnalyzer(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
edm::InputTag _genEventInfoCollection
virtual void endJob()
List of registered analysis data objects.
std::vector< MonitorElement * > _mes