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