93 for (
auto iterTP : *trackingParticleHandle) {
97 int tmp_eventid = iterTP.eventId().event();
98 float tmp_tp_pt = iterTP.pt();
99 float tmp_tp_phi = iterTP.phi();
100 float tmp_tp_eta = iterTP.eta();
104 theStubRefs = MCTruthTTStubHandle->findTTStubRefs(tp_ptr);
106 int hasStubInLayer[11] = {0};
107 for (
unsigned int is = 0; is < theStubRefs.size(); is++) {
108 DetId detid(theStubRefs.at(is)->getDetId());
111 layer = static_cast<int>(tTopo->
layer(detid)) - 1;
113 layer = static_cast<int>(tTopo->
layer(detid)) + 5;
116 if (MCTruthTTStubHandle->findTrackingParticlePtr(theStubRefs.at(is)).isNull() && hasStubInLayer[layer] < 2)
117 hasStubInLayer[layer] = 1;
119 hasStubInLayer[layer] = 2;
122 int nStubLayerTP = 0;
123 int nStubLayerTP_g = 0;
125 if (hasStubInLayer[
isum] >= 1)
127 else if (hasStubInLayer[
isum] == 2)
143 if (MCTruthTTStubHandle.
isValid()) {
145 theStubRefs = MCTruthTTStubHandle->findTTStubRefs(tp_ptr);
146 nStubTP = (
int)theStubRefs.size();
148 if (MCTruthTTClusterHandle.
isValid() && MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
151 float tmp_tp_vz = iterTP.vz();
152 float tmp_tp_vx = iterTP.vx();
153 float tmp_tp_vy = iterTP.vy();
154 float tmp_tp_charge = tp_ptr->
charge();
155 int tmp_tp_pdgid = iterTP.pdgId();
160 float tmp_tp_t =
tan(2.0 * atan(1.0) - 2.0 * atan(
exp(-tmp_tp_eta)));
161 float delx = -tmp_tp_vx;
162 float dely = -tmp_tp_vy;
163 float K = 0.01 * 0.5696 / tmp_tp_pt * tmp_tp_charge;
164 float A = 1. / (2. * K);
165 float tmp_tp_x0p = delx -
A *
sin(tmp_tp_phi);
166 float tmp_tp_y0p = dely +
A *
cos(tmp_tp_phi);
167 float tmp_tp_rp =
sqrt(tmp_tp_x0p * tmp_tp_x0p + tmp_tp_y0p * tmp_tp_y0p);
168 static double pi = 4.0 * atan(1.0);
169 float delphi = tmp_tp_phi - atan2(-K * tmp_tp_x0p, K * tmp_tp_y0p);
175 float tmp_tp_VtxZ = tmp_tp_vz + tmp_tp_t * delphi / (2.0 * K);
176 float tmp_tp_VtxR =
sqrt(tmp_tp_vx * tmp_tp_vx + tmp_tp_vy * tmp_tp_vy);
177 float tmp_tp_d0 = tmp_tp_charge * tmp_tp_rp - (1. / (2. * K));
181 float other_d0 = -tmp_tp_vx *
sin(tmp_tp_phi) + tmp_tp_vy *
cos(tmp_tp_phi);
182 tmp_tp_d0 = tmp_tp_d0 * (-1);
184 tmp_tp_d0 = other_d0;
185 tmp_tp_VtxZ = tmp_tp_vz;
191 if (tmp_tp_VtxR < 1.0) {
199 if (tmp_tp_VtxR > 1.0)
212 float i_chi2dof = 99999;
213 if (MCTruthTTTrackHandle.
isValid()) {
214 std::vector<edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>> matchedTracks =
215 MCTruthTTTrackHandle->findTTTrackPtrs(tp_ptr);
223 for (
auto thisTrack : matchedTracks) {
224 if (!MCTruthTTTrackHandle->isGenuine(thisTrack))
230 int tmp_trk_nstub = thisTrack->getStubRefs().size();
233 float dmatch_pt = 999;
234 float dmatch_eta = 999;
235 float dmatch_phi = 999;
239 dmatch_pt = std::fabs(my_tp->
p4().pt() - tmp_tp_pt);
240 dmatch_eta = std::fabs(my_tp->
p4().eta() - tmp_tp_eta);
241 dmatch_phi = std::fabs(my_tp->
p4().phi() - tmp_tp_phi);
242 match_id = my_tp->
pdgId();
243 float tmp_trk_chi2dof = (thisTrack->chi2()) / (2 * tmp_trk_nstub -
L1Tk_nPar);
246 if (dmatch_pt < 0.1 && dmatch_eta < 0.1 && dmatch_phi < 0.1 && tmp_tp_pdgid == match_id) {
248 if (i_track < 0 || tmp_trk_chi2dof < i_chi2dof) {
249 i_track = trkCounter;
250 i_chi2dof = tmp_trk_chi2dof;
259 float tmp_matchtrk_pt = -999;
260 float tmp_matchtrk_eta = -999;
261 float tmp_matchtrk_phi = -999;
262 float tmp_matchtrk_VtxZ = -999;
263 float tmp_matchtrk_chi2 = -999;
264 float tmp_matchtrk_chi2dof = -999;
265 int tmp_matchTrk_nStub = -999;
266 float tmp_matchtrk_d0 = -999;
268 tmp_matchtrk_pt = matchedTracks[i_track]->momentum().perp();
269 tmp_matchtrk_eta = matchedTracks[i_track]->eta();
270 tmp_matchtrk_phi = matchedTracks[i_track]->phi();
271 tmp_matchtrk_VtxZ = matchedTracks[i_track]->z0();
272 tmp_matchtrk_chi2 = matchedTracks[i_track]->chi2();
273 tmp_matchtrk_chi2dof = matchedTracks[i_track]->chi2Red();
274 tmp_matchTrk_nStub = (
int)matchedTracks[i_track]->getStubRefs().size();
280 float tmp_matchtrk_x0 = matchedTracks[i_track]->POCA().x();
281 float tmp_matchtrk_y0 = matchedTracks[i_track]->POCA().y();
282 tmp_matchtrk_d0 = -tmp_matchtrk_x0 *
sin(tmp_matchtrk_phi) + tmp_matchtrk_y0 *
cos(tmp_matchtrk_phi);
287 if (tmp_matchTrk_nStub < L1Tk_minNStub || tmp_matchtrk_chi2 >
L1Tk_maxChi2 ||
293 if (tmp_tp_pt > 0 && tmp_tp_pt <= 10)
301 float pt_diff = tmp_matchtrk_pt - tmp_tp_pt;
302 float pt_res = pt_diff / tmp_tp_pt;
303 float eta_res = tmp_matchtrk_eta - tmp_tp_eta;
304 float phi_res = tmp_matchtrk_phi - tmp_tp_phi;
305 float VtxZ_res = tmp_matchtrk_VtxZ - tmp_tp_VtxZ;
306 float d0_res = tmp_matchtrk_d0 - tmp_tp_d0;
315 if (std::fabs(tmp_tp_eta) >= 0 && std::fabs(tmp_tp_eta) < 0.7) {
320 if (tmp_tp_pt >= 2 && tmp_tp_pt < 3)
322 else if (tmp_tp_pt >= 3 && tmp_tp_pt < 8)
324 else if (tmp_tp_pt >= 8)
326 }
else if (std::fabs(tmp_tp_eta) >= 0.7 && std::fabs(tmp_tp_eta) < 1.0) {
331 if (tmp_tp_pt >= 2 && tmp_tp_pt < 3)
333 else if (tmp_tp_pt >= 3 && tmp_tp_pt < 8)
335 else if (tmp_tp_pt >= 8)
337 }
else if (std::fabs(tmp_tp_eta) >= 1.0 && std::fabs(tmp_tp_eta) < 1.2) {
342 if (tmp_tp_pt >= 2 && tmp_tp_pt < 3)
344 else if (tmp_tp_pt >= 3 && tmp_tp_pt < 8)
346 else if (tmp_tp_pt >= 8)
348 }
else if (std::fabs(tmp_tp_eta) >= 1.2 && std::fabs(tmp_tp_eta) < 1.6) {
353 if (tmp_tp_pt >= 2 && tmp_tp_pt < 3)
355 else if (tmp_tp_pt >= 3 && tmp_tp_pt < 8)
357 else if (tmp_tp_pt >= 8)
359 }
else if (std::fabs(tmp_tp_eta) >= 1.6 && std::fabs(tmp_tp_eta) < 2.0) {
364 if (tmp_tp_pt >= 2 && tmp_tp_pt < 3)
366 else if (tmp_tp_pt >= 3 && tmp_tp_pt < 8)
368 else if (tmp_tp_pt >= 8)
370 }
else if (std::fabs(tmp_tp_eta) >= 2.0 && std::fabs(tmp_tp_eta) <= 2.4) {
375 if (tmp_tp_pt >= 2 && tmp_tp_pt < 3)
377 else if (tmp_tp_pt >= 3 && tmp_tp_pt < 8)
379 else if (tmp_tp_pt >= 8)
831 HistoName =
"respt_eta1p2to1p6_pt8toInf";