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