CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes
CheckHitPattern Class Reference

#include <CheckHitPattern.h>

Classes

struct  Result
 

Public Types

typedef std::pair< uint32_t, uint32_t > DetInfo
 

Public Member Functions

void init (const edm::EventSetup &iSetup)
 
Result operator() (const reco::Track &track, const VertexState &vert) const
 

Static Public Member Functions

static bool barrel (uint32_t subDet)
 
static DetInfo interpretDetId (DetId detId, const TrackerTopology *tTopo)
 
static void print (const reco::Track &track)
 
static void print (const reco::HitPattern::HitCategory category, const reco::HitPattern &hp)
 

Private Types

typedef std::map< DetInfo, std::pair< double, double > > RZrangeMap
 

Private Attributes

bool geomInitDone_ = false
 
RZrangeMap rangeRorZ_
 
edm::ESHandle< TransientTrackBuildertrkTool_
 

Detailed Description

Definition at line 25 of file CheckHitPattern.h.

Member Typedef Documentation

◆ DetInfo

typedef std::pair<uint32_t, uint32_t> CheckHitPattern::DetInfo

Definition at line 46 of file CheckHitPattern.h.

◆ RZrangeMap

typedef std::map<DetInfo, std::pair<double, double> > CheckHitPattern::RZrangeMap
private

Definition at line 60 of file CheckHitPattern.h.

Member Function Documentation

◆ barrel()

bool CheckHitPattern::barrel ( uint32_t  subDet)
static

Definition at line 88 of file CheckHitPattern.cc.

References PixelSubdetector::PixelBarrel, StripSubdetector::TIB, and StripSubdetector::TOB.

Referenced by init(), and operator()().

