CMS 3D CMS Logo

MuonRecoAnalyzer.cc
Go to the documentation of this file.
2 
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  // Input booleans
24  IsminiAOD = parameters.getParameter<bool>("IsminiAOD");
25  doMVA = parameters.getParameter<bool>("doMVA");
26  // the services:
27  theService = new MuonServiceProxy(parameters.getParameter<ParameterSet>("ServiceParameters"));
28  theMuonCollectionLabel_ = consumes<edm::View<reco::Muon> > (parameters.getParameter<edm::InputTag>("MuonCollection"));
29  theVertexLabel_ = consumes<reco::VertexCollection> (pSet.getParameter<InputTag>("inputTagVertex"));
30  theBeamSpotLabel_ = consumes<reco::BeamSpot> (pSet.getParameter<InputTag>("inputTagBeamSpot"));
31  dcsStatusCollection_ = consumes<DcsStatusCollection>(pSet.getUntrackedParameter<std::string>("dcsStatusCollection","scalersRawToDigi"));
32 
33  ptBin = parameters.getParameter<int>("ptBin");
34  ptMin = parameters.getParameter<double>("ptMin");
35  ptMax = parameters.getParameter<double>("ptMax");
36  pResBin = parameters.getParameter<int>("pResBin");
37  pResMin = parameters.getParameter<double>("pResMin");
38  pResMax = parameters.getParameter<double>("pResMax");
39  rhBin=parameters.getParameter<int>("rhBin");
40  rhMin=parameters.getParameter<double>("rhMin");
41  rhMax=parameters.getParameter<double>("rhMax");
42  pBin = parameters.getParameter<int>("pBin");
43  pMin = parameters.getParameter<double>("pMin");
44  pMax = parameters.getParameter<double>("pMax");
45  chi2Bin = parameters.getParameter<int>("chi2Bin");
46  chi2Min = parameters.getParameter<double>("chi2Min");
47  chi2Max = parameters.getParameter<double>("chi2Max");
48  phiBin = parameters.getParameter<int>("phiBin");
49  phiMin = parameters.getParameter<double>("phiMin");
50  phiMax = parameters.getParameter<double>("phiMax");
51  tunePBin= parameters.getParameter<int>("tunePBin");
52  tunePMax= parameters.getParameter<double>("tunePMax");
53  tunePMin= parameters.getParameter<double>("tunePMin");
54  thetaBin = parameters.getParameter<int>("thetaBin");
55  thetaMin = parameters.getParameter<double>("thetaMin");
56  thetaMax = parameters.getParameter<double>("thetaMax");
57  etaBin = parameters.getParameter<int>("etaBin");
58  etaMin = parameters.getParameter<double>("etaMin");
59  etaMax = parameters.getParameter<double>("etaMax");
60 
61  theFolder = parameters.getParameter<string>("folder");
62 }
63 
64 
66  delete theService;
67 }
69  edm::Run const & /*iRun*/,
70  edm::EventSetup const & /* iSetup */){
71 
72  ibooker.cd();
73  ibooker.setCurrentFolder(theFolder);
74 
75  muReco = ibooker.book1D("muReco", "muon reconstructed tracks", 6, 1, 7);
76  muReco->setBinLabel(1,"glb+tk+sta");
77  muReco->setBinLabel(2,"glb+sta");
78  muReco->setBinLabel(3,"tk+sta");
79  muReco->setBinLabel(4,"tk");
80  muReco->setBinLabel(5,"sta");
81  muReco->setBinLabel(6,"calo");
82 
83  int binFactor = 4;
84 
86  // monitoring of eta parameter
88  std::string histname = "GlbMuon_";
89  etaGlbTrack .push_back(ibooker.book1D(histname+"Glb_eta", "#eta_{GLB}", etaBin, etaMin, etaMax));
90  etaGlbTrack .push_back(ibooker.book1D(histname+"Tk_eta", "#eta_{TKfromGLB}", etaBin, etaMin, etaMax));
91  etaGlbTrack .push_back(ibooker.book1D(histname+"Sta_eta", "#eta_{STAfromGLB}", etaBin, etaMin, etaMax));
92  etaResolution.push_back(ibooker.book1D("Res_TkGlb_eta", "#eta_{TKfromGLB} - #eta_{GLB}", etaBin*binFactor, etaMin/3000, etaMax/3000));
93  etaResolution.push_back(ibooker.book1D("Res_GlbSta_eta", "#eta_{GLB} - #eta_{STAfromGLB}", etaBin*binFactor, etaMin/100, etaMax/100));
94  etaResolution.push_back(ibooker.book1D("Res_TkSta_eta", "#eta_{TKfromGLB} - #eta_{STAfromGLB}", etaBin*binFactor, etaMin/100, etaMax/100));
95  etaResolution.push_back(ibooker.book2D("ResVsEta_TkGlb_eta", "(#eta_{TKfromGLB} - #eta_{GLB}) vs #eta_{GLB}", etaBin, etaMin, etaMax, etaBin*binFactor, etaMin/3000, etaMax/3000));
96  etaResolution.push_back(ibooker.book2D("ResVsEta_GlbSta_eta", "(#eta_{GLB} - #eta_{STAfromGLB}) vs #eta_{GLB}", etaBin, etaMin, etaMax, etaBin*binFactor, etaMin/100, etaMax/100));
97  etaResolution.push_back(ibooker.book2D("ResVsEta_TkSta_eta", "(#eta_{TKfromGLB} - #eta_{STAfromGLB}) vs #eta_{TKfromGLB}", etaBin, etaMin, etaMax, etaBin*binFactor, etaMin/100, etaMax/100));
98  etaPull = ibooker.book1D("Pull_TkSta_eta", "#eta_{TKfromGLB} - #eta_{GLB} / error", 100, -10, 10);
99  etaTrack = ibooker.book1D("TkMuon_eta", "#eta_{TK}", etaBin, etaMin, etaMax);
100  etaStaTrack = ibooker.book1D("StaMuon_eta", "#eta_{STA}", etaBin, etaMin, etaMax);
101  etaEfficiency.push_back(ibooker.book1D("StaEta", "#eta_{STAfromGLB}", etaBin, etaMin, etaMax));
102  etaEfficiency.push_back(ibooker.book1D("StaEta_ifCombinedAlso", "#eta_{STAfromGLB} if isGlb=true", etaBin, etaMin, etaMax));
103 
105  // monitoring of theta parameter
107  thetaGlbTrack.push_back(ibooker.book1D(histname+"Glb_theta", "#theta_{GLB}", thetaBin, thetaMin, thetaMax)); thetaGlbTrack[0]->setAxisTitle("rad");
108  thetaGlbTrack.push_back(ibooker.book1D(histname+"Tk_theta", "#theta_{TKfromGLB}", thetaBin, thetaMin, thetaMax)); thetaGlbTrack[1]->setAxisTitle("rad");
109  thetaGlbTrack.push_back(ibooker.book1D(histname+"Sta_theta", "#theta_{STAfromGLB}", thetaBin, thetaMin, thetaMax)); thetaGlbTrack[2]->setAxisTitle("rad");
110  thetaResolution.push_back(ibooker.book1D("Res_TkGlb_theta", "#theta_{TKfromGLB} - #theta_{GLB}", thetaBin*binFactor, -(thetaMax/3000), thetaMax/3000)); thetaResolution[0]->setAxisTitle("rad");
111  thetaResolution.push_back(ibooker.book1D("Res_GlbSta_theta", "#theta_{GLB} - #theta_{STAfromGLB}", thetaBin*binFactor,-(thetaMax/100), thetaMax/100));
112  thetaResolution[1]->setAxisTitle("rad");
113  thetaResolution.push_back(ibooker.book1D("Res_TkSta_theta", "#theta_{TKfromGLB} - #theta_{STAfromGLB}", thetaBin*binFactor, -(thetaMax/100), thetaMax/100));
114  thetaResolution[2]->setAxisTitle("rad");
115  thetaResolution.push_back(ibooker.book2D("ResVsTheta_TkGlb_theta", "(#theta_{TKfromGLB} - #theta_{GLB}) vs #theta_{GLB}", thetaBin, thetaMin, thetaMax, thetaBin*binFactor, -(thetaMax/3000), thetaMax/3000));
116  thetaResolution[3]->setAxisTitle("rad",1);
117  thetaResolution[3]->setAxisTitle("rad",2);
118  thetaResolution.push_back(ibooker.book2D("ResVsTheta_GlbSta_theta", "(#theta_{GLB} - #theta_{STAfromGLB}) vs #theta_{GLB}", thetaBin, thetaMin, thetaMax, thetaBin*binFactor, -(thetaMax/100), thetaMax/100));
119  thetaResolution[4]->setAxisTitle("rad",1);
120  thetaResolution[4]->setAxisTitle("rad",2);
121  thetaResolution.push_back(ibooker.book2D("ResVsTheta_TkSta_theta", "(#theta_{TKfromGLB} - #theta_{STAfromGLB}) vs #theta_{TKfromGLB}", thetaBin, thetaMin, thetaMax, thetaBin*binFactor, -(thetaMax/100), thetaMax/100));
122  thetaResolution[5]->setAxisTitle("rad",1);
123  thetaResolution[5]->setAxisTitle("rad",2);
124  thetaPull = ibooker.book1D("Pull_TkSta_theta", "#theta_{TKfromGLB} - #theta_{STAfromGLB} / error", 100,-10,10);
125  thetaTrack = ibooker.book1D("TkMuon_theta", "#theta_{TK}", thetaBin, thetaMin, thetaMax);
126  thetaTrack->setAxisTitle("rad");
127  thetaStaTrack = ibooker.book1D("StaMuon_theta", "#theta_{STA}", thetaBin, thetaMin, thetaMax);
128  thetaStaTrack->setAxisTitle("rad");
129 
130  // monitoring tunePMuonBestTrack Pt
131  tunePResolution = ibooker.book1D("Res_TuneP_pt", "Pt_{MuonBestTrack}-Pt_{tunePMuonBestTrack}/Pt_{MuonBestTrack}", tunePBin, tunePMin, tunePMax);
132 
133  // monitoring of phi paramater
134  phiGlbTrack.push_back(ibooker.book1D(histname+"Glb_phi", "#phi_{GLB}", phiBin, phiMin, phiMax));
135  phiGlbTrack[0]->setAxisTitle("rad");
136  phiGlbTrack.push_back(ibooker.book1D(histname+"Tk_phi", "#phi_{TKfromGLB}", phiBin, phiMin, phiMax));
137  phiGlbTrack[1]->setAxisTitle("rad");
138  phiGlbTrack.push_back(ibooker.book1D(histname+"Sta_phi", "#phi_{STAfromGLB}", phiBin, phiMin, phiMax));
139  phiGlbTrack[2]->setAxisTitle("rad");
140  phiResolution.push_back(ibooker.book1D("Res_TkGlb_phi", "#phi_{TKfromGLB} - #phi_{GLB}", phiBin*binFactor, phiMin/3000, phiMax/3000));
141  phiResolution[0]->setAxisTitle("rad");
142  phiResolution.push_back(ibooker.book1D("Res_GlbSta_phi", "#phi_{GLB} - #phi_{STAfromGLB}", phiBin*binFactor, phiMin/100, phiMax/100));
143  phiResolution[1]->setAxisTitle("rad");
144  phiResolution.push_back(ibooker.book1D("Res_TkSta_phi", "#phi_{TKfromGLB} - #phi_{STAfromGLB}", phiBin*binFactor, phiMin/100, phiMax/100));
145  phiResolution[2]->setAxisTitle("rad");
146  phiResolution.push_back(ibooker.book2D("ResVsPhi_TkGlb_phi", "(#phi_{TKfromGLB} - #phi_{GLB}) vs #phi_GLB", phiBin, phiMin, phiMax, phiBin*binFactor, phiMin/3000, phiMax/3000));
147  phiResolution[3]->setAxisTitle("rad",1);
148  phiResolution[3]->setAxisTitle("rad",2);
149  phiResolution.push_back(ibooker.book2D("ResVsPhi_GlbSta_phi", "(#phi_{GLB} - #phi_{STAfromGLB}) vs #phi_{GLB}", phiBin, phiMin, phiMax, phiBin*binFactor, phiMin/100, phiMax/100));
150  phiResolution[4]->setAxisTitle("rad",1);
151  phiResolution[4]->setAxisTitle("rad",2);
152  phiResolution.push_back(ibooker.book2D("ResVsPhi_TkSta_phi", "(#phi_{TKfromGLB} - #phi_{STAfromGLB}) vs #phi_{TKfromGLB}", phiBin, phiMin, phiMax, phiBin*binFactor, phiMin/100, phiMax/100));
153  phiResolution[5]->setAxisTitle("rad",1);
154  phiResolution[5]->setAxisTitle("rad",2);
155  phiPull = ibooker.book1D("Pull_TkSta_phi", "#phi_{TKfromGLB} - #phi_{STAfromGLB} / error", 100,-10,10);
156  phiTrack = ibooker.book1D("TkMuon_phi", "#phi_{TK}", phiBin, phiMin, phiMax);
157  phiTrack->setAxisTitle("rad");
158  phiStaTrack = ibooker.book1D("StaMuon_phi", "#phi_{STA}", phiBin, phiMin, phiMax);
159  phiStaTrack->setAxisTitle("rad");
160  phiEfficiency.push_back(ibooker.book1D("StaPhi", "#phi_{STAfromGLB}", phiBin, phiMin, phiMax));
161  phiEfficiency[0]->setAxisTitle("rad");
162  phiEfficiency.push_back(ibooker.book1D("StaPhi_ifCombinedAlso", "#phi_{STAfromGLB} if the isGlb=true", phiBin, phiMin, phiMax));
163  phiEfficiency[1]->setAxisTitle("rad");
164 
165  // monitoring of the chi2 parameter
166  chi2OvDFGlbTrack.push_back(ibooker.book1D(histname+"Glb_chi2OverDf", "#chi_{2}OverDF_{GLB}", chi2Bin, chi2Min, chi2Max));
167  chi2OvDFGlbTrack.push_back(ibooker.book1D(histname+"Tk_chi2OverDf", "#chi_{2}OverDF_{TKfromGLB}", phiBin, chi2Min, chi2Max));
168  chi2OvDFGlbTrack.push_back(ibooker.book1D(histname+"Sta_chi2OverDf", "#chi_{2}OverDF_{STAfromGLB}", chi2Bin, chi2Min, chi2Max));
169  chi2OvDFTrack = ibooker.book1D("TkMuon_chi2OverDf", "#chi_{2}OverDF_{TK}", chi2Bin, chi2Min, chi2Max);
170  chi2OvDFStaTrack = ibooker.book1D("StaMuon_chi2OverDf", "#chi_{2}OverDF_{STA}", chi2Bin, chi2Min, chi2Max);
171 //--------------------------
172  probchi2GlbTrack.push_back(ibooker.book1D(histname+"Glb_probchi", "Prob #chi_{GLB}", 120, chi2Min, 1.20));
173  probchi2GlbTrack.push_back(ibooker.book1D(histname+"Tk_probchi", "Prob #chi_{TKfromGLB}", 120, chi2Min, 1.20));
174  probchi2GlbTrack.push_back(ibooker.book1D(histname+"Sta_probchi", "Prob #chi_{STAfromGLB}", 120, chi2Min, 1.20));
175  probchi2Track=ibooker.book1D("TkMuon_probchi", "Prob #chi_{TK}", 120, chi2Min, 1.20);
176  probchi2StaTrack=ibooker.book1D("StaMuon_probchi", "Prob #chi_{STA}", 120, chi2Min, 1.20);
177 
178  // monitoring of the momentum
179  pGlbTrack.push_back(ibooker.book1D(histname+"Glb_p", "p_{GLB}", pBin, pMin, pMax));
180  pGlbTrack[0]->setAxisTitle("GeV");
181  pGlbTrack.push_back(ibooker.book1D(histname+"Tk_p", "p_{TKfromGLB}", pBin, pMin, pMax));
182  pGlbTrack[1]->setAxisTitle("GeV");
183  pGlbTrack.push_back(ibooker.book1D(histname+"Sta_p", "p_{STAfromGLB}", pBin, pMin, pMax));
184  pGlbTrack[2]->setAxisTitle("GeV");
185  pTrack = ibooker.book1D("TkMuon_p", "p_{TK}", pBin, pMin, pMax);
186  pTrack->setAxisTitle("GeV");
187  pStaTrack = ibooker.book1D("StaMuon_p", "p_{STA}", pBin, pMin, pMax);
188  pStaTrack->setAxisTitle("GeV");
189 
190  // monitoring of the transverse momentum
191  ptGlbTrack.push_back(ibooker.book1D(histname+"Glb_pt", "pt_{GLB}", ptBin, ptMin, ptMax));
192  ptGlbTrack[0]->setAxisTitle("GeV");
193  ptGlbTrack.push_back(ibooker.book1D(histname+"Tk_pt", "pt_{TKfromGLB}", ptBin, ptMin, ptMax));
194  ptGlbTrack[1]->setAxisTitle("GeV");
195  ptGlbTrack.push_back(ibooker.book1D(histname+"Sta_pt", "pt_{STAfromGLB}", ptBin, ptMin, ptMax));
196  ptGlbTrack[2]->setAxisTitle("GeV");
197  ptTrack = ibooker.book1D("TkMuon_pt", "pt_{TK}", ptBin, ptMin, ptMax);
198  ptTrack->setAxisTitle("GeV");
199  ptStaTrack = ibooker.book1D("StaMuon_pt", "pt_{STA}", ptBin, ptMin, pMax);
200  ptStaTrack->setAxisTitle("GeV");
201 
202 
203  //monitoring of variables needed by the MVA soft muon
204 
205  ptSoftMuonMVA = ibooker.book1D("ptSoftMuonMVA", "pt_{SoftMuon}", 50, 0, 50);
206  deltaRSoftMuonMVA = ibooker.book1D("deltaRSoftMuonMVA", "#Delta R", 50, 0, 5);
207  gNchi2SoftMuonMVA = ibooker.book1D("gNchi2SoftMuonMVA", "gNchi2", 50, 0, 3);
208  vMuHitsSoftMuonMVA = ibooker.book1D("vMuHitsSoftMuonMVA", "vMuHits", 50, 0, 50);
209  mNuStationsSoftMuonMVA = ibooker.book1D("mNuStationsSoftMuonMVA", "mNuStations", 6, 0, 6);
210  dxyRefSoftMuonMVA = ibooker.book1D("dxyRefSoftMuonMVA", "dxyRef", 50, -0.1, 0.1);
211  dzRefSoftMuonMVA = ibooker.book1D("dzRefSoftMuonMVA", "dzRef", 50, -0.1, 0.1);
212  LWHSoftMuonMVA = ibooker.book1D("LWHSoftMuonMVA", "LWH", 20, 0, 20);
213  valPixHitsSoftMuonMVA = ibooker.book1D("valPixHitsSoftMuonMVA", "valPixHits", 8, 0, 8);
214  innerChi2SoftMuonMVA = ibooker.book1D("innerChi2SoftMuonMVA", "innerChi2", 50, 0, 3);
215  outerChi2SoftMuonMVA = ibooker.book1D("outerChi2SoftMuonMVA", "outerChi2", 50, 0, 4);
216  iValFracSoftMuonMVA = ibooker.book1D("iValFracSoftMuonMVA", "iValFrac", 50, 0.5, 1.0);
217  segCompSoftMuonMVA = ibooker.book1D("segCompSoftMuonMVA", "segComp", 50, 0, 1.2);
218  chi2LocMomSoftMuonMVA = ibooker.book1D("chi2LocMomSoftMuonMVA", "chi2LocMom", 50, 0, 40);
219  chi2LocPosSoftMuonMVA = ibooker.book1D("chi2LocPosSoftMuonMVA", "chi2LocPos", 0, 0, 8);
220  glbTrackTailProbSoftMuonMVA = ibooker.book1D("glbTrackTailProbSoftMuonMVA", "glbTrackTailProb", 50, 0, 8);
221  NTrkVHitsSoftMuonMVA = ibooker.book1D("NTrkVHitsSoftMuonMVA", "NTrkVHits", 50, 0, 35);
222  kinkFinderSoftMuonMVA = ibooker.book1D("kinkFinderSoftMuonMVA", "kinkFinder", 50, 0, 30);
223  vRPChitsSoftMuonMVA = ibooker.book1D("vRPChitsSoftMuonMVA", "vRPChits", 50, 0, 50);
224  glbKinkFinderSoftMuonMVA = ibooker.book1D("glbKinkFinderSoftMuonMVA", "glbKinkFinder", 50, 0, 50);
225  glbKinkFinderLogSoftMuonMVA = ibooker.book1D("glbKinkFinderLogSoftMuonMVA", "glbKinkFinderLog", 50, 0, 50);
226  staRelChi2SoftMuonMVA = ibooker.book1D("staRelChi2SoftMuonMVA", "staRelChi2", 50, 0, 2);
227  glbDeltaEtaPhiSoftMuonMVA = ibooker.book1D("glbDeltaEtaPhiSoftMuonMVA", "glbDeltaEtaPhi", 50, 0, 0.15);
228  trkRelChi2SoftMuonMVA = ibooker.book1D("trkRelChi2SoftMuonMVA", "trkRelChi2", 50, 0, 1.2);
229  vDThitsSoftMuonMVA = ibooker.book1D("vDThitsSoftMuonMVA", "vDThits", 50, 0, 50);
230  vCSChitsSoftMuonMVA = ibooker.book1D("vCSChitsSoftMuonMVA", "vCSChits", 50, 0, 50);
231  timeAtIpInOutSoftMuonMVA = ibooker.book1D("timeAtIpInOutSoftMuonMVA", "timeAtIpInOut", 50, -10.0, 10.0);
232  timeAtIpInOutErrSoftMuonMVA = ibooker.book1D("timeAtIpInOutErrSoftMuonMVA", "timeAtIpInOutErr", 50, 0, 3.5);
233  getMuonHitsPerStationSoftMuonMVA = ibooker.book1D("getMuonHitsPerStationSoftMuonMVA", "getMuonHitsPerStation", 6, 0, 6);
234  QprodSoftMuonMVA = ibooker.book1D("QprodSoftMuonMVA", "Qprod", 4, -2, 2);
235 
236 
237 
238  // monitoring of the muon charge
239  qGlbTrack.push_back(ibooker.book1D(histname+"Glb_q", "q_{GLB}", 5, -2.5, 2.5));
240  qGlbTrack.push_back(ibooker.book1D(histname+"Tk_q", "q_{TKfromGLB}", 5, -2.5, 2.5));
241  qGlbTrack.push_back(ibooker.book1D(histname+"Sta_q", "q_{STAformGLB}", 5, -2.5, 2.5));
242  qGlbTrack.push_back(ibooker.book1D(histname+"qComparison", "comparison between q_{GLB} and q_{TKfromGLB}, q_{STAfromGLB}", 8, 0.5, 8.5));
243  qGlbTrack[3]->setBinLabel(1,"qGlb=qSta");
244  qGlbTrack[3]->setBinLabel(2,"qGlb!=qSta");
245  qGlbTrack[3]->setBinLabel(3,"qGlb=qTk");
246  qGlbTrack[3]->setBinLabel(4,"qGlb!=qTk");
247  qGlbTrack[3]->setBinLabel(5,"qSta=qTk");
248  qGlbTrack[3]->setBinLabel(6,"qSta!=qTk");
249  qGlbTrack[3]->setBinLabel(7,"qGlb!=qSta,qGlb!=Tk");
250  qGlbTrack[3]->setBinLabel(8,"qGlb=qSta,qGlb=Tk");
251  qTrack = ibooker.book1D("TkMuon_q", "q_{TK}", 5, -2.5, 2.5);
252  qStaTrack = ibooker.book1D("StaMuon_q", "q_{STA}", 5, -2.5, 2.5);
253 
255  // monitoring of the momentum resolution
256  qOverpResolution.push_back(ibooker.book1D("Res_TkGlb_qOverp", "(q/p)_{TKfromGLB} - (q/p)_{GLB}", pResBin*binFactor*2, pResMin/10, pResMax/10));
257  qOverpResolution[0]->setAxisTitle("GeV^{-1}");
258  qOverpResolution.push_back(ibooker.book1D("Res_GlbSta_qOverp", "(q/p)_{GLB} - (q/p)_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
259  qOverpResolution[1]->setAxisTitle("GeV^{-1}");
260  qOverpResolution.push_back(ibooker.book1D("Res_TkSta_qOverp", "(q/p)_{TKfromGLB} - (q/p)_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
261  qOverpResolution[2]->setAxisTitle("GeV^{-1}");
262  qOverpPull = ibooker.book1D("Pull_TkSta_qOverp", "(q/p)_{TKfromGLB} - (q/p)_{STAfromGLB} / error", 100,-10,10);
263 
264  oneOverpResolution.push_back(ibooker.book1D("Res_TkGlb_oneOverp", "(1/p)_{TKfromGLB} - (1/p)_{GLB}", pResBin*binFactor*2, pResMin/10, pResMax/10));
265  oneOverpResolution[0]->setAxisTitle("GeV^{-1}");
266  oneOverpResolution.push_back(ibooker.book1D("Res_GlbSta_oneOverp", "(1/p)_{GLB} - (1/p)_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
267  oneOverpResolution[1]->setAxisTitle("GeV^{-1}");
268  oneOverpResolution.push_back(ibooker.book1D("Res_TkSta_oneOverp", "(q/p)_{TKfromGLB} - (q/p)_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
269  oneOverpResolution[2]->setAxisTitle("GeV^{-1}");
270  oneOverpPull = ibooker.book1D("Pull_TkSta_oneOverp", "(1/p)_{TKfromGLB} - (1/p)_{STAfromGLB} / error", 100,-10,10);
271 
272 
273  qOverptResolution.push_back(ibooker.book1D("Res_TkGlb_qOverpt", "(q/p_{t})_{TKfromGLB} - (q/p_{t})_{GLB}", pResBin*binFactor*2, pResMin/10, pResMax/10));
274  qOverptResolution[0]->setAxisTitle("GeV^{-1}");
275  qOverptResolution.push_back(ibooker.book1D("Res_GlbSta_qOverpt", "(q/p_{t})_{GLB} - (q/p_{t})_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
276  qOverptResolution[1]->setAxisTitle("GeV^{-1}");
277  qOverptResolution.push_back(ibooker.book1D("Res_TkSta_qOverpt", "(q/p_{t})_{TKfromGLB} - (q/p_{t})_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
278  qOverptResolution[2]->setAxisTitle("GeV^{-1}");
279  qOverptPull = ibooker.book1D("Pull_TkSta_qOverpt", "(q/pt)_{TKfromGLB} - (q/pt)_{STAfromGLB} / error", 100,-10,10);
280 
281  oneOverptResolution.push_back(ibooker.book1D("Res_TkGlb_oneOverpt", "(1/p_{t})_{TKfromGLB} - (1/p_{t})_{GLB}", pResBin*binFactor*2, pResMin/10, pResMax/10));
282  oneOverptResolution[0]->setAxisTitle("GeV^{-1}");
283  oneOverptResolution.push_back(ibooker.book1D("Res_GlbSta_oneOverpt", "(1/p_{t})_{GLB} - (1/p_{t})_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
284  oneOverptResolution[1]->setAxisTitle("GeV^{-1}");
285  oneOverptResolution.push_back(ibooker.book1D("Res_TkSta_oneOverpt", "(1/p_{t})_{TKfromGLB} - (1/p_{t})_{STAfromGLB}", pResBin*binFactor, pResMin, pResMax));
286  oneOverptResolution[2]->setAxisTitle("GeV^{-1}");
287  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));
288  oneOverptResolution[3]->setAxisTitle("GeV^{-1}",2);
289  oneOverptResolution.push_back(ibooker.book2D("ResVsEta_GlbSta_oneOverpt", "(#eta_{GLB} - #eta_{STAfromGLB} vs (1/p_{t})_{GLB}", etaBin, etaMin, etaMax, pResBin*binFactor, pResMin, pResMax));
290  oneOverptResolution[4]->setAxisTitle("GeV^{-1}",2);
291  oneOverptResolution.push_back(ibooker.book2D("ResVsEta_TkSta_oneOverpt", "(#eta_{TKfromGLB} - #eta_{STAfromGLB}) vs (1/p_{t})_{TKfromGLB}", etaBin, etaMin, etaMax, pResBin*binFactor, pResMin, pResMax));
292  oneOverptResolution[5]->setAxisTitle("GeV^{-1}",2);
293  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));
294  oneOverptResolution[6]->setAxisTitle("rad",1);
295  oneOverptResolution[6]->setAxisTitle("GeV^{-1}",2);
296  oneOverptResolution.push_back(ibooker.book2D("ResVsPhi_GlbSta_oneOverpt", "(#phi_{GLB} - #phi_{STAfromGLB} vs (1/p_{t})_{GLB}", phiBin, phiMin, phiMax, pResBin*binFactor, pResMin, pResMax));
297  oneOverptResolution[7]->setAxisTitle("rad",1);
298  oneOverptResolution[7]->setAxisTitle("GeV^{-1}",2);
299  oneOverptResolution.push_back(ibooker.book2D("ResVsPhi_TkSta_oneOverpt", "(#phi_{TKfromGLB} - #phi_{STAfromGLB}) vs (1/p_{t})_{TKfromGLB}", phiBin, phiMin, phiMax, pResBin*binFactor, pResMin, pResMax));
300  oneOverptResolution[8]->setAxisTitle("rad",1);
301  oneOverptResolution[8]->setAxisTitle("GeV^{-1}",2);
302  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));
303  oneOverptResolution[9]->setAxisTitle("GeV^{-1}",1);
304  oneOverptResolution[9]->setAxisTitle("GeV^{-1}",2);
305  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));
306  oneOverptResolution[10]->setAxisTitle("GeV^{-1}",1);
307  oneOverptResolution[10]->setAxisTitle("GeV^{-1}",2);
308  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));
309  oneOverptResolution[11]->setAxisTitle("GeV^{-1}",1);
310  oneOverptResolution[11]->setAxisTitle("GeV^{-1}",2);
311  oneOverptPull = ibooker.book1D("Pull_TkSta_oneOverpt", "(1/pt)_{TKfromGLB} - (1/pt)_{STAfromGLB} / error", 100,-10,10);
312 
314  // monitoring of the phi-eta
315  phiVsetaGlbTrack.push_back(ibooker.book2D(histname+"Glb_phiVSeta", "#phi vs #eta (GLB)", etaBin/2, etaMin, etaMax, phiBin/2, phiMin, phiMax));
316  phiVsetaGlbTrack.push_back(ibooker.book2D(histname+"Tk_phiVSeta", "#phi vs #eta (TKfromGLB)", etaBin/2, etaMin, etaMax, phiBin/2, phiMin, phiMax));
317  phiVsetaGlbTrack.push_back(ibooker.book2D(histname+"Sta_phiVseta", "#phi vs #eta (STAfromGLB)", etaBin/2, etaMin, etaMax, phiBin/2, phiMin, phiMax));
318 
319  phiVsetaGlbTrack_badlumi.push_back(ibooker.book2D(histname+"Glb_phiVSeta_badlumi", "#phi vs #eta (GLB)", etaBin/2, etaMin, etaMax, phiBin/2, phiMin, phiMax));
320  phiVsetaGlbTrack_badlumi.push_back(ibooker.book2D(histname+"Tk_phiVSeta_badlumi", "#phi vs #eta (TKfromGLB)", etaBin/2, etaMin, etaMax, phiBin/2, phiMin, phiMax));
321  phiVsetaGlbTrack_badlumi.push_back(ibooker.book2D(histname+"Sta_phiVseta_badlumi", "#phi vs #eta (STAfromGLB)", etaBin/2, etaMin, etaMax, phiBin/2, phiMin, phiMax));
322 
323 
325  // monitoring of the recHits provenance
326  rhAnalysis.push_back(ibooker.book1D("StaRh_Frac_inGlb", "recHits_{STAinGLB} / recHits_{GLB}", rhBin, rhMin, rhMax));
327  rhAnalysis.push_back(ibooker.book1D("TkRh_Frac_inGlb", "recHits_{TKinGLB} / recHits_{GLB}", rhBin, rhMin, rhMax));
328  rhAnalysis.push_back(ibooker.book1D("StaRh_inGlb_Div_RhAssoSta", "recHits_{STAinGLB} / recHits_{STAfromGLB}", rhBin, rhMin, rhMax));
329  rhAnalysis.push_back(ibooker.book1D("TkRh_inGlb_Div_RhAssoTk", "recHits_{TKinGLB} / recHits_{TKfromGLB}", rhBin, rhMin, rhMax));
330  rhAnalysis.push_back(ibooker.book1D("GlbRh_Div_RhAssoStaTk", "recHits_{GLB} / (recHits_{TKfromGLB}+recHits_{STAfromGLB})", rhBin, rhMin, rhMax));
331  rhAnalysis.push_back(ibooker.book1D("invalidRh_Frac_inTk", "Invalid recHits / rechits_{GLB}", rhBin, rhMin, rhMax));
332 
334  // monitoring of the muon system rotation w.r.t. tracker
335  muVStkSytemRotation.push_back(ibooker.book2D("muVStkSytemRotation_posMu", "pT_{TK} / pT_{GLB} vs pT_{GLB} for #mu^{+}", 50,0,200,100,0.8,1.2));
336  muVStkSytemRotation.push_back(ibooker.book2D("muVStkSytemRotation_negMu", "pT_{TK} / pT_{GLB} vs pT_{GLB} for #mu^{-}", 50,0,200,100,0.8,1.2));
337 
338 }
339 
340 void MuonRecoAnalyzer::GetRes( reco::TrackRef t1, reco::TrackRef t2, string par, float &res, float &pull){
341 
342  float p1=0, p2=0, p1e=1, p2e=1;
343 
344  if(par == "eta") {
345  p1 = t1->eta(); p1e = t1->etaError();
346  p2 = t2->eta(); p2e = t2->etaError();
347  }
348  else if(par == "theta") {
349  p1 = t1->theta(); p1e = t1->thetaError();
350  p2 = t2->theta(); p2e = t2->thetaError();
351  }
352  else if(par == "phi") {
353  p1 = t1->phi(); p1e = t1->phiError();
354  p2 = t2->phi(); p2e = t2->phiError();
355  }
356  else if(par == "qOverp") {
357  p1 = t1->charge()/t1->p(); p1e = t1->qoverpError();
358  p2 = t2->charge()/t2->p(); p2e = t2->qoverpError();
359  }
360  else if(par == "oneOverp") {
361  p1 = 1./t1->p(); p1e = t1->qoverpError();
362  p2 = 1./t2->p(); p2e = t2->qoverpError();
363  }
364  else if(par == "qOverpt") {
365  p1 = t1->charge()/t1->pt(); p1e = t1->ptError()*p1*p1;
366  p2 = t2->charge()/t2->pt(); p2e = t2->ptError()*p2*p2;
367  }
368  else if(par == "oneOverpt") {
369  p1 = 1./t1->pt(); p1e = t1->ptError()*p1*p1;
370  p2 = 1./t2->pt(); p2e = t2->ptError()*p2*p2;
371  }
372 
373  res = p1 - p2;
374  if(p1e!=0 || p2e!=0) pull = res / sqrt(p1e*p1e + p2e*p2e);
375  else pull = -99;
376  return;
377 }
378 
379 
380 
381 
382 
383 
384 
385 
386 
388  LogTrace(metname)<<"[MuonRecoAnalyzer] Analyze the mu";
389  theService->update(iSetup);
390 
391  // Take the muon container
393  iEvent.getByToken(theMuonCollectionLabel_,muons);
394 
397  if(doMVA) {
398  iEvent.getByToken(theBeamSpotLabel_, beamSpot);
399  if(!beamSpot.isValid()) {edm::LogInfo("MuonRecoAnalyzer") << "Error: Can't get the beamspot" << endl; doMVA = false;}
400  iEvent.getByToken(theVertexLabel_, vertex);
401  if(!vertex.isValid()) {edm::LogInfo("MuonRecoAnalyzer") << "Error: Can't get the vertex collection" << endl; doMVA = false;}
402  }
403 
404  //In this part we determine if we want to fill the plots for events where the DCS flag was set to bad
406  bool fillBadLumi = false;
407  if(iEvent.getByToken(dcsStatusCollection_, dcsStatus) && dcsStatus.isValid()) {
408  for (auto const & dcsStatusItr : *dcsStatus) {
409  if (!dcsStatusItr.ready(DcsStatus::CSCp)) fillBadLumi = true;
410  if (!dcsStatusItr.ready(DcsStatus::CSCm)) fillBadLumi = true;
411  if (!dcsStatusItr.ready(DcsStatus::DT0)) fillBadLumi = true;
412  if (!dcsStatusItr.ready(DcsStatus::DTp)) fillBadLumi = true;
413  if (!dcsStatusItr.ready(DcsStatus::DTm)) fillBadLumi = true;
414  if (!dcsStatusItr.ready(DcsStatus::EBp)) fillBadLumi = true;
415  if (!dcsStatusItr.ready(DcsStatus::EBm)) fillBadLumi = true;
416  if (!dcsStatusItr.ready(DcsStatus::EEp)) fillBadLumi = true;
417  if (!dcsStatusItr.ready(DcsStatus::EEm)) fillBadLumi = true;
418  if (!dcsStatusItr.ready(DcsStatus::ESp)) fillBadLumi = true;
419  if (!dcsStatusItr.ready(DcsStatus::ESm)) fillBadLumi = true;
420  if (!dcsStatusItr.ready(DcsStatus::HBHEa)) fillBadLumi = true;
421  if (!dcsStatusItr.ready(DcsStatus::HBHEb)) fillBadLumi = true;
422  if (!dcsStatusItr.ready(DcsStatus::HBHEc)) fillBadLumi = true;
423  if (!dcsStatusItr.ready(DcsStatus::HF)) fillBadLumi = true;
424  if (!dcsStatusItr.ready(DcsStatus::HO)) fillBadLumi = true;
425  if (!dcsStatusItr.ready(DcsStatus::BPIX)) fillBadLumi = true;
426  if (!dcsStatusItr.ready(DcsStatus::FPIX)) fillBadLumi = true;
427  if (!dcsStatusItr.ready(DcsStatus::RPC)) fillBadLumi = true;
428  if (!dcsStatusItr.ready(DcsStatus::TIBTID)) fillBadLumi = true;
429  if (!dcsStatusItr.ready(DcsStatus::TOB)) fillBadLumi = true;
430  if (!dcsStatusItr.ready(DcsStatus::TECp)) fillBadLumi = true;
431  if (!dcsStatusItr.ready(DcsStatus::TECm)) fillBadLumi = true;
432  //if (!dcsStatusItr.ready(DcsStatus::CASTOR)) fillBadLumi = true;
433  }
434  }
435 
436  float res=0, pull=0;
437  if(!muons.isValid()) return;
438 
439  for (edm::View<reco::Muon>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon){
440 
441 
442  //Needed for MVA soft muon
443 
444  reco::TrackRef gTrack = muon->globalTrack();
445  reco::TrackRef iTrack = muon->innerTrack();
446  reco::TrackRef oTrack = muon->outerTrack();
447  if ( iTrack.isNonnull() && oTrack.isNonnull() && gTrack.isNonnull() ) {
448  const reco::HitPattern gHits = gTrack->hitPattern();
449  const reco::HitPattern iHits = iTrack->hitPattern();
450  const reco::MuonQuality muonQuality = muon->combinedQuality();
451  int pvIndex = 0;
452  math::XYZPoint refPoint;
453  if(doMVA) {
454  pvIndex = getPv(iTrack.index(), &(*vertex)); //HFDumpUtitilies
455  if (pvIndex > -1) {
456  refPoint = vertex->at(pvIndex).position();
457  } else {
458  if(beamSpot.isValid()) {
459  refPoint = beamSpot->position();
460  } else {
461  edm::LogInfo("MuonRecoAnalyzer") << "ERROR: No beam sport found!" << endl;
462  }
463  }
464  }
465  ptSoftMuonMVA->Fill(iTrack->eta());
466  deltaRSoftMuonMVA->Fill(getDeltaR(*iTrack,*oTrack));
467  gNchi2SoftMuonMVA->Fill(gTrack->normalizedChi2());
468  vMuHitsSoftMuonMVA->Fill(gHits.numberOfValidMuonHits());
469  mNuStationsSoftMuonMVA->Fill(muon->numberOfMatchedStations());
470  if(doMVA) {
471  dxyRefSoftMuonMVA->Fill(iTrack->dxy(refPoint));
472  dzRefSoftMuonMVA->Fill(iTrack->dz(refPoint));
473  }
474  LWHSoftMuonMVA->Fill(iHits.trackerLayersWithMeasurement());
475  valPixHitsSoftMuonMVA->Fill(iHits.numberOfValidPixelHits());
476  innerChi2SoftMuonMVA->Fill(iTrack->normalizedChi2());
477  outerChi2SoftMuonMVA->Fill(oTrack->normalizedChi2());
478  iValFracSoftMuonMVA->Fill(iTrack->validFraction());
479  //segCompSoftMuonMVA->Fill(reco::Muon::segmentCompatibility(*muon));
480  chi2LocMomSoftMuonMVA->Fill(muonQuality.chi2LocalMomentum);
481  chi2LocPosSoftMuonMVA->Fill(muonQuality.chi2LocalPosition);
482  glbTrackTailProbSoftMuonMVA->Fill(muonQuality.glbTrackProbability);
483  NTrkVHitsSoftMuonMVA->Fill(iHits.numberOfValidTrackerHits());
484  kinkFinderSoftMuonMVA->Fill(muonQuality.trkKink);
485  vRPChitsSoftMuonMVA->Fill(gHits.numberOfValidMuonRPCHits());
486  glbKinkFinderSoftMuonMVA->Fill(muonQuality.glbKink);
487  glbKinkFinderLogSoftMuonMVA->Fill(TMath::Log(2+muonQuality.glbKink));
488  staRelChi2SoftMuonMVA->Fill(muonQuality.staRelChi2);
489  glbDeltaEtaPhiSoftMuonMVA->Fill(muonQuality.globalDeltaEtaPhi);
490  trkRelChi2SoftMuonMVA->Fill(muonQuality.trkRelChi2);
491  vDThitsSoftMuonMVA->Fill(gHits.numberOfValidMuonDTHits());
492  vCSChitsSoftMuonMVA->Fill(gHits.numberOfValidMuonCSCHits());
493  timeAtIpInOutSoftMuonMVA->Fill(muon->time().timeAtIpInOut);
494  timeAtIpInOutErrSoftMuonMVA->Fill(muon->time().timeAtIpInOutErr);
495  //getMuonHitsPerStationSoftMuonMVA->Fill(gTrack);
496  QprodSoftMuonMVA->Fill((iTrack->charge() * oTrack->charge()));
497  }
498 
499  if(muon->isGlobalMuon()) {
500  LogTrace(metname)<<"[MuonRecoAnalyzer] The mu is global - filling the histos";
501  if(muon->isTrackerMuon() && muon->isStandAloneMuon())
502  muReco->Fill(1);
503  if(!(muon->isTrackerMuon()) && muon->isStandAloneMuon())
504  muReco->Fill(2);
505  if(!muon->isStandAloneMuon())
506  LogTrace(metname)<<"[MuonRecoAnalyzer] ERROR: the mu is global but not standalone!";
507  // get the track combinig the information from both the Tracker and the Spectrometer
508  reco::TrackRef recoCombinedGlbTrack = muon->combinedMuon();
509 
510  // get the track using only the tracker data
511  reco::TrackRef recoTkGlbTrack = muon->track();
512  // get the track using only the mu spectrometer data
513  reco::TrackRef recoStaGlbTrack = muon->standAloneMuon();
514  etaGlbTrack[0]->Fill(recoCombinedGlbTrack->eta());
515  etaGlbTrack[1]->Fill(recoTkGlbTrack->eta());
516  etaGlbTrack[2]->Fill(recoStaGlbTrack->eta());
517 
518  phiVsetaGlbTrack[0]->Fill(recoCombinedGlbTrack->eta(), recoCombinedGlbTrack->phi());
519  phiVsetaGlbTrack[1]->Fill(recoTkGlbTrack->eta() , recoTkGlbTrack->phi());
520  phiVsetaGlbTrack[2]->Fill(recoStaGlbTrack->eta() , recoStaGlbTrack->phi());
521 
522  if(fillBadLumi) {
523  phiVsetaGlbTrack_badlumi[0]->Fill(recoCombinedGlbTrack->eta(), recoCombinedGlbTrack->phi());
524  phiVsetaGlbTrack_badlumi[1]->Fill(recoTkGlbTrack->eta() , recoTkGlbTrack->phi());
525  phiVsetaGlbTrack_badlumi[2]->Fill(recoStaGlbTrack->eta() , recoStaGlbTrack->phi());
526  }
527 
528  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "eta", res, pull);
529  etaResolution[0]->Fill(res);
530  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "eta", res, pull);
531  etaResolution[1]->Fill(res);
532  GetRes(recoTkGlbTrack, recoStaGlbTrack, "eta", res, pull);
533  etaResolution[2]->Fill(res);
534  etaPull->Fill(pull);
535  etaResolution[3]->Fill(recoCombinedGlbTrack->eta(), recoTkGlbTrack->eta()-recoCombinedGlbTrack->eta());
536  etaResolution[4]->Fill(recoCombinedGlbTrack->eta(), -recoStaGlbTrack->eta()+recoCombinedGlbTrack->eta());
537  etaResolution[5]->Fill(recoCombinedGlbTrack->eta(), recoTkGlbTrack->eta()-recoStaGlbTrack->eta());
538 
539  thetaGlbTrack[0]->Fill(recoCombinedGlbTrack->theta());
540  thetaGlbTrack[1]->Fill(recoTkGlbTrack->theta());
541  thetaGlbTrack[2]->Fill(recoStaGlbTrack->theta());
542  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "theta", res, pull);
543  thetaResolution[0]->Fill(res);
544  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "theta", res, pull);
545  thetaResolution[1]->Fill(res);
546 
547  GetRes(recoTkGlbTrack, recoStaGlbTrack, "theta", res, pull);
548  thetaResolution[2]->Fill(res);
549  thetaPull->Fill(pull);
550  thetaResolution[3]->Fill(recoCombinedGlbTrack->theta(), recoTkGlbTrack->theta()-recoCombinedGlbTrack->theta());
551  thetaResolution[4]->Fill(recoCombinedGlbTrack->theta(), -recoStaGlbTrack->theta()+recoCombinedGlbTrack->theta());
552  thetaResolution[5]->Fill(recoCombinedGlbTrack->theta(), recoTkGlbTrack->theta()-recoStaGlbTrack->theta());
553 
554  phiGlbTrack[0]->Fill(recoCombinedGlbTrack->phi());
555  phiGlbTrack[1]->Fill(recoTkGlbTrack->phi());
556  phiGlbTrack[2]->Fill(recoStaGlbTrack->phi());
557  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "phi", res, pull);
558  phiResolution[0]->Fill(res);
559  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "phi", res, pull);
560  phiResolution[1]->Fill(res);
561  GetRes(recoTkGlbTrack, recoStaGlbTrack, "phi", res, pull);
562  phiResolution[2]->Fill(res);
563  phiPull->Fill(pull);
564  phiResolution[3]->Fill(recoCombinedGlbTrack->phi(), recoTkGlbTrack->phi()-recoCombinedGlbTrack->phi());
565  phiResolution[4]->Fill(recoCombinedGlbTrack->phi(), -recoStaGlbTrack->phi()+recoCombinedGlbTrack->phi());
566  phiResolution[5]->Fill(recoCombinedGlbTrack->phi(), recoTkGlbTrack->phi()-recoStaGlbTrack->phi());
567 
568  chi2OvDFGlbTrack[0]->Fill(recoCombinedGlbTrack->normalizedChi2());
569  chi2OvDFGlbTrack[1]->Fill(recoTkGlbTrack->normalizedChi2());
570  chi2OvDFGlbTrack[2]->Fill(recoStaGlbTrack->normalizedChi2());
571  //-------------------------
572  // double probchi = TMath::Prob(recoCombinedGlbTrack->normalizedChi2(),recoCombinedGlbTrack->ndof());
573  // cout << "rellenando histos."<<endl;
574  probchi2GlbTrack[0]->Fill(TMath::Prob(recoCombinedGlbTrack->chi2(),recoCombinedGlbTrack->ndof()));
575  probchi2GlbTrack[1]->Fill(TMath::Prob(recoTkGlbTrack->chi2(),recoTkGlbTrack->ndof()));
576  probchi2GlbTrack[2]->Fill(TMath::Prob(recoStaGlbTrack->chi2(),recoStaGlbTrack->ndof()));
577  // cout << "rellenados histos."<<endl;
578  //-------------------------
579 
580  pGlbTrack[0]->Fill(recoCombinedGlbTrack->p());
581  pGlbTrack[1]->Fill(recoTkGlbTrack->p());
582  pGlbTrack[2]->Fill(recoStaGlbTrack->p());
583 
584  ptGlbTrack[0]->Fill(recoCombinedGlbTrack->pt());
585  ptGlbTrack[1]->Fill(recoTkGlbTrack->pt());
586  ptGlbTrack[2]->Fill(recoStaGlbTrack->pt());
587 
588  qGlbTrack[0]->Fill(recoCombinedGlbTrack->charge());
589  qGlbTrack[1]->Fill(recoTkGlbTrack->charge());
590  qGlbTrack[2]->Fill(recoStaGlbTrack->charge());
591  if(recoCombinedGlbTrack->charge()==recoStaGlbTrack->charge()) qGlbTrack[3]->Fill(1);
592  else qGlbTrack[3]->Fill(2);
593  if(recoCombinedGlbTrack->charge()==recoTkGlbTrack->charge()) qGlbTrack[3]->Fill(3);
594  else qGlbTrack[3]->Fill(4);
595  if(recoStaGlbTrack->charge()==recoTkGlbTrack->charge()) qGlbTrack[3]->Fill(5);
596  else qGlbTrack[3]->Fill(6);
597  if(recoCombinedGlbTrack->charge()!=recoStaGlbTrack->charge() && recoCombinedGlbTrack->charge()!=recoTkGlbTrack->charge()) qGlbTrack[3]->Fill(7);
598  if(recoCombinedGlbTrack->charge()==recoStaGlbTrack->charge() && recoCombinedGlbTrack->charge()==recoTkGlbTrack->charge()) qGlbTrack[3]->Fill(8);
599 
600  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "qOverp", res, pull);
601  qOverpResolution[0]->Fill(res);
602  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "qOverp", res, pull);
603  qOverpResolution[1]->Fill(res);
604  GetRes(recoTkGlbTrack, recoStaGlbTrack, "qOverp", res, pull);
605  qOverpResolution[2]->Fill(res);
606  qOverpPull->Fill(pull);
607 
608 
609  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "oneOverp", res, pull);
610  oneOverpResolution[0]->Fill(res);
611  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "oneOverp", res, pull);
612  oneOverpResolution[1]->Fill(res);
613  GetRes(recoTkGlbTrack, recoStaGlbTrack, "oneOverp", res, pull);
614  oneOverpResolution[2]->Fill(res);
615  oneOverpPull->Fill(pull);
616 
617 
618  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "qOverpt", res, pull);
619  qOverptResolution[0]->Fill(res);
620  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "qOverpt", res, pull);
621  qOverptResolution[1]->Fill(res);
622  GetRes(recoTkGlbTrack, recoStaGlbTrack, "qOverpt", res, pull);
623  qOverptResolution[2]->Fill(res);
624  qOverptPull->Fill(pull);
625 
626  GetRes(recoTkGlbTrack, recoCombinedGlbTrack, "oneOverpt", res, pull);
627  oneOverptResolution[0]->Fill(res);
628  GetRes(recoCombinedGlbTrack, recoStaGlbTrack, "oneOverpt", res, pull);
629  oneOverptResolution[1]->Fill(res);
630  GetRes(recoTkGlbTrack, recoStaGlbTrack, "oneOverpt", res, pull);
631  oneOverptResolution[2]->Fill(res);
632  oneOverptPull->Fill(pull);
633 
634 
635  // //--- Test new tunePMuonBestTrack() method from Muon.h
636 
637  reco::TrackRef recoBestTrack = muon->muonBestTrack();
638 
639  reco::TrackRef recoTunePBestTrack = muon->tunePMuonBestTrack();
640 
641  double bestTrackPt = recoBestTrack->pt();
642 
643  double tunePBestTrackPt = recoTunePBestTrack->pt();
644 
645  double tunePBestTrackRes = (bestTrackPt - tunePBestTrackPt) / bestTrackPt;
646 
647  tunePResolution->Fill(tunePBestTrackRes);
648 
649  oneOverptResolution[3]->Fill(recoCombinedGlbTrack->eta(),(1/recoTkGlbTrack->pt())-(1/recoCombinedGlbTrack->pt()));
650  oneOverptResolution[4]->Fill(recoCombinedGlbTrack->eta(),-(1/recoStaGlbTrack->pt())+(1/recoCombinedGlbTrack->pt()));
651  oneOverptResolution[5]->Fill(recoCombinedGlbTrack->eta(),(1/recoTkGlbTrack->pt())-(1/recoStaGlbTrack->pt()));
652  oneOverptResolution[6]->Fill(recoCombinedGlbTrack->phi(),(1/recoTkGlbTrack->pt())-(1/recoCombinedGlbTrack->pt()));
653  oneOverptResolution[7]->Fill(recoCombinedGlbTrack->phi(),-(1/recoStaGlbTrack->pt())+(1/recoCombinedGlbTrack->pt()));
654  oneOverptResolution[8]->Fill(recoCombinedGlbTrack->phi(),(1/recoTkGlbTrack->pt())-(1/recoStaGlbTrack->pt()));
655  oneOverptResolution[9]->Fill(recoCombinedGlbTrack->pt(),(1/recoTkGlbTrack->pt())-(1/recoCombinedGlbTrack->pt()));
656  oneOverptResolution[10]->Fill(recoCombinedGlbTrack->pt(),-(1/recoStaGlbTrack->pt())+(1/recoCombinedGlbTrack->pt()));
657  oneOverptResolution[11]->Fill(recoCombinedGlbTrack->pt(),(1/recoTkGlbTrack->pt())-(1/recoStaGlbTrack->pt()));
658 
659 
660  if (!IsminiAOD){
661  // valid hits Glb track
662  double rhGlb = recoCombinedGlbTrack->found();
663  // valid hits Glb track from Tracker
664  double rhGlb_StaProvenance=0;
665  // valid hits Glb track from Sta system
666  double rhGlb_TkProvenance=0;
667 
668 
669 
670  for (trackingRecHit_iterator recHit = recoCombinedGlbTrack->recHitsBegin();
671  recHit!=recoCombinedGlbTrack->recHitsEnd(); ++recHit){
672 
673  if((*recHit)->isValid()){
674  DetId id = (*recHit)->geographicalId();
675  if (id.det() == DetId::Muon)
676  rhGlb_StaProvenance++;
677  if (id.det() == DetId::Tracker)
678  rhGlb_TkProvenance++;
679  }
680  }
681  // valid hits Sta track associated to Glb track
682  double rhStaGlb = recoStaGlbTrack->recHitsSize();
683  // valid hits Traker track associated to Glb track
684  double rhTkGlb = recoTkGlbTrack->found();
685  // invalid hits Traker track associated to Glb track
686  double rhTkGlb_notValid = recoTkGlbTrack->lost();
687 
688  // fill the histos
689  rhAnalysis[0]->Fill(rhGlb_StaProvenance/rhGlb);
690  rhAnalysis[1]->Fill(rhGlb_TkProvenance/rhGlb);
691  rhAnalysis[2]->Fill(rhGlb_StaProvenance/rhStaGlb);
692  rhAnalysis[3]->Fill(rhGlb_TkProvenance/rhTkGlb);
693  rhAnalysis[4]->Fill(rhGlb/(rhStaGlb+rhTkGlb));
694  rhAnalysis[5]->Fill(rhTkGlb_notValid/rhGlb);
695  }
696  // aligment plots (mu system w.r.t. tracker rotation)
697  if(recoCombinedGlbTrack->charge()>0)
698  muVStkSytemRotation[0]->Fill(recoCombinedGlbTrack->pt(),recoTkGlbTrack->pt()/recoCombinedGlbTrack->pt());
699  else
700  muVStkSytemRotation[1]->Fill(recoCombinedGlbTrack->pt(),recoTkGlbTrack->pt()/recoCombinedGlbTrack->pt());
701  }
702 
703 
704 
705  if(muon->isTrackerMuon() && !(muon->isGlobalMuon())) {
706  LogTrace(metname)<<"[MuonRecoAnalyzer] The mu is tracker only - filling the histos";
707  if(muon->isStandAloneMuon())
708  muReco->Fill(3);
709  if(!(muon->isStandAloneMuon()))
710  muReco->Fill(4);
711 
712  // get the track using only the tracker data
713  reco::TrackRef recoTrack = muon->track();
714 
715  etaTrack->Fill(recoTrack->eta());
716  thetaTrack->Fill(recoTrack->theta());
717  phiTrack->Fill(recoTrack->phi());
718  chi2OvDFTrack->Fill(recoTrack->normalizedChi2());
719  probchi2Track->Fill(TMath::Prob(recoTrack->chi2(),recoTrack->ndof()));
720  pTrack->Fill(recoTrack->p());
721  ptTrack->Fill(recoTrack->pt());
722  qTrack->Fill(recoTrack->charge());
723 
724  }
725 
726  if(muon->isStandAloneMuon() && !(muon->isGlobalMuon())) {
727  LogTrace(metname)<<"[MuonRecoAnalyzer] The mu is STA only - filling the histos";
728  if(!(muon->isTrackerMuon()))
729  muReco->Fill(5);
730 
731  // get the track using only the mu spectrometer data
732  reco::TrackRef recoStaTrack = muon->standAloneMuon();
733 
734  etaStaTrack->Fill(recoStaTrack->eta());
735  thetaStaTrack->Fill(recoStaTrack->theta());
736  phiStaTrack->Fill(recoStaTrack->phi());
737  chi2OvDFStaTrack->Fill(recoStaTrack->normalizedChi2());
738  probchi2StaTrack->Fill(TMath::Prob(recoStaTrack->chi2(),recoStaTrack->ndof()));
739  pStaTrack->Fill(recoStaTrack->p());
740  ptStaTrack->Fill(recoStaTrack->pt());
741  qStaTrack->Fill(recoStaTrack->charge());
742 
743  }
744 
745  if(muon->isCaloMuon() && !(muon->isGlobalMuon()) && !(muon->isTrackerMuon()) && !(muon->isStandAloneMuon()))
746  muReco->Fill(6);
747 
748  //efficiency plots
749 
750  // get the track using only the mu spectrometer data
751  reco::TrackRef recoStaGlbTrack = muon->standAloneMuon();
752 
753  if(muon->isStandAloneMuon()){
754  etaEfficiency[0]->Fill(recoStaGlbTrack->eta());
755  phiEfficiency[0]->Fill(recoStaGlbTrack->phi());
756  }
757  if(muon->isStandAloneMuon() && muon->isGlobalMuon()){
758  etaEfficiency[1]->Fill(recoStaGlbTrack->eta());
759  phiEfficiency[1]->Fill(recoStaGlbTrack->phi());
760  }
761  }
762 
763 }
764 
765 
766 //Needed by MVA Soft Muon
768 
769  double dphi = acos(cos(track1.phi() - track2.phi()));
770  double deta = track1.eta() - track2.eta();
771  return sqrt(dphi*dphi + deta*deta);
772 
773 }
774 
775 
776 // ----------------------------------------------------------------------
778  if (vc) {
779  for (unsigned int i = 0; i < vc->size(); ++i) {
781  reco::Vertex::trackRef_iterator v1TrackBegin = vc->at(i).tracks_begin();
782  reco::Vertex::trackRef_iterator v1TrackEnd = vc->at(i).tracks_end();
783  for (v1TrackIter = v1TrackBegin; v1TrackIter != v1TrackEnd; v1TrackIter++) {
784  if (static_cast<unsigned int>(tidx) == v1TrackIter->key()) return i;
785  }
786  }
787  }
788  return -1;
789 }
790 
791 
792 
793 
float chi2LocalPosition
chi2 value for the STA-TK matching of local position
Definition: MuonQuality.h:19
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
float chi2LocalMomentum
chi2 value for the STA-TK matching of local momentum
Definition: MuonQuality.h:21
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const std::string metname
float glbKink
value of the kink algorithm applied to the global track
Definition: MuonQuality.h:13
float glbTrackProbability
the tail probability (-ln(P)) of the global fit
Definition: MuonQuality.h:29
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)
key_type index() const
Definition: Ref.h:266
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:684
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
float trkKink
value of the kink algorithm applied to the inner track stub
Definition: MuonQuality.h:11
float trkRelChi2
chi2 value for the inner track stub with respect to the global track
Definition: MuonQuality.h:15
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:557
Definition: Electron.h:6
void analyze(const edm::Event &, const edm::EventSetup &) override
Inizialize parameters for histo binning.
int numberOfValidMuonCSCHits() const
Definition: HitPattern.h:961
int numberOfValidMuonRPCHits() const
Definition: HitPattern.h:966
int iEvent
Definition: GenABIO.cc:224
double getDeltaR(reco::Track track1, reco::Track track2)
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:690
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
float globalDeltaEtaPhi
global delta-Eta-Phi of STA-TK matching
Definition: MuonQuality.h:25
bool isValid() const
Definition: HandleBase.h:74
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
float staRelChi2
chi2 value for the outer track stub with respect to the global track
Definition: MuonQuality.h:17
Definition: DetId.h:18
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
int getPv(int tidx, const reco::VertexCollection *vc)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
int numberOfValidTrackerHits() const
Definition: HitPattern.h:901
HLT enums.
double p1[4]
Definition: TauolaWrapper.h:89
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
int numberOfValidMuonDTHits() const
Definition: HitPattern.h:956
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:37
int numberOfValidPixelHits() const
Definition: HitPattern.h:916
const Point & position() const
position
Definition: BeamSpot.h:62
int numberOfValidMuonHits() const
Definition: HitPattern.h:906
~MuonRecoAnalyzer() override
Destructor.
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: Run.h:45
MuonRecoAnalyzer(const edm::ParameterSet &)
Constructor.