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 
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
RivetAnalyzer::normalizeTree
void normalizeTree()
Definition: RivetAnalyzer.cc:195
RivetAnalyzer::_GENweightNumber
int _GENweightNumber
Definition: RivetAnalyzer.h:54
EDAnalyzer.h
RivetAnalyzer::_lheRunInfoToken
edm::EDGetTokenT< LHERunInfoProduct > _lheRunInfoToken
Definition: RivetAnalyzer.h:58
RivetAnalyzer::_useGENweights
bool _useGENweights
Definition: RivetAnalyzer.h:53
RivetAnalyzer::beginLuminosityBlock
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
Definition: RivetAnalyzer.cc:101
RivetAnalyzer::_xsection
double _xsection
Definition: RivetAnalyzer.h:65
RivetAnalyzer::_useLHEweights
bool _useLHEweights
Definition: RivetAnalyzer.h:51
RivetAnalyzer::beginJob
void beginJob() override
Definition: RivetAnalyzer.cc:58
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< edm::HepMCProduct >
RivetAnalyzer::_doFinalize
bool _doFinalize
Definition: RivetAnalyzer.h:62
DQMStore.h
RivetAnalyzer::DQMStore
dqm::legacy::DQMStore DQMStore
Definition: RivetAnalyzer.h:25
RivetAnalyzer::_genLumiInfoToken
edm::EDGetTokenT< GenLumiInfoHeader > _genLumiInfoToken
Definition: RivetAnalyzer.h:57
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
RivetAnalyzer::_isFirstEvent
bool _isFirstEvent
Definition: RivetAnalyzer.h:60
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
RivetAnalyzer::_lheWeightNames
std::vector< std::string > _lheWeightNames
Definition: RivetAnalyzer.h:67
RivetAnalyzer::_useExternalWeight
bool _useExternalWeight
Definition: RivetAnalyzer.h:50
RivetAnalyzer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: RivetAnalyzer.cc:80
LHERunInfoProduct.h
dqm::legacy::DQMStore
Definition: DQMStore.h:727
RivetAnalyzer::RivetAnalyzer
RivetAnalyzer(const edm::ParameterSet &)
Definition: RivetAnalyzer.cc:19
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RivetAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: RivetAnalyzer.cc:117
RivetAnalyzer::endJob
void endJob() override
List of registered analysis data objects.
Definition: RivetAnalyzer.cc:193
edm::ParameterSet
Definition: ParameterSet.h:36
GenEventInfoProduct.h
RivetAnalyzer::_analysisHandler
Rivet::AnalysisHandler _analysisHandler
Definition: RivetAnalyzer.h:59
RivetAnalyzer::_hepmcCollection
edm::EDGetTokenT< edm::HepMCProduct > _hepmcCollection
Definition: RivetAnalyzer.h:49
RivetAnalyzer::_mes
std::vector< MonitorElement * > _mes
Definition: RivetAnalyzer.h:70
GenLumiInfoHeader.h
edm::EventSetup
Definition: EventSetup.h:57
RivetAnalyzer::_lheLabel
const edm::InputTag _lheLabel
Definition: RivetAnalyzer.h:64
RivetAnalyzer::dbe
DQMStore * dbe
Definition: RivetAnalyzer.h:69
LHEEventProduct.h
RivetAnalyzer
Definition: RivetAnalyzer.h:22
RivetAnalyzer::_LHEweightNumber
int _LHEweightNumber
Definition: RivetAnalyzer.h:52
RivetAnalyzer::_weightNames
std::vector< std::string > _weightNames
Definition: RivetAnalyzer.h:66
RivetAnalyzer::_produceDQM
bool _produceDQM
Definition: RivetAnalyzer.h:63
RivetAnalyzer::~RivetAnalyzer
~RivetAnalyzer() override
Definition: RivetAnalyzer.cc:56
RivetAnalyzer::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: RivetAnalyzer.cc:174
RivetAnalyzer::_LHECollection
edm::EDGetTokenT< LHEEventProduct > _LHECollection
Definition: RivetAnalyzer.h:55
RivetAnalyzer::endLuminosityBlock
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
Definition: RivetAnalyzer.cc:115
HepMCProduct.h
RivetAnalyzer::_genEventInfoCollection
edm::EDGetTokenT< GenEventInfoProduct > _genEventInfoCollection
Definition: RivetAnalyzer.h:56
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
RivetAnalyzer::MonitorElement
dqm::legacy::MonitorElement MonitorElement
Definition: RivetAnalyzer.h:26
RivetAnalyzer::_outFileName
std::string _outFileName
Definition: RivetAnalyzer.h:61