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