CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
reco::PFDisplacedVertexCandidate Class Reference

A block of tracks linked together. More...

#include <PFDisplacedVertexCandidate.h>

Classes

struct  VertexLink
 

Public Types

typedef std::map< float, std::pair< int, int > > DistMap
 
typedef std::vector< float > DistVector
 
typedef std::map< unsigned int, VertexLinkVertexLinkData
 
enum  VertexLinkTest { LINKTEST_DCA, LINKTEST_DUMMY, LINKTEST_ALL }
 

Public Member Functions

void addElement (const TrackBaseRef)
 add a track Reference to the current Candidate More...
 
void associatedElements (const unsigned i, const VertexLinkData &vertexLinkData, std::multimap< float, unsigned > &sortedAssociates, const VertexLinkTest test=LINKTEST_DCA) const
 associate 2 elements More...
 
const GlobalPoint dcaPoint (unsigned ie1, unsigned ie2) const
 
DistVector distVector () const
 
void Dump (std::ostream &out=std::cout) const
 cout function More...
 
const std::vector< TrackBaseRef > & elements () const
 
bool isValid () const
 A Vertex Candidate is valid if it has at least two tracks. More...
 
unsigned nTracks () const
 
 PFDisplacedVertexCandidate ()
 Default constructor. More...
 
DistMap r2Map () const
 --—— Provide useful information --—— /// More...
 
DistVector r2Vector () const
 
void setLink (unsigned i1, unsigned i2, const float dist, const GlobalPoint &dcaPoint, const VertexLinkTest test=LINKTEST_DCA)
 
const TrackBaseReftref (unsigned ie) const
 
const VertexLinkDatavertexLinkData () const
 

Private Member Functions

const float dist (unsigned ie1, unsigned ie2) const
 --—— Internal tools --—— /// More...
 
bool matrix2vector (unsigned i, unsigned j, unsigned &index) const
 
bool testLink (unsigned ie1, unsigned ie2) const
 test if a link between two tracks is valid: value_link =! -1 More...
 
unsigned vertexLinkDataSize () const
 --—— Storage of the information --—— /// More...
 

Private Attributes

std::vector< TrackBaseRefelements_
 --—— MEMBERS --—— /// More...
 
VertexLinkData vertexLinkData_
 map of links between tracks More...
 

Friends

std::ostream & operator<< (std::ostream &, const PFDisplacedVertexCandidate &)
 cout function More...
 

Detailed Description

A block of tracks linked together.

Author
Gouzevitch Maxime
Date
November 2009

A DisplacedVertexCandidate is a format produced by the DisplacedVertexCandidateFinder to hold a Collection of Refs to the tracks linked together by DCA. It contains:

Definition at line 28 of file PFDisplacedVertexCandidate.h.

Member Typedef Documentation

◆ DistMap

typedef std::map<float, std::pair<int, int> > reco::PFDisplacedVertexCandidate::DistMap

A type to provide the information about the position of DCA Points or values of DCA.

Definition at line 49 of file PFDisplacedVertexCandidate.h.

◆ DistVector

Definition at line 50 of file PFDisplacedVertexCandidate.h.

◆ VertexLinkData

Definition at line 45 of file PFDisplacedVertexCandidate.h.

Member Enumeration Documentation

◆ VertexLinkTest

Test used for the track linkind. For the moment only DCA is used, but other are possibles like distance between inner hits.

Enumerator
LINKTEST_DCA 
LINKTEST_DUMMY 
LINKTEST_ALL 

Definition at line 43 of file PFDisplacedVertexCandidate.h.

Constructor & Destructor Documentation

◆ PFDisplacedVertexCandidate()

PFDisplacedVertexCandidate::PFDisplacedVertexCandidate ( )

Default constructor.

Definition at line 9 of file PFDisplacedVertexCandidate.cc.

9 {}

Member Function Documentation

◆ addElement()

void PFDisplacedVertexCandidate::addElement ( const TrackBaseRef  element)

add a track Reference to the current Candidate

Definition at line 11 of file PFDisplacedVertexCandidate.cc.

Referenced by PFDisplacedVertexCandidateFinder::associate().

11 { elements_.push_back(element); }
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///

◆ associatedElements()

void PFDisplacedVertexCandidate::associatedElements ( const unsigned  i,
const VertexLinkData vertexLinkData,
std::multimap< float, unsigned > &  sortedAssociates,
const VertexLinkTest  test = LINKTEST_DCA 
) const

associate 2 elements

Definition at line 39 of file PFDisplacedVertexCandidate.cc.

References mps_fire::i, caHitNtupletGeneratorKernels::if(), and ctpps_dqm_sourceclient-live_cfg::test.

