89 for (
const auto &iterTP : *trackingParticleHandle) {
94 float tmp_tp_pt = iterTP.pt();
95 float tmp_tp_phi = iterTP.phi();
96 float tmp_tp_eta = iterTP.eta();
100 theStubRefs = MCTruthTTStubHandle->findTTStubRefs(tp_ptr);
102 int hasStubInLayer[11] = {0};
103 for (
unsigned int is = 0; is < theStubRefs.size(); is++) {
104 DetId detid(theStubRefs.at(is)->getDetId());
107 layer = static_cast<int>(tTopo->
layer(detid)) - 1;
109 layer = static_cast<int>(tTopo->
layer(detid)) + 5;
112 if (MCTruthTTStubHandle->findTrackingParticlePtr(theStubRefs.at(is)).isNull() && hasStubInLayer[layer] < 2)
113 hasStubInLayer[layer] = 1;
115 hasStubInLayer[layer] = 2;
118 int nStubLayerTP = 0;
120 if (hasStubInLayer[
isum] >= 1)
136 if (MCTruthTTStubHandle.
isValid()) {
138 theStubRefs = MCTruthTTStubHandle->findTTStubRefs(tp_ptr);
139 nStubTP = (
int)theStubRefs.size();
141 if (MCTruthTTClusterHandle.
isValid() && MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
144 float tmp_tp_vz = iterTP.vz();
145 float tmp_tp_vx = iterTP.vx();
146 float tmp_tp_vy = iterTP.vy();
147 float tmp_tp_charge = tp_ptr->
charge();
148 int tmp_tp_pdgid = iterTP.pdgId();
153 float tmp_tp_t =
tan(2.0 * atan(1.0) - 2.0 * atan(
exp(-tmp_tp_eta)));
154 float delx = -tmp_tp_vx;
155 float dely = -tmp_tp_vy;
156 float K = 0.01 * 0.5696 / tmp_tp_pt * tmp_tp_charge;
157 float A = 1. / (2. * K);
158 float tmp_tp_x0p = delx -
A *
sin(tmp_tp_phi);
159 float tmp_tp_y0p = dely +
A *
cos(tmp_tp_phi);
160 float tmp_tp_rp =
sqrt(tmp_tp_x0p * tmp_tp_x0p + tmp_tp_y0p * tmp_tp_y0p);
161 static double pi = 4.0 * atan(1.0);
162 float delphi = tmp_tp_phi - atan2(-K * tmp_tp_x0p, K * tmp_tp_y0p);
168 float tmp_tp_VtxZ = tmp_tp_vz + tmp_tp_t * delphi / (2.0 * K);
169 float tmp_tp_VtxR =
sqrt(tmp_tp_vx * tmp_tp_vx + tmp_tp_vy * tmp_tp_vy);
170 float tmp_tp_d0 = tmp_tp_charge * tmp_tp_rp - (1. / (2. * K));
174 float other_d0 = -tmp_tp_vx *
sin(tmp_tp_phi) + tmp_tp_vy *
cos(tmp_tp_phi);
175 tmp_tp_d0 = tmp_tp_d0 * (-1);
177 tmp_tp_d0 = other_d0;
178 tmp_tp_VtxZ = tmp_tp_vz;
184 if (tmp_tp_VtxR < 1.0) {
192 if (tmp_tp_VtxR > 1.0)
205 float i_chi2dof = 99999;
206 if (MCTruthTTTrackHandle.
isValid()) {
207 std::vector<edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>> matchedTracks =
208 MCTruthTTTrackHandle->findTTTrackPtrs(tp_ptr);
216 for (
const auto &thisTrack : matchedTracks) {
217 if (!MCTruthTTTrackHandle->isGenuine(thisTrack))
223 int tmp_trk_nstub = thisTrack->getStubRefs().size();
226 float dmatch_pt = 999;
227 float dmatch_eta = 999;
228 float dmatch_phi = 999;
232 dmatch_pt = std::fabs(my_tp->
p4().pt() - tmp_tp_pt);
233 dmatch_eta = std::fabs(my_tp->
p4().eta() - tmp_tp_eta);
234 dmatch_phi = std::fabs(my_tp->
p4().phi() - tmp_tp_phi);
235 match_id = my_tp->
pdgId();
236 float tmp_trk_chi2dof = thisTrack->chi2Red();
239 if (dmatch_pt < 0.1 && dmatch_eta < 0.1 && dmatch_phi < 0.1 && tmp_tp_pdgid == match_id) {
241 if (i_track < 0 || tmp_trk_chi2dof < i_chi2dof) {
242 i_track = trkCounter;
243 i_chi2dof = tmp_trk_chi2dof;
252 float tmp_matchtrk_pt = -999;
253 float tmp_matchtrk_eta = -999;
254 float tmp_matchtrk_phi = -999;
255 float tmp_matchtrk_VtxZ = -999;
256 float tmp_matchtrk_chi2dof = -999;
257 int tmp_matchTrk_nStub = -999;
258 float tmp_matchtrk_d0 = -999;
260 tmp_matchtrk_pt = matchedTracks[i_track]->momentum().perp();
261 tmp_matchtrk_eta = matchedTracks[i_track]->momentum().eta();
262 tmp_matchtrk_phi = matchedTracks[i_track]->momentum().phi();
263 tmp_matchtrk_VtxZ = matchedTracks[i_track]->z0();
264 tmp_matchtrk_chi2dof = matchedTracks[i_track]->chi2Red();
265 tmp_matchTrk_nStub = (
int)matchedTracks[i_track]->getStubRefs().size();
268 float tmp_matchtrk_x0 = matchedTracks[i_track]->POCA().x();
269 float tmp_matchtrk_y0 = matchedTracks[i_track]->POCA().y();
270 tmp_matchtrk_d0 = -tmp_matchtrk_x0 *
sin(tmp_matchtrk_phi) + tmp_matchtrk_y0 *
cos(tmp_matchtrk_phi);
273 if (tmp_matchTrk_nStub < L1Tk_minNStub || tmp_matchtrk_chi2dof >
L1Tk_maxChi2dof)
278 if (tmp_tp_pt > 0 && tmp_tp_pt <= 10)
286 float pt_diff = tmp_matchtrk_pt - tmp_tp_pt;
287 float pt_res = pt_diff / tmp_tp_pt;
288 float eta_res = tmp_matchtrk_eta - tmp_tp_eta;
289 float phi_res = tmp_matchtrk_phi - tmp_tp_phi;
290 float VtxZ_res = tmp_matchtrk_VtxZ - tmp_tp_VtxZ;
291 float d0_res = tmp_matchtrk_d0 - tmp_tp_d0;
300 if (std::fabs(tmp_tp_eta) >= 0 && std::fabs(tmp_tp_eta) < 0.7) {
305 if (tmp_tp_pt >= 2 && tmp_tp_pt < 3)
307 else if (tmp_tp_pt >= 3 && tmp_tp_pt < 8)
309 else if (tmp_tp_pt >= 8)
311 }
else if (std::fabs(tmp_tp_eta) >= 0.7 && std::fabs(tmp_tp_eta) < 1.0) {
316 if (tmp_tp_pt >= 2 && tmp_tp_pt < 3)
318 else if (tmp_tp_pt >= 3 && tmp_tp_pt < 8)
320 else if (tmp_tp_pt >= 8)
322 }
else if (std::fabs(tmp_tp_eta) >= 1.0 && std::fabs(tmp_tp_eta) < 1.2) {
327 if (tmp_tp_pt >= 2 && tmp_tp_pt < 3)
329 else if (tmp_tp_pt >= 3 && tmp_tp_pt < 8)
331 else if (tmp_tp_pt >= 8)
333 }
else if (std::fabs(tmp_tp_eta) >= 1.2 && std::fabs(tmp_tp_eta) < 1.6) {
338 if (tmp_tp_pt >= 2 && tmp_tp_pt < 3)
340 else if (tmp_tp_pt >= 3 && tmp_tp_pt < 8)
342 else if (tmp_tp_pt >= 8)
344 }
else if (std::fabs(tmp_tp_eta) >= 1.6 && std::fabs(tmp_tp_eta) < 2.0) {
349 if (tmp_tp_pt >= 2 && tmp_tp_pt < 3)
351 else if (tmp_tp_pt >= 3 && tmp_tp_pt < 8)
353 else if (tmp_tp_pt >= 8)
355 }
else if (std::fabs(tmp_tp_eta) >= 2.0 && std::fabs(tmp_tp_eta) <= 2.4) {
360 if (tmp_tp_pt >= 2 && tmp_tp_pt < 3)
362 else if (tmp_tp_pt >= 3 && tmp_tp_pt < 8)
364 else if (tmp_tp_pt >= 8)
792 HistoName =
"respt_eta1p2to1p6_pt8toInf";