CMS 3D CMS Logo

HarvestingAnalyzer.cc
Go to the documentation of this file.
2 
4  std::string MsgLoggerCat = "HarvestingAnalyzer_HarvestingAnalyzer";
5 
6  fName = iPSet.getUntrackedParameter<std::string>("Name");
7  verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
8 
9  if (verbosity >= 0) {
10  edm::LogInfo(MsgLoggerCat) << "\n===============================\n"
11  << "Initialized as EDAnalyzer with parameter values:\n"
12  << " Name = " << fName << "\n"
13  << " Verbosity = " << verbosity << "\n"
14  << "===============================\n";
15  }
16 }
17 
19 
20 void HarvestingAnalyzer::beginJob() { return; }
21 
23  dbe = nullptr;
25 
26  if (dbe) {
27  // monitoring element numerator and denominator histogram
28  MonitorElement *meN = dbe->get("ConverterTest/TH1F/Random1DN");
29  MonitorElement *meD = dbe->get("ConverterTest/TH1F/Random1DD");
30 
31  if (meN && meD) {
32  // get the numerator and denominator histogram
33  TH1F *numerator = meN->getTH1F();
34  numerator->Sumw2();
35  TH1F *denominator = meD->getTH1F();
36  denominator->Sumw2();
37 
38  // set the current directory
39  dbe->setCurrentFolder("ConverterTest/TH1F");
40 
41  // booked the new histogram to contain the results
42  MonitorElement *me = dbe->book1D("Divide",
43  "Divide calculation",
44  numerator->GetNbinsX(),
45  numerator->GetXaxis()->GetXmin(),
46  numerator->GetXaxis()->GetXmax());
47 
48  // Calculate the efficiency
49  me->getTH1F()->Divide(numerator, denominator, 1., 1., "B");
50 
51  } else {
52  std::cout << "Monitor elements don't exist" << std::endl;
53  }
54  } else {
55  std::cout << "Don't have a valid DQM back end" << std::endl;
56  }
57 
58  return;
59 }
60 
61 void HarvestingAnalyzer::beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) { return; }
62 
63 void HarvestingAnalyzer::endRun(const edm::Run &iRun, const edm::EventSetup &iSetup) { return; }
64 
65 void HarvestingAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { return; }
void endRun(const edm::Run &, const edm::EventSetup &) override
T getUntrackedParameter(std::string const &, T const &) const
TH1F * getTH1F() const
HarvestingAnalyzer(const edm::ParameterSet &)
MonitorElement * book1D(char_string const &name, char_string const &title, int const nchX, double const lowX, double const highX)
Book 1D histogram.
Definition: DQMStore.cc:1098
void beginJob() override
void beginRun(const edm::Run &, const edm::EventSetup &) override
void endJob() override
int iEvent
Definition: GenABIO.cc:224
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1613
void analyze(const edm::Event &, const edm::EventSetup &) override
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:571
~HarvestingAnalyzer() override
Definition: Run.h:45