CMS 3D CMS Logo

HarvestingAnalyzer.cc
Go to the documentation of this file.
2 
4 {
5  std::string MsgLoggerCat = "HarvestingAnalyzer_HarvestingAnalyzer";
6 
7  fName = iPSet.getUntrackedParameter<std::string>("Name");
8  verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
9 
10  if (verbosity >= 0) {
11  edm::LogInfo(MsgLoggerCat)
12  << "\n===============================\n"
13  << "Initialized as EDAnalyzer with parameter values:\n"
14  << " Name = " << fName << "\n"
15  << " Verbosity = " << verbosity << "\n"
16  << "===============================\n";
17  }
18 }
19 
21 
23 {
24  return;
25 }
26 
28 {
29 
30  dbe = nullptr;
32 
33  if (dbe) {
34 
35  // monitoring element numerator and denominator histogram
36  MonitorElement *meN =
37  dbe->get("ConverterTest/TH1F/Random1DN");
38  MonitorElement *meD =
39  dbe->get("ConverterTest/TH1F/Random1DD");
40 
41  if (meN && meD) {
42 
43  // get the numerator and denominator histogram
44  TH1F *numerator = meN->getTH1F();
45  numerator->Sumw2();
46  TH1F *denominator = meD->getTH1F();
47  denominator->Sumw2();
48 
49  // set the current directory
50  dbe->setCurrentFolder("ConverterTest/TH1F");
51 
52  // booked the new histogram to contain the results
53  MonitorElement *me =
54  dbe->book1D("Divide","Divide calculation",
55  numerator->GetNbinsX(),
56  numerator->GetXaxis()->GetXmin(),
57  numerator->GetXaxis()->GetXmax());
58 
59  // Calculate the efficiency
60  me->getTH1F()->Divide(numerator, denominator, 1., 1., "B");
61 
62  } else {
63  std::cout << "Monitor elements don't exist" << std::endl;
64  }
65  } else {
66  std::cout << "Don't have a valid DQM back end" << std::endl;
67  }
68 
69  return;
70 }
71 
73  const edm::EventSetup& iSetup)
74 {
75  return;
76 }
77 
79  const edm::EventSetup& iSetup)
80 {
81  return;
82 }
83 
85  const edm::EventSetup& iSetup)
86 {
87  return;
88 }
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:1086
void beginJob() override
void beginRun(const edm::Run &, const edm::EventSetup &) override
void endJob() override
int iEvent
Definition: GenABIO.cc:230
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1601
void analyze(const edm::Event &, const edm::EventSetup &) override
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:565
~HarvestingAnalyzer() override
Definition: Run.h:44