42  {
43  sortedAssociates.clear();
44 
45  // i is too large
46  if (i > elements_.size())
47  return;
48  // assert(i>=0); // i >= 0, since i is unsigned
49  for (unsigned ie = 0; ie < elements_.size(); ie++) {
50  // considered element itself
51  if (ie == i) {
52  continue;
53  }
54 
55  // Order the elements by increasing distance !
56 
57  unsigned index = 0;
58  if (!matrix2vector(i, ie, index))
59  continue;
60 
61  float c2 = -1;
62  VertexLinkData::const_iterator it = vertexLinkData.find(index);
63  if (it != vertexLinkData.end() && (((1 << test) & it->second.test_) != 0 || (test == LINKTEST_ALL)))
64  c2 = it->second.distance_;
65 
66  // not associated
67  if (c2 < 0) {
68  continue;
69  }
70 
71  sortedAssociates.insert(pair<float, unsigned>(c2, ie));
72  }
73 }
const VertexLinkData & vertexLinkData() const
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const

◆ dcaPoint()

const GlobalPoint PFDisplacedVertexCandidate::dcaPoint ( unsigned  ie1,
unsigned  ie2 
) const
Returns
DCA point between two tracks

Definition at line 126 of file PFDisplacedVertexCandidate.cc.

Referenced by PFDisplacedVertexFinder::findSeedsFromCandidate().

126  {
127  GlobalPoint dcaPoint(1e10, 1e10, 1e10);
128 
129  unsigned index = 0;
130  if (!matrix2vector(ie1, ie2, index))
131  return dcaPoint;
132  VertexLinkData::const_iterator it = vertexLinkData_.find(index);
133  if (it != vertexLinkData_.end())
134  dcaPoint = it->second.dcaPoint_;
135 
136  return dcaPoint;
137 }
const GlobalPoint dcaPoint(unsigned ie1, unsigned ie2) const
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
VertexLinkData vertexLinkData_
map of links between tracks

◆ dist()

const float PFDisplacedVertexCandidate::dist ( unsigned  ie1,
unsigned  ie2 
) const
private

--—— Internal tools --—— ///

Returns
distance of link between two tracks

Definition at line 148 of file PFDisplacedVertexCandidate.cc.

148  {
149  float dist = -1;
150 
151  unsigned index = 0;
152  if (!matrix2vector(ie1, ie2, index))
153  return dist;
154  VertexLinkData::const_iterator it = vertexLinkData_.find(index);
155  if (it != vertexLinkData_.end())
156  dist = it->second.distance_;
157 
158  return dist;
159 }
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
VertexLinkData vertexLinkData_
map of links between tracks
const float dist(unsigned ie1, unsigned ie2) const
--—— Internal tools --—— ///

◆ distVector()

PFDisplacedVertexCandidate::DistVector PFDisplacedVertexCandidate::distVector ( ) const
Returns
the vector of DCA useful for DCA

Definition at line 111 of file PFDisplacedVertexCandidate.cc.

References ztail::d.

111  {
113 
114  for (unsigned ie1 = 0; ie1 < elements_.size(); ie1++)
115  for (unsigned ie2 = ie1 + 1; ie2 < elements_.size(); ie2++) {
116  float d = dist(ie1, ie2);
117  if (d < -0.5)
118  continue;
119 
120  distVector.push_back(d);
121  }
122 
123  return distVector;
124 }
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
d
Definition: ztail.py:151
const float dist(unsigned ie1, unsigned ie2) const
--—— Internal tools --—— ///

◆ Dump()

void PFDisplacedVertexCandidate::Dump ( std::ostream &  out = std::cout) const

cout function

Definition at line 192 of file PFDisplacedVertexCandidate.cc.

References bookConverter::elements, MillePedeFileConverter_cfg::out, Pi, DiDispStaMuonMonitor_cfi::pt, and mathSSE::sqrt().

192  {
193  if (!out)
194  return;
195 
196  const vector<TrackBaseRef>& elements = elements_;
197  out << "\t--- DisplacedVertexCandidate --- " << endl;
198  out << "\tnumber of elements: " << elements.size() << endl;
199 
200  // Build element label (string) : elid from type, layer and occurence number
201  // use stringstream instead of sprintf to concatenate string and integer into string
202  for (unsigned ie = 0; ie < elements.size(); ie++) {
203  math::XYZPoint Pi(elements[ie].get()->innerPosition());
204  math::XYZPoint Po(elements[ie].get()->outerPosition());
205 
206  float innermost_radius = sqrt(Pi.x() * Pi.x() + Pi.y() * Pi.y() + Pi.z() * Pi.z());
207  float outermost_radius = sqrt(Po.x() * Po.x() + Po.y() * Po.y() + Po.z() * Po.z());
208  float innermost_rho = sqrt(Pi.x() * Pi.x() + Pi.y() * Pi.y());
209  float outermost_rho = sqrt(Po.x() * Po.x() + Po.y() * Po.y());
210 
211  double pt = elements[ie]->pt();
212 
213  out << "ie = " << elements[ie].key() << " pt = " << pt << " innermost hit radius = " << innermost_radius
214  << " rho = " << innermost_rho << " outermost hit radius = " << outermost_radius << " rho = " << outermost_rho
215  << endl;
216  }
217 
218  out << endl;
219 }
const double Pi
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
T sqrt(T t)
Definition: SSEVec.h:19
const std::vector< TrackBaseRef > & elements() const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12

