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 putenv(strdup(rivetref.c_str()));
82 putenv(strdup(rivetinfo.c_str()));
185 TiXmlDocument
doc(filename);
188 string err =
"Error in " +
string(doc.Value());
189 err +=
": " +
string(doc.ErrorDesc());
199 const TiXmlNode* yodaN = doc.FirstChild(
"yoda");
200 if (!yodaN)
throw cms::Exception(
"RivetHarvesting") <<
"Couldn't get <yoda> root element";
201 for (
const TiXmlNode* dpsN = yodaN->FirstChild(
"dataPointSet"); dpsN; dpsN = dpsN->NextSibling()) {
202 const TiXmlElement* dpsE = dpsN->ToElement();
203 const string plotname = dpsE->Attribute(
"name");
204 const string plotpath = dpsE->Attribute(
"path");
205 if (plotpath != path && plotname != name)
215 for (
const TiXmlNode* dpN = dpsN->FirstChild(
"dataPoint"); dpN; dpN = dpN->NextSibling()) {
216 const TiXmlNode* xMeasN = dpN->FirstChild(
"measurement");
217 const TiXmlNode* yMeasN = xMeasN->NextSibling();
218 if (xMeasN && yMeasN) {
219 const TiXmlElement* xMeasE = xMeasN->ToElement();
220 const TiXmlElement* yMeasE = yMeasN->ToElement();
221 const string xcentreStr = xMeasE->Attribute(
"value");
222 const string xerrplusStr = xMeasE->Attribute(
"errorPlus");
223 const string xerrminusStr = xMeasE->Attribute(
"errorMinus");
224 const string ycentreStr = yMeasE->Attribute(
"value");
225 const string yerrplusStr = yMeasE->Attribute(
"errorPlus");
226 const string yerrminusStr = yMeasE->Attribute(
"errorMinus");
230 istringstream xssC(xcentreStr);
231 istringstream xssP(xerrplusStr);
232 istringstream xssM(xerrminusStr);
233 istringstream yssC(ycentreStr);
234 istringstream yssP(yerrplusStr);
235 istringstream yssM(yerrminusStr);
236 double xcentre, xerrplus, xerrminus, ycentre, yerrplus, yerrminus;
237 xssC >> xcentre; xssP >> xerrplus; xssM >> xerrminus;
238 yssC >> ycentre; yssP >> yerrplus; yssM >> yerrminus;
240 Point2D pt(xcentre, xerrminus, xerrplus, ycentre, yerrminus, yerrplus);
241 points.push_back(pt);
243 cerr <<
"Couldn't get <measurement> tag" << endl;
255 cerr << e.what() << endl;
259 throw cms::Exception(
"RivetHarvesting") <<
"could not find " << path <<
"/" << name <<
" in file " <<
filename;
T getParameter(std::string const &) const
std::vector< double > _lumis
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
#define DEFINE_FWK_MODULE(type)
virtual void endRun(const edm::Run &, const edm::EventSetup &)
std::vector< YODA::Point2D > getPoint2DValsErrs(std::string filename, std::string path, std::string name)
virtual ~RivetHarvesting()
edm::InputTag _hepmcCollection
std::vector< double > _crossSections
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
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< std::string > _analysisNames