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
void analyze(const edm::Event &, const edm::EventSetup &) override
void endRun(const edm::Run &, const edm::EventSetup &) override
std::string _deselectMultiWeights
Definition: RivetAnalyzer.h:55
std::unique_ptr< Rivet::AnalysisHandler > _analysisHandler
Definition: RivetAnalyzer.h:61
std::vector< std::string > _cleanedWeightNames
Definition: RivetAnalyzer.h:71
std::string _setNominalWeightName
Definition: RivetAnalyzer.h:56
std::vector< std::string > _analysisNames
Definition: RivetAnalyzer.h:64
const edm::InputTag _lheLabel
Definition: RivetAnalyzer.h:67
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
std::string _selectMultiWeights
Definition: RivetAnalyzer.h:54
void beginJob() override
bool _skipMultiWeights
Definition: RivetAnalyzer.h:53
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:59
edm::EDGetTokenT< edm::HepMCProduct > _hepmcCollection
Definition: RivetAnalyzer.h:49
edm::EDGetTokenT< LHERunInfoProduct > _lheRunInfoToken
Definition: RivetAnalyzer.h:60
double _xsection
Definition: RivetAnalyzer.h:68
DQMStore * dbe
Definition: RivetAnalyzer.h:73
std::vector< std::string > _lheWeightNames
Definition: RivetAnalyzer.h:70
std::string _outFileName
Definition: RivetAnalyzer.h:63
dqm::legacy::DQMStore DQMStore
Definition: RivetAnalyzer.h:25
void endJob() override
List of registered analysis data objects.
edm::EDGetTokenT< LHEEventProduct > _LHECollection
Definition: RivetAnalyzer.h:57
std::vector< std::string > _weightNames
Definition: RivetAnalyzer.h:69
dqm::legacy::MonitorElement MonitorElement
Definition: RivetAnalyzer.h:26
edm::EDGetTokenT< GenEventInfoProduct > _genEventInfoCollection
Definition: RivetAnalyzer.h:58
void normalizeTree()
Definition: Run.h:45
double _NLOSmearing
Definition: RivetAnalyzer.h:52
std::vector< MonitorElement * > _mes
Definition: RivetAnalyzer.h:74
double _weightCap
Definition: RivetAnalyzer.h:51
~RivetAnalyzer() override