CMS 3D CMS Logo

PhotonDataCertification.cc
Go to the documentation of this file.
1 #include <iostream>
2 
5 #include "RooGlobalFunc.h"
6 #include "RooRealVar.h"
7 #include "RooDataSet.h"
8 #include "RooBreitWigner.h"
9 #include "RooDataHist.h"
10 #include "RooFitResult.h"
11 
14 //
15 // Original Author: Louis James Antonelli
16 // Created: Thu Jan 22 13:42:28CET 2009
17 //
18 
19 using namespace std;
20 
22 
23 {
24  parameters_ = pset;
25  verbose_ = parameters_.getParameter<bool>("verbose");
26 
27  if (verbose_)
28  cout << ">>> Constructor (PhotonDataCertification) <<<" << endl;
29 }
30 
32 
33 // ------------ method called right after a run ends ------------
35  using namespace RooFit;
36  if (verbose_)
37  std::cout << ">>> endJob (PhotonDataCertification) <<<" << std::endl;
38 
39  //booking histograms according to naming conventions
40  ibooker.setCurrentFolder("Egamma/EventInfo/");
41  reportSummary_ = ibooker.bookFloat("reportSummary");
42  reportSummaryMap_ = ibooker.book2D("reportSummaryMap", "reportSummaryMap", 3, 0, 3, 1, 0, 1);
43 
44  TH2F* reportSummaryMapTH2 = reportSummaryMap_->getTH2F();
45  reportSummaryMapTH2->GetXaxis()->SetBinLabel(1, "EB");
46  reportSummaryMapTH2->GetXaxis()->SetBinLabel(2, "EE");
47  reportSummaryMapTH2->GetXaxis()->SetBinLabel(3, "Total");
48  reportSummaryMapTH2->GetYaxis()->SetBinLabel(1, "InvMassTest");
49 
50  float EBResult = invMassZtest(
51  "Egamma/stdPhotonAnalyzer/InvMass/h_02_invMassIsoPhotonsEBarrel", "invMassIsolatedPhotonsEB", igetter);
52 
53  float EEResult = invMassZtest(
54  "Egamma/stdPhotonAnalyzer/InvMass/h_03_invMassIsoPhotonsEEndcap", "invMassIsolatedPhotonsEE", igetter);
55 
56  float AllResult = invMassZtest(
57  "Egamma/stdPhotonAnalyzer/InvMass/h_01_invMassAllIsolatedPhotons", "invMassAllIsolatedPhotons", igetter);
58 
59  if (verbose_) {
60  std::cout << "EBResult: " << EBResult << std::endl;
61  std::cout << "EEResult: " << EEResult << std::endl;
62  std::cout << "AllResult: " << AllResult << std::endl;
63  }
64 
65  reportSummaryMapTH2->SetBinContent(1, 1, EBResult);
66  reportSummaryMapTH2->SetBinContent(2, 1, EEResult);
67  reportSummaryMapTH2->SetBinContent(3, 1, AllResult);
68  reportSummary_->Fill(AllResult);
69 }
70 
72  float ZMass = 91.2;
73  float ZWidth = 2.5;
74  MonitorElement* TestElem = nullptr;
75  TestElem = igetter.get(path);
76  if (TestElem == nullptr)
77  return 0;
78  TH1F* TestHist = TestElem->getTH1F();
79  if (TestHist == nullptr)
80  return 0;
81  RooMsgService::instance().setGlobalKillBelow(RooFit::WARNING);
82  RooRealVar mass("mass", "Mass_{2#gamma}", 0, 200, "GeV");
83  RooRealVar mRes("M_{Z}", "Z Mass", ZMass, 70, 110);
84  RooRealVar gamma("#Gamma", "#Gamma", ZWidth, 0, 10.0);
85  RooBreitWigner BreitWigner("BreitWigner", "Breit-Wigner", mass, mRes, gamma);
86  RooDataHist test(name, name, mass, TestHist);
87 
88  BreitWigner.fitTo(test, RooFit::Range(80, 100), RooFit::PrintLevel(-1000));
89 
90  if (std::abs(mRes.getValV() - ZMass) < ZWidth) {
91  return 1.0;
92  } else if (std::abs(mRes.getValV() - ZMass) < gamma.getValV()) {
93  return 0.9;
94  } else {
95  return 0.0;
96  }
97 }
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
static PFTauRenderPlugin instance
PixelRecoRange< float > Range
PhotonDataCertification(const edm::ParameterSet &pset)
float invMassZtest(std::string path, TString name, DQMStore::IGetter &)
virtual TH2F * getTH2F() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual TH1F * getTH1F() const
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override