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 
12 
15 //
16 // Original Author: Louis James Antonelli
17 // Created: Thu Jan 22 13:42:28CET 2009
18 //
19 
20 using namespace std;
21 
23 
24 {
25 
26 
27  parameters_ = pset;
28  verbose_ = parameters_.getParameter<bool>("verbose");
29 
30  if(verbose_) cout << ">>> Constructor (PhotonDataCertification) <<<" << endl;
31 
32 }
33 
34 
36 
37 
38 
39 // ------------ method called right after a run ends ------------
40 void
42 
43  using namespace RooFit;
44  if (verbose_) std::cout << ">>> endJob (PhotonDataCertification) <<<" << std::endl;
45 
46  //booking histograms according to naming conventions
47  ibooker.setCurrentFolder("Egamma/EventInfo/");
48  reportSummary_ = ibooker.bookFloat("reportSummary");
49  reportSummaryMap_ = ibooker.book2D("reportSummaryMap","reportSummaryMap",3,0,3,1,0,1);
50 
51  TH2F * reportSummaryMapTH2 = reportSummaryMap_->getTH2F();
52  reportSummaryMapTH2->GetXaxis()->SetBinLabel(1, "EB");
53  reportSummaryMapTH2->GetXaxis()->SetBinLabel(2, "EE");
54  reportSummaryMapTH2->GetXaxis()->SetBinLabel(3, "Total");
55  reportSummaryMapTH2->GetYaxis()->SetBinLabel(1, "InvMassTest");
56 
57  float EBResult = invMassZtest("Egamma/stdPhotonAnalyzer/InvMass/h_02_invMassIsoPhotonsEBarrel",
58  "invMassIsolatedPhotonsEB", igetter);
59 
60  float EEResult = invMassZtest("Egamma/stdPhotonAnalyzer/InvMass/h_03_invMassIsoPhotonsEEndcap",
61  "invMassIsolatedPhotonsEE", igetter);
62 
63  float AllResult = invMassZtest("Egamma/stdPhotonAnalyzer/InvMass/h_01_invMassAllIsolatedPhotons",
64  "invMassAllIsolatedPhotons", igetter);
65 
66  if (verbose_) {
67  std::cout << "EBResult: " << EBResult << std::endl;
68  std::cout << "EEResult: " << EEResult << std::endl;
69  std::cout << "AllResult: " << AllResult << std::endl;
70  }
71 
72  reportSummaryMapTH2->SetBinContent(1, 1, EBResult);
73  reportSummaryMapTH2->SetBinContent(2, 1, EEResult);
74  reportSummaryMapTH2->SetBinContent(3, 1, AllResult);
75  reportSummary_->Fill(AllResult);
76 }
77 
79  DQMStore::IGetter & igetter) {
80 
81  float ZMass = 91.2;
82  float ZWidth = 2.5;
83  MonitorElement *TestElem = 0;
84  TestElem = igetter.get(path);
85  if (TestElem == 0) return 0;
86  TH1F *TestHist = TestElem->getTH1F();
87  if (TestHist == 0) return 0;
88  RooRealVar mass("mass","Mass_{2#gamma}", 0, 200,"GeV");
89  RooRealVar mRes("M_{Z}", "Z Mass", ZMass, 70, 110);
90  RooRealVar gamma("#Gamma", "#Gamma", ZWidth, 0, 10.0);
91  RooBreitWigner BreitWigner("BreitWigner", "Breit-Wigner", mass, mRes, gamma);
92  RooDataHist test(name, name, mass, TestHist);
93 
94  BreitWigner.fitTo(test, RooFit::Range(80, 100));
95 
96  if (abs(mRes.getValV() - ZMass) < ZWidth) {
97  return 1.0;
98  } else if (abs(mRes.getValV() - ZMass) < gamma.getValV()) {
99  return 0.9;
100  } else {
101  return 0.0;
102  }
103 }
PhotonDataCertification(const edm::ParameterSet &pset)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
float invMassZtest(std::string path, TString name, DQMStore::IGetter &)
PixelRecoRange< float > Range
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
TH1F * getTH1F(void) const
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:109
TH2F * getTH2F(void) const
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override