CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RivetAnalyzer.h
Go to the documentation of this file.
1 #ifndef GeneratorInterface_RivetInterface_RivetAnalyzer
2 #define GeneratorInterface_RivetInterface_RivetAnalyzer
3 
6 #include "Rivet/AnalysisHandler.hh"
7 
8 //DQM services
12 
13 #include "Rivet/Tools/RivetYODA.hh"
14 #include "YODA/ROOTCnv.h"
15 
16 
17 #include <vector>
18 #include <string>
19 
20 namespace edm{
21  class ParameterSet;
22  class Event;
23  class EventSetup;
24  class InputTag;
25 }
26 
28 {
29  public:
31 
32  virtual ~RivetAnalyzer();
33 
34  virtual void beginJob();
35 
36  virtual void endJob();
37 
38  virtual void analyze(const edm::Event&, const edm::EventSetup&);
39 
40  virtual void beginRun(const edm::Run&, const edm::EventSetup&);
41 
42  virtual void endRun(const edm::Run&, const edm::EventSetup&);
43 
44  private:
45 
46  void normalizeTree();
47 
51  Rivet::AnalysisHandler _analysisHandler;
56 
58  std::vector<MonitorElement *> _mes;
59 };
60 
61 
62 /*
63 template<class YODATYPE, class ROOTTYPE>
64 ROOTTYPE*
65  RivetAnalyzer::prebook(const YODATYPE* yodah, const std::string& name){
66  ROOTTYPE* h = 0;
67  if (yodah->axis().isFixedBinning() ) {//equidistant binning (easier case)
68  int nbins = yodah->axis().bins();
69  h = new ROOTTYPE(name.c_str(), name.c_str(), nbins, yodah->axis().lowerEdge(), yodah->axis().upperEdge());
70  } else {
71  int nbins = yodah->axis().bins();
72  const YODA::Axis1D* vax = dynamic_cast<const YODA::Axis1D*>(&yodah->axis());
73  if (! vax ){
74  throw cms::Exception("RivetAnalyzer") << "Cannot dynamix cast an YODA axis to VariAxis ";
75  }
76  double* bins = new double[nbins+1];
77  for (int i=0; i<nbins; ++i) {
78  bins[i] = vax->binEdges(i).first;
79  }
80  bins[nbins] = vax->binEdges(nbins-1).second; //take last bin right border
81  h = new ROOTTYPE(name.c_str(), name.c_str(), nbins, bins);
82  delete bins;
83  }
84  return h;
85 }
86 
87 template<>
88 TH1F* RivetAnalyzer::yoda2root(const YODA::IHistogram1D* yodah, const std::string& name){
89  TH1F* h = prebook<YODA::Histo1D, TH1F>(yodah, name);
90  for (int i = 0; i < yodah->axis().bins(); ++i){
91  h->SetBinContent(i+1, yodah->binHeight(i));
92  h->SetBinError(i+1, yodah->binError(i));
93  }
94  return h;
95 }
96 
97 template<>
98 TProfile* RivetAnalyzer::yoda2root(const YODA::IProfile1D* yodah, const std::string& name){
99  TProfile* h = prebook<YODA::IProfile1D, TProfile>(yodah, name);
100  for (int i = 0; i < yodah->axis().bins(); ++i){
101  h->SetBinContent(i+1, yodah->binMean(i));
102  h->SetBinError(i+1, yodah->binRms(i));
103  }
104  return h;
105 }
106 */
107 
108 #endif
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 &)
edm::InputTag _hepmcCollection
Definition: RivetAnalyzer.h:48
Rivet::AnalysisHandler _analysisHandler
Definition: RivetAnalyzer.h:51
RivetAnalyzer(const edm::ParameterSet &)
DQMStore * dbe
Definition: RivetAnalyzer.h:57
std::string _outFileName
Definition: RivetAnalyzer.h:53
bool _useExternalWeight
Definition: RivetAnalyzer.h:49
edm::InputTag _genEventInfoCollection
Definition: RivetAnalyzer.h:50
virtual ~RivetAnalyzer()
virtual void beginJob()
void normalizeTree()
Definition: Run.h:41
virtual void endJob()
List of registered analysis data objects.
std::vector< MonitorElement * > _mes
Definition: RivetAnalyzer.h:58