CMS 3D CMS Logo

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::HitCategory category, 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< TransientTrackBuildertrkTool_
 

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.

References analyze(), init(), print(), and HiIsolationCommonParameters_cff::track.

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 96 of file CheckHitPattern.cc.

References FixTrackHitPattern::analyze(), barrel(), TransientTrackBuilder::build(), 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, AnalysisDataFormats_SUSYBSMObjects::hp, mps_fire::i, init(), LogDebug, M_PI, CheckHitPattern::Result::missHitsAfterVert, reco::HitPattern::MISSING_INNER_HITS, reco::HitPattern::missingHitFilter(), reco::HitPattern::numberOfHits(), reco::HitPattern::numberOfValidPixelHits(), reco::HitPattern::numberOfValidStripTIBHits(), reco::HitPattern::numberOfValidStripTOBHits(), PV3DBase< T, PVType, FrameType >::perp(), VertexState::position(), rangeRorZ_, mps_fire::result, reco::HitPattern::TRACK_HITS, reco::HitPattern::trackerHitFilter(), reco::TransientTrack::trajectoryStateClosestToPoint(), trkTool_, reco::HitPattern::validHitFilter(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ~CheckHitPattern().

98 {
99  // Check if hit pattern of this track is consistent with it being produced
100  // at given vertex.
101 
102  // Initialise geometry info if not yet done.
103  if (!geomInitDone_) this->init(iSetup);
104 
105  // Optionally set vertex position to zero for debugging.
106  // VertexState vertDebug( GlobalPoint(0.,0.,0.) , GlobalError(1e-8, 0., 1e-8, 0., 0., 1e-8) );
107 
108  // Evaluate track parameters at vertex.
109  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",trkTool_); // Needed for vertex fits
110  reco::TransientTrack t_trk = trkTool_->build(track);
111  GlobalVector p3_trk = t_trk.trajectoryStateClosestToPoint(vert.position()).momentum();
112  bool trkGoesInsideOut = fabs(reco::deltaPhi<const GlobalVector, const GlobalPoint>(p3_trk, vert.position())) < 0.5*M_PI;
113 
114  LogDebug("CHP") << "TRACK: in-->out ? "
115  << trkGoesInsideOut
116  << " dxy=" << track.dxy()
117  << " sz=" <<track.dz()
118  << " eta=" <<track.eta()
119  <<" barrel hits=" << track.hitPattern().numberOfValidPixelHits()
120  <<"/" << track.hitPattern().numberOfValidStripTIBHits()
121  <<"/" << track.hitPattern().numberOfValidStripTOBHits();
122  LogDebug("CHP")<<"VERT: r="<<vert.position().perp()<<" z="<<vert.position().z();
123  // 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";
124  // Get hit patterns of this track
125  const reco::HitPattern &hp = track.hitPattern();
126  reco::HitPattern ip = track.hitPattern();
127 
128  // Optionally fix inner hit pattern (needed if uncertainty on track trajectory is large).
129  if (fixHitPattern) {
130  static FixTrackHitPattern fixTrackHitPattern;
131  ip = fixTrackHitPattern.analyze(iSetup, track).innerHitPattern;
132  }
133 
134  // Count number of valid hits on track definately in front of the vertex,
135  // taking into account finite depth of each layer.
136  unsigned int nHitBefore = 0;
137  for (int i = 0; i < hp.numberOfHits(reco::HitPattern::TRACK_HITS); i++) {
140  uint32_t subDet = reco::HitPattern::getSubStructure(hit);
141  uint32_t layer = reco::HitPattern::getLayer(hit);
142  DetInfo detInfo(subDet, layer);
143  double maxRZ = rangeRorZ_[detInfo].second;
144 
145  if (this->barrel(subDet)) {
146  // Be careful. If the track starts by going outside-->in, it is allowed to have hits before the vertex !
147  if (vert.position().perp() > maxRZ && trkGoesInsideOut) nHitBefore++;
148  } else {
149  if (fabs(vert.position().z()) > maxRZ) nHitBefore++;
150  }
151  }
152  }
153 
154  // Count number of missing hits before the innermost hit on the track,
155  // taking into account finite depth of each layer.
156  unsigned int nMissHitAfter = 0;
157  for (int i = 0; i < ip.numberOfHits(reco::HitPattern::MISSING_INNER_HITS); i++) {
159  // if (ip.trackerHitFilter(hit)) {
161  uint32_t subDet = reco::HitPattern::getSubStructure(hit);
162  uint32_t layer = reco::HitPattern::getLayer(hit);
163  DetInfo detInfo(subDet, layer);
164  double minRZ = rangeRorZ_[detInfo].first;
165 
166  if (this->barrel(subDet)) {
167  // Be careful. If the track starts by going outside-->in, then it misses hits
168  // in all layers it crosses before its innermost valid hit.
169  if (vert.position().perp() < minRZ || ! trkGoesInsideOut) nMissHitAfter++;
170  } else {
171  if (fabs(vert.position().z()) < minRZ) nMissHitAfter++;
172  }
173  }
174  }
175 
176  Result result;
177  result.hitsInFrontOfVert = nHitBefore;
178  result.missHitsAfterVert = nMissHitAfter;
179  return result;
180 }
#define LogDebug(id)
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:700
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:792
GlobalPoint position() const
Definition: VertexState.h:69
int numberOfValidStripTOBHits() const
Definition: HitPattern.h:868
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:787
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
Result analyze(const edm::EventSetup &iSetup, const reco::Track &track)
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
T z() const
Definition: PV3DBase.h:64
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:691
#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:604
void init(const edm::EventSetup &iSetup)
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:677
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:445
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
const T & get() const
Definition: EventSetup.h:56
int numberOfValidStripTIBHits() const
Definition: HitPattern.h:858
static RZrangeMap rangeRorZ_
int numberOfValidPixelHits() const
Definition: HitPattern.h:838
edm::ESHandle< TransientTrackBuilder > trkTool_
static bool barrel(uint32_t subDet)
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:515
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:586
int numberOfHits(HitCategory category) const
Definition: HitPattern.h:807
bool CheckHitPattern::barrel ( uint32_t  subDet)
staticprivate

