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 
8 //
9 // Original Author: Louis James Antonelli
10 // Created: Thu Jan 22 13:42:28CET 2009
11 // $Id: PhotonDataCertification.cc,v 1.1 2011/04/08 15:55:00 chamont Exp $
12 //
13 
14 
15 
16 
17 using namespace std;
18 
20 
21 {
22 
23  dbe_ = 0;
25  dbe_->setVerbose(0);
26  parameters_ = pset;
27  verbose_ = parameters_.getParameter<bool>("verbose");
28 
29  if(verbose_) cout << ">>> Constructor (PhotonDataCertification) <<<" << endl;
30 
31 }
32 
33 
35 {
36 }
37 
38 
39 //
40 // member functions
41 //
42 
43 // ------------ method called to for each event ------------
44 void
46 {
47  using namespace edm;
48 
49  if(verbose_) std::cout << ">>> Analyze (PhotonDataCertification) <<<" << std::endl;
50 
51 }
52 
53 // ------------ method called once each job just before starting event loop ------------
54 void
56 {
57 }
58 
59 // ------------ method called once each job just after ending the event loop ------------
60 void
62 {
63 }
64 
65 // ------------ method called just before starting a new run ------------
66 void
68 {
69 
70  if(verbose_) std::cout << ">>> BeginRun (PhotonDataCertification) <<<" << std::endl;
71  if(verbose_) std::cout << ">>> "<< run.id() << std::endl;
72 
73 }
74 
75 // ------------ method called right after a run ends ------------
76 void
78 {
79  if(verbose_) std::cout << ">>> EndRun (PhotonDataCertification) <<<" << std::endl;
80 
81  std::vector<string> histoNameVector;
82 
83 
84  //booking histograms according to naming conventions
85 
86  if(!dbe_) return;
87 
88  dbe_->setCurrentFolder("Egamma/EventInfo/");
89 
90  MonitorElement* reportSummary = dbe_->bookFloat("reportSummary");
91  MonitorElement* CertificationSummary = dbe_->bookFloat("CertificationSummary");
92 
93  //for now these will hold values from eta/phi tests for spikes/holes
94  MonitorElement* reportSummaryMap = dbe_->book2D("reportSummaryMap","reportSummaryMap",2,0,2,2,0,2);
95  MonitorElement* CertificationSummaryMap = dbe_->book2D("CertificationSummaryMap","CertificationSummaryMap",2,0,2,2,0,2);
96 
97  TH2 * reportSummaryMapTH2 = reportSummaryMap->getTH2F();
98 
99  reportSummaryMapTH2->GetXaxis()->SetBinLabel(1,"Eta");
100  reportSummaryMapTH2->GetXaxis()->SetBinLabel(2,"Phi");
101  reportSummaryMapTH2->GetYaxis()->SetBinLabel(1,"SpikeTest");
102  reportSummaryMapTH2->GetYaxis()->SetBinLabel(2,"HoleTest");
103 
104  TH2 * CertificationSummaryMapTH2 = CertificationSummaryMap->getTH2F();
105 
106  CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(1,"Eta");
107  CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(2,"Phi");
108  CertificationSummaryMapTH2->GetYaxis()->SetBinLabel(1,"SpikeTest");
109  CertificationSummaryMapTH2->GetYaxis()->SetBinLabel(2,"HoleTest");
110 
111 
112 
113  //histograms to be tested and results put into Egamma/EventInfo/reportSummaryContents
114  histoNameVector.push_back("nPhoAllEcal");
115  histoNameVector.push_back("r9AllEcal");
116  histoNameVector.push_back("phoEta");
117  histoNameVector.push_back("phoPhi");
118 
119 
120 // histoNameVector.push_back("phoEtAllEcal");
121 // histoNameVector.push_back("EfficiencyVsEtHLT");
122 // histoNameVector.push_back("EfficiencyVsEtaHLT");
123 // histoNameVector.push_back("EfficiencyVsEtLoose");
124 // histoNameVector.push_back("EfficiencyVsEtaLoose");
125 
126 
127  // to do: what do we want in certification contents?
128  // dbe_->setCurrentFolder("Egamma/EventInfo/CertificationContents/");
129 
130 
131  //looping over histograms to be tested
132  if(verbose_) std::cout << "\n>>> looping over histograms to be tested <<<\n\n";
133  for(std::vector<string>::iterator it=histoNameVector.begin();it!=histoNameVector.end();++it){
134 
135  string HistoName = (*it);
136  if(verbose_) std::cout << ">>> " << HistoName;
137 
138  MonitorElement * TestHist=0;
139 
140  if(HistoName.find("Efficiency")!=std::string::npos){
141  TestHist = dbe_->get("Egamma/PhotonAnalyzer/Efficiencies/"+HistoName);
142  }
143  else{
144  TestHist = dbe_->get("Egamma/PhotonAnalyzer/GoodCandidatePhotons/Et above 0 GeV/"+HistoName);
145  }
146  bool validMe = TestHist!=0;
147  if(verbose_) std::cout << " is valid? " << validMe << "\n";
148  if(!validMe) continue;
149 
150  if(verbose_) std::cout << ">>> TestHist Name: " << TestHist->getName() << "\n\n";
151 
152 
153 
154  //get QReports associated to each ME
155  std::vector<QReport *> myQReports = TestHist->getQReports();
156  if(verbose_) cout << TestHist->getName() <<": myQReports.size() = " << myQReports.size() << "\n\n";
157  for(uint i=0;i!=myQReports.size();++i) {
158 
159  std::string qtname = myQReports[i]->getQRName() ; // get QT name
160  float qtresult = myQReports[i]->getQTresult(); // get QT result value
161  int qtstatus = myQReports[i]->getStatus() ; // get QT status value
162 
163  if(verbose_) std::cout << "\tTest " << i << ": qtname: " << qtname << "\n";
164  if(verbose_) std::cout << "\tTest " << i << ": qtresult: " << qtresult << std::endl;
165  if(verbose_) std::cout << "\tTest " << i << ": qtstatus: " << qtstatus << "\n\n";
166 
167 
168  //book and fill float for each test done
169  dbe_->setCurrentFolder("Egamma/EventInfo/reportSummaryContents/");
170  MonitorElement * Float = dbe_->bookFloat(HistoName+"_"+qtname);
171  Float->Fill(qtresult);
172 
173  }
174  }
175 
176 
177 
178  //filling summaries based on geometric spikes/holes
179 
180  float etaSpikeTestResult=0;
181  float phiSpikeTestResult=0;
182  float etaHoleTestResult=0;
183  float phiHoleTestResult=0;
184 
185  if(dbe_->get("Egamma/EventInfo/reportSummaryContents/phoEta_SpikeTest")!=0)
186  etaSpikeTestResult = dbe_->get("Egamma/EventInfo/reportSummaryContents/phoEta_SpikeTest")->getFloatValue();
187  else etaSpikeTestResult = -1;
188 
189  if(dbe_->get("Egamma/EventInfo/reportSummaryContents/phoPhi_SpikeTest")!=0)
190  phiSpikeTestResult = dbe_->get("Egamma/EventInfo/reportSummaryContents/phoPhi_SpikeTest")->getFloatValue();
191  else phiSpikeTestResult = -1;
192 
193  if(dbe_->get("Egamma/EventInfo/reportSummaryContents/phoEta_HoleTest")!=0)
194  etaHoleTestResult = dbe_->get("Egamma/EventInfo/reportSummaryContents/phoEta_HoleTest")->getFloatValue();
195  else etaHoleTestResult = -1;
196 
197  if(dbe_->get("Egamma/EventInfo/reportSummaryContents/phoPhi_HoleTest")!=0)
198  phiHoleTestResult = dbe_->get("Egamma/EventInfo/reportSummaryContents/phoPhi_HoleTest")->getFloatValue();
199  else phiHoleTestResult = -1;
200 
201 
202 
203  if(verbose_) std::cout << ">>> Results of tests to be put into Summary Maps <<<\n\n";
204  if(verbose_) std::cout << "\tetaSpikeTestResult= " << etaSpikeTestResult << "\n";
205  if(verbose_) std::cout << "\tphiSpikeTestResult= " << phiSpikeTestResult << "\n";
206  if(verbose_) std::cout << "\tetaHoleTestResult= " << etaHoleTestResult << "\n";
207  if(verbose_) std::cout << "\tphiHoleTestResult= " << phiHoleTestResult << "\n\n";
208 
209 
210  //fill reportSummary & CertificationSummary with average of hole/spike tests
211  float reportSummaryFloat = (etaSpikeTestResult+etaHoleTestResult+phiSpikeTestResult+phiHoleTestResult)/4.;
212  if(reportSummaryFloat<0) reportSummaryFloat = -1;
213  reportSummary->Fill(reportSummaryFloat);
214  CertificationSummary->Fill(reportSummaryFloat);
215 
216  reportSummaryMap->Fill(0,0,etaSpikeTestResult);
217  reportSummaryMap->Fill(0,1,etaHoleTestResult);
218  reportSummaryMap->Fill(1,0,phiSpikeTestResult);
219  reportSummaryMap->Fill(1,1,phiHoleTestResult);
220 
221  CertificationSummaryMap->Fill(0,0,etaSpikeTestResult);
222  CertificationSummaryMap->Fill(0,1,etaHoleTestResult);
223  CertificationSummaryMap->Fill(1,0,phiSpikeTestResult);
224  CertificationSummaryMap->Fill(1,1,phiHoleTestResult);
225 
226 
227 
228 
229 }
T getParameter(std::string const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
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:654
void Fill(long long x)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:243
virtual void endRun(const edm::Run &, const edm::EventSetup &)
double getFloatValue(void) const
void setVerbose(unsigned level)
Definition: DQMStore.cc:393
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
DQMStore * dbe_
std::vector< QReport * > getQReports(void) const
get map of QReports
std::string HistoName
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:845
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33