CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MuonRecoTest.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * \author G. Mila - INFN Torino
6  */
7 
9 
10 // Framework
17 
21 
22 #include <iostream>
23 #include <cstdio>
24 #include <string>
25 #include <cmath>
26 #include "TF1.h"
27 
28 using namespace edm;
29 using namespace std;
30 
32  parameters = ps;
33 
34  prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 1);
35 
36  // Parameters
37  etaBin = parameters.getParameter<int>("etaBin");
38  etaMin = parameters.getParameter<double>("etaMin");
39  etaMax = parameters.getParameter<double>("etaMax");
40 
41  phiBin = parameters.getParameter<int>("phiBin");
42  phiMin = parameters.getParameter<double>("phiMin");
43  phiMax = parameters.getParameter<double>("phiMax");
44 
45  EfficiencyCriterionName = parameters.getUntrackedParameter<string>("efficiencyTestName", "EfficiencyInRange");
46 }
47 
49  DQMStore::IGetter& igetter,
50  edm::Run const&,
51  edm::EventSetup const&) {
52  // efficiency plot
53  ibooker.setCurrentFolder("Muons/Tests/muonRecoTest");
54  etaEfficiency = ibooker.book1D("etaEfficiency_staMuon", "#eta_{STA} efficiency", etaBin, etaMin, etaMax);
55  phiEfficiency = ibooker.book1D("phiEfficiency_staMuon", "#phi_{STA} efficiency", phiBin, phiMin, phiMax);
56 
58  string path = "Muons/MuonRecoAnalyzer/StaEta_ifCombinedAlso";
59  MonitorElement* staEtaIfComb_histo = igetter.get(path);
60  path = "Muons/MuonRecoAnalyzer/StaEta";
61  MonitorElement* staEta_histo = igetter.get(path);
62 
63  if (staEtaIfComb_histo && staEta_histo) {
64  TH1F* staEtaIfComb_root = staEtaIfComb_histo->getTH1F();
65  TH1F* staEta_root = staEta_histo->getTH1F();
66 
67  if (staEtaIfComb_root->GetXaxis()->GetNbins() != etaBin || staEtaIfComb_root->GetXaxis()->GetXmax() != etaMax ||
68  staEtaIfComb_root->GetXaxis()->GetXmin() != etaMin) {
69  LogTrace(metname) << "[MuonRecoTest] wrong histo binning on eta histograms";
70  return;
71  }
72 
73  for (int i = 1; i <= etaBin; i++) {
74  if (staEta_root->GetBinContent(i) != 0) {
75  double efficiency = double(staEtaIfComb_root->GetBinContent(i)) / double(staEta_root->GetBinContent(i));
76  etaEfficiency->setBinContent(i, efficiency);
77  }
78  }
79  }
80 
81  path = "Muons/MuonRecoAnalyzer/StaPhi_ifCombinedAlso";
82  MonitorElement* staPhiIfComb_histo = igetter.get(path);
83  path = "Muons/MuonRecoAnalyzer/StaPhi";
84  MonitorElement* staPhi_histo = igetter.get(path);
85 
86  if (staPhiIfComb_histo && staPhi_histo) {
87  TH1F* staPhiIfComb_root = staPhiIfComb_histo->getTH1F();
88  TH1F* staPhi_root = staPhi_histo->getTH1F();
89 
90  if (staPhiIfComb_root->GetXaxis()->GetNbins() != phiBin || staPhiIfComb_root->GetXaxis()->GetXmax() != phiMax ||
91  staPhiIfComb_root->GetXaxis()->GetXmin() != phiMin) {
92  LogTrace(metname) << "[MuonRecoTest] wrong histo binning on phi histograms";
93  return;
94  }
95 
96  for (int i = 1; i <= etaBin; i++) {
97  if (staPhi_root->GetBinContent(i) != 0) {
98  double efficiency = double(staPhiIfComb_root->GetBinContent(i)) / double(staPhi_root->GetBinContent(i));
99  phiEfficiency->setBinContent(i, efficiency);
100  }
101  }
102  }
103 }
104 
107  ibooker.setCurrentFolder("Muons/Tests/muonRecoTest");
108  // alignment plots
109  globalRotation.push_back(ibooker.book1D(
110  "muVStkSytemRotation_posMu_profile", "pT_{TK} / pT_{GLB} vs pT_{GLB} profile for #mu^{+}", 50, 0, 200));
111  globalRotation.push_back(ibooker.book1D(
112  "muVStkSytemRotation_negMu_profile", "pT_{TK} / pT_{GLB} vs pT_{GLB} profile for #mu^{-}", 50, 0, 200));
113  globalRotation.push_back(ibooker.book1D(
114  "muVStkSytemRotation_profile", "pT_{TK} / pT_{GLB} vs pT_{GLB} profile for #mu^{+}-#mu^{-}", 50, 0, 200));
115 
116  // efficiency test
117 
118  // eta efficiency
119  const QReport* theEtaQReport = etaEfficiency->getQReport(EfficiencyCriterionName);
120  if (theEtaQReport) {
121  vector<dqm::me_util::Channel> badChannels = theEtaQReport->getBadChannels();
122  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
123  channel++) {
124  LogTrace(metname) << "[etaEfficiency test] bad ranges: " << (*channel).getBin()
125  << " Contents : " << (*channel).getContents() << endl;
126  }
127  LogTrace(metname) << "-------- type: [etaEfficiency] " << theEtaQReport->getMessage() << " ------- "
128  << theEtaQReport->getStatus() << endl;
129  }
130  // phi efficiency
131  const QReport* thePhiQReport = phiEfficiency->getQReport(EfficiencyCriterionName);
132  if (thePhiQReport) {
133  vector<dqm::me_util::Channel> badChannels = thePhiQReport->getBadChannels();
134  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
135  channel++) {
136  LogTrace(metname) << "[phiEfficiency test] bad ranges: " << (*channel).getBin()
137  << " Contents : " << (*channel).getContents() << endl;
138  }
139  LogTrace(metname) << "-------- type: [phiEfficiency] " << thePhiQReport->getMessage() << " ------- "
140  << thePhiQReport->getStatus() << endl;
141  }
142 
143  //alignment plot
144  string pathPos = "Muons/MuonRecoAnalyzer/muVStkSytemRotation_posMu";
145  MonitorElement* muVStkSytemRotation_posMu_histo = igetter.get(pathPos);
146  string pathNeg = "Muons/MuonRecoAnalyzer/muVStkSytemRotation_negMu";
147  MonitorElement* muVStkSytemRotation_negMu_histo = igetter.get(pathNeg);
148  if (muVStkSytemRotation_posMu_histo && muVStkSytemRotation_negMu_histo) {
149  TH2F* muVStkSytemRotation_posMu_root = muVStkSytemRotation_posMu_histo->getTH2F();
150  TProfile* muVStkSytemRotation_posMu_profile = muVStkSytemRotation_posMu_root->ProfileX("", 1, 100);
151  TH2F* muVStkSytemRotation_negMu_root = muVStkSytemRotation_negMu_histo->getTH2F();
152  TProfile* muVStkSytemRotation_negMu_profile = muVStkSytemRotation_negMu_root->ProfileX("", 1, 100);
153 
154  for (int x = 1; x < 50; x++) {
155  globalRotation[0]->Fill((x * 4) - 1, muVStkSytemRotation_posMu_profile->GetBinContent(x));
156  globalRotation[0]->setBinError(x, muVStkSytemRotation_posMu_profile->GetBinError(x));
157  globalRotation[1]->Fill((x * 4) - 1, muVStkSytemRotation_negMu_profile->GetBinContent(x));
158  globalRotation[1]->setBinError(x, muVStkSytemRotation_negMu_profile->GetBinError(x));
159  globalRotation[2]->Fill(
160  (x * 4) - 1,
161  muVStkSytemRotation_posMu_profile->GetBinContent(x) - muVStkSytemRotation_negMu_profile->GetBinContent(x));
162  globalRotation[2]->setBinError(
163  x,
164  sqrt(
165  (muVStkSytemRotation_posMu_profile->GetBinError(x) * muVStkSytemRotation_posMu_profile->GetBinError(x)) +
166  (muVStkSytemRotation_negMu_profile->GetBinError(x) * muVStkSytemRotation_negMu_profile->GetBinError(x))));
167  }
168  }
169 }
virtual TH2F * getTH2F() const
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
const std::string metname
virtual TH1F * getTH1F() const
tuple etaMin
Definition: Puppi_cff.py:46
#define LogTrace(id)
int getStatus() const
get test status
void dqmEndRun(DQMStore::IBooker &, DQMStore::IGetter &, edm::Run const &, edm::EventSetup const &) override
Endjob.
Definition: MuonRecoTest.cc:48
const std::string & getMessage() const
get message attached to test
T sqrt(T t)
Definition: SSEVec.h:19
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
const std::vector< DQMChannel > & getBadChannels() const
MuonRecoTest(const edm::ParameterSet &ps)
Constructor.
Definition: MuonRecoTest.cc:31
float x
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
tuple etaMax
Definition: Puppi_cff.py:47
int etaBin(const l1t::HGCalMulticluster *cl)
Definition: Run.h:45