12 #include "Rivet/AnalysisHandler.hh"
13 #include "Rivet/Analysis.hh"
21 using namespace Rivet;
27 _outFileName(pset.getParameter<std::
string>(
"OutputFile")),
30 _doFinalize(pset.getParameter<bool>(
"DoFinalize")),
31 _produceDQM(pset.getParameter<bool>(
"ProduceDQMOutput"))
34 std::vector<std::string> analysisNames = pset.
getParameter<std::vector<std::string> >(
"AnalysisNames");
39 if (_useExternalWeight) {
40 if (!pset.
exists(
"GenEventInfoCollection")){
41 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 " ;
54 const std::set< AnaHandle, CmpAnaHandle > & analyses =
_analysisHandler.analyses();
56 std::set< AnaHandle, CmpAnaHandle >::const_iterator ibeg = analyses.begin();
57 std::set< AnaHandle, CmpAnaHandle >::const_iterator iend = analyses.end();
58 std::set< AnaHandle, CmpAnaHandle >::const_iterator iana;
59 double xsection = -1.;
61 for (iana = ibeg; iana != iend; ++iana){
62 if ((*iana)->needsCrossSection())
63 (*iana)->setCrossSection(xsection);
79 char * cmsswbase = getenv(
"CMSSW_BASE");
80 char * cmsswrelease = getenv(
"CMSSW_RELEASE_BASE");
82 rivetref =
"RIVET_REF_PATH=" +
string(cmsswbase) +
"/src/GeneratorInterface/RivetInterface/data:" +
string(cmsswrelease) +
"/src/GeneratorInterface/RivetInterface/data";
83 rivetinfo =
"RIVET_INFO_PATH=" +
string(cmsswbase) +
"/src/GeneratorInterface/RivetInterface/data:" +
string(cmsswrelease) +
"/src/GeneratorInterface/RivetInterface/data";
84 putenv(strdup(rivetref.c_str()));
85 putenv(strdup(rivetinfo.c_str()));
99 const HepMC::GenEvent *myGenEvent = evt->GetEvent();
104 HepMC::GenEvent * tmpGenEvtPtr =
new HepMC::GenEvent( *(evt->GetEvent()) );
105 if (tmpGenEvtPtr->weights().size() == 0) {
106 throw cms::Exception(
"RivetAnalyzer") <<
"Original weight container has 0 size ";
108 if (tmpGenEvtPtr->weights().size() > 1) {
109 edm::LogWarning(
"RivetAnalyzer") <<
"Original event weight size is " << tmpGenEvtPtr->weights().size() <<
". Will change only the first one ";
115 tmpGenEvtPtr->weights()[0] = genEventInfoProduct->weight();
120 tmpGenEvtPtr->weights()[0] = wgt.
wgt;
122 myGenEvent = tmpGenEvtPtr;
171 using namespace YODA;
175 const string tmpdir =
"/RivetNormalizeTmp";
177 foreach (
const string& analysis, analyses) {
179 dbe->setCurrentFolder((
"Rivet/"+analysis).c_str());
182 TH1F
nevent(
"nEvt",
"n analyzed Events", 1, 0., 1.);
184 _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 _LHECollection
edm::InputTag _genEventInfoCollection
virtual void endJob()
List of registered analysis data objects.
std::vector< MonitorElement * > _mes