CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
< TransientTrackBuilder
trkTool_
 

Detailed Description

Definition at line 25 of file CheckHitPattern.h.

Member Typedef Documentation

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

Definition at line 46 of file CheckHitPattern.h.

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

Definition at line 60 of file CheckHitPattern.h.

Member Function Documentation

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
void CheckHitPattern::init ( const edm::EventSetup iSetup)

Definition at line 21 of file CheckHitPattern.cc.

References barrel(), gather_cfg::cout, ztail::d, geomInitDone_, edm::EventSetup::get(), mps_fire::i, interpretDetId(), position, edm::ESHandle< class >::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
tuple d
Definition: ztail.py:151
std::vector< const GeomDet * > DetContainer
static DetInfo interpretDetId(DetId detId, const TrackerTopology *tTopo)
T const * product() const
Definition: ESHandle.h:86
static int position[264][3]
Definition: ReadPGInfo.cc:289
T get() const
Definition: EventSetup.h:88
edm::ESHandle< TransientTrackBuilder > trkTool_
static bool barrel(uint32_t subDet)
tuple cout
Definition: gather_cfg.py:144
RZrangeMap rangeRorZ_
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
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
unsigned int layer(const DetId &id) const
CheckHitPattern::Result CheckHitPattern::operator() ( const reco::Track track,
const VertexState vert 
) const

Definition at line 94 of file CheckHitPattern.cc.

References barrel(), reco::TrackBase::dxy(), reco::TrackBase::dz(), reco::TrackBase::eta(), Exception, geomInitDone_, reco::HitPattern::getHitPattern(), reco::HitPattern::getLayer(), reco::HitPattern::getSubStructure(), reco::TrackBase::hitPattern(), CheckHitPattern::Result::hitsInFrontOfVert, mps_fire::i, if(), phase1PixelTopology::layer, LogDebug, M_PI, CheckHitPattern::Result::missHitsAfterVert, reco::HitPattern::MISSING_INNER_HITS, reco::HitPattern::missingHitFilter(), reco::HitPattern::numberOfAllHits(), reco::HitPattern::numberOfValidPixelHits(), reco::HitPattern::numberOfValidStripTIBHits(), reco::HitPattern::numberOfValidStripTOBHits(), PV3DBase< T, PVType, FrameType >::perp(), VertexState::position(), rangeRorZ_, mps_fire::result, edm::second(), 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.
106  reco::TransientTrack t_trk = trkTool_->build(track);
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() << "/"
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++) {
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++) {
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 }
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:715
T perp() const
Definition: PV3DBase.h:69
std::pair< uint32_t, uint32_t > DetInfo
static bool missingHitFilter(uint16_t pattern)
Definition: HitPattern.h:792
GlobalPoint position() const
Definition: VertexState.h:62
int numberOfValidStripTOBHits() const
Definition: HitPattern.h:849
constexpr std::array< uint8_t, layerIndexSize > layer
tuple result
Definition: mps_fire.py:311
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:790
U second(std::pair< T, U > const &p)
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
T z() const
Definition: PV3DBase.h:61
if(conf_.getParameter< bool >("UseStripCablingDB"))
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:798
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:707
#define M_PI
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:622
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:673
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:504
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
int numberOfValidStripTIBHits() const
Definition: HitPattern.h:841
int numberOfValidPixelHits() const
Definition: HitPattern.h:825
edm::ESHandle< TransientTrackBuilder > trkTool_
static bool barrel(uint32_t subDet)
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:531
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:608
RZrangeMap rangeRorZ_
#define LogDebug(id)
void CheckHitPattern::print ( const reco::Track track)
static

Definition at line 172 of file CheckHitPattern.cc.

References gather_cfg::cout, reco::TrackBase::hitPattern(), reco::HitPattern::MISSING_INNER_HITS, 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 }
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:504
static void print(const reco::Track &track)
tuple cout
Definition: gather_cfg.py:144
void CheckHitPattern::print ( const reco::HitPattern::HitCategory  category,
const reco::HitPattern hp 
)
static

Definition at line 181 of file CheckHitPattern.cc.

References gather_cfg::cout, reco::HitPattern::getHitPattern(), reco::HitPattern::getHitType(), reco::HitPattern::getLayer(), reco::HitPattern::getSubStructure(), mps_fire::i, phase1PixelTopology::layer, reco::HitPattern::numberOfAllHits(), 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);
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 }
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:715
static const char category[]
constexpr std::array< uint8_t, layerIndexSize > layer
static uint32_t getHitType(uint16_t pattern)
Definition: HitPattern.h:741
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:798
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:707
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:673
tuple cout
Definition: gather_cfg.py:144
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:531

Member Data Documentation

bool CheckHitPattern::geomInitDone_ = false
private

Definition at line 56 of file CheckHitPattern.h.

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

RZrangeMap CheckHitPattern::rangeRorZ_
private

Definition at line 61 of file CheckHitPattern.h.

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

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

Definition at line 64 of file CheckHitPattern.h.

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