CMS 3D CMS Logo

PFCheckHitPattern.cc
Go to the documentation of this file.
2 
3 // To get Tracker Geometry
9 
10 // To convert detId to subdet/layer number.
14 
15 #include <map>
16 
17 using namespace reco;
18 using namespace std;
19 
20 void PFCheckHitPattern::init(const TrackerTopology* tkerTopo, const TrackerGeometry* tkerGeom) {
21  //
22  // Note min/max radius (z) of each barrel layer (endcap disk).
23  //
24 
25  geomInitDone_ = true;
26 
27  // Get Tracker geometry
28  const TrackingGeometry::DetContainer& dets = tkerGeom->dets();
29 
30  // Loop over all modules in the Tracker.
31  for (unsigned int i = 0; i < dets.size(); i++) {
32  // Get subdet and layer of this module
33  auto detId = dets[i]->geographicalId();
34  auto detInfo = DetInfo(detId.subdetId(), tkerTopo->layer(detId));
35  uint32_t subDet = detInfo.first;
36 
37  // Note r (or z) of module if barrel (or endcap).
38  double r_or_z;
39  if (this->barrel(subDet)) {
40  r_or_z = dets[i]->position().perp();
41  } else {
42  r_or_z = fabs(dets[i]->position().z());
43  }
44 
45  // Recover min/max r/z value of this layer/disk found so far.
46  double minRZ = 999.;
47  double maxRZ = 0.;
48  if (rangeRorZ_.find(detInfo) != rangeRorZ_.end()) {
49  minRZ = rangeRorZ_[detInfo].first;
50  maxRZ = rangeRorZ_[detInfo].second;
51  }
52 
53  // Update with those of this module if it exceeds them.
54  if (minRZ > r_or_z)
55  minRZ = r_or_z;
56  if (maxRZ < r_or_z)
57  maxRZ = r_or_z;
58  rangeRorZ_[detInfo] = pair<double, double>(minRZ, maxRZ);
59  }
60 
61 #if 0
62  //def DEBUG_CHECKHITPATTERN
63  RZrangeMap::const_iterator d;
64  for (d = rangeRorZ_.begin(); d != rangeRorZ_.end(); d++) {
65  DetInfo detInfo = d->first;
66  pair<double, double> rangeRZ = d->second;
67  }
68 #endif
69 }
70 
71 bool PFCheckHitPattern::barrel(uint32_t subDet) {
72  // Determines if given sub-detector is in the barrel.
73  return (subDet == StripSubdetector::TIB || subDet == StripSubdetector::TOB ||
75 }
76 
77 pair<PFCheckHitPattern::PFTrackHitInfo, PFCheckHitPattern::PFTrackHitInfo> PFCheckHitPattern::analyze(
78  const TrackerTopology* tkerTopo,
79  const TrackerGeometry* tkerGeom,
80  const TrackBaseRef track,
81  const TransientVertex& vert) {
82  // PFCheck if hit pattern of this track is consistent with it being produced
83  // at given vertex. Pair.first gives number of hits on track in front of vertex.
84  // Pair.second gives number of missing hits between vertex and innermost hit
85  // on track.
86 
87  // Initialise geometry info if not yet done.
88  if (!geomInitDone_)
89  this->init(tkerTopo, tkerGeom);
90 
91  // Get hit patterns of this track
92  const reco::HitPattern& hp = track.get()->hitPattern();
93 
94  // Count number of valid hits on track definately in front of the vertex,
95  // taking into account finite depth of each layer.
96  unsigned int nHitBefore = 0;
97  unsigned int nHitAfter = 0;
98 
99  for (int i = 0; i < hp.numberOfAllHits(HitPattern::TRACK_HITS); i++) {
100  uint32_t hit = hp.getHitPattern(HitPattern::TRACK_HITS, i);
101  if (hp.trackerHitFilter(hit) && hp.validHitFilter(hit)) {
102  uint32_t subDet = hp.getSubStructure(hit);
103  uint32_t layer = hp.getLayer(hit);
104  DetInfo detInfo(subDet, layer);
105  double maxRZ = rangeRorZ_[detInfo].second;
106 
107  if (this->barrel(subDet)) {
108  if (vert.position().perp() > maxRZ)
109  nHitBefore++;
110  else
111  nHitAfter++;
112  } else {
113  if (fabs(vert.position().z()) > maxRZ)
114  nHitBefore++;
115  else
116  nHitAfter++;
117  }
118  }
119  }
120 
121  // Count number of missing hits before the innermost hit on the track,
122  // taking into account finite depth of each layer.
123  unsigned int nMissHitAfter = 0;
124  unsigned int nMissHitBefore = 0;
125 
126  for (int i = 0; i < hp.numberOfAllHits(HitPattern::MISSING_INNER_HITS); i++) {
127  uint32_t hit = hp.getHitPattern(HitPattern::MISSING_INNER_HITS, i);
129  uint32_t subDet = reco::HitPattern::getSubStructure(hit);
131  DetInfo detInfo(subDet, layer);
132  double minRZ = rangeRorZ_[detInfo].first;
133 
134  // cout << "subDet = " << subDet << " layer = " << layer << " minRZ = " << minRZ << endl;
135 
136  if (this->barrel(subDet)) {
137  if (vert.position().perp() < minRZ)
138  nMissHitAfter++;
139  else
140  nMissHitBefore++;
141  } else {
142  if (fabs(vert.position().z()) < minRZ)
143  nMissHitAfter++;
144  else
145  nMissHitBefore++;
146  }
147  }
148  }
149 
150  PFTrackHitInfo trackToVertex(nHitBefore, nMissHitBefore);
151  PFTrackHitInfo trackFromVertex(nHitAfter, nMissHitAfter);
152 
153  return pair<PFTrackHitInfo, PFTrackHitInfo>(trackToVertex, trackFromVertex);
154 }
155 
157  // Get hit patterns of this track
158  const reco::HitPattern& hp = track.get()->hitPattern();
159 
160  cout << "=== Hits on Track ===" << endl;
162  cout << "=== Hits before track ===" << endl;
164 }
165 
167  for (int i = 0; i < hp.numberOfAllHits(category); i++) {
168  uint32_t hit = hp.getHitPattern(category, i);
169  if (hp.trackerHitFilter(hit)) {
170  uint32_t subdet = hp.getSubStructure(hit);
171  uint32_t layer = hp.getLayer(hit);
172  cout << "hit " << i << " subdet=" << subdet << " layer=" << layer << " type " << hp.getHitType(hit) << endl;
173  }
174  }
175 }
reco::HitPattern::getSubStructure
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:695
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:31
init
int init
Definition: HydjetWrapper.h:64
mps_fire.i
i
Definition: mps_fire.py:428
PixelSubdetector.h
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
TrackerGeometry.h
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
PFCheckHitPattern::print
void print(const reco::TrackBaseRef track) const
Print hit pattern on track.
Definition: PFCheckHitPattern.cc:156
ESHandle.h
TrackerTopology
Definition: TrackerTopology.h:16
gather_cfg.cout
cout
Definition: gather_cfg.py:144
reco::HitPattern::trackerHitFilter
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:663
TransientVertex::position
GlobalPoint position() const
Definition: TransientVertex.h:169
TrackerTopology::layer
unsigned int layer(const DetId &id) const
Definition: TrackerTopology.cc:47
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
TrackerTopology.h
reco::HitPattern
Definition: HitPattern.h:147
trackingPlots.hp
hp
Definition: trackingPlots.py:1230
PFCheckHitPattern::analyze
PFTrackHitFullInfo analyze(const TrackerTopology *tkerTopo, const TrackerGeometry *tkerGeom, const reco::TrackBaseRef track, const TransientVertex &vert)
Definition: PFCheckHitPattern.cc:77
PFCheckHitPattern::init
void init(const TrackerTopology *, const TrackerGeometry *)
Create map indicating r/z values of all layers/disks.
Definition: PFCheckHitPattern.cc:20
StripSubdetector::TIB
static constexpr auto TIB
Definition: StripSubdetector.h:16
reco::HitPattern::missingHitFilter
static bool missingHitFilter(uint16_t pattern)
Definition: HitPattern.h:767
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
reco::HitPattern::getLayer
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:702
PFCheckHitPattern::PFTrackHitInfo
std::pair< unsigned int, unsigned int > PFTrackHitInfo
Definition: PFCheckHitPattern.h:40
TrackerDigiGeometryRecord.h
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
TrackingGeometry::DetContainer
std::vector< const GeomDet * > DetContainer
Definition: TrackingGeometry.h:29
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
PFCheckHitPattern::DetInfo
std::pair< uint32_t, uint32_t > DetInfo
Definition: PFCheckHitPattern.h:62
TransientVertex
Definition: TransientVertex.h:18
TrackerGeometry::dets
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Definition: TrackerGeometry.h:62
reco::HitPattern::TRACK_HITS
Definition: HitPattern.h:155
GeomDet.h
std
Definition: JetResolutionObject.h:76
reco::HitPattern::HitCategory
HitCategory
Definition: HitPattern.h:155
reco::HitPattern::MISSING_INNER_HITS
Definition: HitPattern.h:155
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
edm::RefToBase< reco::Track >
Exception.h
ztail.d
d
Definition: ztail.py:151
PFCheckHitPattern::barrel
static bool barrel(uint32_t subDet)
Return a bool indicating if a given subdetector is in the barrel.
Definition: PFCheckHitPattern.cc:71
PFCheckHitPattern.h
StripSubdetector.h
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
hit
Definition: SiStripHitEffFromCalibTree.cc:88
TrackerGeometry
Definition: TrackerGeometry.h:14