◆ elements()

const std::vector<TrackBaseRef>& reco::PFDisplacedVertexCandidate::elements ( ) const
inline
Returns
the vector of Refs to tracks

Definition at line 95 of file PFDisplacedVertexCandidate.h.

References elements_.

Referenced by PFDisplacedVertexCandidateFinder::associate(), PFDisplacedVertexCandidateFinder::findDisplacedVertexCandidates(), and PFDisplacedVertexCandidateFinder::packLinks().

95 { return elements_; }
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///

◆ isValid()

bool reco::PFDisplacedVertexCandidate::isValid ( void  ) const
inline

A Vertex Candidate is valid if it has at least two tracks.

Definition at line 89 of file PFDisplacedVertexCandidate.h.

References elements_.

Referenced by ntupleDataFormat._Object::_checkIsValid(), PFDisplacedVertexCandidateFinder::findDisplacedVertexCandidates(), and core.AutoHandle.AutoHandle::ReallyLoad().

89 { return elements_.size() > 1; }
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///

◆ matrix2vector()

bool PFDisplacedVertexCandidate::matrix2vector ( unsigned  i,
unsigned  j,
unsigned &  index 
) const
private

makes the correspondance between a 2d element matrix and the 1D vector which is the most compact way to store the matrix

Definition at line 172 of file PFDisplacedVertexCandidate.cc.

References combine::missing, and edm::swap().

172  {
173  unsigned size = elements_.size();
174  if (iindex == jindex || iindex >= size || jindex >= size) {
175  return false;
176  }
177 
178  if (iindex > jindex)
179  swap(iindex, jindex);
180 
181  index = jindex - iindex - 1;
182 
183  if (iindex > 0) {
184  index += iindex * size;
185  unsigned missing = iindex * (iindex + 1) / 2;
186  index -= missing;
187  }
188 
189  return true;
190 }
size
Write out results.
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
missing
Definition: combine.py:5
void swap(reco::ClusterRemovalInfo &cri1, reco::ClusterRemovalInfo &cri2)

◆ nTracks()

unsigned reco::PFDisplacedVertexCandidate::nTracks ( ) const
inline
Returns
the number of tracks associated to the candidate

Definition at line 98 of file PFDisplacedVertexCandidate.h.

References elements_.

98 { return elements_.size(); }
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///

◆ r2Map()

PFDisplacedVertexCandidate::DistMap PFDisplacedVertexCandidate::r2Map ( ) const

--—— Provide useful information --—— ///

Returns
the map of Radius^2 to DCA Points

Definition at line 77 of file PFDisplacedVertexCandidate.cc.

References diffTwoXMLs::r2.

Referenced by PFDisplacedVertexFinder::findSeedsFromCandidate().

77  {
78  DistMap r2Map;
79 
80  for (unsigned ie1 = 0; ie1 < elements_.size(); ie1++)
81  for (unsigned ie2 = ie1 + 1; ie2 < elements_.size(); ie2++) {
82  GlobalPoint P = dcaPoint(ie1, ie2);
83  if (P.x() > 1e9)
84  continue;
85 
86  float r2 = P.x() * P.x() + P.y() * P.y() + P.z() * P.z();
87 
88  r2Map.insert(pair<float, pair<int, int> >(r2, pair<int, int>(ie1, ie2)));
89  }
90 
91  return r2Map;
92 }
const GlobalPoint dcaPoint(unsigned ie1, unsigned ie2) const
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
std::pair< OmniClusterRef, TrackingParticleRef > P
std::map< float, std::pair< int, int > > DistMap
DistMap r2Map() const
--—— Provide useful information --—— ///

◆ r2Vector()

PFDisplacedVertexCandidate::DistVector PFDisplacedVertexCandidate::r2Vector ( ) const
Returns
the vector of Radius^2 to DCA Points useful for FWLite

Definition at line 94 of file PFDisplacedVertexCandidate.cc.

References diffTwoXMLs::r2.

