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