11 #include "Rivet/AnalysisHandler.hh" 12 #include "Rivet/Analysis.hh" 13 #include "Rivet/Tools/RivetYODA.hh" 22 using namespace Rivet;
28 _fileNames(pset.getParameter<
std::vector<
std::
string> >(
"FilesToHarvest")),
29 _sumOfWeights(pset.getParameter<
std::vector<double> >(
"VSumOfWeights")),
30 _crossSections(pset.getParameter<
std::vector<double> >(
"VCrossSections")),
31 _outFileName(pset.getParameter<
std::
string>(
"OutputFile")),
33 _hepmcCollection(pset.getParameter<
edm::
InputTag>(
"HepMCCollection")),
34 _analysisNames(pset.getParameter<
std::vector<
std::
string> >(
"AnalysisNames"))
48 const std::set< AnaHandle, CmpAnaHandle > & analyses =
_analysisHandler.analyses();
50 std::set< AnaHandle, CmpAnaHandle >::const_iterator ibeg = analyses.begin();
51 std::set< AnaHandle, CmpAnaHandle >::const_iterator iend = analyses.end();
52 std::set< AnaHandle, CmpAnaHandle >::const_iterator iana;
53 double xsection = -1.;
55 for (iana = ibeg; iana != iend; ++iana){
56 if ((*iana)->needsCrossSection())
57 (*iana)->setCrossSection(xsection);
76 char * cmsswbase = getenv(
"CMSSW_BASE");
77 char * cmsswrelease = getenv(
"CMSSW_RELEASE_BASE");
79 rivetref =
"RIVET_REF_PATH=" +
string(cmsswbase) +
"/src/GeneratorInterface/RivetInterface/data:" +
string(cmsswrelease) +
"/src/GeneratorInterface/RivetInterface/data";
80 rivetinfo =
"RIVET_INFO_PATH=" +
string(cmsswbase) +
"/src/GeneratorInterface/RivetInterface/data:" +
string(cmsswrelease) +
"/src/GeneratorInterface/RivetInterface/data";
81 char *rivetrefCstr = strdup(rivetref.c_str());
84 char *rivetinfoCstr = strdup(rivetinfo.c_str());
85 putenv(rivetinfoCstr);
103 const HepMC::GenEvent *myGenEvent = evt->
GetEvent();
189 TiXmlDocument
doc(filename);
192 string err =
"Error in " +
string(doc.Value());
193 err +=
": " +
string(doc.ErrorDesc());
203 const TiXmlNode* yodaN = doc.FirstChild(
"yoda");
204 if (!yodaN)
throw cms::Exception(
"RivetHarvesting") <<
"Couldn't get <yoda> root element";
205 for (
const TiXmlNode* dpsN = yodaN->FirstChild(
"dataPointSet"); dpsN; dpsN = dpsN->NextSibling()) {
206 const TiXmlElement* dpsE = dpsN->ToElement();
207 const string plotname = dpsE->Attribute(
"name");
208 const string plotpath = dpsE->Attribute(
"path");
209 if (plotpath != path && plotname != name)
219 for (
const TiXmlNode* dpN = dpsN->FirstChild(
"dataPoint"); dpN; dpN = dpN->NextSibling()) {
220 const TiXmlNode* xMeasN = dpN->FirstChild(
"measurement");
221 const TiXmlNode* yMeasN = xMeasN->NextSibling();
222 if (xMeasN && yMeasN) {
223 const TiXmlElement* xMeasE = xMeasN->ToElement();
224 const TiXmlElement* yMeasE = yMeasN->ToElement();
225 const string xcentreStr = xMeasE->Attribute(
"value");
226 const string xerrplusStr = xMeasE->Attribute(
"errorPlus");
227 const string xerrminusStr = xMeasE->Attribute(
"errorMinus");
228 const string ycentreStr = yMeasE->Attribute(
"value");
229 const string yerrplusStr = yMeasE->Attribute(
"errorPlus");
230 const string yerrminusStr = yMeasE->Attribute(
"errorMinus");
234 istringstream xssC(xcentreStr);
235 istringstream xssP(xerrplusStr);
236 istringstream xssM(xerrminusStr);
237 istringstream yssC(ycentreStr);
238 istringstream yssP(yerrplusStr);
239 istringstream yssM(yerrminusStr);
240 double xcentre, xerrplus, xerrminus, ycentre, yerrplus, yerrminus;
241 xssC >> xcentre; xssP >> xerrplus; xssM >> xerrminus;
242 yssC >> ycentre; yssP >> yerrplus; yssM >> yerrminus;
244 Point2D pt(xcentre, xerrminus, xerrplus, ycentre, yerrminus, yerrplus);
245 points.push_back(pt);
247 cerr <<
"Couldn't get <measurement> tag" << endl;
259 cerr << e.what() << endl;
263 throw cms::Exception(
"RivetHarvesting") <<
"could not find " << path <<
"/" << name <<
" in file " <<
filename;
T getParameter(std::string const &) const
std::vector< double > _lumis
#define DEFINE_FWK_MODULE(type)
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< YODA::Point2D > getPoint2DValsErrs(std::string filename, std::string path, std::string name)
edm::InputTag _hepmcCollection
std::vector< double > _crossSections
~RivetHarvesting() override
RivetHarvesting(const edm::ParameterSet &)
std::vector< std::string > _fileNames
std::vector< double > _sumOfWeights
Rivet::AnalysisHandler _analysisHandler
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
const HepMC::GenEvent * GetEvent() const
void endRun(const edm::Run &, const edm::EventSetup &) override
void beginRun(const edm::Run &, const edm::EventSetup &) override
std::vector< std::string > _analysisNames