CMS 3D CMS Logo

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

PFCheckHitPatter. More...

#include <PFCheckHitPattern.h>

Public Types

typedef std::pair
< PFTrackHitInfo,
PFTrackHitInfo
PFTrackHitFullInfo
 
typedef std::pair< unsigned
int, unsigned int > 
PFTrackHitInfo
 

Public Member Functions

PFTrackHitFullInfo analyze (edm::ESHandle< TrackerGeometry >, const reco::TrackBaseRef track, const TransientVertex &vert)
 
 PFCheckHitPattern ()
 
void print (const reco::TrackBaseRef track) const
 Print hit pattern on track. More...
 
 ~PFCheckHitPattern ()
 

Private Types

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

Private Member Functions

void init (edm::ESHandle< TrackerGeometry >)
 Create map indicating r/z values of all layers/disks. More...
 
void print (const reco::HitPattern::HitCategory, const reco::HitPattern &hp) const
 

Static Private Member Functions

static bool barrel (uint32_t subDet)
 Return a bool indicating if a given subdetector is in the barrel. More...
 
static DetInfo interpretDetId (DetId detId)
 

Private Attributes

bool geomInitDone_
 Note if geometry info is already initialized. More...
 
RZrangeMap rangeRorZ_
 

Detailed Description

PFCheckHitPatter.

Author
Ian Tomalin, modified by Maxime Gouzevitch
Date
October 2009

Definition at line 34 of file PFCheckHitPattern.h.

Member Typedef Documentation

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

Return a pair<uint32, uint32> consisting of the numbers used by HitPattern to identify subdetector and layer number respectively.

Definition at line 65 of file PFCheckHitPattern.h.

Definition at line 43 of file PFCheckHitPattern.h.

typedef std::pair<unsigned int, unsigned int> PFCheckHitPattern::PFTrackHitInfo

Definition at line 42 of file PFCheckHitPattern.h.

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

For a given subdetector & layer number, this stores the minimum and maximum r (or z) values if it is barrel (or endcap) respectively.

Definition at line 79 of file PFCheckHitPattern.h.

Constructor & Destructor Documentation

PFCheckHitPattern::PFCheckHitPattern ( )
inline

Definition at line 38 of file PFCheckHitPattern.h.

38 : geomInitDone_(false) {}
bool geomInitDone_
Note if geometry info is already initialized.
PFCheckHitPattern::~PFCheckHitPattern ( )
inline

Definition at line 40 of file PFCheckHitPattern.h.

40 {}

Member Function Documentation

pair< PFCheckHitPattern::PFTrackHitInfo, PFCheckHitPattern::PFTrackHitInfo > PFCheckHitPattern::analyze ( edm::ESHandle< TrackerGeometry tkerGeomHandle_,
const reco::TrackBaseRef  track,
const TransientVertex vert 
)

PFCheck if hit pattern of this track is consistent with it being produced at given vertex. Pair.first gives number of hits on track in front of vertex. Pair.second gives number of missing hits between vertex and innermost hit on track.

Definition at line 103 of file PFCheckHitPattern.cc.

