test
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  double _xsection;
54 
56  std::vector<MonitorElement *> _mes;
57 };
58 
59 
60 /*
61 template<class YODATYPE, class ROOTTYPE>
62 ROOTTYPE*
63  RivetAnalyzer::prebook(const YODATYPE* yodah, const std::string& name){
64  ROOTTYPE* h = 0;
65  if (yodah->axis().isFixedBinning() ) {//equidistant binning (easier case)
66  int nbins = yodah->axis().bins();
67  h = new ROOTTYPE(name.c_str(), name.c_str(), nbins, yodah->axis().lowerEdge(), yodah->axis().upperEdge());
68  } else {
69  int nbins = yodah->axis().bins();
70  const YODA::Axis1D* vax = dynamic_cast<const YODA::Axis1D*>(&yodah->axis());
71  if (! vax ){
72  throw cms::Exception("RivetAnalyzer") << "Cannot dynamix cast an YODA axis to VariAxis ";
73  }
74  double* bins = new double[nbins+1];
75  for (int i=0; i<nbins; ++i) {
76  bins[i] = vax->binEdges(i).first;
77  }
78  bins[nbins] = vax->binEdges(nbins-1).second; //take last bin right border
79  h = new ROOTTYPE(name.c_str(), name.c_str(), nbins, bins);
80  delete bins;
81  }
82  return h;
83 }
84 
85 template<>
86 TH1F* RivetAnalyzer::yoda2root(const YODA::IHistogram1D* yodah, const std::string& name){
87  TH1F* h = prebook<YODA::Histo1D, TH1F>(yodah, name);
88  for (int i = 0; i < yodah->axis().bins(); ++i){
89  h->SetBinContent(i+1, yodah->binHeight(i));
90  h->SetBinError(i+1, yodah->binError(i));
91  }
92  return h;
93 }
94 
95 template<>
96 TProfile* RivetAnalyzer::yoda2root(const YODA::IProfile1D* yodah, const std::string& name){
97  TProfile* h = prebook<YODA::IProfile1D, TProfile>(yodah, name);
98  for (int i = 0; i < yodah->axis().bins(); ++i){
99  h->SetBinContent(i+1, yodah->binMean(i));
100  h->SetBinError(i+1, yodah->binRms(i));
101  }
102  return h;
103 }
104 */
105 
106 #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
double _xsection
Definition: RivetAnalyzer.h:53
DQMStore * dbe
Definition: RivetAnalyzer.h:55
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:56