CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
8 
10 
11 // Framework
18 
19 
24 
25 #include <iostream>
26 #include <stdio.h>
27 #include <string>
28 #include <math.h>
29 #include "TF1.h"
30 
31 using namespace edm;
32 using namespace std;
33 
34 
36 
37  parameters = ps;
38 
39  theDbe = edm::Service<DQMStore>().operator->();
40 
41  prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 1);
42 
43 }
44 
45 
47 
48  LogTrace(metname) << "MuonRecoTest: analyzed " << nevents << " events";
49 
50 }
51 
52 
54 
55  metname = "muonRecoTest";
56  theDbe->setCurrentFolder("Muons/Tests/muonRecoTest");
57 
58  LogTrace(metname)<<"[MuonRecoTest] beginJob: Parameters initialization";
59 
60  // efficiency plot
61 
62  etaBin = parameters.getParameter<int>("etaBin");
63  etaMin = parameters.getParameter<double>("etaMin");
64  etaMax = parameters.getParameter<double>("etaMax");
65  etaEfficiency = theDbe->book1D("etaEfficiency_staMuon", "#eta_{STA} efficiency", etaBin, etaMin, etaMax);
66 
67  phiBin = parameters.getParameter<int>("phiBin");
68  phiMin = parameters.getParameter<double>("phiMin");
69  phiMax = parameters.getParameter<double>("phiMax");
70  phiEfficiency = theDbe->book1D("phiEfficiency_staMuon", "#phi_{STA} efficiency", phiBin, phiMin, phiMax);
71 
72  // alignment plots
73  globalRotation.push_back(theDbe->book1D("muVStkSytemRotation_posMu_profile", "pT_{TK} / pT_{GLB} vs pT_{GLB} profile for #mu^{+}",50,0,200));
74  globalRotation.push_back(theDbe->book1D("muVStkSytemRotation_negMu_profile", "pT_{TK} / pT_{GLB} vs pT_{GLB} profile for #mu^{-}",50,0,200));
75  globalRotation.push_back(theDbe->book1D("muVStkSytemRotation_profile", "pT_{TK} / pT_{GLB} vs pT_{GLB} profile for #mu^{+}-#mu^{-}",50,0,200));
76 
77 }
78 
79 void MuonRecoTest::beginRun(Run const& run, EventSetup const& eSetup) {
80 
81  LogTrace(metname)<<"[MuonRecoTest]: beginRun";
82 
83 }
84 
85 void MuonRecoTest::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
86 
87  // LogTrace(metname)<<"[MuonRecoTest]: beginLuminosityBlock";
88 
89  // Get the run number
90  run = lumiSeg.run();
91 
92 }
93 
94 
95 void MuonRecoTest::analyze(const edm::Event& e, const edm::EventSetup& context){
96 
97  nevents++;
98  LogTrace(metname)<< "[MuonRecoTest]: "<<nevents<<" events";
99 
100 }
101 
102 
103 
104 void MuonRecoTest::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
105 
106  // LogTrace(metname)<<"[MuonRecoTest]: endLuminosityBlock, performing the DQM LS client operation";
107 
108  // counts number of lumiSegs
109  nLumiSegs = lumiSeg.id().luminosityBlock();
110 
111  // prescale factor
112  if ( nLumiSegs%prescaleFactor != 0 ) return;
113 
114 }
115 
116 void MuonRecoTest::endRun(Run const& run, EventSetup const& eSetup) {
117 
118  LogTrace(metname)<<"[MuonRecoTest]: endRun, performing the DQM end of run client operation";
119 
120  string path = "Muons/MuonRecoAnalyzer/StaEta_ifCombinedAlso";
121  MonitorElement * staEtaIfComb_histo = theDbe->get(path);
122  path = "Muons/MuonRecoAnalyzer/StaEta";
123  MonitorElement * staEta_histo = theDbe->get(path);
124 
125  if(staEtaIfComb_histo && staEta_histo){
126  TH1F * staEtaIfComb_root = staEtaIfComb_histo->getTH1F();
127  TH1F * staEta_root = staEta_histo->getTH1F();
128 
129  if(staEtaIfComb_root->GetXaxis()->GetNbins()!=etaBin
130  || staEtaIfComb_root->GetXaxis()->GetXmax()!=etaMax
131  || staEtaIfComb_root->GetXaxis()->GetXmin()!=etaMin){
132  LogTrace(metname)<<"[MuonRecoTest] wrong histo binning on eta histograms";
133  return;
134  }
135 
136  for(int i=1; i<=etaBin; i++){
137  if(staEta_root->GetBinContent(i)!=0){
138  double efficiency = double(staEtaIfComb_root->GetBinContent(i))/double(staEta_root->GetBinContent(i));
139  etaEfficiency->setBinContent(i,efficiency);
140  }
141  }
142  }
143 
144  path = "Muons/MuonRecoAnalyzer/StaPhi_ifCombinedAlso";
145  MonitorElement * staPhiIfComb_histo = theDbe->get(path);
146  path = "Muons/MuonRecoAnalyzer/StaPhi";
147  MonitorElement * staPhi_histo = theDbe->get(path);
148 
149  if(staPhiIfComb_histo && staPhi_histo){
150 
151  TH1F * staPhiIfComb_root = staPhiIfComb_histo->getTH1F();
152  TH1F * staPhi_root = staPhi_histo->getTH1F();
153 
154  if(staPhiIfComb_root->GetXaxis()->GetNbins()!=phiBin
155  || staPhiIfComb_root->GetXaxis()->GetXmax()!=phiMax
156  || staPhiIfComb_root->GetXaxis()->GetXmin()!=phiMin){
157  LogTrace(metname)<<"[MuonRecoTest] wrong histo binning on phi histograms";
158  return;
159  }
160 
161  for(int i=1; i<=etaBin; i++){
162  if(staPhi_root->GetBinContent(i)!=0){
163  double efficiency = double(staPhiIfComb_root->GetBinContent(i))/double(staPhi_root->GetBinContent(i));
164  phiEfficiency->setBinContent(i,efficiency);
165  }
166  }
167  }
168 
169 
170  // efficiency test
171  string EfficiencyCriterionName = parameters.getUntrackedParameter<string>("efficiencyTestName","EfficiencyInRange");
172 
173  // eta efficiency
174  const QReport * theEtaQReport = etaEfficiency->getQReport(EfficiencyCriterionName);
175  if(theEtaQReport) {
176  vector<dqm::me_util::Channel> badChannels = theEtaQReport->getBadChannels();
177  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
178  channel != badChannels.end(); channel++) {
179  LogTrace(metname)<<"[etaEfficiency test] bad ranges: "<<(*channel).getBin()<<" Contents : "<<(*channel).getContents()<<endl;
180  }
181  LogTrace(metname)<< "-------- type: [etaEfficiency] "<<theEtaQReport->getMessage()<<" ------- "<<theEtaQReport->getStatus()<<endl;
182  }
183  // phi efficiency
184  const QReport * thePhiQReport = phiEfficiency->getQReport(EfficiencyCriterionName);
185  if(thePhiQReport) {
186  vector<dqm::me_util::Channel> badChannels = thePhiQReport->getBadChannels();
187  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
188  channel != badChannels.end(); channel++) {
189  LogTrace(metname)<< "[phiEfficiency test] bad ranges: "<<(*channel).getBin()<<" Contents : "<<(*channel).getContents()<<endl;
190  }
191  LogTrace(metname)<<"-------- type: [phiEfficiency] "<<thePhiQReport->getMessage()<<" ------- "<<thePhiQReport->getStatus()<<endl;
192  }
193 
194  //alignment plot
195  string pathPos = "Muons/MuonRecoAnalyzer/muVStkSytemRotation_posMu";
196  MonitorElement * muVStkSytemRotation_posMu_histo = theDbe->get(pathPos);
197  string pathNeg = "Muons/MuonRecoAnalyzer/muVStkSytemRotation_negMu";
198  MonitorElement * muVStkSytemRotation_negMu_histo = theDbe->get(pathNeg);
199  if(muVStkSytemRotation_posMu_histo && muVStkSytemRotation_negMu_histo){
200 
201  TH2F * muVStkSytemRotation_posMu_root = muVStkSytemRotation_posMu_histo->getTH2F();
202  TProfile * muVStkSytemRotation_posMu_profile = muVStkSytemRotation_posMu_root->ProfileX("",1,100);
203  TH2F * muVStkSytemRotation_negMu_root = muVStkSytemRotation_negMu_histo->getTH2F();
204  TProfile * muVStkSytemRotation_negMu_profile = muVStkSytemRotation_negMu_root->ProfileX("",1,100);
205 
206  for(int x=1; x<50; x++){
207  globalRotation[0]->Fill((x*4)-1,muVStkSytemRotation_posMu_profile->GetBinContent(x));
208  globalRotation[0]->setBinError(x,muVStkSytemRotation_posMu_profile->GetBinError(x));
209  globalRotation[1]->Fill((x*4)-1,muVStkSytemRotation_negMu_profile->GetBinContent(x));
210  globalRotation[1]->setBinError(x,muVStkSytemRotation_negMu_profile->GetBinError(x));
211  globalRotation[2]->Fill((x*4)-1,muVStkSytemRotation_posMu_profile->GetBinContent(x)-muVStkSytemRotation_negMu_profile->GetBinContent(x));
212  globalRotation[2]->setBinError(x,sqrt((muVStkSytemRotation_posMu_profile->GetBinError(x)*muVStkSytemRotation_posMu_profile->GetBinError(x))
213  + (muVStkSytemRotation_negMu_profile->GetBinError(x)*muVStkSytemRotation_negMu_profile->GetBinError(x))));
214  }
215  }
216 
217 }
218 
220 
221  LogTrace(metname)<< "[MuonRecoTest] endJob called!";
222  theDbe->rmdir("Muons/Tests/muonRecoTest");
223 
224 }
225 
LuminosityBlockID id() const
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
DQM Client Diagnostic.
const std::string metname
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
Definition: MuonRecoTest.cc:85
const std::string & getMessage(void) const
get message attached to test
Definition: QReport.h:24
void beginJob(void)
BeginJob.
Definition: MuonRecoTest.cc:53
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
Definition: MuonRecoTest.cc:95
T sqrt(T t)
Definition: SSEVec.h:48
int getStatus(void) const
get test status (see Core/interface/QTestStatus.h)
Definition: QReport.h:16
RunNumber_t run() const
int nevents
void endJob()
Endjob.
const std::vector< DQMChannel > & getBadChannels(void) const
Definition: QReport.h:33
#define LogTrace(id)
void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup)
Definition: MuonRecoTest.cc:79
TH1F * getTH1F(void) const
LuminosityBlockNumber_t luminosityBlock() const
MuonRecoTest(const edm::ParameterSet &ps)
Constructor.
Definition: MuonRecoTest.cc:35
Definition: DDAxes.h:10
TH2F * getTH2F(void) const
Definition: Run.h:41
virtual ~MuonRecoTest()
Destructor.
Definition: MuonRecoTest.cc:46