Definition at line 89 of file CheckHitPattern.cc.

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

Referenced by analyze(), and init().

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

Definition at line 25 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_, and z.

Referenced by analyze(), and ~CheckHitPattern().

25  {
26 
27  //Retrieve tracker topology from geometry
29  iSetup.get<TrackerTopologyRcd>().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 }
std::pair< uint32_t, uint32_t > DetInfo
const DetContainer & dets() const
Returm a vector of all GeomDet (including all GeomDetUnits)
static DetInfo interpretDetId(DetId detId, const TrackerTopology *tTopo)
const T & get() const
Definition: EventSetup.h:56
static RZrangeMap rangeRorZ_
static int position[264][3]
Definition: ReadPGInfo.cc:509
static bool barrel(uint32_t subDet)
std::vector< GeomDet const * > DetContainer
T const * product() const
Definition: ESHandle.h:86
CheckHitPattern::DetInfo CheckHitPattern::interpretDetId ( DetId  detId,
const TrackerTopology tTopo 
)
staticprivate

Definition at line 83 of file CheckHitPattern.cc.

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

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  return DetInfo( detId.subdetId(), tTopo->layer(detId) );
87 }
std::pair< uint32_t, uint32_t > DetInfo
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
unsigned int layer(const DetId &id) const
void CheckHitPattern::print ( const reco::Track track) const

Definition at line 182 of file CheckHitPattern.cc.

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

Referenced by ~CheckHitPattern().

182  {
183  // Get hit patterns of this track
184  const reco::HitPattern &hp = track.hitPattern();
185  std::cout<<"=== Hits on Track ==="<<std::endl;
187  std::cout<<"=== Hits before track ==="<<std::endl;
189 }
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:445
void print(const reco::Track &track) const
void CheckHitPattern::print ( const reco::HitPattern::HitCategory  category,
const reco::HitPattern hp 
) const
private

Definition at line 191 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::numberOfHits(), and reco::HitPattern::trackerHitFilter().

191  {
192  for (int i = 0; i < hp.numberOfHits(category); i++) {
193  uint32_t hit = hp.getHitPattern(category, i);
195  uint32_t subdet = reco::HitPattern::getSubStructure(hit);
196  uint32_t layer = reco::HitPattern::getLayer(hit);
197  std::cout<<"hit "<<i<<" subdet="<<subdet<<" layer="<<layer<<" type "<<hp.getHitType(hit)<<std::endl;
198  }
199  }
200 }
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:700
static uint32_t getHitType(uint16_t pattern)
Definition: HitPattern.h:733
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:691
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:677
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:515
int numberOfHits(HitCategory category) const
Definition: HitPattern.h:807

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