CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
CheckHitPattern Class Reference

#include <CheckHitPattern.h>

Classes

struct  Result
 

Public Member Functions

Result analyze (const edm::EventSetup &iSetup, const reco::Track &track, const VertexState &vert, bool fixHitPattern=true)
 
 CheckHitPattern ()
 
void print (const reco::Track &track) const
 
 ~CheckHitPattern ()
 

Private Types

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

Private Member Functions

void init (const edm::EventSetup &iSetup)
 
void print (const reco::HitPattern &hp) const
 

Static Private Member Functions

static bool barrel (uint32_t subDet)
 
static DetInfo interpretDetId (DetId detId, const TrackerTopology *tTopo)
 

Private Attributes

bool geomInitDone_
 
edm::ESHandle
< TransientTrackBuilder
trkTool_
 

Static Private Attributes

static RZrangeMap rangeRorZ_
 

Detailed Description

Definition at line 30 of file CheckHitPattern.h.

Member Typedef Documentation

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

Definition at line 63 of file CheckHitPattern.h.

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

Definition at line 77 of file CheckHitPattern.h.

Constructor & Destructor Documentation

CheckHitPattern::CheckHitPattern ( )
inline

Definition at line 41 of file CheckHitPattern.h.

41 : geomInitDone_(false) {}
CheckHitPattern::~CheckHitPattern ( )
inline

Definition at line 43 of file CheckHitPattern.h.

43 {}

Member Function Documentation

CheckHitPattern::Result CheckHitPattern::analyze ( const edm::EventSetup iSetup,
const reco::Track track,
const VertexState vert,
bool  fixHitPattern = true 
)

Definition at line 110 of file CheckHitPattern.cc.

References FixTrackHitPattern::analyze(), barrel(), reco::TrackBase::dxy(), reco::TrackBase::dz(), reco::TrackBase::eta(), geomInitDone_, edm::EventSetup::get(), reco::HitPattern::getHitPattern(), reco::HitPattern::getLayer(), reco::HitPattern::getSubStructure(), reco::TrackBase::hitPattern(), CheckHitPattern::Result::hitsInFrontOfVert, i, init(), FixTrackHitPattern::Result::innerHitPattern, LogDebug, M_PI, CheckHitPattern::Result::missHitsAfterVert, reco::HitPattern::numberOfHits(), reco::HitPattern::numberOfValidPixelHits(), reco::HitPattern::numberOfValidStripTIBHits(), reco::HitPattern::numberOfValidStripTOBHits(), PV3DBase< T, PVType, FrameType >::perp(), VertexState::position(), rangeRorZ_, query::result, reco::TrackBase::trackerExpectedHitsInner(), reco::HitPattern::trackerHitFilter(), reco::TransientTrack::trajectoryStateClosestToPoint(), trkTool_, reco::HitPattern::type_1_HitFilter(), reco::HitPattern::validHitFilter(), and PV3DBase< T, PVType, FrameType >::z().

