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 | Static 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 &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...
 

Static Private Attributes

static 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 108 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(), i, init, reco::HitPattern::numberOfHits(), PV3DBase< T, PVType, FrameType >::perp(), TransientVertex::position(), reco::TrackBase::trackerExpectedHitsInner(), reco::HitPattern::trackerHitFilter(), reco::HitPattern::validHitFilter(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by PFDisplacedVertexFinder::fitVertexFromSeed().

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

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

Definition at line 100 of file PFCheckHitPattern.cc.

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

100  {
101  // Determines if given sub-detector is in the barrel.
102  return (subDet == StripSubdetector::TIB || subDet == StripSubdetector::TOB ||
103  subDet == PixelSubdetector::PixelBarrel);
104 }
void PFCheckHitPattern::init ( edm::ESHandle< TrackerGeometry tkerGeomHandle_)
private

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

Definition at line 30 of file PFCheckHitPattern.cc.

References Reference_intrackfit_cff::barrel, i, position, and detailsBasic3DVector::z.

30  {
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  const TrackingGeometry::DetContainer& dets = tkerGeomHandle_->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());
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] = pair<double, double>(minRZ, maxRZ);
68  }
69 
70 #if 0
71  //def DEBUG_CHECKHITPATTERN
72  RZrangeMap::const_iterator d;
73  for (d = rangeRorZ_.begin(); d != rangeRorZ_.end(); d++) {
74  DetInfo detInfo = d->first;
75  pair<double, double> rangeRZ = d->second;
76  }
77 #endif
78 }
bool geomInitDone_
Note if geometry info is already initialized.
int i
Definition: DBlmapReader.cc:9
static RZrangeMap rangeRorZ_
std::vector< GeomDet * > DetContainer
double double double z
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
static DetInfo interpretDetId(DetId detId)
std::pair< uint32_t, uint32_t > DetInfo
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 80 of file PFCheckHitPattern.cc.

References PXFDetId::disk(), 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().

80  {
81  // Convert detId to a pair<uint32, uint32> consisting of the numbers used by HitPattern
82  // to identify subdetector and layer number respectively.
83  if (detId.subdetId() == StripSubdetector::TIB) {
84  return DetInfo( detId.subdetId() , TIBDetId(detId).layer() );
85  } else if (detId.subdetId() == StripSubdetector::TOB) {
86  return DetInfo( detId.subdetId() , TOBDetId(detId).layer() );
87  } else if (detId.subdetId() == StripSubdetector::TID) {
88  return DetInfo( detId.subdetId() , TIDDetId(detId).wheel() );
89  } else if (detId.subdetId() == StripSubdetector::TEC) {
90  return DetInfo( detId.subdetId() , TECDetId(detId).wheel() );
91  } else if (detId.subdetId() == PixelSubdetector::PixelBarrel) {
92  return DetInfo( detId.subdetId() , PXBDetId(detId).layer() );
93  } else if (detId.subdetId() == PixelSubdetector::PixelEndcap) {
94  return DetInfo( detId.subdetId() , PXFDetId(detId).disk() );
95  } else {
96  throw Genexception("Found DetId that is not in Tracker");
97  }
98 }
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:39
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 180 of file PFCheckHitPattern.cc.

References gather_cfg::cout, edm::RefToBase< T >::get(), reco::TrackBase::hitPattern(), reco::print(), and reco::TrackBase::trackerExpectedHitsInner().

180  {
181  // Get hit patterns of this track
182  const reco::HitPattern& hp = track.get()->hitPattern();
183  const reco::HitPattern& ip = track.get()->trackerExpectedHitsInner();
184 
185  cout<<"=== Hits on Track ==="<<endl;
186  this->print(hp);
187  cout<<"=== Hits before track ==="<<endl;
188  this->print(ip);
189 }
void print(const reco::TrackBaseRef track) const
Print hit pattern on track.
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
value_type const * get() const
Definition: RefToBase.h:212
void PFCheckHitPattern::print ( const reco::HitPattern hp) const
private

Definition at line 191 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().

191  {
192  for (int i = 0; i < hp.numberOfHits(); i++) {
193  uint32_t hit = hp.getHitPattern(i);
194  if (hp.trackerHitFilter(hit)) {
195  uint32_t subdet = hp.getSubStructure(hit);
196  uint32_t layer = hp.getLayer(hit);
197  cout<<"hit "<<i<<" subdet="<<subdet<<" layer="<<layer<<" type "<<hp.getHitType(hit)<<endl;
198  }
199  }
200 }
int i
Definition: DBlmapReader.cc:9
static uint32_t getLayer(uint32_t pattern)
Definition: HitPattern.h:485
static bool trackerHitFilter(uint32_t pattern)
Definition: HitPattern.h:466
static uint32_t getHitType(uint32_t pattern)
Definition: HitPattern.h:501
int numberOfHits() const
Definition: HitPattern.cc:213
static uint32_t getSubStructure(uint32_t pattern)
Definition: HitPattern.h:479
tuple cout
Definition: gather_cfg.py:121
uint32_t getHitPattern(int position) const
Definition: HitPattern.cc:144

Member Data Documentation

bool PFCheckHitPattern::geomInitDone_
private

Note if geometry info is already initialized.

Definition at line 75 of file PFCheckHitPattern.h.

PFCheckHitPattern::RZrangeMap PFCheckHitPattern::rangeRorZ_
staticprivate

Definition at line 80 of file PFCheckHitPattern.h.