45 enum { VALID, MISSING, INACTIVE, EFFICIENCY, VERTICES };
64 SiPixelPhase1TrackEfficiency::SiPixelPhase1TrackEfficiency(
const edm::ParameterSet& iConfig)
71 trajTrackCollectionToken_ =
92 trackerTopology_ = trackerTopologyHandle.
product();
97 std::unique_ptr<Propagator> propagatorUniquePtr(propagatorHandle.
product()->
clone());
98 trackerPropagator_ = propagatorUniquePtr.get();
99 const_cast<Propagator*>(trackerPropagator_)->setPropagationDirection(
oppositeToMomentum);
104 chi2MeasurementEstimator_ = chi2MeasurementEstimatorHandle.
product();
117 if (applyVertexCut_ &&
vertices->empty())
131 iEvent.getByToken(trajTrackCollectionToken_, trajTrackCollectionHandle);
132 if (!trajTrackCollectionHandle.
isValid())
153 int TRACK_QUALITY_HIGH_PURITY_BIT = 2;
154 int TRACK_QUALITY_HIGH_PURITY_MASK = 1 << TRACK_QUALITY_HIGH_PURITY_BIT;
157 float TRACK_PT_CUT_VAL = 1.0f;
160 int TRACK_NSTRIP_CUT_VAL = 10;
163 std::array<float, 4> TRACK_D0_CUT_BARREL_VAL = {{0.01f, 0.02f, 0.02f, 0.02f}};
164 float TRACK_D0_CUT_FORWARD_VAL = 0.05f;
167 float TRACK_DZ_CUT_BARREL_VAL = 0.01f;
168 float TRACK_DZ_CUT_FORWARD_VAL = 0.5f;
170 bool isBpixtrack =
false, isFpixtrack =
false;
179 bool passcuts =
true;
180 bool passcuts_hit =
true;
183 bool valid_layerFrom =
false;
189 std::vector<TrajectoryMeasurement> expTrajMeasurements;
190 std::vector<std::pair<int, bool[3]>> eff_pxb1_vector;
192 for (
const auto& pair : *trajTrackCollectionHandle) {
196 expTrajMeasurements.clear();
197 eff_pxb1_vector.clear();
199 if (applyVertexCut_ &&
203 isBpixtrack =
false, isFpixtrack =
false;
218 auto hb =
track->recHitsBegin();
219 for (
unsigned int h = 0;
h <
track->recHitsSize();
h++) {
225 uint32_t subdetid = (
id.subdetId());
230 if (trackerTopology_->pxbLayer(
id) == 1)
232 if (trackerTopology_->pxbLayer(
id) == 2)
234 if (trackerTopology_->pxbLayer(
id) == 3)
236 if (trackerTopology_->pxbLayer(
id) == 4)
241 if (trackerTopology_->pxfDisk(
id) == 1)
243 if (trackerTopology_->pxfDisk(
id) == 2)
245 if (trackerTopology_->pxfDisk(
id) == 3)
264 if (!isBpixtrack && !isFpixtrack)
268 if (!((
track->qualityMask() & TRACK_QUALITY_HIGH_PURITY_MASK) >> TRACK_QUALITY_HIGH_PURITY_BIT))
272 if (!(TRACK_PT_CUT_VAL < track->
pt()))
276 if (!(TRACK_NSTRIP_CUT_VAL < nStripHits))
280 for (
unsigned int h = 0;
h <
track->recHitsSize();
h++) {
285 uint32_t subdetid = (
id.subdetId());
296 TRACK_D0_CUT_BARREL_VAL[trackerTopology_->pxbLayer(
id) - 1]))
297 passcuts_hit =
false;
301 passcuts_hit =
false;
307 passcuts_hit =
false;
311 passcuts_hit =
false;
316 if (trackerTopology_->pxbLayer(
id) == 1)
317 if (!((nBpixL2Hits > 0 && nBpixL3Hits > 0 && nBpixL4Hits > 0) ||
318 (nBpixL2Hits > 0 && nBpixL3Hits > 0 && nFpixD1Hits > 0) ||
319 (nBpixL2Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0) ||
320 (nFpixD1Hits > 0 && nFpixD2Hits > 0 && nFpixD3Hits > 0)))
321 passcuts_hit =
false;
322 if (trackerTopology_->pxbLayer(
id) == 2)
323 if (!((nBpixL1Hits > 0 && nBpixL3Hits > 0 && nBpixL4Hits > 0) ||
324 (nBpixL1Hits > 0 && nBpixL3Hits > 0 && nFpixD1Hits > 0) ||
325 (nBpixL1Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0)))
326 passcuts_hit =
false;
327 if (trackerTopology_->pxbLayer(
id) == 3)
328 if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nBpixL4Hits > 0) ||
329 (nBpixL1Hits > 0 && nBpixL2Hits > 0 && nFpixD1Hits > 0)))
330 passcuts_hit =
false;
331 if (trackerTopology_->pxbLayer(
id) == 4)
332 if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nBpixL3Hits > 0)))
333 passcuts_hit =
false;
336 if (trackerTopology_->pxfDisk(
id) == 1)
337 if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nBpixL3Hits > 0) ||
338 (nBpixL1Hits > 0 && nBpixL2Hits > 0 && nFpixD2Hits > 0) ||
339 (nBpixL1Hits > 0 && nFpixD2Hits > 0 && nFpixD3Hits > 0)))
340 passcuts_hit =
false;
341 if (trackerTopology_->pxfDisk(
id) == 2)
342 if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nFpixD1Hits > 0) ||
343 (nBpixL1Hits > 0 && nFpixD1Hits > 0 && nFpixD3Hits > 0)))
344 passcuts_hit =
false;
345 if (trackerTopology_->pxfDisk(
id) == 3)
346 if (!((nBpixL1Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0)))
347 passcuts_hit =
false;
370 if (passcuts_hit ==
true && passcuts) {
388 valid_layerFrom =
false;
391 for (
const auto& tm : traj->measurements()) {
392 if (tm.recHit().get() && tm.recHitR().isValid()) {
393 DetId where = tm.recHitR().geographicalId();
397 int source_layer = trackerTopology_->pxbLayer(where);
398 if (source_layer == 2) {
399 if (tm.updatedState().isValid()) {
400 tsosPXB2 = tm.updatedState();
401 valid_layerFrom =
true;
407 int source_layer = trackerTopology_->pxfDisk(where);
408 if (source_layer == 1) {
409 if (tm.updatedState().isValid()) {
410 tsosPXB2 = tm.updatedState();
411 valid_layerFrom =
true;
418 if (!valid_layerFrom)
424 expTrajMeasurements =
425 theLayerMeasurements_->
measurements(*pxbLayer1_, tsosPXB2, *trackerPropagator_, *chi2MeasurementEstimator_);
426 auto compDets = pxbLayer1_->compatibleDets(tsosPXB2, *trackerPropagator_, *chi2MeasurementEstimator_);
427 std::pair<int, bool[3]> eff_map;
433 for (
uint p = 0;
p < expTrajMeasurements.size();
p++) {
435 const auto& pxb1Hit = pxb1TM.recHit();
436 int detidHit = pxb1Hit->geographicalId();
440 const SiPixelRecHit* pixhit = dynamic_cast<const SiPixelRecHit*>(pxb1Hit->hit());
442 const PixelTopology& topol = geomdetunit->specificTopology();
450 int row = (
int)mp.
x() % 80;
456 if (!((
col < (centercol + 10)) && (
col > (centercol - 10)) && (row < (centerrow + 10)) &&
457 (row > (centerrow - 10))))
458 passcuts_hit =
false;
461 for (
const auto& detAndState : compDets) {
462 const auto& pXb1_lpos = detAndState.second.localPosition();
463 int detid = detAndState.first->geographicalId().rawId();
467 DetId detId(iter_cl->id());
469 minD[0] = minD[1] = 10000.;
470 if (detId.rawId() != detAndState.first->geographicalId().rawId())
472 if (pxb1Hit->geographicalId().rawId() != detAndState.first->geographicalId().rawId())
477 for (; itCluster != iter_cl->
end(); ++itCluster) {
478 LocalPoint lp(itCluster->x(), itCluster->y(), 0.);
482 float Xdist =
abs(lp.
x() - pXb1_lpos.x());
483 float Ydist =
abs(lp.
y() - pXb1_lpos.y());
484 if (Xdist < minD[0]) {
487 if (Ydist < minD[1]) {
492 if ((minD[0] < 0.02) && (minD[1] < 0.02)) {
507 TRACK_D0_CUT_BARREL_VAL[trackerTopology_->pxbLayer(detid) - 1]))
508 passcuts_hit =
false;
511 passcuts_hit =
false;
513 if (!((nBpixL2Hits > 0 && nBpixL3Hits > 0 && nBpixL4Hits > 0) ||
514 (nBpixL2Hits > 0 && nBpixL3Hits > 0 && nFpixD1Hits > 0) ||
515 (nBpixL2Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0) ||
516 (nFpixD1Hits > 0 && nFpixD2Hits > 0 && nFpixD3Hits > 0)))
517 passcuts_hit =
false;
518 bool found_det =
false;
520 if (passcuts && passcuts_hit) {
521 for (
unsigned int i_eff = 0; i_eff < eff_pxb1_vector.size(); i_eff++) {
523 if (eff_pxb1_vector[i_eff].
first == detid) {
525 if (eff_pxb1_vector[i_eff].
second[0] ==
false &&
valid ==
true) {
526 eff_pxb1_vector[i_eff].second[0] =
valid;
527 eff_pxb1_vector[i_eff].second[1] =
missing;
532 eff_map.first = detid;
533 eff_map.second[0] =
valid;
535 eff_pxb1_vector.push_back(eff_map);
543 for (
uint p = 0;
p < expTrajMeasurements.size();
p++) {
545 const auto& pxb1Hit = pxb1TM.recHit();
547 int detid = pxb1Hit->geographicalId();
548 bool found_det =
false;
550 if (passcuts && passcuts_hit) {
551 for (
unsigned int i_eff = 0; i_eff < eff_pxb1_vector.size(); i_eff++) {
553 if (eff_pxb1_vector[i_eff].
first == detid) {
555 if (eff_pxb1_vector[i_eff].
second[0] ==
false &&
valid ==
true) {
556 eff_pxb1_vector[i_eff].second[2] = inactive;
563 eff_map.first = detid;
564 eff_map.second[2] = inactive;
565 eff_pxb1_vector.push_back(eff_map);
571 if (eff_pxb1_vector.size() == 1) {
574 if (eff_pxb1_vector[0].
second[0]) {
578 if (eff_pxb1_vector[0].
second[1]) {
583 if (eff_pxb1_vector[0].
second[2]) {
592 histo[INACTIVE].executePerEventHarvesting(&
iEvent);