94  {
96 
97  for (unsigned ie1 = 0; ie1 < elements_.size(); ie1++)
98  for (unsigned ie2 = ie1 + 1; ie2 < elements_.size(); ie2++) {
99  GlobalPoint P = dcaPoint(ie1, ie2);
100  if (P.x() > 1e9)
101  continue;
102 
103  float r2 = P.x() * P.x() + P.y() * P.y() + P.z() * P.z();
104 
105  r2Vector.push_back(r2);
106  }
107 
108  return r2Vector;
109 }
const GlobalPoint dcaPoint(unsigned ie1, unsigned ie2) const
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
std::pair< OmniClusterRef, TrackingParticleRef > P

◆ setLink()

void PFDisplacedVertexCandidate::setLink ( unsigned  i1,
unsigned  i2,
const float  dist,
const GlobalPoint dcaPoint,
const VertexLinkTest  test = LINKTEST_DCA 
)

set a link between elements of indices i1 and i2, of "distance" dist the link is set in the linkData vector provided as an argument. As indicated by the 'const' statement, 'this' is not modified.

Definition at line 13 of file PFDisplacedVertexCandidate.cc.

References cms::cuda::assert(), testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, MainPageGenerator::l, convertSQLiteXML::ok, and ctpps_dqm_sourceclient-live_cfg::test.

Referenced by PFDisplacedVertexCandidateFinder::packLinks().

14  {
16 
17  unsigned index = 0;
18  bool ok = matrix2vector(i1, i2, index);
19 
20  if (ok) {
21  //ignore the -1, -1 pair
22  if (dist > -0.5) {
23  VertexLink& l = vertexLinkData_[index];
24  l.distance_ = dist;
25  l.dcaPoint_ = dcaPoint;
26  l.test_ |= (1 << test);
27  } else //delete if existing
28  {
29  VertexLinkData::iterator it = vertexLinkData_.find(index);
30  if (it != vertexLinkData_.end())
31  vertexLinkData_.erase(it);
32  }
33 
34  } else {
35  assert(0);
36  }
37 }
const GlobalPoint dcaPoint(unsigned ie1, unsigned ie2) const
assert(be >=bs)
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
VertexLinkData vertexLinkData_
map of links between tracks
const float dist(unsigned ie1, unsigned ie2) const
--—— Internal tools --—— ///

◆ testLink()

bool PFDisplacedVertexCandidate::testLink ( unsigned  ie1,
unsigned  ie2 
) const
private

test if a link between two tracks is valid: value_link =! -1

Definition at line 141 of file PFDisplacedVertexCandidate.cc.

References ztail::d.

141  {
142  float d = dist(ie1, ie2);
143  if (d < -0.5)
144  return false;
145  return true;
146 }
d
Definition: ztail.py:151
const float dist(unsigned ie1, unsigned ie2) const
--—— Internal tools --—— ///

◆ tref()

const TrackBaseRef& reco::PFDisplacedVertexCandidate::tref ( unsigned  ie) const
inline
Returns
the reference to a given tracks

Definition at line 92 of file PFDisplacedVertexCandidate.h.

References elements_.

Referenced by PFDisplacedVertexFinder::findSeedsFromCandidate().

92 { return elements_[ie]; }
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///

◆ vertexLinkData()

const VertexLinkData& reco::PFDisplacedVertexCandidate::vertexLinkData ( ) const
inline
Returns
the map of link data

Definition at line 101 of file PFDisplacedVertexCandidate.h.

References vertexLinkData_.

101 { return vertexLinkData_; }
VertexLinkData vertexLinkData_
map of links between tracks

◆ vertexLinkDataSize()

unsigned PFDisplacedVertexCandidate::vertexLinkDataSize ( ) const
private

--—— Storage of the information --—— ///

Those are the tools from PFBlockAlgo

Returns
size of linkData_, calculated from the number of elements

Definition at line 163 of file PFDisplacedVertexCandidate.cc.

References dqmiodumpmetadata::n.

163  {
164  unsigned n = elements_.size();
165 
166  // number of possible undirected links between n elements.
167  // reflective links impossible.
168 
169  return n * (n - 1) / 2;
170 }
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  ,
const PFDisplacedVertexCandidate  
)
friend

cout function

Member Data Documentation

◆ elements_

std::vector<TrackBaseRef> reco::PFDisplacedVertexCandidate::elements_
private

--—— MEMBERS --—— ///

vector of refs to the associated tracks

Definition at line 131 of file PFDisplacedVertexCandidate.h.

Referenced by elements(), isValid(), nTracks(), and tref().

◆ vertexLinkData_

VertexLinkData reco::PFDisplacedVertexCandidate::vertexLinkData_
private

map of links between tracks

Definition at line 134 of file PFDisplacedVertexCandidate.h.

Referenced by vertexLinkData().