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 26 of file CheckHitPattern.h.

Member Typedef Documentation

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

Definition at line 51 of file CheckHitPattern.h.

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

Definition at line 65 of file CheckHitPattern.h.

Member Function Documentation

bool CheckHitPattern::barrel ( uint32_t  subDet)
static

Definition at line 87 of file CheckHitPattern.cc.

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

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

87  {
88  // Determines if given sub-detector is in the barrel.
89  return (subDet == StripSubdetector::TIB || subDet == StripSubdetector::TOB ||
91 }
void CheckHitPattern::init ( const edm::EventSetup iSetup)

Definition at line 21 of file CheckHitPattern.cc.

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

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

Definition at line 81 of file CheckHitPattern.cc.

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

Referenced by init().

81  {
82  // Convert detId to a pair<uint32, uint32> consisting of the numbers used by HitPattern
83  // to identify subdetector and layer number respectively.
84  return DetInfo( detId.subdetId(), tTopo->layer(detId) );
85 }
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:41
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(), TransientTrackBuilder::build(), 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, AnalysisDataFormats_SUSYBSMObjects::hp, mps_fire::i, 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().

95 {
96  // Check if hit pattern of this track is consistent with it being produced
97  // at given vertex.
98 
99  // Initialise geometry info if not yet done.
100  if (!geomInitDone_) 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 = fabs(reco::deltaPhi<const GlobalVector, const GlobalPoint>(p3_trk, vert.position())) < 0.5*M_PI;
109 
110  LogDebug("CHP") << "TRACK: in-->out ? "
111  << trkGoesInsideOut
112  << " dxy=" << track.dxy()
113  << " sz=" <<track.dz()
114  << " eta=" <<track.eta()
115  <<" barrel hits=" << track.hitPattern().numberOfValidPixelHits()
116  <<"/" << track.hitPattern().numberOfValidStripTIBHits()
117  <<"/" << track.hitPattern().numberOfValidStripTOBHits();
118  LogDebug("CHP")<<"VERT: r="<<vert.position().perp()<<" z="<<vert.position().z();
119  // 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";
120  // Get hit patterns of this track
121  const reco::HitPattern &hp = track.hitPattern();
122 
123  // Count number of valid hits on track definately in front of the vertex,
124  // taking into account finite depth of each layer.
125  unsigned int nHitBefore = 0;
126  for (int i = 0; i < hp.numberOfAllHits(reco::HitPattern::TRACK_HITS); i++) {
129  uint32_t subDet = reco::HitPattern::getSubStructure(hit);
130  uint32_t layer = reco::HitPattern::getLayer(hit);
131  DetInfo detInfo(subDet, layer);
132  auto maxRZ = (*rangeRorZ_.find(detInfo)).second.second;
133 
134  if (this->barrel(subDet)) {
135  // Be careful. If the track starts by going outside-->in, it is allowed to have hits before the vertex !
136  if (vert.position().perp() > maxRZ && trkGoesInsideOut) nHitBefore++;
137  } else {
138  if (fabs(vert.position().z()) > maxRZ) nHitBefore++;
139  }
140  }
141  }
142 
143  // Count number of missing hits before the innermost hit on the track,
144  // taking into account finite depth of each layer.
145  unsigned int nMissHitAfter = 0;
146  for (int i = 0; i < hp.numberOfAllHits(reco::HitPattern::MISSING_INNER_HITS); i++) {
148  // if (hp.trackerHitFilter(hit)) {
150  uint32_t subDet = reco::HitPattern::getSubStructure(hit);
151  uint32_t layer = reco::HitPattern::getLayer(hit);
152  DetInfo detInfo(subDet, layer);
153  auto minRZ = (*rangeRorZ_.find(detInfo)).second.first;
154 
155  if (this->barrel(subDet)) {
156  // Be careful. If the track starts by going outside-->in, then it misses hits
157  // in all layers it crosses before its innermost valid hit.
158  if (vert.position().perp() < minRZ || ! trkGoesInsideOut) nMissHitAfter++;
159  } else {
160  if (fabs(vert.position().z()) < minRZ) nMissHitAfter++;
161  }
162  }
163  }
164 
165  Result result;
166  result.hitsInFrontOfVert = nHitBefore;
167  result.missHitsAfterVert = nMissHitAfter;
168  return result;
169 }
#define LogDebug(id)
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:751
T perp() const
Definition: PV3DBase.h:72
std::pair< uint32_t, uint32_t > DetInfo
reco::TransientTrack build(const reco::Track *p) const
static bool missingHitFilter(uint16_t pattern)
Definition: HitPattern.h:852
GlobalPoint position() const
Definition: VertexState.h:69
int numberOfValidStripTOBHits() const
Definition: HitPattern.h:938
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:847
U second(std::pair< T, U > const &p)
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:684
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
T z() const
Definition: PV3DBase.h:64
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:867
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:742
#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:642
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:707
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:479
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
int numberOfValidStripTIBHits() const
Definition: HitPattern.h:928
int numberOfValidPixelHits() const
Definition: HitPattern.h:908
edm::ESHandle< TransientTrackBuilder > trkTool_
static bool barrel(uint32_t subDet)
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:545
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:624
RZrangeMap rangeRorZ_
void CheckHitPattern::print ( const reco::Track track)
static

Definition at line 171 of file CheckHitPattern.cc.

References gather_cfg::cout, reco::TrackBase::hitPattern(), AnalysisDataFormats_SUSYBSMObjects::hp, reco::HitPattern::MISSING_INNER_HITS, and reco::HitPattern::TRACK_HITS.

171  {
172  // Get hit patterns of this track
173  const reco::HitPattern &hp = track.hitPattern();
174  std::cout<<"=== Hits on Track ==="<<std::endl;
176  std::cout<<"=== Hits before track ==="<<std::endl;
178 }
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:479
static void print(const reco::Track &track)
void CheckHitPattern::print ( const reco::HitPattern::HitCategory  category,
const reco::HitPattern hp 
)
static

Definition at line 180 of file CheckHitPattern.cc.

References gather_cfg::cout, reco::HitPattern::getHitPattern(), reco::HitPattern::getHitType(), reco::HitPattern::getLayer(), reco::HitPattern::getSubStructure(), mps_fire::i, reco::HitPattern::numberOfAllHits(), and reco::HitPattern::trackerHitFilter().

180  {
181  for (int i = 0; i < hp.numberOfAllHits(category); i++) {
182  uint32_t hit = hp.getHitPattern(category, i);
184  uint32_t subdet = reco::HitPattern::getSubStructure(hit);
185  uint32_t layer = reco::HitPattern::getLayer(hit);
186  std::cout<<"hit "<<i<<" subdet="<<subdet<<" layer="<<layer<<" type "<<hp.getHitType(hit)<<std::endl;
187  }
188  }
189 }
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:751
static uint32_t getHitType(uint16_t pattern)
Definition: HitPattern.h:784
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:867
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:742
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:707
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:545

Member Data Documentation

bool CheckHitPattern::geomInitDone_ =false
private

Definition at line 61 of file CheckHitPattern.h.

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

RZrangeMap CheckHitPattern::rangeRorZ_
private

Definition at line 66 of file CheckHitPattern.h.

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

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

Definition at line 69 of file CheckHitPattern.h.

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