44 enum { VALID, MISSING, INACTIVE, EFFICIENCY, VERTICES };
70 SiPixelPhase1TrackEfficiency::SiPixelPhase1TrackEfficiency(
const edm::ParameterSet& iConfig)
74 tracksToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<
edm::InputTag>(
"tracks"));
75 vtxToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<
edm::InputTag>(
"primaryvertices"));
76 applyVertexCut_ = iConfig.getUntrackedParameter<
bool>(
"VertexCut",
true);
77 trajTrackCollectionToken_ =
78 consumes<TrajTrackAssociationCollection>(iConfig.getParameter<
edm::InputTag>(
"trajectoryInput"));
79 clustersToken_ = consumes<edmNew::DetSetVector<SiPixelCluster>>(iConfig.getParameter<
edm::InputTag>(
"clusters"));
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();
115 iSetup.
getHandle(chi2MeasurementEstimatorBaseToken_);
116 chi2MeasurementEstimator_ = chi2MeasurementEstimatorHandle.
product();
128 if (applyVertexCut_ &&
vertices->empty())
142 iEvent.getByToken(trajTrackCollectionToken_, trajTrackCollectionHandle);
143 if (!trajTrackCollectionHandle.
isValid())
163 static constexpr int TRACK_QUALITY_HIGH_PURITY_BIT = 2;
164 static constexpr int TRACK_QUALITY_HIGH_PURITY_MASK = 1 << TRACK_QUALITY_HIGH_PURITY_BIT;
167 static constexpr float TRACK_PT_CUT_VAL = 1.0f;
170 static constexpr int TRACK_NSTRIP_CUT_VAL = 10;
173 static constexpr std::array<float, 4> TRACK_D0_CUT_BARREL_VAL = {{0.01f, 0.02f, 0.02f, 0.02f}};
174 static constexpr float TRACK_D0_CUT_FORWARD_VAL = 0.05f;
177 static constexpr float TRACK_DZ_CUT_BARREL_VAL = 0.01f;
178 static constexpr float TRACK_DZ_CUT_FORWARD_VAL = 0.5f;
181 bool valid_layerFrom =
false;
187 std::vector<TrajectoryMeasurement> expTrajMeasurements;
188 std::vector<std::pair<int, bool[3]>> eff_pxb1_vector;
190 for (
const auto& pair : *trajTrackCollectionHandle) {
194 expTrajMeasurements.clear();
195 eff_pxb1_vector.clear();
197 if (applyVertexCut_ &&
201 bool isBpixtrack =
false;
202 bool isFpixtrack =
false;
211 bool passcuts =
true;
216 auto hb =
track->recHitsBegin();
217 for (
unsigned int h = 0;
h <
track->recHitsSize();
h++) {
223 uint32_t subdetid = (
id.subdetId());
228 if (trackerTopology_->pxbLayer(
id) == 1)
230 else if (trackerTopology_->pxbLayer(
id) == 2)
232 else if (trackerTopology_->pxbLayer(
id) == 3)
234 else if (trackerTopology_->pxbLayer(
id) == 4)
238 if (trackerTopology_->pxfDisk(
id) == 1)
240 else if (trackerTopology_->pxfDisk(
id) == 2)
242 else if (trackerTopology_->pxfDisk(
id) == 3)
252 if (!isBpixtrack && !isFpixtrack)
256 if (!((
track->qualityMask() & TRACK_QUALITY_HIGH_PURITY_MASK) >> TRACK_QUALITY_HIGH_PURITY_BIT))
260 if (!(TRACK_PT_CUT_VAL < track->
pt()))
264 if (!(TRACK_NSTRIP_CUT_VAL < nStripHits))
268 for (
unsigned int h = 0;
h <
track->recHitsSize();
h++) {
269 bool passcuts_hit =
true;
273 uint32_t subdetid = (
id.subdetId());
284 TRACK_D0_CUT_BARREL_VAL[trackerTopology_->pxbLayer(
id) - 1]))
285 passcuts_hit =
false;
288 passcuts_hit =
false;
294 passcuts_hit =
false;
297 passcuts_hit =
false;
302 if (trackerTopology_->pxbLayer(
id) == 1) {
303 if (!((nBpixL2Hits > 0 && nBpixL3Hits > 0 && nBpixL4Hits > 0) ||
304 (nBpixL2Hits > 0 && nBpixL3Hits > 0 && nFpixD1Hits > 0) ||
305 (nBpixL2Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0) ||
306 (nFpixD1Hits > 0 && nFpixD2Hits > 0 && nFpixD3Hits > 0)))
307 passcuts_hit =
false;
308 }
else if (trackerTopology_->pxbLayer(
id) == 2) {
309 if (!((nBpixL1Hits > 0 && nBpixL3Hits > 0 && nBpixL4Hits > 0) ||
310 (nBpixL1Hits > 0 && nBpixL3Hits > 0 && nFpixD1Hits > 0) ||
311 (nBpixL1Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0)))
312 passcuts_hit =
false;
313 }
else if (trackerTopology_->pxbLayer(
id) == 3) {
314 if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nBpixL4Hits > 0) ||
315 (nBpixL1Hits > 0 && nBpixL2Hits > 0 && nFpixD1Hits > 0)))
316 passcuts_hit =
false;
317 }
else if (trackerTopology_->pxbLayer(
id) == 4)
318 if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nBpixL3Hits > 0)))
319 passcuts_hit =
false;
321 if (trackerTopology_->pxfDisk(
id) == 1) {
322 if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nBpixL3Hits > 0) ||
323 (nBpixL1Hits > 0 && nBpixL2Hits > 0 && nFpixD2Hits > 0) ||
324 (nBpixL1Hits > 0 && nFpixD2Hits > 0 && nFpixD3Hits > 0)))
325 passcuts_hit =
false;
326 }
else if (trackerTopology_->pxfDisk(
id) == 2) {
327 if (!((nBpixL1Hits > 0 && nBpixL2Hits > 0 && nFpixD1Hits > 0) ||
328 (nBpixL1Hits > 0 && nFpixD1Hits > 0 && nFpixD3Hits > 0)))
329 passcuts_hit =
false;
330 }
else if (trackerTopology_->pxfDisk(
id) == 3) {
331 if (!((nBpixL1Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0)))
332 passcuts_hit =
false;
356 if (passcuts_hit && passcuts) {
374 valid_layerFrom =
false;
377 for (
const auto& tm : traj->measurements()) {
378 if (tm.recHit().get() && tm.recHitR().isValid()) {
379 DetId where = tm.recHitR().geographicalId();
383 int source_layer = trackerTopology_->pxbLayer(where);
384 if (source_layer == 2) {
385 if (tm.updatedState().isValid()) {
386 tsosPXB2 = tm.updatedState();
387 valid_layerFrom =
true;
393 int source_layer = trackerTopology_->pxfDisk(where);
394 if (source_layer == 1) {
395 if (tm.updatedState().isValid()) {
396 tsosPXB2 = tm.updatedState();
397 valid_layerFrom =
true;
404 if (!valid_layerFrom)
410 expTrajMeasurements =
411 theLayerMeasurements_->
measurements(*pxbLayer1_, tsosPXB2, *trackerPropagator_, *chi2MeasurementEstimator_);
412 auto compDets = pxbLayer1_->compatibleDets(tsosPXB2, *trackerPropagator_, *chi2MeasurementEstimator_);
413 std::pair<int, bool[3]> eff_map;
416 for (
uint p = 0;
p < expTrajMeasurements.size();
p++) {
419 bool passcuts_hit =
true;
421 const auto& pxb1Hit = pxb1TM.recHit();
423 int detidHit = pxb1Hit->geographicalId();
438 int row = (
int)mp.
x() % nRows;
439 int col = (
int)mp.
y() % nColumns;
441 int centerrow = nRows / 2;
442 int centercol = nColumns / 2;
444 if (!((
col < (centercol + 10)) && (
col > (centercol - 10)) && (row < (centerrow + 10)) &&
445 (row > (centerrow - 10))))
446 passcuts_hit =
false;
449 for (
const auto& detAndState : compDets) {
450 const auto& pXb1_lpos = detAndState.second.localPosition();
451 if (pxb1Hit->geographicalId().rawId() != detAndState.first->geographicalId().rawId())
453 int detid = detAndState.first->geographicalId().rawId();
459 float minD[2], minDist = 10000;
460 minD[0] = minD[1] = 10000.;
461 if (
detId.rawId() != detAndState.first->geographicalId().rawId())
467 for (; itCluster != iter_cl->
end(); ++itCluster) {
468 LocalPoint lp(itCluster->x(), itCluster->y(), 0.);
472 float Xdist =
abs(lp.
x() - pXb1_lpos.x());
473 float Ydist =
abs(lp.
y() - pXb1_lpos.y());
474 float dist =
sqrt(Xdist * Xdist + Ydist * Ydist);
475 if (dist < minDist) {
482 if ((minD[0] < 0.02) && (minD[1] < 0.02)) {
486 }
else if (inactive) {
500 TRACK_D0_CUT_BARREL_VAL[trackerTopology_->pxbLayer(detid) - 1]))
501 passcuts_hit =
false;
504 passcuts_hit =
false;
506 if (!((nBpixL2Hits > 0 && nBpixL3Hits > 0 && nBpixL4Hits > 0) ||
507 (nBpixL2Hits > 0 && nBpixL3Hits > 0 && nFpixD1Hits > 0) ||
508 (nBpixL2Hits > 0 && nFpixD1Hits > 0 && nFpixD2Hits > 0) ||
509 (nFpixD1Hits > 0 && nFpixD2Hits > 0 && nFpixD3Hits > 0)))
510 passcuts_hit =
false;
511 bool found_det =
false;
513 if (passcuts && passcuts_hit) {
514 for (
unsigned int i_eff = 0; i_eff < eff_pxb1_vector.size(); i_eff++) {
516 if (eff_pxb1_vector[i_eff].
first == detid) {
518 if (eff_pxb1_vector[i_eff].
second[0] ==
false &&
valid ==
true) {
519 eff_pxb1_vector[i_eff].second[0] =
valid;
520 eff_pxb1_vector[i_eff].second[1] =
missing;
521 eff_pxb1_vector[i_eff].second[2] = inactive;
526 eff_map.first = detid;
527 eff_map.second[0] =
valid;
529 eff_map.second[2] = inactive;
530 eff_pxb1_vector.push_back(eff_map);
536 if (eff_pxb1_vector.size() == 1) {
539 if (eff_pxb1_vector[0].
second[0]) {
543 if (eff_pxb1_vector[0].
second[1]) {
548 if (eff_pxb1_vector[0].
second[2]) {
557 histo[INACTIVE].executePerEventHarvesting(&
iEvent);
static constexpr auto TEC
T getParameter(std::string const &) const
static const char tracker_[]
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
virtual int rowsperroc() const =0
virtual Propagator * clone() const =0
data_type const * const_iterator
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
key_type key() const
Accessor for product key.
U second(std::pair< T, U > const &p)
T const * product() const
virtual int colsperroc() const =0
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
static constexpr auto TOB
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
std::vector< BarrelDetLayer const * > const & pixelBarrelLayers() const
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
static constexpr auto TIB
void analyze(edm::Event const &e, edm::EventSetup const &) override=0
const GeometricSearchTracker * geometricSearchTracker() const
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
LocalPoint localPosition() const override
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
std::tuple< LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType > ReturnType
static constexpr auto TID