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 
51  double _weightCap;
52  double _NLOSmearing;
61  std::unique_ptr<Rivet::AnalysisHandler> _analysisHandler;
64  std::vector<std::string> _analysisNames;
68  double _xsection;
69  std::vector<std::string> _weightNames;
70  std::vector<std::string> _lheWeightNames;
71  std::vector<std::string> _cleanedWeightNames;
72 
74  std::vector<MonitorElement *> _mes;
75 };
76 
77 /*
78 template<class YODATYPE, class ROOTTYPE>
79 ROOTTYPE*
80  RivetAnalyzer::prebook(const YODATYPE* yodah, const std::string& name){
81  ROOTTYPE* h = 0;
82  if (yodah->axis().isFixedBinning() ) {//equidistant binning (easier case)
83  int nbins = yodah->axis().bins();
84  h = new ROOTTYPE(name.c_str(), name.c_str(), nbins, yodah->axis().lowerEdge(), yodah->axis().upperEdge());
85  } else {
86  int nbins = yodah->axis().bins();
87  const YODA::Axis1D* vax = dynamic_cast<const YODA::Axis1D*>(&yodah->axis());
88  if (! vax ){
89  throw cms::Exception("RivetAnalyzer") << "Cannot dynamix cast an YODA axis to VariAxis ";
90  }
91  double* bins = new double[nbins+1];
92  for (int i=0; i<nbins; ++i) {
93  bins[i] = vax->binEdges(i).first;
94  }
95  bins[nbins] = vax->binEdges(nbins-1).second; //take last bin right border
96  h = new ROOTTYPE(name.c_str(), name.c_str(), nbins, bins);
97  delete bins;
98  }
99  return h;
100 }
101 
102 template<>
103 TH1F* RivetAnalyzer::yoda2root(const YODA::IHistogram1D* yodah, const std::string& name){
104  TH1F* h = prebook<YODA::Histo1D, TH1F>(yodah, name);
105  for (int i = 0; i < yodah->axis().bins(); ++i){
106  h->SetBinContent(i+1, yodah->binHeight(i));
107  h->SetBinError(i+1, yodah->binError(i));
108  }
109  return h;
110 }
111 
112 template<>
113 TProfile* RivetAnalyzer::yoda2root(const YODA::IProfile1D* yodah, const std::string& name){
114  TProfile* h = prebook<YODA::IProfile1D, TProfile>(yodah, name);
115  for (int i = 0; i < yodah->axis().bins(); ++i){
116  h->SetBinContent(i+1, yodah->binMean(i));
117  h->SetBinError(i+1, yodah->binRms(i));
118  }
119  return h;
120 }
121 */
122 
123 #endif
RivetAnalyzer::_cleanedWeightNames
std::vector< std::string > _cleanedWeightNames
Definition: RivetAnalyzer.h:71
RivetAnalyzer::normalizeTree
void normalizeTree()
Definition: RivetAnalyzer.cc:209
EDAnalyzer.h
RivetAnalyzer::_lheRunInfoToken
edm::EDGetTokenT< LHERunInfoProduct > _lheRunInfoToken
Definition: RivetAnalyzer.h:60
RivetAnalyzer::beginLuminosityBlock
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
Definition: RivetAnalyzer.cc:102
RivetAnalyzer::_xsection
double _xsection
Definition: RivetAnalyzer.h:68
RivetAnalyzer::_useLHEweights
bool _useLHEweights
Definition: RivetAnalyzer.h:50
RivetAnalyzer::beginJob
void beginJob() override
Definition: RivetAnalyzer.cc:59
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< edm::HepMCProduct >
RivetAnalyzer::_doFinalize
bool _doFinalize
Definition: RivetAnalyzer.h:65
DQMStore.h
RivetAnalyzer::DQMStore
dqm::legacy::DQMStore DQMStore
Definition: RivetAnalyzer.h:25
RivetAnalyzer::_genLumiInfoToken
edm::EDGetTokenT< GenLumiInfoHeader > _genLumiInfoToken
Definition: RivetAnalyzer.h:59
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
RivetAnalyzer::_isFirstEvent
bool _isFirstEvent
Definition: RivetAnalyzer.h:62
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
RivetAnalyzer::_lheWeightNames
std::vector< std::string > _lheWeightNames
Definition: RivetAnalyzer.h:70
RivetAnalyzer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: RivetAnalyzer.cc:81
RivetAnalyzer::_skipMultiWeights
bool _skipMultiWeights
Definition: RivetAnalyzer.h:53
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:118
RivetAnalyzer::endJob
void endJob() override
List of registered analysis data objects.
Definition: RivetAnalyzer.cc:207
edm::ParameterSet
Definition: ParameterSet.h:47
GenEventInfoProduct.h
RivetAnalyzer::_hepmcCollection
edm::EDGetTokenT< edm::HepMCProduct > _hepmcCollection
Definition: RivetAnalyzer.h:49
RivetAnalyzer::_mes
std::vector< MonitorElement * > _mes
Definition: RivetAnalyzer.h:74
RivetAnalyzer::_NLOSmearing
double _NLOSmearing
Definition: RivetAnalyzer.h:52
GenLumiInfoHeader.h
edm::EventSetup
Definition: EventSetup.h:57
RivetAnalyzer::_lheLabel
const edm::InputTag _lheLabel
Definition: RivetAnalyzer.h:67
RivetAnalyzer::dbe
DQMStore * dbe
Definition: RivetAnalyzer.h:73
RivetAnalyzer::_analysisNames
std::vector< std::string > _analysisNames
Definition: RivetAnalyzer.h:64
LHEEventProduct.h
RivetAnalyzer
Definition: RivetAnalyzer.h:22
RivetAnalyzer::_analysisHandler
std::unique_ptr< Rivet::AnalysisHandler > _analysisHandler
Definition: RivetAnalyzer.h:61
RivetAnalyzer::_weightNames
std::vector< std::string > _weightNames
Definition: RivetAnalyzer.h:69
RivetAnalyzer::_produceDQM
bool _produceDQM
Definition: RivetAnalyzer.h:66
RivetAnalyzer::~RivetAnalyzer
~RivetAnalyzer() override
Definition: RivetAnalyzer.cc:57
RivetAnalyzer::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: RivetAnalyzer.cc:188
RivetAnalyzer::_LHECollection
edm::EDGetTokenT< LHEEventProduct > _LHECollection
Definition: RivetAnalyzer.h:57
RivetAnalyzer::endLuminosityBlock
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
Definition: RivetAnalyzer.cc:116
HepMCProduct.h
RivetAnalyzer::_genEventInfoCollection
edm::EDGetTokenT< GenEventInfoProduct > _genEventInfoCollection
Definition: RivetAnalyzer.h:58
edm::Event
Definition: Event.h:73
RivetAnalyzer::_deselectMultiWeights
std::string _deselectMultiWeights
Definition: RivetAnalyzer.h:55
RivetAnalyzer::_weightCap
double _weightCap
Definition: RivetAnalyzer.h:51
edm::InputTag
Definition: InputTag.h:15
RivetAnalyzer::MonitorElement
dqm::legacy::MonitorElement MonitorElement
Definition: RivetAnalyzer.h:26
RivetAnalyzer::_outFileName
std::string _outFileName
Definition: RivetAnalyzer.h:63
RivetAnalyzer::_setNominalWeightName
std::string _setNominalWeightName
Definition: RivetAnalyzer.h:56
RivetAnalyzer::_selectMultiWeights
std::string _selectMultiWeights
Definition: RivetAnalyzer.h:54