112 {
113  // Check if hit pattern of this track is consistent with it being produced
114  // at given vertex.
115 
116  // Initialise geometry info if not yet done.
117  if (!geomInitDone_) this->init(iSetup);
118 
119  // Optionally set vertex position to zero for debugging.
120  // VertexState vertDebug( GlobalPoint(0.,0.,0.) , GlobalError(1e-8, 0., 1e-8, 0., 0., 1e-8) );
121 
122  // Evaluate track parameters at vertex.
123  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",trkTool_); // Needed for vertex fits
124  reco::TransientTrack t_trk = trkTool_->build(track);
125  GlobalVector p3_trk = t_trk.trajectoryStateClosestToPoint(vert.position()).momentum();
126  bool trkGoesInsideOut = fabs(reco::deltaPhi<const GlobalVector, const GlobalPoint>(p3_trk, vert.position())) < 0.5*M_PI;
127 
128  LogDebug("CHP")<<"TRACK: in-->out ? "<<trkGoesInsideOut<<" dxy="<<track.dxy()<<" sz="<<track.dz()<<" eta="<<track.eta()<<" barrel hits="<<track.hitPattern().numberOfValidPixelHits()<<"/"<<track.hitPattern().numberOfValidStripTIBHits()<<"/"<<track.hitPattern().numberOfValidStripTOBHits();
129  LogDebug("CHP")<<"VERT: r="<<vert.position().perp()<<" z="<<vert.position().z();
130  // 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";
131  // Get hit patterns of this track
132  const reco::HitPattern& hp = track.hitPattern();
134 
135  // Optionally fix inner hit pattern (needed if uncertainty on track trajectory is large).
136  if (fixHitPattern) {
137  static FixTrackHitPattern fixTrackHitPattern;
138  FixTrackHitPattern::Result fixedHP = fixTrackHitPattern.analyze(iSetup, track);
139  ip = fixedHP.innerHitPattern;
140  }
141 
142  // Count number of valid hits on track definately in front of the vertex,
143  // taking into account finite depth of each layer.
144  unsigned int nHitBefore = 0;
145  for (int i = 0; i < hp.numberOfHits(); i++) {
146  uint32_t hit = hp.getHitPattern(i);
147  if (hp.trackerHitFilter(hit) && hp.validHitFilter(hit)) {
148  uint32_t subDet = hp.getSubStructure(hit);
149  uint32_t layer = hp.getLayer(hit);
150  DetInfo detInfo(subDet, layer);
151  double maxRZ = rangeRorZ_[detInfo].second;
152 
153  if (this->barrel(subDet)) {
154  // Be careful. If the track starts by going outside-->in, it is allowed to have hits before the vertex !
155  if (vert.position().perp() > maxRZ && trkGoesInsideOut) nHitBefore++;
156  } else {
157  if (fabs(vert.position().z()) > maxRZ) nHitBefore++;
158  }
159  }
160  }
161 
162  // Count number of missing hits before the innermost hit on the track,
163  // taking into account finite depth of each layer.
164  unsigned int nMissHitAfter = 0;
165  for (int i = 0; i < ip.numberOfHits(); i++) {
166  uint32_t hit = ip.getHitPattern(i);
167  // if (ip.trackerHitFilter(hit)) {
168  if (ip.trackerHitFilter(hit) && ip.type_1_HitFilter(hit)) {
169  uint32_t subDet = ip.getSubStructure(hit);
170  uint32_t layer = ip.getLayer(hit);
171  DetInfo detInfo(subDet, layer);
172  double minRZ = rangeRorZ_[detInfo].first;
173 
174  if (this->barrel(subDet)) {
175  // Be careful. If the track starts by going outside-->in, then it misses hits
176  // in all layers it crosses before its innermost valid hit.
177  if (vert.position().perp() < minRZ || ! trkGoesInsideOut) nMissHitAfter++;
178  } else {
179  if (fabs(vert.position().z()) < minRZ) nMissHitAfter++;
180  }
181  }
182  }
183 
184  Result result;
185  result.hitsInFrontOfVert = nHitBefore;
186  result.missHitsAfterVert = nMissHitAfter;
187  return result;
188 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
T perp() const
Definition: PV3DBase.h:72
static uint32_t getLayer(uint32_t pattern)
Definition: HitPattern.h:501
std::pair< uint32_t, uint32_t > DetInfo
static bool trackerHitFilter(uint32_t pattern)
Definition: HitPattern.h:482
GlobalPoint position() const
Definition: VertexState.h:29
int numberOfValidStripTOBHits() const
Definition: HitPattern.h:606
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:141
Result analyze(const edm::EventSetup &iSetup, const reco::Track &track)
static bool type_1_HitFilter(uint32_t pattern)
Definition: HitPattern.h:550
T z() const
Definition: PV3DBase.h:64
tuple result
Definition: query.py:137
int numberOfHits() const
Definition: HitPattern.cc:213
static uint32_t getSubStructure(uint32_t pattern)
Definition: HitPattern.h:495
const HitPattern & trackerExpectedHitsInner() const
Access the hit pattern counting (in the Tracker) the number of expected crossed layers before the fir...
Definition: TrackBase.h:225
static bool validHitFilter(uint32_t pattern)
Definition: HitPattern.h:545
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:223
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:127
void init(const edm::EventSetup &iSetup)
reco::HitPattern innerHitPattern
#define M_PI
Definition: BFit3D.cc:3
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
const T & get() const
Definition: EventSetup.h:55
int numberOfValidStripTIBHits() const
Definition: HitPattern.h:598
static RZrangeMap rangeRorZ_
int numberOfValidPixelHits() const
Definition: HitPattern.h:582
edm::ESHandle< TransientTrackBuilder > trkTool_
static bool barrel(uint32_t subDet)
uint32_t getHitPattern(int position) const
Definition: HitPattern.cc:144
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:121
bool CheckHitPattern::barrel ( uint32_t  subDet)
staticprivate

Definition at line 103 of file CheckHitPattern.cc.

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

Referenced by analyze(), and init().

103  {
104  // Determines if given sub-detector is in the barrel.
105  return (subDet == StripSubdetector::TIB || subDet == StripSubdetector::TOB ||
106  subDet == PixelSubdetector::PixelBarrel);
107 }
void CheckHitPattern::init ( const edm::EventSetup iSetup)
private

Definition at line 25 of file CheckHitPattern.cc.

References barrel(), gather_cfg::cout, geomInitDone_, edm::EventSetup::get(), i, interpretDetId(), position, edm::ESHandle< class >::product(), rangeRorZ_, and detailsBasic3DVector::z.

Referenced by analyze().

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

Definition at line 83 of file CheckHitPattern.cc.

References edm::hlt::Exception, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TrackerTopology::pxbLayer(), TrackerTopology::pxfDisk(), DetId::subdetId(), StripSubdetector::TEC, TrackerTopology::tecWheel(), StripSubdetector::TIB, TrackerTopology::tibLayer(), StripSubdetector::TID, TrackerTopology::tidWheel(), StripSubdetector::TOB, and TrackerTopology::tobLayer().

Referenced by init().

83  {
84  // Convert detId to a pair<uint32, uint32> consisting of the numbers used by HitPattern
85  // to identify subdetector and layer number respectively.
86  if (detId.subdetId() == StripSubdetector::TIB) {
87  return DetInfo( detId.subdetId(), tTopo->tibLayer(detId) );
88  } else if (detId.subdetId() == StripSubdetector::TOB) {
89  return DetInfo( detId.subdetId(), tTopo->tobLayer(detId) );
90  } else if (detId.subdetId() == StripSubdetector::TID) {
91  return DetInfo( detId.subdetId(), tTopo->tidWheel(detId) );
92  } else if (detId.subdetId() == StripSubdetector::TEC) {
93  return DetInfo( detId.subdetId(), tTopo->tecWheel(detId) );
94  } else if (detId.subdetId() == PixelSubdetector::PixelBarrel) {
95  return DetInfo( detId.subdetId(), tTopo->pxbLayer(detId) );
96  } else if (detId.subdetId() == PixelSubdetector::PixelEndcap) {
97  return DetInfo( detId.subdetId(), tTopo->pxfDisk(detId) );
98  } else {
99  throw cms::Exception("NotFound","Found DetId that is not in Tracker");
100  }
101 }
unsigned int tibLayer(const DetId &id) const
std::pair< uint32_t, uint32_t > DetInfo
unsigned int pxfDisk(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
unsigned int pxbLayer(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
unsigned int tobLayer(const DetId &id) const
void CheckHitPattern::print ( const reco::Track track) const

Definition at line 190 of file CheckHitPattern.cc.

References gather_cfg::cout, reco::TrackBase::hitPattern(), and reco::TrackBase::trackerExpectedHitsInner().

190  {
191  // Get hit patterns of this track
192  const reco::HitPattern& hp = track.hitPattern();
193  const reco::HitPattern& ip = track.trackerExpectedHitsInner();
194 
195  std::cout<<"=== Hits on Track ==="<<std::endl;
196  this->print(hp);
197  std::cout<<"=== Hits before track ==="<<std::endl;
198  this->print(ip);
199 }
const HitPattern & trackerExpectedHitsInner() const
Access the hit pattern counting (in the Tracker) the number of expected crossed layers before the fir...
Definition: TrackBase.h:225
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:223
tuple cout
Definition: gather_cfg.py:121
void print(const reco::Track &track) const
void CheckHitPattern::print ( const reco::HitPattern hp) const
private

Definition at line 201 of file CheckHitPattern.cc.

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

201  {
202  for (int i = 0; i < hp.numberOfHits(); i++) {
203  uint32_t hit = hp.getHitPattern(i);
204  if (hp.trackerHitFilter(hit)) {
205  uint32_t subdet = hp.getSubStructure(hit);
206  uint32_t layer = hp.getLayer(hit);
207  std::cout<<"hit "<<i<<" subdet="<<subdet<<" layer="<<layer<<" type "<<hp.getHitType(hit)<<std::endl;
208  }
209  }
210 }
int i
Definition: DBlmapReader.cc:9
static uint32_t getLayer(uint32_t pattern)
Definition: HitPattern.h:501
static bool trackerHitFilter(uint32_t pattern)
Definition: HitPattern.h:482
static uint32_t getHitType(uint32_t pattern)
Definition: HitPattern.h:517
int numberOfHits() const
Definition: HitPattern.cc:213
static uint32_t getSubStructure(uint32_t pattern)
Definition: HitPattern.h:495
tuple cout
Definition: gather_cfg.py:121
uint32_t getHitPattern(int position) const
Definition: HitPattern.cc:144

Member Data Documentation

bool CheckHitPattern::geomInitDone_
private

Definition at line 73 of file CheckHitPattern.h.

Referenced by analyze(), and init().

CheckHitPattern::RZrangeMap CheckHitPattern::rangeRorZ_
staticprivate

Definition at line 78 of file CheckHitPattern.h.

Referenced by analyze(), and init().

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

Definition at line 81 of file CheckHitPattern.h.

Referenced by analyze().