44 enum { VALID, MISSING, INACTIVE, EFFICIENCY, VERTICES };
70 SiPixelPhase1TrackEfficiency::SiPixelPhase1TrackEfficiency(
const edm::ParameterSet& iConfig)
77 trajTrackCollectionToken_ =
81 trackerTopoToken_ = esConsumes<TrackerTopology, TrackerTopologyRcd>();
82 trackerGeomToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
83 propagatorToken_ = esConsumes<Propagator, TrackingComponentsRecord>(
edm::ESInputTag(
"",
"PropagatorWithMaterial"));
84 chi2MeasurementEstimatorBaseToken_ =
85 esConsumes<Chi2MeasurementEstimatorBase, TrackingComponentsRecord>(
edm::ESInputTag(
"",
"Chi2"));
86 measurementTrackerToken_ = esConsumes<MeasurementTracker, CkfComponentsRecord>();
87 pixelClusterParameterEstimatorToken_ =
88 esConsumes<PixelClusterParameterEstimator, TkPixelCPERecord>(
edm::ESInputTag(
"",
"PixelCPEGeneric"));
105 trackerTopology_ = trackerTopologyHandle.
product();
109 std::unique_ptr<Propagator> propagatorUniquePtr(propagatorHandle.
product()->
clone());
110 trackerPropagator_ = propagatorUniquePtr.get();
111 const_cast<Propagator*>(trackerPropagator_)->setPropagationDirection(
oppositeToMomentum);
115 iSetup.
getHandle(chi2MeasurementEstimatorBaseToken_);
116 chi2MeasurementEstimator_ = chi2MeasurementEstimatorHandle.
product();
128 if (applyVertexCut_ &&
vertices->empty())
142 iEvent.getByToken(trajTrackCollectionToken_, trajTrackCollectionHandle);
143 if (!trajTrackCollectionHandle.
isValid())
163 int TRACK_QUALITY_HIGH_PURITY_BIT = 2;
164 int TRACK_QUALITY_HIGH_PURITY_MASK = 1 << TRACK_QUALITY_HIGH_PURITY_BIT;
167 float TRACK_PT_CUT_VAL = 1.0f;
170 int TRACK_NSTRIP_CUT_VAL = 10;
173 std::array<float, 4> TRACK_D0_CUT_BARREL_VAL = {{0.01f, 0.02f, 0.02f, 0.02f}};
174 float TRACK_D0_CUT_FORWARD_VAL = 0.05f;
177 float TRACK_DZ_CUT_BARREL_VAL = 0.01f;
178 float TRACK_DZ_CUT_FORWARD_VAL = 0.5f;
180 bool isBpixtrack =
false, isFpixtrack =
false;
189 bool passcuts =
true;
190 bool passcuts_hit =
true;
193 bool valid_layerFrom =
false;
199 std::vector<TrajectoryMeasurement> expTrajMeasurements;
200 std::vector<std::pair<int, bool[3]>> eff_pxb1_vector;
202 for (
const auto& pair : *trajTrackCollectionHandle) {
206 expTrajMeasurements.clear();
207 eff_pxb1_vector.clear();
209 if (applyVertexCut_ &&
213 isBpixtrack =
false, isFpixtrack =
false;
228 auto hb =
track->recHitsBegin();
229 for (
unsigned int h = 0;
h <
track->recHitsSize();
h++) {
235 uint32_t subdetid = (
id.subdetId());
240 if (trackerTopology_->pxbLayer(
id) == 1)
242 if (trackerTopology_->pxbLayer(
id) == 2)
244 if (trackerTopology_->pxbLayer(
id) == 3)
246 if (trackerTopology_->pxbLayer(
id) == 4)
251 if (trackerTopology_->pxfDisk(
id) == 1)
253 if (trackerTopology_->pxfDisk(
id) == 2)
255 if (trackerTopology_->pxfDisk(
id) == 3)
274 if (!isBpixtrack && !isFpixtrack)
278 if (!((
track->qualityMask() & TRACK_QUALITY_HIGH_PURITY_MASK) >> TRACK_QUALITY_HIGH_PURITY_BIT))
282 if (!(TRACK_PT_CUT_VAL < track->
pt()))
286 if (!(TRACK_NSTRIP_CUT_VAL < nStripHits))
290 for (
unsigned int h = 0;
h <
track->recHitsSize();
h++) {
295 uint32_t subdetid = (
id.subdetId());
306 TRACK_D0_CUT_BARREL_VAL[trackerTopology_->pxbLayer(
id) - 1]))
307 passcuts_hit =
false;
311 passcuts_hit =
false;
317 passcuts_hit =
false;
321 passcuts_hit =
false;
326 if (trackerTopology_->pxbLayer(
id) == 1)
327 if (!((nBpixL2Hits > 0 && nBpixL3Hits > 0 && nBpixL4Hits > 0) ||
328 (nBpixL2Hits > 0 && nBpixL3Hits > 0 && nFpixD1Hits > 0) ||
329 (nBpixL2Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0) ||
330 (nFpixD1Hits > 0 && nFpixD2Hits > 0 && nFpixD3Hits > 0)))
331 passcuts_hit =
false;
332 if (trackerTopology_->pxbLayer(
id) == 2)
333 if (!((nBpixL1Hits > 0 && nBpixL3Hits > 0 && nBpixL4Hits > 0) ||
334 (nBpixL1Hits > 0 && nBpixL3Hits > 0 && nFpixD1Hits > 0) ||
335 (nBpixL1Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0)))
336 passcuts_hit =
false;
337 if (trackerTopology_->pxbLayer(
id) == 3)
338 if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nBpixL4Hits > 0) ||
339 (nBpixL1Hits > 0 && nBpixL2Hits > 0 && nFpixD1Hits > 0)))
340 passcuts_hit =
false;
341 if (trackerTopology_->pxbLayer(
id) == 4)
342 if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nBpixL3Hits > 0)))
343 passcuts_hit =
false;
346 if (trackerTopology_->pxfDisk(
id) == 1)
347 if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nBpixL3Hits > 0) ||
348 (nBpixL1Hits > 0 && nBpixL2Hits > 0 && nFpixD2Hits > 0) ||
349 (nBpixL1Hits > 0 && nFpixD2Hits > 0 && nFpixD3Hits > 0)))
350 passcuts_hit =
false;
351 if (trackerTopology_->pxfDisk(
id) == 2)
352 if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nFpixD1Hits > 0) ||
353 (nBpixL1Hits > 0 && nFpixD1Hits > 0 && nFpixD3Hits > 0)))
354 passcuts_hit =
false;
355 if (trackerTopology_->pxfDisk(
id) == 3)
356 if (!((nBpixL1Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0)))
357 passcuts_hit =
false;
380 if (passcuts_hit ==
true && passcuts) {
398 valid_layerFrom =
false;
401 for (
const auto& tm : traj->measurements()) {
402 if (tm.recHit().get() && tm.recHitR().isValid()) {
403 DetId where = tm.recHitR().geographicalId();
407 int source_layer = trackerTopology_->pxbLayer(where);
408 if (source_layer == 2) {
409 if (tm.updatedState().isValid()) {
410 tsosPXB2 = tm.updatedState();
411 valid_layerFrom =
true;
417 int source_layer = trackerTopology_->pxfDisk(where);
418 if (source_layer == 1) {
419 if (tm.updatedState().isValid()) {
420 tsosPXB2 = tm.updatedState();
421 valid_layerFrom =
true;
428 if (!valid_layerFrom)
434 expTrajMeasurements =
435 theLayerMeasurements_->
measurements(*pxbLayer1_, tsosPXB2, *trackerPropagator_, *chi2MeasurementEstimator_);
436 auto compDets = pxbLayer1_->compatibleDets(tsosPXB2, *trackerPropagator_, *chi2MeasurementEstimator_);
437 std::pair<int, bool[3]> eff_map;
443 for (
uint p = 0;
p < expTrajMeasurements.size();
p++) {
445 const auto& pxb1Hit = pxb1TM.recHit();
446 int detidHit = pxb1Hit->geographicalId();
450 const SiPixelRecHit* pixhit = dynamic_cast<const SiPixelRecHit*>(pxb1Hit->hit());
452 const PixelTopology& topol = geomdetunit->specificTopology();
460 int row = (
int)mp.
x() % 80;
466 if (!((
col < (centercol + 10)) && (
col > (centercol - 10)) && (row < (centerrow + 10)) &&
467 (row > (centerrow - 10))))
468 passcuts_hit =
false;
471 for (
const auto& detAndState : compDets) {
472 const auto& pXb1_lpos = detAndState.second.localPosition();
473 int detid = detAndState.first->geographicalId().rawId();
477 DetId detId(iter_cl->id());
479 minD[0] = minD[1] = 10000.;
480 if (detId.rawId() != detAndState.first->geographicalId().rawId())
482 if (pxb1Hit->geographicalId().rawId() != detAndState.first->geographicalId().rawId())
487 for (; itCluster != iter_cl->
end(); ++itCluster) {
488 LocalPoint lp(itCluster->x(), itCluster->y(), 0.);
492 float Xdist =
abs(lp.
x() - pXb1_lpos.x());
493 float Ydist =
abs(lp.
y() - pXb1_lpos.y());
494 if (Xdist < minD[0]) {
497 if (Ydist < minD[1]) {
502 if ((minD[0] < 0.02) && (minD[1] < 0.02)) {
517 TRACK_D0_CUT_BARREL_VAL[trackerTopology_->pxbLayer(detid) - 1]))
518 passcuts_hit =
false;
521 passcuts_hit =
false;
523 if (!((nBpixL2Hits > 0 && nBpixL3Hits > 0 && nBpixL4Hits > 0) ||
524 (nBpixL2Hits > 0 && nBpixL3Hits > 0 && nFpixD1Hits > 0) ||
525 (nBpixL2Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0) ||
526 (nFpixD1Hits > 0 && nFpixD2Hits > 0 && nFpixD3Hits > 0)))
527 passcuts_hit =
false;
528 bool found_det =
false;
530 if (passcuts && passcuts_hit) {
531 for (
unsigned int i_eff = 0; i_eff < eff_pxb1_vector.size(); i_eff++) {
533 if (eff_pxb1_vector[i_eff].
first == detid) {
535 if (eff_pxb1_vector[i_eff].
second[0] ==
false &&
valid ==
true) {
536 eff_pxb1_vector[i_eff].second[0] =
valid;
537 eff_pxb1_vector[i_eff].second[1] =
missing;
542 eff_map.first = detid;
543 eff_map.second[0] =
valid;
545 eff_pxb1_vector.push_back(eff_map);
553 for (
uint p = 0;
p < expTrajMeasurements.size();
p++) {
555 const auto& pxb1Hit = pxb1TM.recHit();
557 int detid = pxb1Hit->geographicalId();
558 bool found_det =
false;
560 if (passcuts && passcuts_hit) {
561 for (
unsigned int i_eff = 0; i_eff < eff_pxb1_vector.size(); i_eff++) {
563 if (eff_pxb1_vector[i_eff].
first == detid) {
565 if (eff_pxb1_vector[i_eff].
second[0] ==
false &&
valid ==
true) {
566 eff_pxb1_vector[i_eff].second[2] = inactive;
573 eff_map.first = detid;
574 eff_map.second[2] = inactive;
575 eff_pxb1_vector.push_back(eff_map);
581 if (eff_pxb1_vector.size() == 1) {
584 if (eff_pxb1_vector[0].
second[0]) {
588 if (eff_pxb1_vector[0].
second[1]) {
593 if (eff_pxb1_vector[0].
second[2]) {
602 histo[INACTIVE].executePerEventHarvesting(&
iEvent);