References Reference_intrackfit_cff::barrel, edm::RefToBase< T >::get(), reco::HitPattern::getHitPattern(), reco::HitPattern::getLayer(), reco::HitPattern::getSubStructure(), reco::TrackBase::hitPattern(), AnalysisDataFormats_SUSYBSMObjects::hp, i, init, reco::HitPattern::MISSING_INNER_HITS, reco::HitPattern::numberOfHits(), PV3DBase< T, PVType, FrameType >::perp(), TransientVertex::position(), reco::HitPattern::TRACK_HITS, reco::HitPattern::trackerHitFilter(), reco::HitPattern::validHitFilter(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by PFDisplacedVertexFinder::fitVertexFromSeed().

105 {
106 
107  // PFCheck if hit pattern of this track is consistent with it being produced
108  // at given vertex. Pair.first gives number of hits on track in front of vertex.
109  // Pair.second gives number of missing hits between vertex and innermost hit
110  // on track.
111 
112  // Initialise geometry info if not yet done.
113  if (!geomInitDone_) this->init(tkerGeomHandle_);
114 
115  // Get hit patterns of this track
116  const reco::HitPattern& hp = track.get()->hitPattern();
117 
118  // Count number of valid hits on track definately in front of the vertex,
119  // taking into account finite depth of each layer.
120  unsigned int nHitBefore = 0;
121  unsigned int nHitAfter = 0;
122 
123  for (int i = 0; i < hp.numberOfHits(HitPattern::TRACK_HITS); i++) {
124  uint32_t hit = hp.getHitPattern(HitPattern::TRACK_HITS, i);
125  if (hp.trackerHitFilter(hit) && hp.validHitFilter(hit)) {
126  uint32_t subDet = hp.getSubStructure(hit);
127  uint32_t layer = hp.getLayer(hit);
128  DetInfo detInfo(subDet, layer);
129  double maxRZ = rangeRorZ_[detInfo].second;
130 
131  if (this->barrel(subDet)) {
132  if (vert.position().perp() > maxRZ) nHitBefore++;
133  else nHitAfter++;
134  } else {
135  if (fabs(vert.position().z()) > maxRZ) nHitBefore++;
136  else nHitAfter++;
137  }
138  }
139  }
140 
141  // Count number of missing hits before the innermost hit on the track,
142  // taking into account finite depth of each layer.
143  unsigned int nMissHitAfter = 0;
144  unsigned int nMissHitBefore = 0;
145 
146  for (int i = 0; i < hp.numberOfHits(HitPattern::MISSING_INNER_HITS); i++) {
147  uint32_t hit = hp.getHitPattern(HitPattern::MISSING_INNER_HITS, i);
149  uint32_t subDet = reco::HitPattern::getSubStructure(hit);
150  uint32_t layer = reco::HitPattern::getLayer(hit);
151  DetInfo detInfo(subDet, layer);
152  double minRZ = rangeRorZ_[detInfo].first;
153 
154  // cout << "subDet = " << subDet << " layer = " << layer << " minRZ = " << minRZ << endl;
155 
156  if (this->barrel(subDet)) {
157  if (vert.position().perp() < minRZ) nMissHitAfter++;
158  else nMissHitBefore++;
159  } else {
160  if (fabs(vert.position().z()) < minRZ) nMissHitAfter++;
161  else nMissHitBefore++;
162  }
163  }
164  }
165 
166 
167  PFTrackHitInfo trackToVertex(nHitBefore, nMissHitBefore);
168  PFTrackHitInfo trackFromVertex(nHitAfter, nMissHitAfter);
169 
170 
171  return pair< PFTrackHitInfo, PFTrackHitInfo>(trackToVertex, trackFromVertex);
172 }
value_type const * get() const
Definition: RefToBase.h:225
bool geomInitDone_
Note if geometry info is already initialized.
int i
Definition: DBlmapReader.cc:9
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:680
T perp() const
Definition: PV3DBase.h:72
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:765
std::pair< unsigned int, unsigned int > PFTrackHitInfo
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
GlobalPoint position() const
T z() const
Definition: PV3DBase.h:64
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:671
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:657
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:437
std::pair< uint32_t, uint32_t > DetInfo
void init(edm::ESHandle< TrackerGeometry >)
Create map indicating r/z values of all layers/disks.
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:502
static bool barrel(uint32_t subDet)
Return a bool indicating if a given subdetector is in the barrel.
int numberOfHits(HitCategory category) const
Definition: HitPattern.h:785
bool PFCheckHitPattern::barrel ( uint32_t  subDet)
staticprivate

Return a bool indicating if a given subdetector is in the barrel.

Definition at line 95 of file PFCheckHitPattern.cc.

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

