CMS 3D CMS Logo

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