88  {
89  // Determines if given sub-detector is in the barrel.
90  return (subDet == StripSubdetector::TIB || subDet == StripSubdetector::TOB ||
92 }
static constexpr auto TOB
static constexpr auto TIB

◆ init()

void CheckHitPattern::init ( const edm::EventSetup iSetup)

Definition at line 21 of file CheckHitPattern.cc.

References barrel(), gather_cfg::cout, ztail::d, TrackerGeometry::dets(), geomInitDone_, edm::EventSetup::get(), mps_fire::i, interpretDetId(), position, edm::ESHandle< T >::product(), rangeRorZ_, trkTool_, and z.

21  {
22  //Retrieve tracker topology from geometry
24  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
25  const TrackerTopology* const tTopo = tTopoHandle.product();
26 
27  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", trkTool_); // Needed for vertex fits
28 
29  //
30  // Note min/max radius (z) of each barrel layer (endcap disk).
31  //
32 
33  geomInitDone_ = true;
34 
35  // Get Tracker geometry
36  edm::ESHandle<TrackerGeometry> trackerGeometry;
37  iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
38  const TrackingGeometry::DetContainer& dets = trackerGeometry->dets();
39 
40  // Loop over all modules in the Tracker.
41  for (unsigned int i = 0; i < dets.size(); i++) {
42  // Get subdet and layer of this module
43  DetInfo detInfo = this->interpretDetId(dets[i]->geographicalId(), tTopo);
44  uint32_t subDet = detInfo.first;
45 
46  // Note r (or z) of module if barrel (or endcap).
47  double r_or_z;
48  if (this->barrel(subDet)) {
49  r_or_z = dets[i]->position().perp();
50  } else {
51  r_or_z = fabs(dets[i]->position().z());
52  }
53 
54  // Recover min/max r/z value of this layer/disk found so far.
55  double minRZ = 999.;
56  double maxRZ = 0.;
57  if (rangeRorZ_.find(detInfo) != rangeRorZ_.end()) {
58  minRZ = rangeRorZ_[detInfo].first;
59  maxRZ = rangeRorZ_[detInfo].second;
60  }
61 
62  // Update with those of this module if it exceeds them.
63  if (minRZ > r_or_z)
64  minRZ = r_or_z;
65  if (maxRZ < r_or_z)
66  maxRZ = r_or_z;
67  rangeRorZ_[detInfo] = std::pair<double, double>(minRZ, maxRZ);
68  }
69 
70 #ifdef DEBUG_CHECKHITPATTERN
71  RZrangeMap::const_iterator d;
72  for (d = rangeRorZ_.begin(); d != rangeRorZ_.end(); d++) {
73  DetInfo detInfo = d->first;
74  std::pair<double, double> rangeRZ = d->second;
75  std::std::cout << "CHECKHITPATTERN: Tracker subdetector type=" << detInfo.first << " layer=" << detInfo.second
76  << " has min r (or z) =" << rangeRZ.first << " and max r (or z) = " << rangeRZ.second
77  << std::std::endl;
78  }
79 #endif
80 }
std::pair< uint32_t, uint32_t > DetInfo
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
std::vector< const GeomDet * > DetContainer
T const * product() const
Definition: ESHandle.h:86
T get() const
Definition: EventSetup.h:82
d
Definition: ztail.py:151
static DetInfo interpretDetId(DetId detId, const TrackerTopology *tTopo)
static int position[264][3]
Definition: ReadPGInfo.cc:289
edm::ESHandle< TransientTrackBuilder > trkTool_
static bool barrel(uint32_t subDet)
RZrangeMap rangeRorZ_

◆ interpretDetId()

CheckHitPattern::DetInfo CheckHitPattern::interpretDetId ( DetId  detId,
const TrackerTopology tTopo 
)
static

Definition at line 82 of file CheckHitPattern.cc.

References TrackerTopology::layer(), and DetId::subdetId().

Referenced by init().

82  {
83  // Convert detId to a pair<uint32, uint32> consisting of the numbers used by HitPattern
84  // to identify subdetector and layer number respectively.
85  return DetInfo(detId.subdetId(), tTopo->layer(detId));
86 }
std::pair< uint32_t, uint32_t > DetInfo
unsigned int layer(const DetId &id) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48

◆ operator()()

CheckHitPattern::Result CheckHitPattern::operator() ( const reco::Track track,
const VertexState vert 
) const

Definition at line 94 of file CheckHitPattern.cc.

References barrel(), TransientTrackBuilder::build(), Exception, geomInitDone_, reco::HitPattern::getLayer(), reco::HitPattern::getSubStructure(), trackingPlots::hp, mps_fire::i, if(), phase1PixelTopology::layer, LogDebug, M_PI, reco::HitPattern::MISSING_INNER_HITS, reco::HitPattern::missingHitFilter(), PV3DBase< T, PVType, FrameType >::perp(), VertexState::position(), rangeRorZ_, mps_fire::result, edm::second(), HLT_2022v12_cff::track, reco::HitPattern::TRACK_HITS, reco::HitPattern::trackerHitFilter(), reco::TransientTrack::trajectoryStateClosestToPoint(), trkTool_, reco::HitPattern::validHitFilter(), and PV3DBase< T, PVType, FrameType >::z().

94  {
95  // Check if hit pattern of this track is consistent with it being produced
96  // at given vertex.
97 
98  // Initialise geometry info if not yet done.
99  if (!geomInitDone_)
100  throw cms::Exception("CheckHitPattern::operator() called before CheckHitPattern::init");
101 
102  // Optionally set vertex position to zero for debugging.
103  // VertexState vertDebug( GlobalPoint(0.,0.,0.) , GlobalError(1e-8, 0., 1e-8, 0., 0., 1e-8) );
104 
105  // Evaluate track parameters at vertex.
107  GlobalVector p3_trk = t_trk.trajectoryStateClosestToPoint(vert.position()).momentum();
108  bool trkGoesInsideOut =
109  fabs(reco::deltaPhi<const GlobalVector, const GlobalPoint>(p3_trk, vert.position())) < 0.5 * M_PI;
110 
111  LogDebug("CHP") << "TRACK: in-->out ? " << trkGoesInsideOut << " dxy=" << track.dxy() << " sz=" << track.dz()
112  << " eta=" << track.eta() << " barrel hits=" << track.hitPattern().numberOfValidPixelHits() << "/"
113  << track.hitPattern().numberOfValidStripTIBHits() << "/"
114  << track.hitPattern().numberOfValidStripTOBHits();
115  LogDebug("CHP") << "VERT: r=" << vert.position().perp() << " z=" << vert.position().z();
116  // if (vert.position().perp() < 3.5 && fabs(vert.position().z()) < 10. && fabs(track.eta()) < 1 && fabs(track.dxy()) < 2 && fabs(track.dz()) < 2 && track.hitPattern().numberOfValidPixelHits() == 0 && track.hitPattern().numberOfValidStripTIBHits() == 0) LogDebug("CHP")<<"LOOKATTHISTRACK";
117  // Get hit patterns of this track
118  const reco::HitPattern& hp = track.hitPattern();
119 
120  // Count number of valid hits on track definately in front of the vertex,
121  // taking into account finite depth of each layer.
122  unsigned int nHitBefore = 0;
123  for (int i = 0; i < hp.numberOfAllHits(reco::HitPattern::TRACK_HITS); i++) {
124  uint32_t hit = hp.getHitPattern(reco::HitPattern::TRACK_HITS, i);
126  uint32_t subDet = reco::HitPattern::getSubStructure(hit);
128  DetInfo detInfo(subDet, layer);
129  auto maxRZ = (*rangeRorZ_.find(detInfo)).second.second;
130 
131  if (this->barrel(subDet)) {
132  // Be careful. If the track starts by going outside-->in, it is allowed to have hits before the vertex !
133  if (vert.position().perp() > maxRZ && trkGoesInsideOut)
134  nHitBefore++;
135  } else {
136  if (fabs(vert.position().z()) > maxRZ)
137  nHitBefore++;
138  }
139  }
140  }
141 
142  // Count number of missing hits before the innermost hit on the track,
143  // taking into account finite depth of each layer.
144  unsigned int nMissHitAfter = 0;
145  for (int i = 0; i < hp.numberOfAllHits(reco::HitPattern::MISSING_INNER_HITS); i++) {
146  uint32_t hit = hp.getHitPattern(reco::HitPattern::MISSING_INNER_HITS, i);
147  // if (hp.trackerHitFilter(hit)) {
149  uint32_t subDet = reco::HitPattern::getSubStructure(hit);
151  DetInfo detInfo(subDet, layer);
152  auto minRZ = (*rangeRorZ_.find(detInfo)).second.first;
153 
154  if (this->barrel(subDet)) {
155  // Be careful. If the track starts by going outside-->in, then it misses hits
156  // in all layers it crosses before its innermost valid hit.
157  if (vert.position().perp() < minRZ || !trkGoesInsideOut)
158  nMissHitAfter++;
159  } else {
160  if (fabs(vert.position().z()) < minRZ)
161  nMissHitAfter++;
162  }
163  }
164  }
165 
166  Result result;
167  result.hitsInFrontOfVert = nHitBefore;
168  result.missHitsAfterVert = nMissHitAfter;
169  return result;
170 }
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:721
T perp() const
Definition: PV3DBase.h:69
std::pair< uint32_t, uint32_t > DetInfo
T z() const
Definition: PV3DBase.h:61
static bool missingHitFilter(uint16_t pattern)
Definition: HitPattern.h:798
constexpr std::array< uint8_t, layerIndexSize > layer
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:796
reco::TransientTrack build(const reco::Track *p) const
U second(std::pair< T, U > const &p)
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:713
#define M_PI
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:679
edm::ESHandle< TransientTrackBuilder > trkTool_
static bool barrel(uint32_t subDet)
RZrangeMap rangeRorZ_
#define LogDebug(id)
GlobalPoint position() const
Definition: VertexState.h:62

