CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTMuon.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <istream>
4 #include <fstream>
5 #include <iomanip>
6 #include <string>
7 #include <cmath>
8 #include <functional>
9 #include <stdlib.h>
10 #include <string.h>
11 
13 
15  evtCounter=0;
16 
17  //set parameter defaults
18  _Monte=false;
19  _Debug=false;
20 }
21 
22 /* Setup the analysis to put the branch-variables into the tree. */
23 void HLTMuon::setup(const edm::ParameterSet& pSet, TTree* HltTree) {
24 
25  edm::ParameterSet myEmParams = pSet.getParameter<edm::ParameterSet>("RunParameters") ;
26  std::vector<std::string> parameterNames = myEmParams.getParameterNames() ;
27 
28  for ( std::vector<std::string>::iterator iParam = parameterNames.begin();
29  iParam != parameterNames.end(); iParam++ ){
30  if ( (*iParam) == "Monte" ) _Monte = myEmParams.getParameter<bool>( *iParam );
31  else if ( (*iParam) == "Debug" ) _Debug = myEmParams.getParameter<bool>( *iParam );
32  }
33 
34  const int kMaxMuon = 10000;
35  muonpt = new float[kMaxMuon];
36  muonphi = new float[kMaxMuon];
37  muoneta = new float[kMaxMuon];
38  muonet = new float[kMaxMuon];
39  muone = new float[kMaxMuon];
40  muonchi2NDF = new float[kMaxMuon];
41  muoncharge = new float[kMaxMuon];
42  muonTrkIsoR03 = new float[kMaxMuon];
43  muonECalIsoR03 = new float[kMaxMuon];
44  muonHCalIsoR03 = new float[kMaxMuon];
45  muonD0 = new float[kMaxMuon];
46  muontype = new int[kMaxMuon];
47  muonNValidTrkHits = new int[kMaxMuon];
48  muonNValidMuonHits = new int[kMaxMuon];
49  const int kMaxMuonL2 = 500;
50  muonl2pt = new float[kMaxMuonL2];
51  muonl2phi = new float[kMaxMuonL2];
52  muonl2eta = new float[kMaxMuonL2];
53  muonl2dr = new float[kMaxMuonL2];
54  muonl2drsign = new float[kMaxMuonL2];
55  muonl2dz = new float[kMaxMuonL2];
56  muonl2vtxz = new float[kMaxMuonL2];
57  muonl2chg = new int[kMaxMuonL2];
58  muonl2pterr = new float[kMaxMuonL2];
59  muonl2iso = new int[kMaxMuonL2];
60  muonl2nhits = new int[kMaxMuonL2];
61  muonl2nchambers = new int[kMaxMuonL2];
62  muonl2nstat = new int[kMaxMuonL2];
63  muonl2ndtcscstat = new int[kMaxMuonL2];
64  muonl21idx = new int[kMaxMuonL2];
65  const int kMaxMuonL3 = 500;
66  muonl3pt = new float[kMaxMuonL3];
67  muonl3phi = new float[kMaxMuonL3];
68  muonl3eta = new float[kMaxMuonL3];
69  muonl3dr = new float[kMaxMuonL3];
70  muonl3dz = new float[kMaxMuonL3];
71  muonl3vtxz = new float[kMaxMuonL3];
72  muonl3chg = new int[kMaxMuonL3];
73  muonl3pterr = new float[kMaxMuonL3];
74  muonl3iso = new int[kMaxMuonL3];
75  muonl3trk10iso = new int[kMaxMuonL3];
76  muonl3nhits = new int[kMaxMuonL3];
77  muonl3normchi2 = new float[kMaxMuonL3];
78  muonl3npixelhits = new int[kMaxMuonL3];
79  muonl3ntrackerhits = new int[kMaxMuonL3];
80  muonl3nmuonhits = new int[kMaxMuonL3];
81  muonl32idx = new int[kMaxMuonL3];
82  muonl3globalpt = new float[kMaxMuonL3];
83  muonl3globaleta = new float[kMaxMuonL3];
84  muonl3globalphi = new float[kMaxMuonL3];
85  muonl3globaldr = new float[kMaxMuonL3];
86  muonl3globaldrsign = new float[kMaxMuonL3];
87  muonl3globaldz = new float[kMaxMuonL3];
88  muonl3globalvtxz = new float[kMaxMuonL3];
89  muonl3globalchg = new int[kMaxMuonL3];
90  muonl3global2idx = new int[kMaxMuonL3];
91  const int kMaxTrackerMuon = 500;
92  trackermuonpt = new float[kMaxTrackerMuon];
93  trackermuonphi = new float[kMaxTrackerMuon];
94  trackermuoneta = new float[kMaxTrackerMuon];
95  trackermuonchg = new int[kMaxTrackerMuon];
96  trackermuonnhits = new int[kMaxTrackerMuon];
97  const int kMaxOniaPixel = 500;
98  oniaPixelpt = new float[kMaxOniaPixel];
99  oniaPixelphi = new float[kMaxOniaPixel];
100  oniaPixeleta = new float[kMaxOniaPixel];
101  oniaPixeldr = new float[kMaxOniaPixel];
102  oniaPixeldz = new float[kMaxOniaPixel];
103  oniaPixelchg = new int[kMaxOniaPixel];
104  oniaPixelHits = new int[kMaxOniaPixel];
105  oniaPixelNormChi2 = new float[kMaxOniaPixel];
106  const int kMaxTrackPixel = 500;
107  oniaTrackpt = new float[kMaxTrackPixel];
108  oniaTrackphi = new float[kMaxTrackPixel];
109  oniaTracketa = new float[kMaxTrackPixel];
110  oniaTrackdr = new float[kMaxTrackPixel];
111  oniaTrackdz = new float[kMaxTrackPixel];
112  oniaTrackchg = new int[kMaxTrackPixel];
113  oniaTrackHits = new int[kMaxTrackPixel];
114  oniaTrackNormChi2 = new float[kMaxTrackPixel];
115  const int kMaxMuonL2NoVtx = 500;
116  muonl2novtxpt = new float[kMaxMuonL2NoVtx];
117  muonl2novtxphi = new float[kMaxMuonL2NoVtx];
118  muonl2novtxeta = new float[kMaxMuonL2NoVtx];
119  muonl2novtxdr = new float[kMaxMuonL2NoVtx];
120  muonl2novtxdrsign = new float[kMaxMuonL2NoVtx];
121  muonl2novtxdz = new float[kMaxMuonL2NoVtx];
122  muonl2novtxchg = new int[kMaxMuonL2NoVtx];
123  muonl2novtxpterr = new float[kMaxMuonL2NoVtx];
124  muonl2novtxnhits = new int[kMaxMuonL2NoVtx];
125  muonl2novtxnchambers = new int[kMaxMuonL2NoVtx];
126  muonl2novtxnstat = new int[kMaxMuonL2NoVtx];
127  muonl2novtxndtcscstat = new int[kMaxMuonL2NoVtx];
128  muonl2novtx1idx = new int[kMaxMuonL2NoVtx];
129  const int kMaxDiMu = 500;
130  dimudca = new float[kMaxDiMu];
131  dimu1st = new int[kMaxDiMu];
132  dimu2nd = new int[kMaxDiMu];
133  const int kMaxDiMuVtx = 500;
134  dimuvtx1st = new int[kMaxDiMuVtx];
135  dimuvtx2nd = new int[kMaxDiMuVtx];
136  dimuvtxchi2 = new float[kMaxDiMuVtx];
137  dimuvtxr = new float[kMaxDiMuVtx];
138  dimuvtxrsig = new float[kMaxDiMuVtx];
139  dimuvtxroversig = new float[kMaxDiMuVtx];
140  dimuvtxcosalpha = new float[kMaxDiMuVtx];
141  dimuvtxmu2dipmax = new float[kMaxDiMuVtx];
142  dimuvtxmu2dipmin = new float[kMaxDiMuVtx];
143  dimuvtxmu2dipsigmax = new float[kMaxDiMuVtx];
144  dimuvtxmu2dipsigmin = new float[kMaxDiMuVtx];
145 
146  //pf
147  const int kMaxPfmuon = 10000;
148  pfmuonpt = new float[kMaxPfmuon];
149  pfmuonphi = new float[kMaxPfmuon];
150  pfmuoneta = new float[kMaxPfmuon];
151  pfmuonet = new float[kMaxPfmuon];
152  pfmuone = new float[kMaxPfmuon];
153  pfmuoncharge = new float[kMaxPfmuon];
154 
155  // Muon-specific branches of the tree
156  HltTree->Branch("NrecoMuon",&nmuon,"NrecoMuon/I");
157  HltTree->Branch("recoMuonPt",muonpt,"recoMuonPt[NrecoMuon]/F");
158  HltTree->Branch("recoMuonPhi",muonphi,"recoMuonPhi[NrecoMuon]/F");
159  HltTree->Branch("recoMuonEta",muoneta,"recoMuonEta[NrecoMuon]/F");
160  HltTree->Branch("recoMuonEt",muonet,"recoMuonEt[NrecoMuon]/F");
161  HltTree->Branch("recoMuonE",muone,"recoMuonE[NrecoMuon]/F");
162  HltTree->Branch("recoMuonChi2NDF", muonchi2NDF, "recoMuonChi2NDF[NrecoMuon]/F");
163  HltTree->Branch("recoMuonCharge", muoncharge , "recoMuonCharge[NrecoMuon]/F");
164  HltTree->Branch("recoMuonTrkIsoR03", muonTrkIsoR03 , "recoMuonTrkIsoR03[NrecoMuon]/F");
165  HltTree->Branch("recoMuonECalIsoR03", muonECalIsoR03 , "recoMuonECalIsoR03[NrecoMuon]/F");
166  HltTree->Branch("recoMuonHCalIsoR03", muonHCalIsoR03 , "recoMuonHCalIsoR03[NrecoMuon]/F");
167  HltTree->Branch("recoMuonD0", muonD0 , "recoMuonD0[NrecoMuon]/F");
168  HltTree->Branch("recoMuonType", muontype , "recoMuonType[NrecoMuon]/I");
169  HltTree->Branch("recoMuonNValidTrkHits", muonNValidTrkHits, "recoMuonNValidTrkHits[NrecoMuon]/I");
170  HltTree->Branch("recoMuonNValidMuonHits", muonNValidMuonHits,"recoMuonNValidMuonHits[NrecoMuon]/I");
171 
172  HltTree->Branch("NohMuL2",&nmu2cand,"NohMuL2/I");
173  HltTree->Branch("ohMuL2Pt",muonl2pt,"ohMuL2Pt[NohMuL2]/F");
174  HltTree->Branch("ohMuL2Phi",muonl2phi,"ohMuL2Phi[NohMuL2]/F");
175  HltTree->Branch("ohMuL2Eta",muonl2eta,"ohMuL2Eta[NohMuL2]/F");
176  HltTree->Branch("ohMuL2Chg",muonl2chg,"ohMuL2Chg[NohMuL2]/I");
177  HltTree->Branch("ohMuL2PtErr",muonl2pterr,"ohMuL2PtErr[NohMuL2]/F");
178  HltTree->Branch("ohMuL2Iso",muonl2iso,"ohMuL2Iso[NohMuL2]/I");
179  HltTree->Branch("ohMuL2Dr",muonl2dr,"ohMuL2Dr[NohMuL2]/F");
180  HltTree->Branch("ohMuL2DrSign",muonl2drsign,"ohMuL2DrSign[NohMuL2]/F");
181  HltTree->Branch("ohMuL2Dz",muonl2dz,"ohMuL2Dz[NohMuL2]/F");
182  HltTree->Branch("ohMuL2VtxZ",muonl2vtxz,"ohMuL2VtxZ[NohMuL2]/F");
183  HltTree->Branch("ohMuL2Nhits",muonl2nhits,"ohMuL2Nhits[NohMuL2]/I");
184  HltTree->Branch("ohMuL2Nchambers",muonl2nchambers,"ohMuL2Nchambers[NohMuL2]/I");
185  HltTree->Branch("ohMuL2Nstat",muonl2nstat,"ohMuL2Nstat[NohMuL2]/I");
186  HltTree->Branch("ohMuL2NDtCscStat",muonl2ndtcscstat,"ohMuL2NDtCscStat[NohMuL2]/I");
187  HltTree->Branch("ohMuL2L1idx",muonl21idx,"ohMuL2L1idx[NohMuL2]/I");
188  HltTree->Branch("NohMuL3",&nmu3cand,"NohMuL3/I");
189  HltTree->Branch("ohMuL3Pt",muonl3pt,"ohMuL3Pt[NohMuL3]/F");
190  HltTree->Branch("ohMuL3Phi",muonl3phi,"ohMuL3Phi[NohMuL3]/F");
191  HltTree->Branch("ohMuL3Eta",muonl3eta,"ohMuL3Eta[NohMuL3]/F");
192  HltTree->Branch("ohMuL3Chg",muonl3chg,"ohMuL3Chg[NohMuL3]/I");
193  HltTree->Branch("ohMuL3PtErr",muonl3pterr,"ohMuL3PtErr[NohMuL3]/F");
194  HltTree->Branch("ohMuL3Iso",muonl3iso,"ohMuL3Iso[NohMuL3]/I");
195  HltTree->Branch("ohMuL3Trk10Iso",muonl3trk10iso,"ohMuL3Trk10Iso[NohMuL3]/I");
196  HltTree->Branch("ohMuL3Dr",muonl3dr,"ohMuL3Dr[NohMuL3]/F");
197  HltTree->Branch("ohMuL3Dz",muonl3dz,"ohMuL3Dz[NohMuL3]/F");
198  HltTree->Branch("ohMuL3VtxZ",muonl3vtxz,"ohMuL3VtxZ[NohMuL3]/F");
199  HltTree->Branch("ohMuL3Nhits",muonl3nhits,"ohMuL3Nhits[NohMuL3]/I");
200  HltTree->Branch("ohMuL3NormChi2", muonl3normchi2, "ohMuL3NormChi2[NohMuL3]/F");
201  HltTree->Branch("ohMuL3Npixelhits", muonl3npixelhits, "ohMuL3Npixelhits[NohMuL3]/I");
202  HltTree->Branch("ohMuL3Ntrackerhits", muonl3ntrackerhits, "ohMuL3Ntrackerhits[NohMuL3]/I");
203  HltTree->Branch("ohMuL3Nmuonhits", muonl3nmuonhits, "ohMuL3Nmuonhits[NohMuL3]/I");
204  HltTree->Branch("ohMuL3L2idx",muonl32idx,"ohMuL3L2idx[NohMuL3]/I");
205  HltTree->Branch("ohMuL3globalPt",muonl3globalpt,"ohMuL3globalPt[NohMuL3]/F");
206  HltTree->Branch("ohMuL3globalEta",muonl3globaleta,"ohMuL3globalEta[NohMuL3]/F");
207  HltTree->Branch("ohMuL3globalPhi",muonl3globalphi,"ohMuL3globalPhi[NohMuL3]/F");
208  HltTree->Branch("ohMuL3globalDr",muonl3globaldr,"ohMuL3globalDr[NohMuL3]/F");
209  HltTree->Branch("ohMuL3globalDrSign",muonl3globaldrsign,"ohMuL3globalDrSign[NohMuL3]/F");
210  HltTree->Branch("ohMuL3globalDz",muonl3globaldz,"ohMuL3globalDz[NohMuL3]/F");
211  HltTree->Branch("ohMuL3globalVtxZ",muonl3globalvtxz,"ohMuL3globalVtxZ[NohMuL3]/F");
212  HltTree->Branch("ohMuL3globalL2idx",muonl3global2idx,"ohMuL3globalL2idx[NohMuL3]/I");
213 
214  HltTree->Branch("NohOniaPixel",&nOniaPixelCand,"NohOniaPixel/I");
215  HltTree->Branch("ohOniaPixelPt",oniaPixelpt,"ohOniaPixelPt[NohOniaPixel]/F");
216  HltTree->Branch("ohOniaPixelPhi",oniaPixelphi,"ohOniaPixelPhi[NohOniaPixel]/F");
217  HltTree->Branch("ohOniaPixelEta",oniaPixeleta,"ohOniaPixelEta[NohOniaPixel]/F");
218  HltTree->Branch("ohOniaPixelChg",oniaPixelchg,"ohOniaPixelChg[NohOniaPixel]/I");
219  HltTree->Branch("ohOniaPixelDr",oniaPixeldr,"ohOniaPixelDr[NohOniaPixel]/F");
220  HltTree->Branch("ohOniaPixelDz",oniaPixeldz,"ohOniaPixelDz[NohOniaPixel]/F");
221  HltTree->Branch("ohOniaPixelHits",oniaPixelHits,"ohOniaPixelHits[NohOniaPixel]/I");
222  HltTree->Branch("ohOniaPixelNormChi2",oniaPixelNormChi2,"ohOniaPixelNormChi2[NohOniaPixel]/F");
223  HltTree->Branch("NohOniaTrack",&nOniaTrackCand,"NohOniaTrack/I");
224  HltTree->Branch("ohOniaTrackPt",oniaTrackpt,"ohOniaTrackPt[NohOniaTrack]/F");
225  HltTree->Branch("ohOniaTrackPhi",oniaTrackphi,"ohOniaTrackPhi[NohOniaTrack]/F");
226  HltTree->Branch("ohOniaTrackEta",oniaTracketa,"ohOniaTrackEta[NohOniaTrack]/F");
227  HltTree->Branch("ohOniaTrackChg",oniaTrackchg,"ohOniaTrackChg[NohOniaTrack]/I");
228  HltTree->Branch("ohOniaTrackDr",oniaTrackdr,"ohOniaTrackDr[NohOniaTrack]/F");
229  HltTree->Branch("ohOniaTrackDz",oniaTrackdz,"ohOniaTrackDz[NohOniaTrack]/F");
230  HltTree->Branch("ohOniaTrackHits",oniaTrackHits,"ohOniaTrackHits[NohOniaTrack]/I");
231  HltTree->Branch("ohOniaTrackNormChi2",oniaTrackNormChi2,"ohOniaTrackNormChi2[NohOniaTrack]/F");
232  HltTree->Branch("NohMuL2NoVtx",&nmu2cand,"NohMuL2NoVtx/I");
233  HltTree->Branch("ohMuL2NoVtxPt",muonl2novtxpt,"ohMuL2NoVtxPt[NohMuL2NoVtx]/F");
234  HltTree->Branch("ohMuL2NoVtxPhi",muonl2novtxphi,"ohMuL2NoVtxPhi[NohMuL2NoVtx]/F");
235  HltTree->Branch("ohMuL2NoVtxEta",muonl2novtxeta,"ohMuL2NoVtxEta[NohMuL2NoVtx]/F");
236  HltTree->Branch("ohMuL2NoVtxChg",muonl2novtxchg,"ohMuL2NoVtxChg[NohMuL2NoVtx]/I");
237  HltTree->Branch("ohMuL2NoVtxPtErr",muonl2novtxpterr,"ohMuL2NoVtxPtErr[NohMuL2NoVtx]/F");
238  HltTree->Branch("ohMuL2NoVtxDr",muonl2novtxdr,"ohMuL2NoVtxDr[NohMuL2NoVtx]/F");
239  HltTree->Branch("ohMuL2NoVtxDrSign",muonl2novtxdrsign,"ohMuL2NoVtxDrSign[NohMuL2NoVtx]/F");
240  HltTree->Branch("ohMuL2NoVtxDz",muonl2novtxdz,"ohMuL2NoVtxDz[NohMuL2NoVtx]/F");
241  HltTree->Branch("ohMuL2NoVtxNhits",muonl2novtxnhits,"ohMuL2NoVtxNhits[NohMuL2NoVtx]/I");
242  HltTree->Branch("ohMuL2NoVtxNchambers",muonl2novtxnchambers,"ohMuL2NoVtxNchambers[NohMuL2NoVtx]/I");
243  HltTree->Branch("ohMuL2NoVtxNstat",muonl2novtxnstat,"ohMuL2NoVtxNstat[NohMuL2NoVtx]/I");
244  HltTree->Branch("ohMuL2NoVtxNDtCscStat",muonl2novtxndtcscstat,"ohMuL2NoVtxNDtCscStat[NohMuL2NoVtx]/I");
245  HltTree->Branch("ohMuL2NoVtxL1idx",muonl2novtx1idx,"ohMuL2NoVtxL1idx[NohMuL2NoVtx]/I");
246  HltTree->Branch("NohDiMu",&nDiMu,"NohDiMu/I");
247  HltTree->Branch("ohDiMuDCA",dimudca,"ohDiMuDCA[NohDiMu]/F");
248  HltTree->Branch("ohDiMu1st",dimu1st,"ohDiMu1st[NohDiMu]/I");
249  HltTree->Branch("ohDiMu2nd",dimu2nd,"ohDiMu2nd[NohDiMu]/I");
250  HltTree->Branch("NohDiMuVtx",&nDiMuVtx,"NohDiMuVtx/I");
251  HltTree->Branch("ohDiMuVtx1st",dimuvtx1st,"ohDiMuVtx1st[NohDiMuVtx]/I");
252  HltTree->Branch("ohDiMuVtx2nd",dimuvtx2nd,"ohDiMuVtx2nd[NohDiMuVtx]/I");
253  HltTree->Branch("ohDiMuVtxChi2",dimuvtxchi2,"ohDiMuVtxChi2[NohDiMuVtx]/F");
254  HltTree->Branch("ohDiMuVtxR",dimuvtxr,"ohDiMuVtxR[NohDiMuVtx]/F");
255  HltTree->Branch("ohDiMuVtxRSig",dimuvtxrsig,"ohDiMuVtxRSig[NohDiMuVtx]/F");
256  HltTree->Branch("ohDiMuVtxROverSig",dimuvtxroversig,"ohDiMuVtxROverSig[NohDiMuVtx]/F");
257  HltTree->Branch("ohDiMuVtxCosAlpha",dimuvtxcosalpha,"ohDiMuVtxCosAlpha[NohDiMuVtx]/F");
258  HltTree->Branch("ohDiMuVtxMu2DIpMax",dimuvtxmu2dipmax,"ohDiMuVtxMu2DIpMax[NohDiMuVtx]/F");
259  HltTree->Branch("ohDiMuVtxMu2DIpMin",dimuvtxmu2dipmin,"ohDiMuVtxMu2DIpMin[NohDiMuVtx]/F");
260  HltTree->Branch("ohDiMuVtxMu2DIpSigMax",dimuvtxmu2dipsigmax,"ohDiMuVtxMu2DIpSigMax[NohDiMuVtx]/F");
261  HltTree->Branch("ohDiMuVtxMu2DIpSigMin",dimuvtxmu2dipsigmin,"ohDiMuVtxMu2DIpSigMin[NohDiMuVtx]/F");
262  HltTree->Branch("NohTrackerMuon",&ntrackermuoncand,"NohTrackerMuon/I");
263  HltTree->Branch("ohTrackerMuonPt",trackermuonpt,"ohTrackerMuonPt[NohTrackerMuon]/F");
264  HltTree->Branch("ohTrackerMuonPhi",trackermuonphi,"ohTrackerMuonPhi[NohTrackerMuon]/F");
265  HltTree->Branch("ohTrackerMuonEta",trackermuoneta,"ohTrackerMuonEta[NohTrackerMuon]/F");
266  HltTree->Branch("ohTrackerMuonChg",trackermuonchg,"ohTrackerMuonChg[NohTrackerMuon]/I");
267  HltTree->Branch("ohTrackerMuonNhits",trackermuonnhits,"ohTrackerMuonNhits[NohTrackerMuon]/I");
268 
269  HltTree->Branch("NpfMuon",&npfmuon,"NpfMuon/I");
270  HltTree->Branch("pfMuonPt",pfmuonpt,"pfMuonPt[NpfMuon]/F");
271  HltTree->Branch("pfMuonPhi",pfmuonphi,"pfMuonPhi[NpfMuon]/F");
272  HltTree->Branch("pfMuonEta",pfmuoneta,"pfMuonEta[NpfMuon]/F");
273  HltTree->Branch("pfMuonEt",pfmuonet,"pfMuonEt[NpfMuon]/F");
274  HltTree->Branch("pfMuonE",pfmuone,"pfMuonE[NpfMuon]/F");
275  HltTree->Branch("pfMuonCharge", pfmuoncharge , "pfMuonCharge[NpfMuon]/F");
276 
277 
278 }
279 
280 /* **Analyze the event** */
285  const edm::Handle<edm::ValueMap<bool> > & isoMap2,
287  const edm::Handle<edm::ValueMap<bool> > & isoMap3,
288  const edm::Handle<edm::ValueMap<bool> > & isoTrk10Map3,
291  const edm::Handle<reco::VertexCollection> & DiMuVtxCands3,
293  const edm::Handle<reco::MuonCollection> & trkmucands,
294  const edm::ESHandle<MagneticField> & theMagField,
295  const edm::Handle<reco::BeamSpot> & recoBeamSpotHandle,
296  TTree* HltTree) {
297 
298  reco::BeamSpot::Point BSPosition(0,0,0);
299  BSPosition = recoBeamSpotHandle->position();
300  const GlobalPoint theBeamSpot = GlobalPoint(recoBeamSpotHandle->position().x(),
301  recoBeamSpotHandle->position().y(),
302  recoBeamSpotHandle->position().z());
303  reco::BeamSpot vtxBS = *recoBeamSpotHandle;
304 
305  //std::cout << " Beginning HLTMuon " << std::endl;
306 
307  if (Muon.isValid()) {
308  reco::MuonCollection mymuons;
309  mymuons = * Muon;
310  std::sort(mymuons.begin(),mymuons.end(),PtGreater());
311  nmuon = mymuons.size();
312  typedef reco::MuonCollection::const_iterator muiter;
313  int imu=0;
314  for (muiter i=mymuons.begin(); i!=mymuons.end(); i++)
315  {
316  muonpt[imu] = i->pt();
317  muonphi[imu] = i->phi();
318  muoneta[imu] = i->eta();
319  muonet[imu] = i->et();
320  muone[imu] = i->energy();
321  muontype[imu] = i->type();
322  muoncharge[imu] = i->charge();
323  muonTrkIsoR03[imu] = i->isolationR03().sumPt;
324  muonECalIsoR03[imu] = i->isolationR03().emEt;
325  muonHCalIsoR03[imu] = i->isolationR03().hadEt;
326 
327 
328  if (i->globalTrack().isNonnull())
329  {
330  muonchi2NDF[imu] = i->globalTrack()->normalizedChi2();
331  muonD0[imu] = i->globalTrack()->dxy(BSPosition);
332  }
333  else
334  {
335  muonchi2NDF[imu] = -99.;
336  muonD0[imu] = -99.;}
337 
338  if (i->innerTrack().isNonnull()) muonNValidTrkHits[imu] = i->innerTrack()->numberOfValidHits();
339  else muonNValidTrkHits[imu] = -99;
340 
341  if (i->isGlobalMuon()!=0) muonNValidMuonHits[imu] = i->globalTrack()->hitPattern().numberOfValidMuonHits();
342  else muonNValidMuonHits[imu] = -99;
343 
344  imu++;
345  }
346  }
347  else {nmuon = 0;}
348 
350  myMucands1 = * MuCands1;
351  // reco::RecoChargedCandidateCollection myMucands1;
352  std::sort(myMucands1.begin(),myMucands1.end(),PtGreater());
353 
355 
356  // Dealing with L2 muons
358  if (MuCands2.isValid()) {
359  // reco::RecoChargedCandidateCollection myMucands2;
360  myMucands2 = * MuCands2;
361  std::sort(myMucands2.begin(),myMucands2.end(),PtGreater());
362  nmu2cand = myMucands2.size();
363  typedef reco::RecoChargedCandidateCollection::const_iterator cand;
364  int imu2c=0;
365  for (cand i=myMucands2.begin(); i!=myMucands2.end(); i++) {
366  reco::TrackRef tk = i->get<reco::TrackRef>();
367 
368  muonl2pt[imu2c] = tk->pt();
369  // eta (we require |eta|<2.5 in all filters
370  muonl2eta[imu2c] = tk->eta();
371  muonl2phi[imu2c] = tk->phi();
372 
373  // Dr (transverse distance to (0,0,0))
374  // For baseline triggers, we do no cut at L2 (|dr|<9999 cm)
375  // However, we use |dr|<200 microns at L3, which it probably too tough for LHC startup
376  muonl2dr[imu2c] = fabs(tk->dxy(BSPosition));
377  muonl2drsign[imu2c] = ( tk->dxyError() > 0. ? muonl2dr[imu2c] / tk->dxyError() : 999. );
378 
379  // Dz (longitudinal distance to z=0 when at minimum transverse distance)
380  // For baseline triggers, we do no cut (|dz|<9999 cm), neither at L2 nor at L3
381  muonl2dz[imu2c] = tk->dz(BSPosition);
382  muonl2vtxz[imu2c] = tk->dz();
383  muonl2nhits[imu2c] = tk->numberOfValidHits();
384  muonl2nchambers[imu2c] = validChambers(tk);
385  muonl2nstat[imu2c] = tk->hitPattern().muonStationsWithAnyHits();
386  muonl2ndtcscstat[imu2c] = tk->hitPattern().dtStationsWithAnyHits() + tk->hitPattern().cscStationsWithAnyHits();
387 
388  // At present we do not cut on this, but on a 90% CL value "ptLx" defined here below
389  // We should change this in the future and cut directly on "pt", to avoid unnecessary complications and risks
390  // Baseline cuts (HLT exercise):
391  // Relaxed Single muon: ptLx>16 GeV
392  // Isolated Single muon: ptLx>11 GeV
393  // Relaxed Double muon: ptLx>3 GeV
394  double l2_err0 = tk->error(0); // error on q/p
395  double l2_abspar0 = fabs(tk->parameter(0)); // |q/p|
396  // double ptLx = tk->pt();
397  // convert 50% efficiency threshold to 90% efficiency threshold
398  // For L2 muons: nsigma_Pt_ = 3.9
399  // double nsigma_Pt_ = 3.9;
400  // For L3 muons: nsigma_Pt_ = 2.2
401  // these are the old TDR values for nsigma_Pt_
402  // We know that these values are slightly smaller for CMSSW
403  // But as quoted above, we want to get rid of this gymnastics in the future
404  // if (abspar0>0) ptLx += nsigma_Pt_*err0/abspar0*tk->pt();
405 
406  // Charge
407  // We use the charge in some dimuon paths
408  muonl2pterr[imu2c] = l2_err0/l2_abspar0;
409  muonl2chg[imu2c] = tk->charge();
410 
411  if (isoMap2.isValid()){
412  // Isolation flag (this is a bool value: true => isolated)
413  edm::ValueMap<bool> ::value_type muon1IsIsolated = (*isoMap2)[tk];
414  muonl2iso[imu2c] = muon1IsIsolated;
415  }
416  else {muonl2iso[imu2c] = -999;}
417 
419  int il2 = 0;
420  //find the corresponding L1
421  l1 = tk->seedRef().castTo<edm::Ref< L2MuonTrajectorySeedCollection> >()->l1Particle();
422  il2++;
423  int imu1idx = 0;
424  if (MuCands1.isValid()) {
425  typedef l1extra::L1MuonParticleCollection::const_iterator candl1;
426  for (candl1 j=myMucands1.begin(); j!=myMucands1.end(); j++) {
427  if((j->pt() == l1->pt()) &&
428  (j->eta() == l1->eta()) &&
429  (j->phi() == l1->phi()) &&
430  (j->gmtMuonCand().quality() == l1->gmtMuonCand().quality()))
431  {break;}
432  // std::cout << << std::endl;
433  // if ( tkl1 == l1 ) {break;}
434  imu1idx++;
435  }
436  }
437  else {imu1idx = -999;}
438  muonl21idx[imu2c] = imu1idx; // Index of the L1 muon having matched with the L2 muon with index imu2c
439 
440  imu2c++;
441  }
442  }
443  else {nmu2cand = 0;}
444 
445  // Dealing with L3 muons
447  if (MuCands3.isValid()) {
448  int k = 0;
449  myMucands3 = * MuCands3;
450  std::sort(myMucands3.begin(),myMucands3.end(),PtGreater());
451  nmu3cand = myMucands3.size();
452  typedef reco::RecoChargedCandidateCollection::const_iterator cand;
453  int imu3c=0;
454  int idimuc=0;
455  for (cand i=myMucands3.begin(); i!=myMucands3.end(); i++) {
456  reco::TrackRef tk = i->get<reco::TrackRef>();
457 
459 
460  reco::TrackRef staTrack;
461  typedef reco::MuonTrackLinksCollection::const_iterator l3muon;
462  int il3 = 0;
463  //find the corresponding L2 track
464  staTrack = tk->seedRef().castTo<edm::Ref< L3MuonTrajectorySeedCollection> >()->l2Track();
465  il3++;
466  int imu2idx = 0;
467  if (MuCands2.isValid()) {
468  typedef reco::RecoChargedCandidateCollection::const_iterator candl2;
469  for (candl2 i=myMucands2.begin(); i!=myMucands2.end(); i++) {
470  reco::TrackRef tkl2 = i->get<reco::TrackRef>();
471  if ( tkl2 == staTrack ) {break;}
472  imu2idx++;
473  }
474  }
475  else {imu2idx = -999;}
476  muonl3global2idx[imu3c] = imu2idx; // Index of the L2 muon having matched with the L3 muon with index imu3c
477  muonl32idx[imu3c] = imu2idx;
478 
479  muonl3globalpt[imu3c] = tk->pt();
480  muonl3pt[imu3c] = candref->pt();
481  // eta (we require |eta|<2.5 in all filters
482  muonl3globaleta[imu3c] = tk->eta();
483  muonl3globalphi[imu3c] = tk->phi();
484  muonl3eta[imu3c] = candref->eta();
485  muonl3phi[imu3c] = candref->phi();
486 
487  // // Dr (transverse distance to (0,0,0))
488  // // For baseline triggers, we do no cut at L2 (|dr|<9999 cm)
489  // // However, we use |dr|<300 microns at L3, which it probably too tough for LHC startup
490  muonl3dr[imu3c] = fabs( (- (candref->vx()-BSPosition.x()) * candref->py() + (candref->vy()-BSPosition.y()) * candref->px() ) / candref->pt() );
491  muonl3globaldr[imu3c] = fabs(tk->dxy(BSPosition));
492  muonl3globaldrsign[imu3c] = ( tk->dxyError() > 0. ? muonl3globaldr[imu3c] / tk->dxyError() : -999. );
493 
494  // // Dz (longitudinal distance to z=0 when at minimum transverse distance)
495  // // For baseline triggers, we do no cut (|dz|<9999 cm), neither at L2 nor at L3
496  muonl3dz[imu3c] = (candref->vz()-BSPosition.z()) - ((candref->vx()-BSPosition.x())*candref->px()+(candref->vy()-BSPosition.y())*candref->py())/candref->pt() * candref->pz()/candref->pt();
497  muonl3globaldz[imu3c] = tk->dz(BSPosition);
498 
499  muonl3vtxz[imu3c] = candref->vz() - ( candref->vx()*candref->px() + candref->vy()*candref->py() )/candref->pt() * candref->pz()/candref->pt();
500  muonl3globalvtxz[imu3c] = tk->dz();
501  //muonl3vtxz[imu3c] = candref->vz();
502  //muonl3globalvtxz[imu3c] = tk->vz();
503 
504  muonl3nhits[imu3c] = tk->numberOfValidHits();
505 
506  // // At present we do not cut on this, but on a 90% CL value "ptLx" defined here below
507  // // We should change this in the future and cut directly on "pt", to avoid unnecessary complications and risks
508  // // Baseline cuts (HLT exercise):
509  // // Relaxed Single muon: ptLx>16 GeV
510  // // Isolated Single muon: ptLx>11 GeV
511  // // Relaxed Double muon: ptLx>3 GeV
512  double l3_err0 = tk->error(0); // error on q/p
513  double l3_abspar0 = fabs(tk->parameter(0)); // |q/p|
514  // // double ptLx = tk->pt();
515  // // convert 50% efficiency threshold to 90% efficiency threshold
516  // // For L2 muons: nsigma_Pt_ = 3.9
517  // // For L3 muons: nsigma_Pt_ = 2.2
518  // // double nsigma_Pt_ = 2.2;
519  // // these are the old TDR values for nsigma_Pt_
520  // // We know that these values are slightly smaller for CMSSW
521  // // But as quoted above, we want to get rid of this gymnastics in the future
522  // // if (abspar0>0) ptLx += nsigma_Pt_*err0/abspar0*tk->pt();
523 
524  // Charge
525  // We use the charge in some dimuon paths
526  muonl3pterr[imu3c] = l3_err0/l3_abspar0;
527  muonl3globalchg[imu3c] = tk->charge();
528  muonl3chg[imu3c] = candref->charge();
529 
530  muonl3normchi2[imu3c] = tk->normalizedChi2();
531  muonl3npixelhits[imu3c] = tk->hitPattern().numberOfValidPixelHits();
532  muonl3ntrackerhits[imu3c] = tk->hitPattern().numberOfValidTrackerHits();
533  muonl3nmuonhits[imu3c] = tk->hitPattern().numberOfValidMuonHits();
534 
535  if (isoMap3.isValid()){
536  // Isolation flag (this is a bool value: true => isolated)
537  edm::ValueMap<bool> ::value_type muon1IsIsolated = (*isoMap3)[tk];
538  muonl3iso[imu3c] = muon1IsIsolated;
539  }
540  else {muonl3iso[imu3c] = -999;}
541 
542  if (isoTrk10Map3.isValid()){
543  // Isolation flag (this is a bool value: true => isolated)
544  edm::ValueMap<bool> ::value_type muon1IsTrk10Isolated = (*isoTrk10Map3)[tk];
545  muonl3trk10iso[imu3c] = muon1IsTrk10Isolated;
546  }
547  else {muonl3trk10iso[imu3c] =-999;}
548 
549  //Check DCA for muon combinations
550  int imu3c2nd = imu3c + 1;// This will be the index in the hltTree for the 2nd muon of the dimuon combination
551 
552  for (cand j=i; j!=myMucands3.end(); j++) if (i!=j) {//Loop over all L3 muons from the one we are already treating
553  reco::TrackRef tk2nd = j->get<reco::TrackRef>();
554  reco::TransientTrack transMu1(*tk, &(*theMagField) );
555  reco::TransientTrack transMu2(*tk2nd, &(*theMagField) );
556  TrajectoryStateClosestToPoint mu1TS = transMu1.impactPointTSCP();
558  if (mu1TS.isValid() && mu2TS.isValid()) {
560  cApp.calculate(mu1TS.theState(), mu2TS.theState());
561  if (cApp.status()) {
562  dimudca[idimuc] = cApp.distance();//Save the DCA
563  dimu1st[idimuc] = imu3c;//Save which is the index in the hltTree for the 1st muon
564  dimu2nd[idimuc] = imu3c2nd;//Save which is the index in the hltTree for the 2nd muon
565  idimuc++;
566  }
567  }
568  imu3c2nd++;
569  }
570 
571  imu3c++;
572  k++;
573  }
574  nDiMu = idimuc;
575  }
576 
577  else {nmu3cand = 0; nDiMu = 0;}
578  // Dealing with dimu vertices
579  reco::VertexCollection myDimuvtxcands3;
580  if (DiMuVtxCands3.isValid()) {
581  myDimuvtxcands3 = * DiMuVtxCands3;
582  nDiMuVtx = myDimuvtxcands3.size();
583  typedef reco::VertexCollection::const_iterator cand;
584  int idimu3c=0;
585  for (cand ivtx = myDimuvtxcands3.begin(); ivtx != myDimuvtxcands3.end(); ++ivtx) {
586  dimuvtxchi2[idimu3c] = ivtx->normalizedChi2();
587  reco::Vertex::trackRef_iterator trackIt = ivtx->tracks_begin();
588  reco::TrackRef vertextkRef1 = (*trackIt).castTo<reco::TrackRef>();
589  ++trackIt;
590  reco::TrackRef vertextkRef2 = (*trackIt).castTo<reco::TrackRef>();
591  dimuvtx2nd[idimu3c] = -1; dimuvtx1st[idimu3c] = -1;
592  for (int j=0 ; j<nmu3cand ; j++){
593  if(fabs(muonl3pt[j] - vertextkRef1->pt()) < 0.0001 && fabs(muonl3eta[j] - vertextkRef1->eta()) < 0.0001 && fabs(muonl3phi[j] - vertextkRef1->phi()) < 0.0001) dimuvtx1st[idimu3c] = j;
594  if(fabs(muonl3pt[j] - vertextkRef2->pt()) < 0.0001 && fabs(muonl3eta[j] - vertextkRef2->eta()) < 0.0001 && fabs(muonl3phi[j] - vertextkRef2->phi()) < 0.0001) dimuvtx2nd[idimu3c] = j;
595  }
596  math::XYZVector pperp(vertextkRef1->px() + vertextkRef2->px(),
597  vertextkRef1->py() + vertextkRef2->py(),
598  0.);
599  reco::Vertex::Point vpoint = ivtx->position();
600  GlobalPoint vtxPos (vpoint.x(), vpoint.y(), vpoint.z());
601  reco::Vertex::Error verr = ivtx->error();
602  GlobalError vtxErr (verr.At(0,0),verr.At(1,0),verr.At(1,1),verr.At(2,0),verr.At(2,1),verr.At(2,2));
603  GlobalPoint vtxDisFromBS(-1*((vtxBS.x0() - vtxPos.x()) + (vtxPos.z() - vtxBS.z0())*vtxBS.dxdz()),
604  -1*((vtxBS.y0() - vtxPos.y()) + (vtxPos.z() - vtxBS.z0())*vtxBS.dydz()), 0.0);
605  dimuvtxr[idimu3c] = vtxDisFromBS.perp();
606  dimuvtxrsig[idimu3c] = sqrt(vtxErr.rerr(vtxDisFromBS));
607  dimuvtxroversig[idimu3c] = dimuvtxr[idimu3c]/dimuvtxrsig[idimu3c];
608  reco::Vertex::Point vperp(vtxDisFromBS.x(),vtxDisFromBS.y(),0.);
609  dimuvtxcosalpha[idimu3c] = vperp.Dot(pperp)/(vperp.R()*pperp.R());
610  float mu1ip = -1.0;
611  float mu2ip = -1.0;
612  float mu1ipsig = -1.0;
613  float mu2ipsig = -1.0;
614  reco::TransientTrack transMu1(*vertextkRef1, &(*theMagField) );
615  TrajectoryStateClosestToPoint trajMu1BS = transMu1.trajectoryStateClosestToPoint(theBeamSpot);
616  if(trajMu1BS.isValid()){
617  mu1ip = fabs(trajMu1BS.perigeeParameters().transverseImpactParameter());
618  if(trajMu1BS.hasError()) mu1ipsig = mu1ip/trajMu1BS.perigeeError().transverseImpactParameterError();
619  }
620  reco::TransientTrack transMu2(*vertextkRef2, &(*theMagField) );
621  TrajectoryStateClosestToPoint trajMu2BS = transMu2.trajectoryStateClosestToPoint(theBeamSpot);
622  if(trajMu2BS.isValid()){
623  mu2ip = fabs(trajMu2BS.perigeeParameters().transverseImpactParameter());
624  if(trajMu2BS.hasError()) mu2ipsig = mu2ip/trajMu2BS.perigeeError().transverseImpactParameterError();
625  }
626  dimuvtxmu2dipmax[idimu3c] = fmax(mu1ip,mu2ip);
627  dimuvtxmu2dipmin[idimu3c] = fmin(mu1ip,mu2ip);
628  dimuvtxmu2dipsigmax[idimu3c] = fmax(mu1ipsig,mu2ipsig);
629  dimuvtxmu2dipsigmin[idimu3c] = fmin(mu1ipsig,mu2ipsig);
630  }
631 
632 
633  }
634  else {nDiMuVtx = 0;}
635 
636 
637  // Dealing with L2 no-Vertex muons
638  reco::RecoChargedCandidateCollection muNoVtxMucands2;
639  if (MuNoVtxCands2.isValid()) {
640  muNoVtxMucands2 = * MuNoVtxCands2;
641  std::sort(muNoVtxMucands2.begin(),muNoVtxMucands2.end(),PtGreater());
642  nmu2cand = muNoVtxMucands2.size();
643  typedef reco::RecoChargedCandidateCollection::const_iterator cand;
644  int imu2c=0;
645  for (cand i=muNoVtxMucands2.begin(); i!=muNoVtxMucands2.end(); i++) {
646  reco::TrackRef tk = i->get<reco::TrackRef>();
647 
648  muonl2novtxpt[imu2c] = tk->pt();
649  muonl2novtxeta[imu2c] = tk->eta();
650  muonl2novtxphi[imu2c] = tk->phi();
651  muonl2novtxdr[imu2c] = fabs(tk->dxy(BSPosition));
652  muonl2novtxdrsign[imu2c] = ( tk->dxyError() > 0. ? muonl2novtxdr[imu2c] / tk->dxyError() : 999. );
653  muonl2novtxdz[imu2c] = tk->dz(BSPosition);
654  muonl2novtxnhits[imu2c] = tk->numberOfValidHits();
655  muonl2novtxnchambers[imu2c] = validChambers(tk);
656  muonl2novtxnstat[imu2c] = tk->hitPattern().muonStationsWithAnyHits();
657  muonl2novtxndtcscstat[imu2c] = tk->hitPattern().dtStationsWithAnyHits() + tk->hitPattern().cscStationsWithAnyHits();
658 
659  double l2_err0 = tk->error(0); // error on q/p
660  double l2_abspar0 = fabs(tk->parameter(0)); // |q/p|
661 
662  muonl2novtxpterr[imu2c] = l2_err0/l2_abspar0;
663  muonl2novtxchg[imu2c] = tk->charge();
664 
666  int il2 = 0;
667  //find the corresponding L1
668  l1 = tk->seedRef().castTo<edm::Ref< L2MuonTrajectorySeedCollection> >()->l1Particle();
669  il2++;
670  int imu1idx = 0;
671  if (MuCands1.isValid()) {
672  typedef l1extra::L1MuonParticleCollection::const_iterator candl1;
673  for (candl1 j=myMucands1.begin(); j!=myMucands1.end(); j++) {
674  if((j->pt() == l1->pt()) &&
675  (j->eta() == l1->eta()) &&
676  (j->phi() == l1->phi()) &&
677  (j->gmtMuonCand().quality() == l1->gmtMuonCand().quality()))
678  {break;}
679  imu1idx++;
680  }
681  }
682  else {imu1idx = -999;}
683  muonl2novtx1idx[imu2c] = imu1idx; // Index of the L1 muon having matched with the L2 muon with index imu2c
684 
685  imu2c++;
686  }
687  }
688  else {nmu2cand = 0;}
689 
690 
691 
692  // Dealing with Onia Pixel tracks
693  reco::RecoChargedCandidateCollection myOniaPixelCands;
694  if (oniaPixelCands.isValid()) {
695  myOniaPixelCands = * oniaPixelCands;
696  std::sort(myOniaPixelCands.begin(),myOniaPixelCands.end(),PtGreater());
697  nOniaPixelCand = myOniaPixelCands.size();
698  typedef reco::RecoChargedCandidateCollection::const_iterator cand;
699  int ic=0;
700  for (cand i=myOniaPixelCands.begin(); i!=myOniaPixelCands.end(); i++) {
701  reco::TrackRef tk = i->get<reco::TrackRef>();
702 
703  oniaPixelpt[ic] = tk->pt();
704  oniaPixeleta[ic] = tk->eta();
705  oniaPixelphi[ic] = tk->phi();
706  oniaPixeldr[ic] = tk->dxy(BSPosition);
707  oniaPixeldz[ic] = tk->dz(BSPosition);
708  oniaPixelchg[ic] = tk->charge();
709  oniaPixelHits[ic] = tk->numberOfValidHits();
710  oniaPixelNormChi2[ic] = tk->normalizedChi2();
711 
712  ic++;
713  }
714  }
715  else {nOniaPixelCand = 0;}
716 
717  // Dealing with Onia Tracks
718  reco::RecoChargedCandidateCollection myOniaTrackCands;
719  if (oniaTrackCands.isValid()) {
720  myOniaTrackCands = * oniaTrackCands;
721  std::sort(myOniaTrackCands.begin(),myOniaTrackCands.end(),PtGreater());
722  nOniaTrackCand = myOniaTrackCands.size();
723  typedef reco::RecoChargedCandidateCollection::const_iterator cand;
724  int ic=0;
725  for (cand i=myOniaTrackCands.begin(); i!=myOniaTrackCands.end(); i++) {
726  reco::TrackRef tk = i->get<reco::TrackRef>();
727 
728  oniaTrackpt[ic] = tk->pt();
729  oniaTracketa[ic] = tk->eta();
730  oniaTrackphi[ic] = tk->phi();
731  oniaTrackdr[ic] = tk->dxy(BSPosition);
732  oniaTrackdz[ic] = tk->dz(BSPosition);
733  oniaTrackchg[ic] = tk->charge();
734  oniaTrackHits[ic] = tk->numberOfValidHits();
735  oniaTrackNormChi2[ic] = tk->normalizedChi2();
736 
737  ic++;
738  }
739  }
740  else {nOniaTrackCand = 0;}
741 
742 
743  // Dealing with trackerMuons
744  if(trkmucands.isValid()) {
745  int itrackermuc=0;
746  for ( unsigned int i=0; i<trkmucands->size(); ++i ){
747  const reco::Muon& muon(trkmucands->at(i));
748  if (muon.isTrackerMuon()) {
749  trackermuonpt[itrackermuc] = muon.pt();
750  trackermuoneta[itrackermuc] = muon.eta();
751  trackermuonphi[itrackermuc] = muon.phi();
752  trackermuonchg[itrackermuc] = muon.charge();
753  if ( !muon.innerTrack().isNull() ){
754  trackermuonnhits[itrackermuc] = muon.innerTrack()->numberOfValidHits();
755  }
756  itrackermuc++;
757  }
758  }
759  ntrackermuoncand=itrackermuc;
760  }
761  else {ntrackermuoncand = 0;}
762 
764 
765  if (pfMuon.isValid()) {
766  reco::PFCandidateCollection mypfmuons;
767  mypfmuons = * pfMuon;
768  std::sort(mypfmuons.begin(),mypfmuons.end(),PtGreater());
769  npfmuon = mypfmuons.size();
770  typedef reco::PFCandidateCollection::const_iterator muiter;
771  int ipfmu=0;
772  for (muiter i=mypfmuons.begin(); i!=mypfmuons.end(); i++)
773  {
774  pfmuonpt[ipfmu] = i->pt();
775  pfmuonphi[ipfmu] = i->phi();
776  pfmuoneta[ipfmu] = i->eta();
777  pfmuonet[ipfmu] = i->et();
778  pfmuone[ipfmu] = i->energy();
779  pfmuoncharge[ipfmu] = i->charge();
780 
781  ipfmu++;
782  }
783  }
784  else {npfmuon = 0;}
785 
786 }
787 
789 {
790  // count hits in chambers using std::maps
791  std::map<uint32_t,int> DTchambers;
792  std::map<uint32_t,int> CSCchambers;
793 
794  for (trackingRecHit_iterator hit = track->recHitsBegin(); hit != track->recHitsEnd(); ++hit) {
795  if( !((*hit)->isValid()) ) continue;
796 
797  DetId id = (*hit)->geographicalId();
798 
799  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT) {
800  // get the DT chamber index, not the layer index, by using DTChamberId
801  uint32_t index = DTChamberId(id).rawId();
802 
803  if (DTchambers.find(index) == DTchambers.end()) {
804  DTchambers[index] = 0;
805  }
806  DTchambers[index]++;
807  }
808 
809  else if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
810  // get the CSC chamber index, not the layer index, by explicitly setting the layer id to 0
811  CSCDetId id2(id);
812  uint32_t index = CSCDetId(id2.endcap(), id2.station(), id2.ring(), id2.chamber(), 0);
813 
814  if (CSCchambers.find(index) == CSCchambers.end()) {
815  CSCchambers[index] = 0;
816  }
817  CSCchambers[index]++;
818  }
819  }
820 
821  // count chambers that satisfy minimal numbers of hits per chamber
822  int validChambers = 0;
823 
824  int minDThits = 1;
825  int minCSChits = 1;
826 
827  for (std::map<uint32_t,int>::const_iterator iter = DTchambers.begin(); iter != DTchambers.end(); ++iter) {
828  if (iter->second >= minDThits) {
829  validChambers++;
830  }
831  }
832  for (std::map<uint32_t,int>::const_iterator iter = CSCchambers.begin(); iter != CSCchambers.end(); ++iter) {
833  if (iter->second >= minCSChits) {
834  validChambers++;
835  }
836  }
837  return validChambers;
838 }
int ntrackermuoncand
Definition: HLTMuon.h:109
int * muonl32idx
Definition: HLTMuon.h:110
int chamber() const
Definition: CSCDetId.h:68
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
int * muonl2iso
Definition: HLTMuon.h:110
int npfmuon
Definition: HLTMuon.h:109
float * muonl2novtxdr
Definition: HLTMuon.h:107
float * muonl2drsign
Definition: HLTMuon.h:104
float * muonchi2NDF
Definition: HLTMuon.h:100
int * muonl2chg
Definition: HLTMuon.h:110
float * dimuvtxcosalpha
Definition: HLTMuon.h:123
int * muonl2novtxndtcscstat
Definition: HLTMuon.h:110
float * pfmuoneta
Definition: HLTMuon.h:102
float * oniaPixelNormChi2
Definition: HLTMuon.h:117
int * dimuvtx2nd
Definition: HLTMuon.h:122
float * dimuvtxmu2dipmax
Definition: HLTMuon.h:124
float * oniaTrackdr
Definition: HLTMuon.h:118
float * muonl2novtxpterr
Definition: HLTMuon.h:108
int * muonl3nhits
Definition: HLTMuon.h:110
float * pfmuone
Definition: HLTMuon.h:102
int nDiMu
Definition: HLTMuon.h:120
float * oniaTrackpt
Definition: HLTMuon.h:118
int * muonNValidTrkHits
Definition: HLTMuon.h:103
float * muonl3normchi2
Definition: HLTMuon.h:105
const PerigeeTrajectoryError & perigeeError() const
int * muonl2nhits
Definition: HLTMuon.h:110
float * muonl2pt
Definition: HLTMuon.h:104
float * muonl3globaldrsign
Definition: HLTMuon.h:106
int * oniaTrackHits
Definition: HLTMuon.h:119
TrajectoryStateClosestToPoint impactPointTSCP() const
int * muonl21idx
Definition: HLTMuon.h:110
const FreeTrajectoryState & theState() const
float * oniaTrackdz
Definition: HLTMuon.h:118
float * muonl3phi
Definition: HLTMuon.h:105
float * dimuvtxrsig
Definition: HLTMuon.h:123
int * muonl2novtxnhits
Definition: HLTMuon.h:110
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
int * muonl2nstat
Definition: HLTMuon.h:110
int * dimu1st
Definition: HLTMuon.h:122
float * muonl3vtxz
Definition: HLTMuon.h:105
int nmu2cand
Definition: HLTMuon.h:109
edm::Ref< RecoChargedCandidateCollection > RecoChargedCandidateRef
reference to an object in a collection of RecoChargedCandidate objects
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
float * muonl2eta
Definition: HLTMuon.h:104
float * muonl3pterr
Definition: HLTMuon.h:108
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
float * oniaPixelpt
Definition: HLTMuon.h:117
int nOniaTrackCand
Definition: HLTMuon.h:116
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:29
float * dimuvtxchi2
Definition: HLTMuon.h:123
float * pfmuonphi
Definition: HLTMuon.h:102
float * trackermuonphi
Definition: HLTMuon.h:112
float * muonl3globaldz
Definition: HLTMuon.h:106
float * oniaTrackNormChi2
Definition: HLTMuon.h:118
float * muone
Definition: HLTMuon.h:100
float * trackermuoneta
Definition: HLTMuon.h:112
int * muontype
Definition: HLTMuon.h:103
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
int nmu3cand
Definition: HLTMuon.h:109
int endcap() const
Definition: CSCDetId.h:93
float * muoncharge
Definition: HLTMuon.h:100
int * muonl2novtxchg
Definition: HLTMuon.h:110
float * oniaTracketa
Definition: HLTMuon.h:118
float * oniaPixeldr
Definition: HLTMuon.h:117
int * trackermuonnhits
Definition: HLTMuon.h:113
void setup(const edm::ParameterSet &pSet, TTree *tree)
Definition: HLTMuon.cc:23
float * muonl2dz
Definition: HLTMuon.h:104
float * muonHCalIsoR03
Definition: HLTMuon.h:100
float * muonl3globaldr
Definition: HLTMuon.h:106
static const int CSC
Definition: MuonSubdetId.h:13
int * muonl2ndtcscstat
Definition: HLTMuon.h:110
float * muonl2pterr
Definition: HLTMuon.h:108
const PerigeeTrajectoryParameters & perigeeParameters() const
T sqrt(T t)
Definition: SSEVec.h:18
float * pfmuonet
Definition: HLTMuon.h:102
bool _Monte
Definition: HLTMuon.h:128
float * dimuvtxmu2dipsigmin
Definition: HLTMuon.h:124
int * muonl2novtx1idx
Definition: HLTMuon.h:110
float * dimuvtxroversig
Definition: HLTMuon.h:123
int * muonNValidMuonHits
Definition: HLTMuon.h:103
int j
Definition: DBlmapReader.cc:9
int * muonl3trk10iso
Definition: HLTMuon.h:111
int * muonl3nmuonhits
Definition: HLTMuon.h:111
float * muonl3pt
Definition: HLTMuon.h:105
float * pfmuonpt
Definition: HLTMuon.h:102
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
float * trackermuonpt
Definition: HLTMuon.h:112
std::vector< std::string > getParameterNames() const
bool isValid() const
Definition: HandleBase.h:75
float * muonl2novtxeta
Definition: HLTMuon.h:107
double transverseImpactParameterError() const
float * muonpt
Definition: HLTMuon.h:100
float * pfmuoncharge
Definition: HLTMuon.h:102
float * muonTrkIsoR03
Definition: HLTMuon.h:100
int * muonl2novtxnstat
Definition: HLTMuon.h:110
float * muonl2novtxpt
Definition: HLTMuon.h:107
int validChambers(const reco::TrackRef &track)
Definition: HLTMuon.cc:788
float * oniaPixeleta
Definition: HLTMuon.h:117
float * muonl3globalpt
Definition: HLTMuon.h:106
int * muonl3chg
Definition: HLTMuon.h:110
int ring() const
Definition: CSCDetId.h:75
int * trackermuonchg
Definition: HLTMuon.h:113
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
void analyze(const edm::Handle< reco::MuonCollection > &muon, const edm::Handle< reco::PFCandidateCollection > &pfmuon, const edm::Handle< l1extra::L1MuonParticleCollection > &mucands1, const edm::Handle< reco::RecoChargedCandidateCollection > &mucands2, const edm::Handle< edm::ValueMap< bool > > &isoMap2, const edm::Handle< reco::RecoChargedCandidateCollection > &mucands3, const edm::Handle< edm::ValueMap< bool > > &isoMap3, const edm::Handle< edm::ValueMap< bool > > &isoTrk10Map3, const edm::Handle< reco::RecoChargedCandidateCollection > &oniaPixelCands, const edm::Handle< reco::RecoChargedCandidateCollection > &oniaTrackCands, const edm::Handle< reco::VertexCollection > &dimuvtxcands3, const edm::Handle< reco::RecoChargedCandidateCollection > &munovtxcands2, const edm::Handle< reco::MuonCollection > &trkmucands, const edm::ESHandle< MagneticField > &theMagField, const edm::Handle< reco::BeamSpot > &recoBeamSpotHandle, TTree *tree)
Definition: HLTMuon.cc:281
Definition: DetId.h:18
bool _Debug
Definition: HLTMuon.h:128
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
int nDiMuVtx
Definition: HLTMuon.h:120
float * muonl2novtxdrsign
Definition: HLTMuon.h:107
int * muonl3global2idx
Definition: HLTMuon.h:110
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
float * dimuvtxmu2dipsigmax
Definition: HLTMuon.h:124
float * muonl3globaleta
Definition: HLTMuon.h:106
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
float * muonl2novtxdz
Definition: HLTMuon.h:107
float * muonphi
Definition: HLTMuon.h:100
float * dimuvtxr
Definition: HLTMuon.h:123
float * muonl3dr
Definition: HLTMuon.h:105
float * muonl2phi
Definition: HLTMuon.h:104
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
int * muonl3globalchg
Definition: HLTMuon.h:110
float * oniaPixeldz
Definition: HLTMuon.h:117
float * muonl3globalvtxz
Definition: HLTMuon.h:106
int * muonl2novtxnchambers
Definition: HLTMuon.h:110
int * muonl3npixelhits
Definition: HLTMuon.h:111
float * muonl3globalphi
Definition: HLTMuon.h:106
HLTMuon()
Definition: HLTMuon.cc:14
float * oniaTrackphi
Definition: HLTMuon.h:118
float * muonl3dz
Definition: HLTMuon.h:105
int nOniaPixelCand
Definition: HLTMuon.h:116
float * muonD0
Definition: HLTMuon.h:100
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:37
float * muonECalIsoR03
Definition: HLTMuon.h:100
int * oniaPixelchg
Definition: HLTMuon.h:119
float * muonl3eta
Definition: HLTMuon.h:105
float * dimuvtxmu2dipmin
Definition: HLTMuon.h:124
int * muonl3iso
Definition: HLTMuon.h:110
int station() const
Definition: CSCDetId.h:86
static const int DT
Definition: MuonSubdetId.h:12
int * muonl2nchambers
Definition: HLTMuon.h:110
float * muonl2dr
Definition: HLTMuon.h:104
float * muonet
Definition: HLTMuon.h:100
float * oniaPixelphi
Definition: HLTMuon.h:117
int * dimuvtx1st
Definition: HLTMuon.h:122
virtual float distance() const
float * muonl2novtxphi
Definition: HLTMuon.h:107
int * dimu2nd
Definition: HLTMuon.h:122
int * oniaPixelHits
Definition: HLTMuon.h:119
int * oniaTrackchg
Definition: HLTMuon.h:119
int * muonl3ntrackerhits
Definition: HLTMuon.h:111
float * muoneta
Definition: HLTMuon.h:100
std::vector< L1MuonParticle > L1MuonParticleCollection
int evtCounter
Definition: HLTMuon.h:130
int nmuon
Definition: HLTMuon.h:109
virtual bool status() const
float * muonl2vtxz
Definition: HLTMuon.h:104
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
float * dimudca
Definition: HLTMuon.h:121