95  {
96  // Determines if given sub-detector is in the barrel.
97  return (subDet == StripSubdetector::TIB || subDet == StripSubdetector::TOB ||
99 }
void PFCheckHitPattern::init ( edm::ESHandle< TrackerGeometry tkerGeomHandle_)
private

Create map indicating r/z values of all layers/disks.

Definition at line 25 of file PFCheckHitPattern.cc.

References Reference_intrackfit_cff::barrel, ztail::d, i, and position.

25  {
26 
27  //
28  // Note min/max radius (z) of each barrel layer (endcap disk).
29  //
30 
31  geomInitDone_ = true;
32 
33  // Get Tracker geometry
34  const TrackingGeometry::DetContainer& dets = tkerGeomHandle_->dets();
35 
36  // Loop over all modules in the Tracker.
37  for (unsigned int i = 0; i < dets.size(); i++) {
38 
39  // Get subdet and layer of this module
40  DetInfo detInfo = this->interpretDetId(dets[i]->geographicalId());
41  uint32_t subDet = detInfo.first;
42 
43  // Note r (or z) of module if barrel (or endcap).
44  double r_or_z;
45  if (this->barrel(subDet)) {
46  r_or_z = dets[i]->position().perp();
47  } else {
48  r_or_z = fabs(dets[i]->position().z());
49  }
50 
51  // Recover min/max r/z value of this layer/disk found so far.
52  double minRZ = 999.;
53  double maxRZ = 0.;
54  if (rangeRorZ_.find(detInfo) != rangeRorZ_.end()) {
55  minRZ = rangeRorZ_[detInfo].first;
56  maxRZ = rangeRorZ_[detInfo].second;
57  }
58 
59  // Update with those of this module if it exceeds them.
60  if (minRZ > r_or_z) minRZ = r_or_z;
61  if (maxRZ < r_or_z) maxRZ = r_or_z;
62  rangeRorZ_[detInfo] = pair<double, double>(minRZ, maxRZ);
63  }
64 
65 #if 0
66  //def DEBUG_CHECKHITPATTERN
67  RZrangeMap::const_iterator d;
68  for (d = rangeRorZ_.begin(); d != rangeRorZ_.end(); d++) {
69  DetInfo detInfo = d->first;
70  pair<double, double> rangeRZ = d->second;
71  }
72 #endif
73 }
bool geomInitDone_
Note if geometry info is already initialized.
int i
Definition: DBlmapReader.cc:9
tuple d
Definition: ztail.py:151
static DetInfo interpretDetId(DetId detId)
std::pair< uint32_t, uint32_t > DetInfo
static int position[264][3]
Definition: ReadPGInfo.cc:509
std::vector< GeomDet const * > DetContainer
static bool barrel(uint32_t subDet)
Return a bool indicating if a given subdetector is in the barrel.
PFCheckHitPattern::DetInfo PFCheckHitPattern::interpretDetId ( DetId  detId)
staticprivate

Definition at line 75 of file PFCheckHitPattern.cc.

References PXFDetId::disk(), Exception, PXBDetId::layer(), TOBDetId::layer(), TIBDetId::layer(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, TIDDetId::wheel(), and TECDetId::wheel().

75  {
76  // Convert detId to a pair<uint32, uint32> consisting of the numbers used by HitPattern
77  // to identify subdetector and layer number respectively.
78  if (detId.subdetId() == StripSubdetector::TIB) {
79  return DetInfo( detId.subdetId() , TIBDetId(detId).layer() );
80  } else if (detId.subdetId() == StripSubdetector::TOB) {
81  return DetInfo( detId.subdetId() , TOBDetId(detId).layer() );
82  } else if (detId.subdetId() == StripSubdetector::TID) {
83  return DetInfo( detId.subdetId() , TIDDetId(detId).wheel() );
84  } else if (detId.subdetId() == StripSubdetector::TEC) {
85  return DetInfo( detId.subdetId() , TECDetId(detId).wheel() );
86  } else if (detId.subdetId() == PixelSubdetector::PixelBarrel) {
87  return DetInfo( detId.subdetId() , PXBDetId(detId).layer() );
88  } else if (detId.subdetId() == PixelSubdetector::PixelEndcap) {
89  return DetInfo( detId.subdetId() , PXFDetId(detId).disk() );
90  } else {
91  throw cms::Exception("RecoParticleFlow", "Found DetId that is not in Tracker");
92  }
93 }
unsigned int layer() const
layer id
Definition: TOBDetId.h:39
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
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 disk() const
disk id
Definition: PXFDetId.h:43
unsigned int wheel() const
wheel id
Definition: TECDetId.h:52
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
std::pair< uint32_t, uint32_t > DetInfo
unsigned int wheel() const
wheel id
Definition: TIDDetId.h:50
void PFCheckHitPattern::print ( const reco::TrackBaseRef  track) const

Print hit pattern on track.

Definition at line 174 of file PFCheckHitPattern.cc.

References gather_cfg::cout, edm::RefToBase< T >::get(), reco::TrackBase::hitPattern(), AnalysisDataFormats_SUSYBSMObjects::hp, reco::HitPattern::MISSING_INNER_HITS, reco::print(), and reco::HitPattern::TRACK_HITS.

174  {
175  // Get hit patterns of this track
176  const reco::HitPattern &hp = track.get()->hitPattern();
177 
178  cout<<"=== Hits on Track ==="<<endl;
180  cout<<"=== Hits before track ==="<<endl;
182 }
value_type const * get() const
Definition: RefToBase.h:225
void print(const reco::TrackBaseRef track) const
Print hit pattern on track.
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:437
tuple cout
Definition: gather_cfg.py:121
void PFCheckHitPattern::print ( const reco::HitPattern::HitCategory  category,
const reco::HitPattern hp 
) const
private

Definition at line 184 of file PFCheckHitPattern.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().

184  {
185  for (int i = 0; i < hp.numberOfHits(category); i++) {
186  uint32_t hit = hp.getHitPattern(category, i);
187  if (hp.trackerHitFilter(hit)) {
188  uint32_t subdet = hp.getSubStructure(hit);
189  uint32_t layer = hp.getLayer(hit);
190  cout<<"hit "<<i<<" subdet="<<subdet<<" layer="<<layer<<" type "<<hp.getHitType(hit)<<endl;
191  }
192  }
193 }
int i
Definition: DBlmapReader.cc:9
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:680
static uint32_t getHitType(uint16_t pattern)
Definition: HitPattern.h:713
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:671
static bool trackerHitFilter(uint16_t pattern)
Definition: HitPattern.h:657
tuple cout
Definition: gather_cfg.py:121
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:502
int numberOfHits(HitCategory category) const
Definition: HitPattern.h:785

Member Data Documentation

bool PFCheckHitPattern::geomInitDone_
private

Note if geometry info is already initialized.

Definition at line 75 of file PFCheckHitPattern.h.

RZrangeMap PFCheckHitPattern::rangeRorZ_
private

Definition at line 80 of file PFCheckHitPattern.h.