11 #include "Rivet/AnalysisHandler.hh"
12 #include "Rivet/Analysis.hh"
13 #include "Rivet/RivetAIDA.hh"
14 #include "LWH/AIManagedObject.h"
22 using namespace Rivet;
28 _outFileName(pset.getParameter<std::
string>(
"OutputFile")),
31 _doFinalize(pset.getParameter<bool>(
"DoFinalize")),
32 _produceDQM(pset.getParameter<bool>(
"ProduceDQMOutput"))
35 std::vector<std::string> analysisNames = pset.
getParameter<std::vector<std::string> >(
"AnalysisNames");
40 if (_useExternalWeight) {
41 if (!pset.
exists(
"GenEventInfoCollection")){
42 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 " ;
51 const std::set< AnaHandle, AnaHandleLess > & analyses =
_analysisHandler.analyses();
53 std::set< AnaHandle, AnaHandleLess >::const_iterator ibeg = analyses.begin();
54 std::set< AnaHandle, AnaHandleLess >::const_iterator iend = analyses.end();
55 std::set< AnaHandle, AnaHandleLess >::const_iterator iana;
56 double xsection = -1.;
58 for (iana = ibeg; iana != iend; ++iana){
59 if ((*iana)->needsCrossSection())
60 (*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()));
96 const HepMC::GenEvent *myGenEvent = evt->GetEvent();
99 HepMC::GenEvent * tmpGenEvtPtr =
new HepMC::GenEvent( *(evt->GetEvent()) );
100 if (tmpGenEvtPtr->weights().size() == 0) {
101 throw cms::Exception(
"RivetAnalyzer") <<
"Original weight container has 0 size ";
103 if (tmpGenEvtPtr->weights().size() > 1) {
104 edm::LogWarning(
"RivetAnalyzer") <<
"Original event weight size is " << tmpGenEvtPtr->weights().size() <<
". Will change only the first one ";
108 tmpGenEvtPtr->weights()[0] = genEventInfoProduct->weight();
109 myGenEvent = tmpGenEvtPtr;
144 using namespace AIDA;
147 const string tmpdir =
"/RivetNormalizeTmp";
149 foreach (
const string& analysis, analyses) {
154 TH1F
nevent(
"nEvt",
"n analyzed Events", 1, 0., 1.);
163 const vector<string>
paths = tree.listObjectNames(
"/"+analysis,
true);
164 std::cout <<
"Number of objects in AIDA tree for analysis " << analysis <<
" = " << paths.size() << std::endl;
165 foreach (
const string&
path, paths) {
166 IManagedObject* hobj = tree.find(path);
170 IHistogram1D*
histo = 0;
171 IProfile1D* prof =
dynamic_cast<IProfile1D*
>(hobj);
172 if (!prof) histo =
dynamic_cast<IHistogram1D*
>(hobj);
174 std::cout <<
"Converting histo " << path <<
" to DPS" << std::endl;
175 tree.mv(path, tmpdir);
176 const size_t lastslash = path.find_last_of(
"/");
177 const string basename = path.substr(lastslash+1, path.length() - (lastslash+1));
178 const string tmppath = tmpdir +
"/" + basename;
182 IHistogram1D* tmphisto =
dynamic_cast<IHistogram1D*
>(tree.find(tmppath));
187 TH1F*
h = aida2root<IHistogram1D, TH1F>(
histo, basename);
195 IProfile1D* tmpprof =
dynamic_cast<IProfile1D*
>(tree.find(tmppath));
200 TProfile*
p = aida2root<IProfile1D, TProfile>(prof, basename);
T getParameter(std::string const &) const
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
virtual void endRun(const edm::Run &, const edm::EventSetup &)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
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
tuple path
else: Piece not in the list, fine.
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
void setVerbose(unsigned level)
RivetAnalyzer(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void normalizeTree(AIDA::ITree &tree)
edm::InputTag _genEventInfoCollection
void setCurrentFolder(const std::string &fullpath)
std::vector< MonitorElement * > _mes