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::HitPattern::HitCategory category, const reco::HitPattern &hp)
 
static void print (const reco::Track &track)
 

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.

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

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

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

◆ init()

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

Definition at line 21 of file CheckHitPattern.cc.

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
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 }

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

◆ interpretDetId()

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

Definition at line 82 of file CheckHitPattern.cc.

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 }

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

Referenced by init().

◆ operator()()

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

Definition at line 94 of file CheckHitPattern.cc.

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);
127  uint32_t layer = reco::HitPattern::getLayer(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);
150  uint32_t layer = reco::HitPattern::getLayer(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 }

References barrel(), TransientTrackBuilder::build(), Exception, geomInitDone_, reco::HitPattern::getLayer(), reco::HitPattern::getSubStructure(), trackingPlots::hp, mps_fire::i, 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_2018_cff::track, reco::HitPattern::TRACK_HITS, reco::HitPattern::trackerHitFilter(), reco::TransientTrack::trajectoryStateClosestToPoint(), trkTool_, reco::HitPattern::validHitFilter(), and PV3DBase< T, PVType, FrameType >::z().

◆ print() [1/2]

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

Definition at line 181 of file CheckHitPattern.cc.

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);
186  uint32_t layer = reco::HitPattern::getLayer(hit);
187  std::cout << "hit " << i << " subdet=" << subdet << " layer=" << layer << " type " << hp.getHitType(hit)
188  << std::endl;
189  }
190  }
191 }

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

◆ print() [2/2]

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

Definition at line 172 of file CheckHitPattern.cc.

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 }

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

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()().

Vector3DBase
Definition: Vector3DBase.h:8
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
reco::HitPattern::getSubStructure
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:695
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:30
mps_fire.i
i
Definition: mps_fire.py:355
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
CheckHitPattern::barrel
static bool barrel(uint32_t subDet)
Definition: CheckHitPattern.cc:88
CheckHitPattern::rangeRorZ_
RZrangeMap rangeRorZ_
Definition: CheckHitPattern.h:61
CheckHitPattern::trkTool_
edm::ESHandle< TransientTrackBuilder > trkTool_
Definition: CheckHitPattern.h:64
TrackerTopology
Definition: TrackerTopology.h:16
reco::HitPattern::validHitFilter
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:765
gather_cfg.cout
cout
Definition: gather_cfg.py:144
reco::HitPattern::trackerHitFilter
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:663
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
TrackerTopology::layer
unsigned int layer(const DetId &id) const
Definition: TrackerTopology.cc:47
trackerGeometry_cfi.trackerGeometry
trackerGeometry
Definition: trackerGeometry_cfi.py:3
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
CheckHitPattern::interpretDetId
static DetInfo interpretDetId(DetId detId, const TrackerTopology *tTopo)
Definition: CheckHitPattern.cc:82
CheckHitPattern::print
static void print(const reco::Track &track)
Definition: CheckHitPattern.cc:172
reco::HitPattern
Definition: HitPattern.h:147
trackingPlots.hp
hp
Definition: trackingPlots.py:1246
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
DDAxes::z
TransientTrackRecord
Definition: TransientTrackRecord.h:11
edm::ESHandle< TrackerTopology >
StripSubdetector::TIB
static constexpr auto TIB
Definition: StripSubdetector.h:16
reco::HitPattern::missingHitFilter
static bool missingHitFilter(uint16_t pattern)
Definition: HitPattern.h:767
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
reco::TransientTrack::trajectoryStateClosestToPoint
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
Definition: TransientTrack.h:90
reco::HitPattern::getLayer
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:702
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
TrackingGeometry::DetContainer
std::vector< const GeomDet * > DetContainer
Definition: TrackingGeometry.h:29
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
CheckHitPattern::DetInfo
std::pair< uint32_t, uint32_t > DetInfo
Definition: CheckHitPattern.h:46
get
#define get
reco::HitPattern::TRACK_HITS
Definition: HitPattern.h:155
reco::TransientTrack
Definition: TransientTrack.h:19
Exception
Definition: hltDiff.cc:246
reco::HitPattern::MISSING_INNER_HITS
Definition: HitPattern.h:155
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
CheckHitPattern::geomInitDone_
bool geomInitDone_
Definition: CheckHitPattern.h:56
VertexState::position
GlobalPoint position() const
Definition: VertexState.h:62
TransientTrackBuilder::build
reco::TransientTrack build(const reco::Track *p) const
Definition: TransientTrackBuilder.cc:20
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
ztail.d
d
Definition: ztail.py:151
mps_fire.result
result
Definition: mps_fire.py:303
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
hit
Definition: SiStripHitEffFromCalibTree.cc:88