CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
40 //
41 // member functions
42 //
43 
44 // ------------ method called to for each event ------------
45 void
47 {
48  //if(verbose_) std::cout << ">>> Analyze (PhotonDataCertification) <<<" << std::endl;
49 
50 }
51 
52 // ------------ method called once each job just before starting event loop ------------
53 void
55 {
56  dbe_ = 0;
58  dbe_->setVerbose(0);
59 }
60 
61 // ------------ method called once each job just after ending the event loop ------------
62 void
64 {
65 }
66 
67 // ------------ method called just before starting a new run ------------
68 void
70 {
71 
72  if(verbose_) std::cout << ">>> BeginRun (PhotonDataCertification) <<<" << std::endl;
73  if(verbose_) std::cout << ">>> "<< run.id() << std::endl;
74 
75 }
76 
77 // ------------ method called right after a run ends ------------
78 void
80 {
81  using namespace RooFit;
82  if(verbose_) std::cout << ">>> EndRun (PhotonDataCertification) <<<" << std::endl;
83  if(!dbe_) return;
84 
85  //booking histograms according to naming conventions
86  dbe_->setCurrentFolder("Egamma/EventInfo/");
87  reportSummary_ = dbe_->bookFloat("reportSummary");
88  reportSummaryMap_ = dbe_->book2D("reportSummaryMap","reportSummaryMap",3,0,3,1,0,1);
89 
90  TH2F * reportSummaryMapTH2 = reportSummaryMap_->getTH2F();
91  reportSummaryMapTH2->GetXaxis()->SetBinLabel(1,"EB");
92  reportSummaryMapTH2->GetXaxis()->SetBinLabel(2,"EE");
93  reportSummaryMapTH2->GetXaxis()->SetBinLabel(3,"Total");
94  reportSummaryMapTH2->GetYaxis()->SetBinLabel(1,"InvMassTest");
95 
96  float EBResult = invMassZtest("Egamma/PhotonAnalyzer/InvMass/h_02_invMassIsoPhotonsEBarrel","invMassIsolatedPhotonsEB");
97  float EEResult = invMassZtest("Egamma/PhotonAnalyzer/InvMass/h_03_invMassIsoPhotonsEEndcap","invMassIsolatedPhotonsEE");
98  float AllResult = invMassZtest("Egamma/PhotonAnalyzer/InvMass/h_01_invMassAllIsolatedPhotons","invMassAllIsolatedPhotons");
99 
100  if(verbose_){
101  std::cout << "EBResult: " << EBResult << std::endl;
102  std::cout << "EEResult: " << EEResult << std::endl;
103  std::cout << "AllResult: " << AllResult << std::endl;
104  }
105 
106  reportSummaryMapTH2->SetBinContent(1, 1, EBResult);
107  reportSummaryMapTH2->SetBinContent(2, 1, EEResult);
108  reportSummaryMapTH2->SetBinContent(3, 1, AllResult);
109  reportSummary_->Fill(AllResult);
110 
111 }
112 
114  float ZMass = 91.2;
115  float ZWidth = 2.5;
116  MonitorElement *TestElem=0;
117  TestElem = dbe_->get(path);
118  if(TestElem==0) return 0;
119  TH1F *TestHist = TestElem->getTH1F();
120  if(TestHist==0) return 0;
121  RooRealVar mass("mass","Mass_{2#gamma}", 0, 200,"GeV");
122  RooRealVar mRes("M_{Z}", "Z Mass", ZMass, 70, 110);
123  RooRealVar gamma("#Gamma", "#Gamma", ZWidth, 0, 10.0);
124  RooBreitWigner BreitWigner("BreitWigner","Breit-Wigner",mass,mRes,gamma);
125  RooDataHist test(name, name, mass, TestHist);
126 
127  BreitWigner.fitTo(test, RooFit::Range(80,100));
128 
129  if(abs(mRes.getValV() - ZMass) < ZWidth){return 1.0;}
130  else if(abs(mRes.getValV() - ZMass) < gamma.getValV()){return 0.9;}
131  else{return 0.0;}
132 
133 }
T getParameter(std::string const &) const
RunID const & id() const
Definition: RunBase.h:41
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
PhotonDataCertification(const edm::ParameterSet &pset)
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:891
virtual void analyze(const edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
tuple path
else: Piece not in the list, fine.
virtual void endRun(const edm::Run &, const edm::EventSetup &)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setVerbose(unsigned level)
Definition: DQMStore.cc:631
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1708
DQMStore * dbe_
PixelRecoRange< float > Range
float invMassZtest(std::string path, TString name)
TH1F * getTH1F(void) const
tuple cout
Definition: gather_cfg.py:121
TH2F * getTH2F(void) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1082
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
Definition: Run.h:41