CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTMuonCertSummary.cc
Go to the documentation of this file.
1 #include <iostream>
2 
3 
4 
7 //
8 // Original Author: Jason Slaunwhite
9 //
10 // Created: Thu Jan 22 13:42:28CET 2009
11 // $Id: HLTMuonCertSummary.cc,v 1.6 2010/07/20 02:58:28 wmtan Exp $
12 //
13 
14 // system include files
15 #include <memory>
16 #include <vector>
17 
19 //
25 
26 //root include files
27 #include "TFile.h"
28 #include "TH1.h"
29 #include "TH2.h"
30 #include "TTree.h"
31 #include "TVector3.h"
32 #include "TProfile.h"
33 //
34 
35 
36 // user include files
39 
41 
44 
45 
46 //DQM services
50 
51 
52 
53 using namespace std;
54 
55 
56 //
57 // class decleration
58 //
59 
61 
62  public:
63  explicit HLTMuonCertSummary(const edm::ParameterSet& pset);
65 
66 
67  virtual void beginJob() ;
68  virtual void analyze(const edm::Event&, const edm::EventSetup&);
69  virtual void endJob() ;
70  virtual void beginRun(const edm::Run&, const edm::EventSetup&) ;
71  virtual void endRun(const edm::Run&, const edm::EventSetup&) ;
72 
73 
74 
75  private:
76 
79 
80  bool verbose_;
81 
82  // ----------member data ---------------------------
83 };
84 
85 
86 
88 
89 {
90 
91  using namespace edm;
92  dbe_ = 0;
94  if (!dbe_) {
95  LogInfo ("DQMGenericClient") << "Can't find DQMStore, no results will be saved"
96  << endl;
97  } else {
98  dbe_->setVerbose(0);
99  }
100 
101  parameters_ = pset;
102  verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
103 
104  if(verbose_) LogInfo ("HLTMuonVal") << ">>> Constructor (HLTMuonCertSummary) <<<" << endl;
105 
106 }
107 
108 
110 {
111 }
112 
113 
114 //
115 // member functions
116 //
117 
118 // ------------ method called to for each event ------------
119 void
121 {
122  using namespace edm;
123 
124  if(verbose_) LogInfo ("HLTMuonVal") << ">>> Analyze (HLTMuonCertSummary) <<<" << std::endl;
125 
126 }
127 
128 // ------------ method called once each job just before starting event loop ------------
129 void
131 {
132 }
133 
134 // ------------ method called once each job just after ending the event loop ------------
135 void
137 {
138 }
139 
140 // ------------ method called just before starting a new run ------------
141 void
143 {
144 
145  using namespace edm;
146  if(verbose_) LogInfo ("HLTMuonVal") << ">>> BeginRun (HLTMuonCertSummary) <<<" << std::endl;
147  if(verbose_) LogInfo ("HLTMuonVal") << ">>> "<< run.id() << std::endl;
148 
149 }
150 
151 // ------------ method called right after a run ends ------------
152 void
154 {
155 
156  using namespace edm;
157  if(verbose_) LogInfo ("HLTMuonVal") << ">>> EndRun (HLTMuonCertSummary) <<<" << std::endl;
158 
159  if(!dbe_) {
160  LogInfo ("DQMGenericClient") << "No dqmstore... skipping processing step" << endl;
161  return;
162  }
163 
164  std::vector<string> histoNameVector;
165 
166 
167  //booking histograms according to naming conventions
168 
169 
170 
171  dbe_->setCurrentFolder("HLT/EventInfo/muonQuality");
172 
173  MonitorElement* reportSummary = dbe_->bookFloat("HLT_MUON_REPORT_SUMMARY");
174 
175  int SummaryBitResult = 100;
176 
177  MonitorElement* CertificationSummary = dbe_->bookFloat("HLT_MUON_CERTIFICATION_SUMMARY");
178 
179 
180 
181  //for now these will hold values from eta/phi tests for spikes/holes
182  MonitorElement* reportSummaryMap = dbe_->book2D("HLT_MUON_ReportSummaryMap","HLT_MUON: ReportSummaryMap",6,-0.5,5.5,1,-0.5,0.5);
183  MonitorElement* CertificationSummaryMap = dbe_->book2D("HLT_MUON_CertificationSummaryMap","HLT_MUON: CertificationSummaryMap",6,-0.5,5.5,1,-0.5,0.5);
184 
185  TH2 * reportSummaryMapTH2 = reportSummaryMap->getTH2F();
186 
187  reportSummaryMapTH2->GetXaxis()->SetBinLabel(1,"PhiEtaOccAll");
188  reportSummaryMapTH2->GetXaxis()->SetBinLabel(2,"PhiEtaOccMatch");
189  reportSummaryMapTH2->GetXaxis()->SetBinLabel(3,"PhiEtaEff");
190  reportSummaryMapTH2->GetXaxis()->SetBinLabel(4,"PhiEff");
191  reportSummaryMapTH2->GetXaxis()->SetBinLabel(5,"EtaEff");
192  reportSummaryMapTH2->GetXaxis()->SetBinLabel(6,"PtEff");
193 
194  reportSummaryMapTH2->GetYaxis()->SetBinLabel(1,"HLT_Mu5_allMuons");
195 
196 
197  TH2 * CertificationSummaryMapTH2 = CertificationSummaryMap->getTH2F();
198 
199  CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(1,"PhiEtaOccAll");
200  CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(2,"PhiEtaOccMatch");
201  CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(3,"PhiEtaEff");
202  CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(4,"PhiEff");
203  CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(5,"EtaEff");
204  CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(6,"PtEff");
205 
206  CertificationSummaryMapTH2->GetYaxis()->SetBinLabel(1,"HLT_Mu5_allMuons");
207 
208 
209  histoNameVector.push_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recPhiVsRecEta_All");
210  histoNameVector.push_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recPhiVsRecEta_L3Filtered");
211  histoNameVector.push_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recEffPhiVsEta_L3Filtered");
212  histoNameVector.push_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recEffPt_L3Filtered");
213  histoNameVector.push_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recEffPhi_L3Filtered");
214  histoNameVector.push_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recEffEta_L3Filtered");
215 
216  // to do: what do we want in certification contents?
217  // dbe_->setCurrentFolder("Egamma/EventInfo/CertificationContents/");
218 
219 
220  // //looping over histograms to be tested
221  if(verbose_) LogInfo ("HLTMuonVal") << "\n>>> looping over histograms to be tested <<<\n\n";
222 
223  for(std::vector<string>::iterator it=histoNameVector.begin();it!=histoNameVector.end();++it){
224 
225  string HistoName = (*it);
226  if(verbose_) LogInfo ("HLTMuonVal") << ">>> " << HistoName;
227 
228 
229  MonitorElement * TestHist=0;
230 
231  TestHist = dbe_->get(HistoName);
232 
233  bool validMe = TestHist!=0;
234  if(verbose_) LogInfo ("HLTMuonVal") << " is valid? " << validMe << "\n";
235  if(!validMe) continue;
236 
237  string histNameNoPath = TestHist->getName();
238 
239  if(verbose_) LogInfo ("HLTMuonVal") << ">>> TestHist Name: " << histNameNoPath << "\n\n";
240 
241 
242 
243  //get QReports associated to each ME
244  std::vector<QReport *> myQReports = TestHist->getQReports();
245  if(verbose_) LogInfo ("HLTMuonVal") << TestHist->getName() <<": myQReports.size() = " << myQReports.size() << "\n\n";
246  for(uint i=0;i!=myQReports.size();++i) {
247 
248  std::string qtname = myQReports[i]->getQRName() ; // get QT name
249  float qtresult = myQReports[i]->getQTresult(); // get QT result value
250  int qtstatus = myQReports[i]->getStatus() ; // get QT status value
251 
252  if(verbose_) LogInfo ("HLTMuonVal") << "\tTest " << i << ": qtname: " << qtname << "\n";
253  if(verbose_) LogInfo ("HLTMuonVal") << "\tTest " << i << ": qtresult: " << qtresult << std::endl;
254  if(verbose_) LogInfo ("HLTMuonVal") << "\tTest " << i << ": qtstatus: " << qtstatus << "\n\n";
255 
256 
257  //book and fill float for each test done
258  dbe_->setCurrentFolder("HLT/EventInfo/muonQuality/");
259  MonitorElement * qValueInt = dbe_->bookFloat(histNameNoPath+"_HLT_Mu5_"+qtname);
260  qValueInt->Fill(qtstatus);
261 
262  // We're assuming that you want all of the bits to go into the decision
263 
264 
265  if (HistoName.find("recPhiVsRecEta_All") != std::string::npos) {
266  reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(1,1), qtstatus);
267  CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(1,1), qtstatus );
268  if ( (qtstatus == 200) && (SummaryBitResult < 300)) SummaryBitResult = 200;
269  if ( (qtstatus == 300) ) SummaryBitResult = 300;
270 
271  }
272 
273  if (HistoName.find("recPhiVsRecEta_L3Filtered") != std::string::npos) {
274  reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(2,1), qtstatus);
275  CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(2,1), qtstatus);
276  if ( (qtstatus == 200) && (SummaryBitResult < 300)) SummaryBitResult = 200;
277  if (qtstatus == 300 ) SummaryBitResult = 300;
278 
279  }
280 
281  if (HistoName.find("recEffPhiVsEta_L3Filtered") != std::string::npos) {
282  reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(3,1), qtstatus );
283  CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(3,1), qtstatus);
284  if ( (qtstatus == 200) && (SummaryBitResult < 300)) SummaryBitResult = 200;
285  if (qtstatus == 300 ) SummaryBitResult = 300;
286  }
287 
288  if (HistoName.find("recEffPhi_L3Filtered") != std::string::npos) {
289  reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(4,1), qtstatus);
290  CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(4,1), qtstatus);
291  }
292 
293  if (HistoName.find("recEffEta_L3Filtered") != std::string::npos) {
294  reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(5,1), qtstatus);
295  CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(5,1), qtstatus);
296  }
297 
298  if (HistoName.find("recEffPt_L3Filtered") != std::string::npos) {
299  reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(6,1), qtstatus);
300  CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(6,1), qtstatus);
301  }
302 
303 
304  }
305  }
306 
307 
308  reportSummary->Fill(SummaryBitResult);
309  CertificationSummary->Fill(SummaryBitResult);
310 
311 
312 
313  // Set the final bits
314 
315  dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContents");
316  MonitorElement* muonHLTQualityBinaryBit = dbe_->bookFloat ("HLT_Muon");
317 
318  if (SummaryBitResult == 100){
319  muonHLTQualityBinaryBit->Fill(1);
320  } else {
321  muonHLTQualityBinaryBit->Fill(0);
322  }
323 
324 
325 
326 }
327 
328 
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
HLTMuonCertSummary(const edm::ParameterSet &pset)
RunID const & id() const
Definition: RunBase.h:41
virtual void endRun(const edm::Run &, const edm::EventSetup &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::ParameterSet parameters_
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:654
void beginJob()
Definition: Breakpoints.cc:15
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:243
virtual void analyze(const edm::Event &, const edm::EventSetup &)
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
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
std::string HistoName
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