11 #include "Rivet/AnalysisHandler.hh"
12 #include "Rivet/Analysis.hh"
13 #include "Rivet/RivetAIDA.hh"
14 #include "LWH/AIManagedObject.h"
23 using namespace Rivet;
29 _fileNames(pset.getParameter<std::vector<std::
string> >(
"FilesToHarvest")),
30 _sumOfWeights(pset.getParameter<std::vector<double> >(
"VSumOfWeights")),
31 _crossSections(pset.getParameter<std::vector<double> >(
"VCrossSections")),
32 _outFileName(pset.getParameter<std::
string>(
"OutputFile")),
34 _hepmcCollection(pset.getParameter<edm::
InputTag>(
"HepMCCollection")),
35 _analysisNames(pset.getParameter<std::vector<std::
string> >(
"AnalysisNames"))
49 const std::set< AnaHandle, AnaHandleLess > & analyses =
_analysisHandler.analyses();
51 std::set< AnaHandle, AnaHandleLess >::const_iterator ibeg = analyses.begin();
52 std::set< AnaHandle, AnaHandleLess >::const_iterator iend = analyses.end();
53 std::set< AnaHandle, AnaHandleLess >::const_iterator iana;
54 double xsection = -1.;
56 for (iana = ibeg; iana != iend; ++iana){
57 if ((*iana)->needsCrossSection())
58 (*iana)->setCrossSection(xsection);
77 char * cmsswbase = getenv(
"CMSSW_BASE");
78 char * cmsswrelease = getenv(
"CMSSW_RELEASE_BASE");
80 rivetref =
"RIVET_REF_PATH=" +
string(cmsswbase) +
"/src/GeneratorInterface/RivetInterface/data:" +
string(cmsswrelease) +
"/src/GeneratorInterface/RivetInterface/data";
81 rivetinfo =
"RIVET_INFO_PATH=" +
string(cmsswbase) +
"/src/GeneratorInterface/RivetInterface/data:" +
string(cmsswrelease) +
"/src/GeneratorInterface/RivetInterface/data";
82 putenv(strdup(rivetref.c_str()));
83 putenv(strdup(rivetinfo.c_str()));
100 const HepMC::GenEvent *myGenEvent = evt->GetEvent();
125 std::vector<std::string> listOfNames = tree.listObjectNames(
"./"+(*iAna),
true);
126 std::vector<std::string>::const_iterator iNameBeg = listOfNames.begin();
127 std::vector<std::string>::const_iterator iNameEnd = listOfNames.end();
128 for (std::vector<std::string>::const_iterator iName = iNameBeg; iName != iNameEnd; ++iName ){
129 AIDA::IManagedObject * iObj = tree.find(*iName);
131 std::cout << *iName <<
" not found; SKIPPING!" << std::endl;
135 std::cout << *iName <<
" FOUND!" << std::endl;
136 vector<string>::const_iterator iFile;
137 vector<string>::const_iterator iFileBeg =
_fileNames.begin();
138 vector<string>::const_iterator iFileEnd =
_fileNames.end();
139 AIDA::IHistogram1D*
histo =
dynamic_cast<AIDA::IHistogram1D*
>(iObj);
140 AIDA::IProfile1D* prof =
dynamic_cast<AIDA::IProfile1D*
>(iObj);
141 string tmpdir =
"/tmpdir";
143 unsigned int ifc = 0;
144 for (iFile = iFileBeg; iFile != iFileEnd; ++iFile) {
145 std::cout <<
"opening file " << *iFile << std::endl;
146 string name = *iName;
147 string tostrip = *iAna+
'/';
148 name.replace(name.find(tostrip),tostrip.length(),
"");
149 name.replace(name.find(
"/"),1,
"");
150 cout << name << endl;
153 const string tmppath = tmpdir +
"/" +
name;
154 cout << tmppath << endl;
155 IHistogram1D* tmphisto =
_analysisHandler.histogramFactory().createCopy(tmppath, *histo);
157 for (
unsigned int i = 0;
i < original.size(); ++
i){
158 tmphisto->fill(original[
i].xval, original[
i].yval);
160 tmphisto->scale(
_lumis[ifc]);
161 histo->add(*tmphisto);
166 std::cout << *iName <<
"is a profile, doing nothing " << std::endl;
168 std::cout << *iName <<
" is neither a IHistogram1D neither a IProfile1D. Doing nothing with it." << std::endl;
172 cout << iObj << endl;
203 vector<DPSXYPoint> rtn;
208 if (!aidaN)
throw cms::Exception(
"RivetHarvesting") <<
"Couldn't get <aida> root element";
211 const string plotname = dpsE->
Attribute(
"name");
212 const string plotpath = dpsE->
Attribute(
"path");
213 if (plotpath != path && plotname != name)
222 vector<DPSXYPoint> points;
226 if (xMeasN && yMeasN) {
229 const string xcentreStr = xMeasE->
Attribute(
"value");
230 const string xerrplusStr = xMeasE->
Attribute(
"errorPlus");
231 const string xerrminusStr = xMeasE->
Attribute(
"errorMinus");
232 const string ycentreStr = yMeasE->
Attribute(
"value");
233 const string yerrplusStr = yMeasE->
Attribute(
"errorPlus");
234 const string yerrminusStr = yMeasE->
Attribute(
"errorMinus");
238 istringstream xssC(xcentreStr);
239 istringstream xssP(xerrplusStr);
240 istringstream xssM(xerrminusStr);
241 istringstream yssC(ycentreStr);
242 istringstream yssP(yerrplusStr);
243 istringstream yssM(yerrminusStr);
244 double xcentre, xerrplus, xerrminus, ycentre, yerrplus, yerrminus;
245 xssC >> xcentre; xssP >> xerrplus; xssM >> xerrminus;
246 yssC >> ycentre; yssP >> yerrplus; yssM >> yerrminus;
248 DPSXYPoint
pt(xcentre, xerrminus, xerrplus, ycentre, yerrminus, yerrplus);
249 points.push_back(pt);
251 cerr <<
"Couldn't get <measurement> tag" << endl;
263 cerr << e.what() << endl;
267 throw cms::Exception(
"RivetHarvesting") <<
"could not find " << path <<
"/" << name <<
" in file " <<
filename;
T getParameter(std::string const &) const
std::vector< double > _lumis
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
#define DEFINE_FWK_MODULE(type)
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
virtual void endRun(const edm::Run &, const edm::EventSetup &)
virtual ~RivetHarvesting()
edm::InputTag _hepmcCollection
std::vector< double > _crossSections
tuple path
else: Piece not in the list, fine.
RivetHarvesting(const edm::ParameterSet &)
std::vector< std::string > _fileNames
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
std::vector< double > _sumOfWeights
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Rivet::AnalysisHandler _analysisHandler
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
std::vector< Rivet::DPSXYPoint > getDPSXYValsErrs(std::string filename, std::string path, std::string name)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
const char * Value() const
std::vector< std::string > _analysisNames
const char * Attribute(const char *name) const