CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonRecoAnalyzer.cc
Go to the documentation of this file.
2 
7 
10 
12 
13 #include <string>
14 #include "TMath.h"
15 using namespace std;
16 using namespace edm;
17 
18 
19 
21  parameters = pSet;
22 
23  // the services:
24  theService = new MuonServiceProxy(parameters.getParameter<ParameterSet>("ServiceParameters"));
25  theDbe = edm::Service<DQMStore>().operator->();
26 
27  theMuonCollectionLabel_ = consumes<reco::MuonCollection>(parameters.getParameter<InputTag>("MuonCollection"));
28 }
29 
30 
32  delete theService;
33 }
34 
35 
37  metname = "muRecoAnalyzer";
38 
39  LogTrace(metname)<<"[MuonRecoAnalyzer] Parameters initialization";
40 
41 }
42 void MuonRecoAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup){
43 
44  theDbe->cd();
45  theDbe->setCurrentFolder("Muons/MuonRecoAnalyzer");
46 
47  muReco = theDbe->book1D("muReco", "muon reconstructed tracks", 6, 1, 7);
48  muReco->setBinLabel(1,"glb+tk+sta");
49  muReco->setBinLabel(2,"glb+sta");
50  muReco->setBinLabel(3,"tk+sta");
51  muReco->setBinLabel(4,"tk");
52  muReco->setBinLabel(5,"sta");
53  muReco->setBinLabel(6,"calo");
54 
55  int binFactor = 4;
56 
58  // monitoring of eta parameter
60  etaBin = parameters.getParameter<int>("etaBin");
61  etaMin = parameters.getParameter<double>("etaMin");
62  etaMax = parameters.getParameter<double>("etaMax");
63 
64  std::string histname = "GlbMuon_";
65  etaGlbTrack .push_back(theDbe->book1D(histname+"Glb_eta", "#eta_{GLB}", etaBin, etaMin, etaMax));
66  etaGlbTrack .push_back(theDbe->book1D(histname+"Tk_eta", "#eta_{TKfromGLB}", etaBin, etaMin, etaMax));
67  etaGlbTrack .push_back(theDbe->book1D(histname+"Sta_eta", "#eta_{STAfromGLB}", etaBin, etaMin, etaMax));
68  etaResolution.push_back(theDbe->book1D("Res_TkGlb_eta", "#eta_{TKfromGLB} - #eta_{GLB}", etaBin*binFactor, etaMin/3000, etaMax/3000));
69  etaResolution.push_back(theDbe->book1D("Res_GlbSta_eta", "#eta_{GLB} - #eta_{STAfromGLB}", etaBin*binFactor, etaMin/100, etaMax/100));
70  etaResolution.push_back(theDbe->book1D("Res_TkSta_eta", "#eta_{TKfromGLB} - #eta_{STAfromGLB}", etaBin*binFactor, etaMin/100, etaMax/100));
71  etaResolution.push_back(theDbe->book2D("ResVsEta_TkGlb_eta", "(#eta_{TKfromGLB} - #eta_{GLB}) vs #eta_{GLB}", etaBin, etaMin, etaMax, etaBin*binFactor, etaMin/3000, etaMax/3000));
72  etaResolution.push_back(theDbe->book2D("ResVsEta_GlbSta_eta", "(#eta_{GLB} - #eta_{STAfromGLB}) vs #eta_{GLB}", etaBin, etaMin, etaMax, etaBin*binFactor, etaMin/100, etaMax/100));
73  etaResolution.push_back(theDbe->book2D("ResVsEta_TkSta_eta", "(#eta_{TKfromGLB} - #eta_{STAfromGLB}) vs #eta_{TKfromGLB}", etaBin, etaMin, etaMax, etaBin*binFactor, etaMin/100, etaMax/100));
74  etaPull = theDbe->book1D("Pull_TkSta_eta", "#eta_{TKfromGLB} - #eta_{GLB} / error", 100, -10, 10);
75  etaTrack = theDbe->book1D("TkMuon_eta", "#eta_{TK}", etaBin, etaMin, etaMax);
76  etaStaTrack = theDbe->book1D("StaMuon_eta", "#eta_{STA}", etaBin, etaMin, etaMax);
77  etaEfficiency.push_back(theDbe->book1D("StaEta", "#eta_{STAfromGLB}", etaBin, etaMin, etaMax));
78  etaEfficiency.push_back(theDbe->book1D("StaEta_ifCombinedAlso", "#eta_{STAfromGLB} if isGlb=true", etaBin, etaMin, etaMax));
79 
81  // monitoring of theta parameter
83  thetaBin = parameters.getParameter<int>("thetaBin");
84  thetaMin = parameters.getParameter<double>("thetaMin");
85  thetaMax = parameters.getParameter<double>("thetaMax");
86  thetaGlbTrack.push_back(theDbe->book1D(histname+"Glb_theta", "#theta_{GLB}", thetaBin, thetaMin, thetaMax)); thetaGlbTrack[0]->setAxisTitle("rad");
87  thetaGlbTrack.push_back(theDbe->book1D(histname+"Tk_theta", "#theta_{TKfromGLB}", thetaBin, thetaMin, thetaMax)); thetaGlbTrack[1]->setAxisTitle("rad");
88  thetaGlbTrack.push_back(theDbe->book1D(histname+"Sta_theta", "#theta_{STAfromGLB}", thetaBin, thetaMin, thetaMax)); thetaGlbTrack[2]->setAxisTitle("rad");
89  thetaResolution.push_back(theDbe->book1D("Res_TkGlb_theta", "#theta_{TKfromGLB} - #theta_{GLB}", thetaBin*binFactor, -(thetaMax/3000), thetaMax/3000)); thetaResolution[0]->setAxisTitle("rad");
90  thetaResolution.push_back(theDbe->book1D("Res_GlbSta_theta", "#theta_{GLB} - #theta_{STAfromGLB}", thetaBin*binFactor,-(thetaMax/100), thetaMax/100));
91  thetaResolution[1]->setAxisTitle("rad");
92  thetaResolution.push_back(theDbe->book1D("Res_TkSta_theta", "#theta_{TKfromGLB} - #theta_{STAfromGLB}", thetaBin*binFactor, -(thetaMax/100), thetaMax/100));
93  thetaResolution[2]->setAxisTitle("rad");
94  thetaResolution.push_back(theDbe->book2D("ResVsTheta_TkGlb_theta", "(#theta_{TKfromGLB} - #theta_{GLB}) vs #theta_{GLB}", thetaBin, thetaMin, thetaMax, thetaBin*binFactor, -(thetaMax/3000), thetaMax/3000));
95  thetaResolution[3]->setAxisTitle("rad",1);
96  thetaResolution[3]->setAxisTitle("rad",2);
97  thetaResolution.push_back(theDbe->book2D("ResVsTheta_GlbSta_theta", "(#theta_{GLB} - #theta_{STAfromGLB}) vs #theta_{GLB}", thetaBin, thetaMin, thetaMax, thetaBin*binFactor, -(thetaMax/100), thetaMax/100));
98  thetaResolution[4]->setAxisTitle("rad",1);
99  thetaResolution[4]->setAxisTitle("rad",2);
100  thetaResolution.push_back(theDbe->book2D("ResVsTheta_TkSta_theta", "(#theta_{TKfromGLB} - #theta_{STAfromGLB}) vs #theta_{TKfromGLB}", thetaBin, thetaMin, thetaMax, thetaBin*binFactor, -(thetaMax/100), thetaMax/100));
101  thetaResolution[5]->setAxisTitle("rad",1);
102  thetaResolution[5]->setAxisTitle("rad",2);
103  thetaPull = theDbe->book1D("Pull_TkSta_theta", "#theta_{TKfromGLB} - #theta_{STAfromGLB} / error", 100,-10,10);
104  thetaTrack = theDbe->book1D("TkMuon_theta", "#theta_{TK}", thetaBin, thetaMin, thetaMax);
105  thetaTrack->setAxisTitle("rad");
106  thetaStaTrack = theDbe->book1D("StaMuon_theta", "#theta_{STA}", thetaBin, thetaMin, thetaMax);
107  thetaStaTrack->setAxisTitle("rad");
108 
109  // monitoring tunePMuonBestTrack Pt
110  tunePBin= parameters.getParameter<int>("tunePBin");
111  tunePMax= parameters.getParameter<double>("tunePMax");
112  tunePMin= parameters.getParameter<double>("tunePMin");
113 
114  tunePResolution = theDbe->book1D("Res_TuneP_pt", "Pt_{MuonBestTrack}-Pt_{tunePMuonBestTrack}/Pt_{MuonBestTrack}", tunePBin, tunePMin, tunePMax);
115 
116  // monitoring of phi paramater
117  phiBin = parameters.getParameter<int>("phiBin");
118  phiMin = parameters.getParameter<double>("phiMin");
119  phiMax = parameters.getParameter<double>("phiMax");
120  phiGlbTrack.push_back(theDbe->book1D(histname+"Glb_phi", "#phi_{GLB}", phiBin, phiMin, phiMax));
121  phiGlbTrack[0]->setAxisTitle("rad");
122  phiGlbTrack.push_back(theDbe->book1D(histname+"Tk_phi", "#phi_{TKfromGLB}", phiBin, phiMin, phiMax));
123  phiGlbTrack[1]->setAxisTitle("rad");
124  phiGlbTrack.push_back(theDbe->book1D(histname+"Sta_phi", "#phi_{STAfromGLB}", phiBin, phiMin, phiMax));
125  phiGlbTrack[2]->setAxisTitle("rad");
126  phiResolution.push_back(theDbe->book1D("Res_TkGlb_phi", "#phi_{TKfromGLB} - #phi_{GLB}", phiBin*binFactor, phiMin/3000, phiMax/3000));
127  phiResolution[0]->setAxisTitle("rad");
128  phiResolution.push_back(theDbe->book1D("Res_GlbSta_phi", "#phi_{GLB} - #phi_{STAfromGLB}", phiBin*binFactor, phiMin/100, phiMax/100));
129  phiResolution[1]->setAxisTitle("rad");
130  phiResolution.push_back(theDbe->book1D("Res_TkSta_phi", "#phi_{TKfromGLB} - #phi_{STAfromGLB}", phiBin*binFactor, phiMin/100, phiMax/100));
131  phiResolution[2]->setAxisTitle("rad");
132  phiResolution.push_back(theDbe->book2D("ResVsPhi_TkGlb_phi", "(#phi_{TKfromGLB} - #phi_{GLB}) vs #phi_GLB", phiBin, phiMin, phiMax, phiBin*binFactor, phiMin/3000, phiMax/3000));
133  phiResolution[3]->setAxisTitle("rad",1);
134  phiResolution[3]->setAxisTitle("rad",2);
135  phiResolution.push_back(theDbe->book2D("ResVsPhi_GlbSta_phi", "(#phi_{GLB} - #phi_{STAfromGLB}) vs #phi_{GLB}", phiBin, phiMin, phiMax, phiBin*binFactor, phiMin/100, phiMax/100));
136  phiResolution[4]->setAxisTitle("rad",1);
137  phiResolution[4]->setAxisTitle("rad",2);
138  phiResolution.push_back(theDbe->book2D("ResVsPhi_TkSta_phi", "(#phi_{TKfromGLB} - #phi_{STAfromGLB}) vs #phi_{TKfromGLB}", phiBin, phiMin, phiMax, phiBin*binFactor, phiMin/100, phiMax/100));
139  phiResolution[5]->setAxisTitle("rad",1);
140  phiResolution[5]->setAxisTitle("rad",2);
141  phiPull = theDbe->book1D("Pull_TkSta_phi", "#phi_{TKfromGLB} - #phi_{STAfromGLB} / error", 100,-10,10);
142  phiTrack = theDbe->book1D("TkMuon_phi", "#phi_{TK}", phiBin, phiMin, phiMax);
143  phiTrack->setAxisTitle("rad");
144  phiStaTrack = theDbe->book1D("StaMuon_phi", "#phi_{STA}", phiBin, phiMin, phiMax);
145  phiStaTrack->setAxisTitle("rad");
146  phiEfficiency.push_back(theDbe->book1D("StaPhi", "#phi_{STAfromGLB}", phiBin, phiMin, phiMax));
147  phiEfficiency[0]->setAxisTitle("rad");
148  phiEfficiency.push_back(theDbe->book1D("StaPhi_ifCombinedAlso", "#phi_{STAfromGLB} if the isGlb=true", phiBin, phiMin, phiMax));
149  phiEfficiency[1]->setAxisTitle("rad");
150 
151  // monitoring of the chi2 parameter
152  chi2Bin = parameters.getParameter<int>("chi2Bin");
153  chi2Min = parameters.getParameter<double>("chi2Min");
154  chi2Max = parameters.getParameter<double>("chi2Max");
155  chi2OvDFGlbTrack.push_back(theDbe->book1D(histname+"Glb_chi2OverDf", "#chi_{2}OverDF_{GLB}", chi2Bin, chi2Min, chi2Max));
156  chi2OvDFGlbTrack.push_back(theDbe->book1D(histname+"Tk_chi2OverDf", "#chi_{2}OverDF_{TKfromGLB}", phiBin, chi2Min, chi2Max));
157  chi2OvDFGlbTrack.push_back(theDbe->book1D(histname+"Sta_chi2OverDf", "#chi_{2}OverDF_{STAfromGLB}", chi2Bin, chi2Min, chi2Max));
158  chi2OvDFTrack = theDbe->book1D("TkMuon_chi2OverDf", "#chi_{2}OverDF_{TK}", chi2Bin, chi2Min, chi2Max);
159  chi2OvDFStaTrack = theDbe->book1D("StaMuon_chi2OverDf", "#chi_{2}OverDF_{STA}", chi2Bin, chi2Min, chi2Max);
160 //--------------------------
161  probchi2GlbTrack.push_back(theDbe->book1D(histname+"Glb_probchi", "Prob #chi_{GLB}", 120, chi2Min, 1.20));
162  probchi2GlbTrack.push_back(theDbe->book1D(histname+"Tk_probchi", "Prob #chi_{TKfromGLB}", 120, chi2Min, 1.20));
163  probchi2GlbTrack.push_back(theDbe->book1D(histname+"Sta_probchi", "Prob #chi_{STAfromGLB}", 120, chi2Min, 1.20));
164  probchi2Track=theDbe->book1D("TkMuon_probchi", "Prob #chi_{TK}", 120, chi2Min, 1.20);
165  probchi2StaTrack=theDbe->book1D("StaMuon_probchi", "Prob #chi_{STA}", 120, chi2Min, 1.20);
166 
167  // monitoring of the momentum
168  pBin = parameters.getParameter<int>("pBin");
169  pMin = parameters.getParameter<double>("pMin");
170  pMax = parameters.getParameter<double>("pMax");
171  pGlbTrack.push_back(theDbe->book1D(histname+"Glb_p", "p_{GLB}", pBin, pMin, pMax));
172  pGlbTrack[0]->setAxisTitle("GeV");
173  pGlbTrack.push_back(theDbe->book1D(histname+"Tk_p", "p_{TKfromGLB}", pBin, pMin, pMax));
174  pGlbTrack[1]->setAxisTitle("GeV");
175  pGlbTrack.push_back(theDbe->book1D(histname+"Sta_p", "p_{STAfromGLB}", pBin, pMin, pMax));
176  pGlbTrack[2]->setAxisTitle("GeV");
177  pTrack = theDbe->book1D("TkMuon_p", "p_{TK}", pBin, pMin, pMax);
178  pTrack->setAxisTitle("GeV");
179  pStaTrack = theDbe->book1D("StaMuon_p", "p_{STA}", pBin, pMin, pMax);
180  pStaTrack->setAxisTitle("GeV");
181 
182  // monitoring of the transverse momentum
183  ptBin = parameters.getParameter<int>("ptBin");
184  ptMin = parameters.getParameter<double>("ptMin");
185  ptMax = parameters.getParameter<double>("ptMax");
186  ptGlbTrack.push_back(theDbe->book1D(histname+"Glb_pt", "pt_{GLB}", ptBin, ptMin, ptMax));
187  ptGlbTrack[0]->setAxisTitle("GeV");
188  ptGlbTrack.push_back(theDbe->book1D(histname+"Tk_pt", "pt_{TKfromGLB}", ptBin, ptMin, ptMax));
189  ptGlbTrack[1]->setAxisTitle("GeV");
190  ptGlbTrack.push_back(theDbe->book1D(histname+"Sta_pt", "pt_{STAfromGLB}", ptBin, ptMin, ptMax));
191  ptGlbTrack[2]->setAxisTitle("GeV");
192  ptTrack = theDbe->book1D("TkMuon_pt", "pt_{TK}", ptBin, ptMin, ptMax);
193  ptTrack->setAxisTitle("GeV");
194  ptStaTrack = theDbe->book1D("StaMuon_pt", "pt_{STA}", ptBin, ptMin, pMax);
195  ptStaTrack->setAxisTitle("GeV");
196 
197  // monitoring of the muon charge
198  qGlbTrack.push_back(theDbe->book1D(histname+"Glb_q", "q_{GLB}", 5, -2.5, 2.5));
199  qGlbTrack.push_back(theDbe->book1D(histname+"Tk_q", "q_{TKfromGLB}", 5, -2.5, 2.5));
200  qGlbTrack.push_back(theDbe->book1D(histname+"Sta_q", "q_{STAformGLB}", 5, -2.5, 2.5));
201  qGlbTrack.push_back(theDbe->book1D(histname+"qComparison", "comparison between q_{GLB} and q_{TKfromGLB}, q_{STAfromGLB}", 8, 0.5, 8.5));
202  qGlbTrack[3]->setBinLabel(1,"qGlb=qSta");
203  qGlbTrack[3]->setBinLabel(2,"qGlb!=qSta");
204  qGlbTrack[3]->setBinLabel(3,"qGlb=qTk");
205  qGlbTrack[3]->setBinLabel(4,"qGlb!=qTk");
206  qGlbTrack[3]->setBinLabel(5,"qSta=qTk");
207  qGlbTrack[3]->setBinLabel(6,"qSta!=qTk");
208  qGlbTrack[3]->setBinLabel(7,"qGlb!=qSta,qGlb!=Tk");
209  qGlbTrack[3]->setBinLabel(8,"qGlb=qSta,qGlb=Tk");
210  qTrack = theDbe->book1D("TkMuon_q", "q_{TK}", 5, -2.5, 2.5);
211  qStaTrack = theDbe->book1D("StaMuon_q", "q_{STA}", 5, -2.5, 2.5);
212 
214  // monitoring of the momentum resolution
215  pResBin = parameters.getParameter<int>("pResBin");
216  pResMin = parameters.getParameter<double>("pResMin");
217  pResMax = parameters.getParameter<double>("pResMax");
218  qOverpResolution.push_back(theDbe->book1D("Res_TkGlb_qOverp", "(q/p)_{TKfromGLB} - (q/p)_{GLB}", pResBin*binFactor*2, pResMin/10, pResMax/10));
219  qOverpResolution[0]->setAxisTitle("GeV^{-1}");
220  qOverpResolution.push_back(theDbe->book1D("Res_GlbSta_qOverp", "(q/p)_{GLB} - (q/p)_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
221  qOverpResolution[1]->setAxisTitle("GeV^{-1}");
222  qOverpResolution.push_back(theDbe->book1D("Res_TkSta_qOverp", "(q/p)_{TKfromGLB} - (q/p)_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
223  qOverpResolution[2]->setAxisTitle("GeV^{-1}");
224  qOverpPull = theDbe->book1D("Pull_TkSta_qOverp", "(q/p)_{TKfromGLB} - (q/p)_{STAfromGLB} / error", 100,-10,10);
225 
226  oneOverpResolution.push_back(theDbe->book1D("Res_TkGlb_oneOverp", "(1/p)_{TKfromGLB} - (1/p)_{GLB}", pResBin*binFactor*2, pResMin/10, pResMax/10));
227  oneOverpResolution[0]->setAxisTitle("GeV^{-1}");
228  oneOverpResolution.push_back(theDbe->book1D("Res_GlbSta_oneOverp", "(1/p)_{GLB} - (1/p)_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
229  oneOverpResolution[1]->setAxisTitle("GeV^{-1}");
230  oneOverpResolution.push_back(theDbe->book1D("Res_TkSta_oneOverp", "(q/p)_{TKfromGLB} - (q/p)_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
231  oneOverpResolution[2]->setAxisTitle("GeV^{-1}");
232  oneOverpPull = theDbe->book1D("Pull_TkSta_oneOverp", "(1/p)_{TKfromGLB} - (1/p)_{STAfromGLB} / error", 100,-10,10);
233 
234 
235  qOverptResolution.push_back(theDbe->book1D("Res_TkGlb_qOverpt", "(q/p_{t})_{TKfromGLB} - (q/p_{t})_{GLB}", pResBin*binFactor*2, pResMin/10, pResMax/10));
236  qOverptResolution[0]->setAxisTitle("GeV^{-1}");
237  qOverptResolution.push_back(theDbe->book1D("Res_GlbSta_qOverpt", "(q/p_{t})_{GLB} - (q/p_{t})_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
238  qOverptResolution[1]->setAxisTitle("GeV^{-1}");
239  qOverptResolution.push_back(theDbe->book1D("Res_TkSta_qOverpt", "(q/p_{t})_{TKfromGLB} - (q/p_{t})_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
240  qOverptResolution[2]->setAxisTitle("GeV^{-1}");
241  qOverptPull = theDbe->book1D("Pull_TkSta_qOverpt", "(q/pt)_{TKfromGLB} - (q/pt)_{STAfromGLB} / error", 100,-10,10);
242 
243  oneOverptResolution.push_back(theDbe->book1D("Res_TkGlb_oneOverpt", "(1/p_{t})_{TKfromGLB} - (1/p_{t})_{GLB}", pResBin*binFactor*2, pResMin/10, pResMax/10));
244  oneOverptResolution[0]->setAxisTitle("GeV^{-1}");
245  oneOverptResolution.push_back(theDbe->book1D("Res_GlbSta_oneOverpt", "(1/p_{t})_{GLB} - (1/p_{t})_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
246  oneOverptResolution[1]->setAxisTitle("GeV^{-1}");
247  oneOverptResolution.push_back(theDbe->book1D("Res_TkSta_oneOverpt", "(1/p_{t})_{TKfromGLB} - (1/p_{t})_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
248  oneOverptResolution[2]->setAxisTitle("GeV^{-1}");
249  oneOverptResolution.push_back(theDbe->book2D("ResVsEta_TkGlb_oneOverpt", "(#eta_{TKfromGLB} - #eta_{GLB}) vs (1/p_{t})_{GLB}", etaBin, etaMin, etaMax, pResBin*binFactor*2, pResMin/10, pResMax/10));
250  oneOverptResolution[3]->setAxisTitle("GeV^{-1}",2);
251  oneOverptResolution.push_back(theDbe->book2D("ResVsEta_GlbSta_oneOverpt", "(#eta_{GLB} - #eta_{STAfromGLB} vs (1/p_{t})_{GLB}", etaBin, etaMin, etaMax, pResBin*binFactor, pResMin, pResMax));
252  oneOverptResolution[4]->setAxisTitle("GeV^{-1}",2);
253  oneOverptResolution.push_back(theDbe->book2D("ResVsEta_TkSta_oneOverpt", "(#eta_{TKfromGLB} - #eta_{STAfromGLB}) vs (1/p_{t})_{TKfromGLB}", etaBin, etaMin, etaMax, pResBin*binFactor, pResMin, pResMax));
254  oneOverptResolution[5]->setAxisTitle("GeV^{-1}",2);
255  oneOverptResolution.push_back(theDbe->book2D("ResVsPhi_TkGlb_oneOverpt", "(#phi_{TKfromGLB} - #phi_{GLB}) vs (1/p_{t})_{GLB}", phiBin, phiMin, phiMax, pResBin*binFactor*2, pResMin/10, pResMax/10));
256  oneOverptResolution[6]->setAxisTitle("rad",1);
257  oneOverptResolution[6]->setAxisTitle("GeV^{-1}",2);
258  oneOverptResolution.push_back(theDbe->book2D("ResVsPhi_GlbSta_oneOverpt", "(#phi_{GLB} - #phi_{STAfromGLB} vs (1/p_{t})_{GLB}", phiBin, phiMin, phiMax, pResBin*binFactor, pResMin, pResMax));
259  oneOverptResolution[7]->setAxisTitle("rad",1);
260  oneOverptResolution[7]->setAxisTitle("GeV^{-1}",2);
261  oneOverptResolution.push_back(theDbe->book2D("ResVsPhi_TkSta_oneOverpt", "(#phi_{TKfromGLB} - #phi_{STAfromGLB}) vs (1/p_{t})_{TKfromGLB}", phiBin, phiMin, phiMax, pResBin*binFactor, pResMin, pResMax));
262  oneOverptResolution[8]->setAxisTitle("rad",1);
263  oneOverptResolution[8]->setAxisTitle("GeV^{-1}",2);
264  oneOverptResolution.push_back(theDbe->book2D("ResVsPt_TkGlb_oneOverpt", "((1/p_{t})_{TKfromGLB} - (1/p_{t})_{GLB}) vs (1/p_{t})_{GLB}", ptBin/5, ptMin, ptMax/100, pResBin*binFactor*2, pResMin/10, pResMax/10));
265  oneOverptResolution[9]->setAxisTitle("GeV^{-1}",1);
266  oneOverptResolution[9]->setAxisTitle("GeV^{-1}",2);
267  oneOverptResolution.push_back(theDbe->book2D("ResVsPt_GlbSta_oneOverpt", "((1/p_{t})_{GLB} - (1/p_{t})_{STAfromGLB} vs (1/p_{t})_{GLB}", ptBin/5, ptMin, ptMax/100, pResBin*binFactor, pResMin, pResMax));
268  oneOverptResolution[10]->setAxisTitle("GeV^{-1}",1);
269  oneOverptResolution[10]->setAxisTitle("GeV^{-1}",2);
270  oneOverptResolution.push_back(theDbe->book2D("ResVsPt_TkSta_oneOverpt", "((1/p_{t})_{TKfromGLB} - (1/p_{t})_{STAfromGLB}) vs (1/p_{t})_{TKfromGLB}", ptBin/5, ptMin, ptMax/100, pResBin*binFactor, pResMin, pResMax));
271  oneOverptResolution[11]->setAxisTitle("GeV^{-1}",1);
272  oneOverptResolution[11]->setAxisTitle("GeV^{-1}",2);
273  oneOverptPull = theDbe->book1D("Pull_TkSta_oneOverpt", "(1/pt)_{TKfromGLB} - (1/pt)_{STAfromGLB} / error", 100,-10,10);
274 
276  // monitoring of the recHits provenance
277  rhBin=parameters.getParameter<int>("rhBin");
278  rhMin=parameters.getParameter<double>("rhMin");
279  rhMax=parameters.getParameter<double>("rhMax");
280  rhAnalysis.push_back(theDbe->book1D("StaRh_Frac_inGlb", "recHits_{STAinGLB} / recHits_{GLB}", rhBin, rhMin, rhMax));
281  rhAnalysis.push_back(theDbe->book1D("TkRh_Frac_inGlb", "recHits_{TKinGLB} / recHits_{GLB}", rhBin, rhMin, rhMax));
282  rhAnalysis.push_back(theDbe->book1D("StaRh_inGlb_Div_RhAssoSta", "recHits_{STAinGLB} / recHits_{STAfromGLB}", rhBin, rhMin, rhMax));
283  rhAnalysis.push_back(theDbe->book1D("TkRh_inGlb_Div_RhAssoTk", "recHits_{TKinGLB} / recHits_{TKfromGLB}", rhBin, rhMin, rhMax));
284  rhAnalysis.push_back(theDbe->book1D("GlbRh_Div_RhAssoStaTk", "recHits_{GLB} / (recHits_{TKfromGLB}+recHits_{STAfromGLB})", rhBin, rhMin, rhMax));
285  rhAnalysis.push_back(theDbe->book1D("invalidRh_Frac_inTk", "Invalid recHits / rechits_{GLB}", rhBin, rhMin, rhMax));
286 
288  // monitoring of the muon system rotation w.r.t. tracker
289  muVStkSytemRotation.push_back(theDbe->book2D("muVStkSytemRotation_posMu", "pT_{TK} / pT_{GLB} vs pT_{GLB} for #mu^{+}", 50,0,200,100,0.8,1.2));
290  muVStkSytemRotation.push_back(theDbe->book2D("muVStkSytemRotation_negMu", "pT_{TK} / pT_{GLB} vs pT_{GLB} for #mu^{-}", 50,0,200,100,0.8,1.2));
291 
292 }
293 
294 void MuonRecoAnalyzer::GetRes( reco::TrackRef t1, reco::TrackRef t2, string par, float &res, float &pull){
295 
296  float p1=0, p2=0, p1e=1, p2e=1;
297 
298  if(par == "eta") {
299  p1 = t1->eta(); p1e = t1->etaError();
300  p2 = t2->eta(); p2e = t2->etaError();
301  }
302  else if(par == "theta") {
303  p1 = t1->theta(); p1e = t1->thetaError();
304  p2 = t2->theta(); p2e = t2->thetaError();
305  }
306  else if(par == "phi") {
307  p1 = t1->phi(); p1e = t1->phiError();
308  p2 = t2->phi(); p2e = t2->phiError();
309  }
310  else if(par == "qOverp") {
311  p1 = t1->charge()/t1->p(); p1e = t1->qoverpError();
312  p2 = t2->charge()/t2->p(); p2e = t2->qoverpError();
313  }
314  else if(par == "oneOverp") {
315  p1 = 1./t1->p(); p1e = t1->qoverpError();
316  p2 = 1./t2->p(); p2e = t2->qoverpError();
317  }
318  else if(par == "qOverpt") {
319  p1 = t1->charge()/t1->pt(); p1e = t1->ptError()*p1*p1;
320  p2 = t2->charge()/t2->pt(); p2e = t2->ptError()*p2*p2;
321  }
322  else if(par == "oneOverpt") {
323  p1 = 1./t1->pt(); p1e = t1->ptError()*p1*p1;
324  p2 = 1./t2->pt(); p2e = t2->ptError()*p2*p2;
325  }
326 
327  res = p1 - p2;
328  if(p1e!=0 || p2e!=0) pull = res / sqrt(p1e*p1e + p2e*p2e);
329  else pull = -99;
330  return;
331 }
333  LogTrace(metname)<<"[MuonRecoAnalyzer] Analyze the mu";
334  theService->update(iSetup);
335 
336  // Take the muon container
338  iEvent.getByToken(theMuonCollectionLabel_,muons);
339 
340 
341  float res=0, pull=0;
342  if(!muons.isValid()) return;
343 
344  for (reco::MuonCollection::const_iterator recoMu = muons->begin(); recoMu!=muons->end(); ++recoMu){
345 
346  if(recoMu->isGlobalMuon()) {
347 
348  LogTrace(metname)<<"[MuonRecoAnalyzer] The mu is global - filling the histos";
349  if(recoMu->isTrackerMuon() && recoMu->isStandAloneMuon())
350  muReco->Fill(1);
351  if(!(recoMu->isTrackerMuon()) && recoMu->isStandAloneMuon())
352  muReco->Fill(2);
353  if(!recoMu->isStandAloneMuon())
354  LogTrace(metname)<<"[MuonRecoAnalyzer] ERROR: the mu is global but not standalone!";
355 
356  // get the track combinig the information from both the Tracker and the Spectrometer
357  reco::TrackRef recoCombinedGlbTrack = recoMu->combinedMuon();
358  // get the track using only the tracker data
359  reco::TrackRef recoTkGlbTrack = recoMu->track();
360  // get the track using only the mu spectrometer data
361  reco::TrackRef recoStaGlbTrack = recoMu->standAloneMuon();
362 
363 
364  etaGlbTrack[0]->Fill(recoCombinedGlbTrack->eta());
365  etaGlbTrack[1]->Fill(recoTkGlbTrack->eta());
366  etaGlbTrack[2]->Fill(recoStaGlbTrack->eta());
367 
368  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "eta", res, pull);
369  etaResolution[0]->Fill(res);
370  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "eta", res, pull);
371  etaResolution[1]->Fill(res);
372  GetRes(recoTkGlbTrack, recoStaGlbTrack, "eta", res, pull);
373  etaResolution[2]->Fill(res);
374  etaPull->Fill(pull);
375 
376  etaResolution[3]->Fill(recoCombinedGlbTrack->eta(), recoTkGlbTrack->eta()-recoCombinedGlbTrack->eta());
377  etaResolution[4]->Fill(recoCombinedGlbTrack->eta(), -recoStaGlbTrack->eta()+recoCombinedGlbTrack->eta());
378  etaResolution[5]->Fill(recoCombinedGlbTrack->eta(), recoTkGlbTrack->eta()-recoStaGlbTrack->eta());
379 
380 
381  thetaGlbTrack[0]->Fill(recoCombinedGlbTrack->theta());
382  thetaGlbTrack[1]->Fill(recoTkGlbTrack->theta());
383  thetaGlbTrack[2]->Fill(recoStaGlbTrack->theta());
384  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "theta", res, pull);
385  thetaResolution[0]->Fill(res);
386 
387  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "theta", res, pull);
388  thetaResolution[1]->Fill(res);
389 
390  GetRes(recoTkGlbTrack, recoStaGlbTrack, "theta", res, pull);
391  thetaResolution[2]->Fill(res);
392  thetaPull->Fill(pull);
393 
394  thetaResolution[3]->Fill(recoCombinedGlbTrack->theta(), recoTkGlbTrack->theta()-recoCombinedGlbTrack->theta());
395  thetaResolution[4]->Fill(recoCombinedGlbTrack->theta(), -recoStaGlbTrack->theta()+recoCombinedGlbTrack->theta());
396  thetaResolution[5]->Fill(recoCombinedGlbTrack->theta(), recoTkGlbTrack->theta()-recoStaGlbTrack->theta());
397 
398 
399 
400  phiGlbTrack[0]->Fill(recoCombinedGlbTrack->phi());
401  phiGlbTrack[1]->Fill(recoTkGlbTrack->phi());
402  phiGlbTrack[2]->Fill(recoStaGlbTrack->phi());
403  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "phi", res, pull);
404  phiResolution[0]->Fill(res);
405  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "phi", res, pull);
406  phiResolution[1]->Fill(res);
407  GetRes(recoTkGlbTrack, recoStaGlbTrack, "phi", res, pull);
408  phiResolution[2]->Fill(res);
409  phiPull->Fill(pull);
410  phiResolution[3]->Fill(recoCombinedGlbTrack->phi(), recoTkGlbTrack->phi()-recoCombinedGlbTrack->phi());
411  phiResolution[4]->Fill(recoCombinedGlbTrack->phi(), -recoStaGlbTrack->phi()+recoCombinedGlbTrack->phi());
412  phiResolution[5]->Fill(recoCombinedGlbTrack->phi(), recoTkGlbTrack->phi()-recoStaGlbTrack->phi());
413 
414  chi2OvDFGlbTrack[0]->Fill(recoCombinedGlbTrack->normalizedChi2());
415  chi2OvDFGlbTrack[1]->Fill(recoTkGlbTrack->normalizedChi2());
416  chi2OvDFGlbTrack[2]->Fill(recoStaGlbTrack->normalizedChi2());
417  //-------------------------
418  // double probchi = TMath::Prob(recoCombinedGlbTrack->normalizedChi2(),recoCombinedGlbTrack->ndof());
419  // cout << "rellenando histos."<<endl;
420  probchi2GlbTrack[0]->Fill(TMath::Prob(recoCombinedGlbTrack->chi2(),recoCombinedGlbTrack->ndof()));
421  probchi2GlbTrack[1]->Fill(TMath::Prob(recoTkGlbTrack->chi2(),recoTkGlbTrack->ndof()));
422  probchi2GlbTrack[2]->Fill(TMath::Prob(recoStaGlbTrack->chi2(),recoStaGlbTrack->ndof()));
423  // cout << "rellenados histos."<<endl;
424  //-------------------------
425 
426  pGlbTrack[0]->Fill(recoCombinedGlbTrack->p());
427  pGlbTrack[1]->Fill(recoTkGlbTrack->p());
428  pGlbTrack[2]->Fill(recoStaGlbTrack->p());
429 
430  ptGlbTrack[0]->Fill(recoCombinedGlbTrack->pt());
431  ptGlbTrack[1]->Fill(recoTkGlbTrack->pt());
432  ptGlbTrack[2]->Fill(recoStaGlbTrack->pt());
433 
434  qGlbTrack[0]->Fill(recoCombinedGlbTrack->charge());
435  qGlbTrack[1]->Fill(recoTkGlbTrack->charge());
436  qGlbTrack[2]->Fill(recoStaGlbTrack->charge());
437  if(recoCombinedGlbTrack->charge()==recoStaGlbTrack->charge()) qGlbTrack[3]->Fill(1);
438  else qGlbTrack[3]->Fill(2);
439  if(recoCombinedGlbTrack->charge()==recoTkGlbTrack->charge()) qGlbTrack[3]->Fill(3);
440  else qGlbTrack[3]->Fill(4);
441  if(recoStaGlbTrack->charge()==recoTkGlbTrack->charge()) qGlbTrack[3]->Fill(5);
442  else qGlbTrack[3]->Fill(6);
443  if(recoCombinedGlbTrack->charge()!=recoStaGlbTrack->charge() && recoCombinedGlbTrack->charge()!=recoTkGlbTrack->charge()) qGlbTrack[3]->Fill(7);
444  if(recoCombinedGlbTrack->charge()==recoStaGlbTrack->charge() && recoCombinedGlbTrack->charge()==recoTkGlbTrack->charge()) qGlbTrack[3]->Fill(8);
445 
446  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "qOverp", res, pull);
447  qOverpResolution[0]->Fill(res);
448  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "qOverp", res, pull);
449  qOverpResolution[1]->Fill(res);
450  GetRes(recoTkGlbTrack, recoStaGlbTrack, "qOverp", res, pull);
451  qOverpResolution[2]->Fill(res);
452  qOverpPull->Fill(pull);
453 
454 
455  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "oneOverp", res, pull);
456  oneOverpResolution[0]->Fill(res);
457  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "oneOverp", res, pull);
458  oneOverpResolution[1]->Fill(res);
459  GetRes(recoTkGlbTrack, recoStaGlbTrack, "oneOverp", res, pull);
460  oneOverpResolution[2]->Fill(res);
461  oneOverpPull->Fill(pull);
462 
463 
464  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "qOverpt", res, pull);
465  qOverptResolution[0]->Fill(res);
466  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "qOverpt", res, pull);
467  qOverptResolution[1]->Fill(res);
468  GetRes(recoTkGlbTrack, recoStaGlbTrack, "qOverpt", res, pull);
469  qOverptResolution[2]->Fill(res);
470  qOverptPull->Fill(pull);
471 
472  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "oneOverpt", res, pull);
473  oneOverptResolution[0]->Fill(res);
474  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "oneOverpt", res, pull);
475  oneOverptResolution[1]->Fill(res);
476  GetRes(recoTkGlbTrack, recoStaGlbTrack, "oneOverpt", res, pull);
477  oneOverptResolution[2]->Fill(res);
478  oneOverptPull->Fill(pull);
479 
480 
481  //--- Test new tunePMuonBestTrack() method from Muon.h
482 
483  reco::TrackRef recoBestTrack = recoMu->muonBestTrack();
484 
485  reco::TrackRef recoTunePBestTrack = recoMu->tunePMuonBestTrack();
486 
487  double bestTrackPt = recoBestTrack->pt();
488 
489  double tunePBestTrackPt = recoTunePBestTrack->pt();
490 
491  double tunePBestTrackRes = (bestTrackPt - tunePBestTrackPt) / bestTrackPt;
492 
493  tunePResolution->Fill(tunePBestTrackRes);
494 
495 
496  oneOverptResolution[3]->Fill(recoCombinedGlbTrack->eta(),(1/recoTkGlbTrack->pt())-(1/recoCombinedGlbTrack->pt()));
497  oneOverptResolution[4]->Fill(recoCombinedGlbTrack->eta(),-(1/recoStaGlbTrack->pt())+(1/recoCombinedGlbTrack->pt()));
498  oneOverptResolution[5]->Fill(recoCombinedGlbTrack->eta(),(1/recoTkGlbTrack->pt())-(1/recoStaGlbTrack->pt()));
499  oneOverptResolution[6]->Fill(recoCombinedGlbTrack->phi(),(1/recoTkGlbTrack->pt())-(1/recoCombinedGlbTrack->pt()));
500  oneOverptResolution[7]->Fill(recoCombinedGlbTrack->phi(),-(1/recoStaGlbTrack->pt())+(1/recoCombinedGlbTrack->pt()));
501  oneOverptResolution[8]->Fill(recoCombinedGlbTrack->phi(),(1/recoTkGlbTrack->pt())-(1/recoStaGlbTrack->pt()));
502  oneOverptResolution[9]->Fill(recoCombinedGlbTrack->pt(),(1/recoTkGlbTrack->pt())-(1/recoCombinedGlbTrack->pt()));
503  oneOverptResolution[10]->Fill(recoCombinedGlbTrack->pt(),-(1/recoStaGlbTrack->pt())+(1/recoCombinedGlbTrack->pt()));
504  oneOverptResolution[11]->Fill(recoCombinedGlbTrack->pt(),(1/recoTkGlbTrack->pt())-(1/recoStaGlbTrack->pt()));
505 
506  // valid hits Glb track
507  double rhGlb = recoCombinedGlbTrack->found();
508  // valid hits Glb track from Tracker
509  double rhGlb_StaProvenance=0;
510  // valid hits Glb track from Sta system
511  double rhGlb_TkProvenance=0;
512  for (trackingRecHit_iterator recHit = recoCombinedGlbTrack->recHitsBegin();
513  recHit!=recoCombinedGlbTrack->recHitsEnd(); ++recHit){
514  if((*recHit)->isValid()){
515  DetId id = (*recHit)->geographicalId();
516  if (id.det() == DetId::Muon)
517  rhGlb_StaProvenance++;
518  if (id.det() == DetId::Tracker)
519  rhGlb_TkProvenance++;
520  }
521  }
522  // valid hits Sta track associated to Glb track
523  double rhStaGlb = recoStaGlbTrack->recHitsSize();
524  // valid hits Traker track associated to Glb track
525  double rhTkGlb = recoTkGlbTrack->found();
526  // invalid hits Traker track associated to Glb track
527  double rhTkGlb_notValid = recoTkGlbTrack->lost();
528 
529  // fill the histos
530  rhAnalysis[0]->Fill(rhGlb_StaProvenance/rhGlb);
531  rhAnalysis[1]->Fill(rhGlb_TkProvenance/rhGlb);
532  rhAnalysis[2]->Fill(rhGlb_StaProvenance/rhStaGlb);
533  rhAnalysis[3]->Fill(rhGlb_TkProvenance/rhTkGlb);
534  rhAnalysis[4]->Fill(rhGlb/(rhStaGlb+rhTkGlb));
535  rhAnalysis[5]->Fill(rhTkGlb_notValid/rhGlb);
536 
537  // aligment plots (mu system w.r.t. tracker rotation)
538  if(recoCombinedGlbTrack->charge()>0)
539  muVStkSytemRotation[0]->Fill(recoCombinedGlbTrack->pt(),recoTkGlbTrack->pt()/recoCombinedGlbTrack->pt());
540  else
541  muVStkSytemRotation[1]->Fill(recoCombinedGlbTrack->pt(),recoTkGlbTrack->pt()/recoCombinedGlbTrack->pt());
542 
543  }
544 
545 
546  if(recoMu->isTrackerMuon() && !(recoMu->isGlobalMuon())) {
547  LogTrace(metname)<<"[MuonRecoAnalyzer] The mu is tracker only - filling the histos";
548  if(recoMu->isStandAloneMuon())
549  muReco->Fill(3);
550  if(!(recoMu->isStandAloneMuon()))
551  muReco->Fill(4);
552 
553  // get the track using only the tracker data
554  reco::TrackRef recoTrack = recoMu->track();
555 
556  etaTrack->Fill(recoTrack->eta());
557  thetaTrack->Fill(recoTrack->theta());
558  phiTrack->Fill(recoTrack->phi());
559  chi2OvDFTrack->Fill(recoTrack->normalizedChi2());
560  probchi2Track->Fill(TMath::Prob(recoTrack->chi2(),recoTrack->ndof()));
561  pTrack->Fill(recoTrack->p());
562  ptTrack->Fill(recoTrack->pt());
563  qTrack->Fill(recoTrack->charge());
564 
565  }
566 
567  if(recoMu->isStandAloneMuon() && !(recoMu->isGlobalMuon())) {
568  LogTrace(metname)<<"[MuonRecoAnalyzer] The mu is STA only - filling the histos";
569  if(!(recoMu->isTrackerMuon()))
570  muReco->Fill(5);
571 
572  // get the track using only the mu spectrometer data
573  reco::TrackRef recoStaTrack = recoMu->standAloneMuon();
574 
575  etaStaTrack->Fill(recoStaTrack->eta());
576  thetaStaTrack->Fill(recoStaTrack->theta());
577  phiStaTrack->Fill(recoStaTrack->phi());
578  chi2OvDFStaTrack->Fill(recoStaTrack->normalizedChi2());
579  probchi2StaTrack->Fill(TMath::Prob(recoStaTrack->chi2(),recoStaTrack->ndof()));
580  pStaTrack->Fill(recoStaTrack->p());
581  ptStaTrack->Fill(recoStaTrack->pt());
582  qStaTrack->Fill(recoStaTrack->charge());
583 
584  }
585 
586  if(recoMu->isCaloMuon() && !(recoMu->isGlobalMuon()) && !(recoMu->isTrackerMuon()) && !(recoMu->isStandAloneMuon()))
587  muReco->Fill(6);
588 
589  //efficiency plots
590 
591  // get the track using only the mu spectrometer data
592  reco::TrackRef recoStaGlbTrack = recoMu->standAloneMuon();
593 
594  if(recoMu->isStandAloneMuon()){
595  etaEfficiency[0]->Fill(recoStaGlbTrack->eta());
596  phiEfficiency[0]->Fill(recoStaGlbTrack->phi());
597  }
598  if(recoMu->isStandAloneMuon() && recoMu->isGlobalMuon()){
599  etaEfficiency[1]->Fill(recoStaGlbTrack->eta());
600  phiEfficiency[1]->Fill(recoStaGlbTrack->phi());
601  }
602  }
603 
604 
605 
606 }
virtual ~MuonRecoAnalyzer()
Destructor.
dictionary parameters
Definition: Parameters.py:2
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
const std::string metname
void analyze(const edm::Event &, const edm::EventSetup &)
Get the analysis.
int iEvent
Definition: GenABIO.cc:243
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:18
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
T sqrt(T t)
Definition: SSEVec.h:48
bool isValid() const
Definition: HandleBase.h:76
double p2[4]
Definition: TauolaWrapper.h:90
#define LogTrace(id)
void GetRes(reco::TrackRef t1, reco::TrackRef t2, std::string par, float &res, float &pull)
Definition: DetId.h:18
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
double p1[4]
Definition: TauolaWrapper.h:89
tuple muons
Definition: patZpeak.py:38
void beginJob()
Inizialize parameters for histo binning.
Definition: Run.h:41
MuonRecoAnalyzer(const edm::ParameterSet &)
Constructor.