◆ print() [1/2]

void CheckHitPattern::print ( const reco::Track track)
static

Definition at line 172 of file CheckHitPattern.cc.

References gather_cfg::cout, trackingPlots::hp, reco::HitPattern::MISSING_INNER_HITS, HLT_2022v12_cff::track, and reco::HitPattern::TRACK_HITS.

172  {
173  // Get hit patterns of this track
174  const reco::HitPattern& hp = track.hitPattern();
175  std::cout << "=== Hits on Track ===" << std::endl;
177  std::cout << "=== Hits before track ===" << std::endl;
179 }
static void print(const reco::Track &track)

◆ print() [2/2]

void CheckHitPattern::print ( const reco::HitPattern::HitCategory  category,
const reco::HitPattern hp 
)
static

Definition at line 181 of file CheckHitPattern.cc.

References taus_updatedMVAIds_cff::category, gather_cfg::cout, reco::HitPattern::getLayer(), reco::HitPattern::getSubStructure(), trackingPlots::hp, mps_fire::i, phase1PixelTopology::layer, and reco::HitPattern::trackerHitFilter().

181  {
182  for (int i = 0; i < hp.numberOfAllHits(category); i++) {
183  uint32_t hit = hp.getHitPattern(category, i);
185  uint32_t subdet = reco::HitPattern::getSubStructure(hit);
187  std::cout << "hit " << i << " subdet=" << subdet << " layer=" << layer << " type " << hp.getHitType(hit)
188  << std::endl;
189  }
190  }
191 }
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:721
constexpr std::array< uint8_t, layerIndexSize > layer
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:713
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:679

Member Data Documentation

◆ geomInitDone_

bool CheckHitPattern::geomInitDone_ = false
private

Definition at line 56 of file CheckHitPattern.h.

Referenced by init(), and operator()().

◆ rangeRorZ_

RZrangeMap CheckHitPattern::rangeRorZ_
private

Definition at line 61 of file CheckHitPattern.h.

Referenced by init(), and operator()().

◆ trkTool_

edm::ESHandle<TransientTrackBuilder> CheckHitPattern::trkTool_
private

Definition at line 64 of file CheckHitPattern.h.

Referenced by init(), and operator()().