CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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,
VertexLink
VertexLinkData
 
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 29 of file PFDisplacedVertexCandidate.h.

Member Typedef Documentation

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 58 of file PFDisplacedVertexCandidate.h.

typedef std::vector< float > reco::PFDisplacedVertexCandidate::DistVector

Definition at line 59 of file PFDisplacedVertexCandidate.h.

Definition at line 54 of file PFDisplacedVertexCandidate.h.

Member Enumeration Documentation

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 47 of file PFDisplacedVertexCandidate.h.

Constructor & Destructor Documentation

PFDisplacedVertexCandidate::PFDisplacedVertexCandidate ( )

Default constructor.

Definition at line 10 of file PFDisplacedVertexCandidate.cc.

10 {}

Member Function Documentation

void PFDisplacedVertexCandidate::addElement ( const TrackBaseRef  element)

add a track Reference to the current Candidate

Definition at line 12 of file PFDisplacedVertexCandidate.cc.

Referenced by PFDisplacedVertexCandidateFinder::associate().

12  {
13  elements_.push_back( element );
14 }
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
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 49 of file PFDisplacedVertexCandidate.cc.

References cmsHarvester::index, and run_regression::test.

52  {
53 
54  sortedAssociates.clear();
55 
56  // i is too large
57  if( i > elements_.size() ) return;
58  // assert(i>=0); // i >= 0, since i is unsigned
59  for(unsigned ie=0; ie<elements_.size(); ie++) {
60 
61  // considered element itself
62  if( ie == i ) {
63  continue;
64  }
65 
66  // Order the elements by increasing distance !
67 
68  unsigned index = 0;
69  if( !matrix2vector(i, ie, index) ) continue;
70 
71  float c2=-1;
72  VertexLinkData::const_iterator it = vertexLinkData.find(index);
73  if ( it!=vertexLinkData.end() &&
74  ( ( (1 << test ) & it->second.test_) !=0 || (test == LINKTEST_ALL) ) )
75  c2= it->second.distance_;
76 
77  // not associated
78  if( c2 < 0 ) {
79  continue;
80  }
81 
82  sortedAssociates.insert( pair<float,unsigned>(c2, ie) );
83  }
84 }
int i
Definition: DBlmapReader.cc:9
const VertexLinkData & vertexLinkData() const
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
const GlobalPoint PFDisplacedVertexCandidate::dcaPoint ( unsigned  ie1,
unsigned  ie2 
) const
Returns
DCA point between two tracks

Definition at line 155 of file PFDisplacedVertexCandidate.cc.

References cmsHarvester::index.

Referenced by PFDisplacedVertexFinder::findSeedsFromCandidate().

155  {
156 
157  GlobalPoint dcaPoint(1e10,1e10,1e10);
158 
159  unsigned index = 0;
160  if( !matrix2vector(ie1, ie2, index) ) return dcaPoint;
161  VertexLinkData::const_iterator it = vertexLinkData_.find(index);
162  if( it!=vertexLinkData_.end() ) dcaPoint = it->second.dcaPoint_;
163 
164  return dcaPoint;
165 
166 }
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
const GlobalPoint dcaPoint(unsigned ie1, unsigned ie2) const
VertexLinkData vertexLinkData_
map of links between tracks
const float PFDisplacedVertexCandidate::dist ( unsigned  ie1,
unsigned  ie2 
) const
private

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

Returns
distance of link between two tracks

Definition at line 178 of file PFDisplacedVertexCandidate.cc.

References cmsHarvester::index.

178  {
179 
180  float dist = -1;
181 
182  unsigned index = 0;
183  if( !matrix2vector(ie1, ie2, index) ) return dist;
184  VertexLinkData::const_iterator it = vertexLinkData_.find(index);
185  if( it!=vertexLinkData_.end() ) dist= it->second.distance_;
186 
187  return dist;
188 
189 }
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
const float dist(unsigned ie1, unsigned ie2) const
--—— Internal tools --—— ///
VertexLinkData vertexLinkData_
map of links between tracks
PFDisplacedVertexCandidate::DistVector PFDisplacedVertexCandidate::distVector ( ) const
Returns
the vector of DCA useful for DCA

Definition at line 136 of file PFDisplacedVertexCandidate.cc.

References ztail::d.

136  {
137 
139 
140 
141  for (unsigned ie1 = 0; ie1<elements_.size(); ie1++)
142  for (unsigned ie2 = ie1+1; ie2<elements_.size(); ie2++){
143 
144  float d = dist(ie1, ie2);
145  if (d < -0.5) continue;
146 
147  distVector.push_back(d);
148 
149  }
150 
151  return distVector;
152 
153 }
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
tuple d
Definition: ztail.py:151
const float dist(unsigned ie1, unsigned ie2) const
--—— Internal tools --—— ///
void PFDisplacedVertexCandidate::Dump ( std::ostream &  out = std::cout) const

cout function

Definition at line 238 of file PFDisplacedVertexCandidate.cc.

References asciidump::elements, Pi, EnergyCorrector::pt, and mathSSE::sqrt().

238  {
239  if(! out ) return;
240 
241  const vector < TrackBaseRef >& elements = elements_;
242  out<<"\t--- DisplacedVertexCandidate --- "<<endl;
243  out<<"\tnumber of elements: "<<elements.size()<<endl;
244 
245  // Build element label (string) : elid from type, layer and occurence number
246  // use stringstream instead of sprintf to concatenate string and integer into string
247  for(unsigned ie=0; ie<elements.size(); ie++) {
248 
249  math::XYZPoint Pi(elements[ie].get()->innerPosition());
250  math::XYZPoint Po(elements[ie].get()->outerPosition());
251 
252  float innermost_radius = sqrt(Pi.x()*Pi.x() + Pi.y()*Pi.y() + Pi.z()*Pi.z());
253  float outermost_radius = sqrt(Po.x()*Po.x() + Po.y()*Po.y() + Po.z()*Po.z());
254  float innermost_rho = sqrt(Pi.x()*Pi.x() + Pi.y()*Pi.y());
255  float outermost_rho = sqrt(Po.x()*Po.x() + Po.y()*Po.y());
256 
257  double pt = elements[ie]->pt();
258 
259 
260  out<<"ie = " << elements[ie].key() << " pt = " << pt
261  <<" innermost hit radius = " << innermost_radius << " rho = " << innermost_rho
262  <<" outermost hit radius = " << outermost_radius << " rho = " << outermost_rho
263  <<endl;
264  }
265 
266  out<<endl;
267 
268 
269 }
const double Pi
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
T sqrt(T t)
Definition: SSEVec.h:48
tuple out
Definition: dbtoconf.py:99
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const std::vector< TrackBaseRef > & elements() const
const std::vector< TrackBaseRef >& reco::PFDisplacedVertexCandidate::elements ( ) const
inline
Returns
the vector of Refs to tracks

Definition at line 110 of file PFDisplacedVertexCandidate.h.

References elements_.

Referenced by PFDisplacedVertexCandidateFinder::packLinks().

111  {return elements_;}
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
bool reco::PFDisplacedVertexCandidate::isValid ( void  ) const
inline

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

Definition at line 101 of file PFDisplacedVertexCandidate.h.

References elements_.

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

102  {return elements_.size()>1;}
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
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 212 of file PFDisplacedVertexCandidate.cc.

References combine::missing, findQualityFiles::size, and std::swap().

214  {
215 
216  unsigned size = elements_.size();
217  if( iindex == jindex ||
218  iindex >= size ||
219  jindex >= size ) {
220  return false;
221  }
222 
223  if( iindex > jindex )
224  swap( iindex, jindex);
225 
226 
227  index = jindex-iindex-1;
228 
229  if(iindex>0) {
230  index += iindex*size;
231  unsigned missing = iindex*(iindex+1)/2;
232  index -= missing;
233  }
234 
235  return true;
236 }
dictionary missing
Definition: combine.py:4
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
tuple size
Write out results.
void swap(reco::ClusterRemovalInfo &cri1, reco::ClusterRemovalInfo &cri2)
unsigned reco::PFDisplacedVertexCandidate::nTracks ( ) const
inline
Returns
the number of tracks associated to the candidate

Definition at line 114 of file PFDisplacedVertexCandidate.h.

References elements_.

115  {return elements_.size();}
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
PFDisplacedVertexCandidate::DistMap PFDisplacedVertexCandidate::r2Map ( ) const

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

Returns
the map of Radius^2 to DCA Points

Definition at line 95 of file PFDisplacedVertexCandidate.cc.

References P, and diffTwoXMLs::r2.

Referenced by PFDisplacedVertexFinder::findSeedsFromCandidate().

95  {
96 
97  DistMap r2Map;
98 
99  for (unsigned ie1 = 0; ie1<elements_.size(); ie1++)
100  for (unsigned ie2 = ie1+1; ie2<elements_.size(); ie2++){
101 
102  GlobalPoint P = dcaPoint(ie1, ie2);
103  if (P.x() > 1e9) continue;
104 
105  float r2 = P.x()*P.x()+P.y()*P.y()+P.z()*P.z();
106 
107  r2Map.insert(pair<float, pair<int,int> >(r2, pair <int, int>(ie1, ie2)));
108  }
109 
110  return r2Map;
111 
112 }
T y() const
Definition: PV3DBase.h:63
#define P
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
std::map< float, std::pair< int, int > > DistMap
const GlobalPoint dcaPoint(unsigned ie1, unsigned ie2) const
T z() const
Definition: PV3DBase.h:64
DistMap r2Map() const
--—— Provide useful information --—— ///
T x() const
Definition: PV3DBase.h:62
PFDisplacedVertexCandidate::DistVector PFDisplacedVertexCandidate::r2Vector ( ) const
Returns
the vector of Radius^2 to DCA Points useful for FWLite

Definition at line 116 of file PFDisplacedVertexCandidate.cc.

References P, and diffTwoXMLs::r2.

116  {
117 
119 
120  for (unsigned ie1 = 0; ie1<elements_.size(); ie1++)
121  for (unsigned ie2 = ie1+1; ie2<elements_.size(); ie2++){
122 
123  GlobalPoint P = dcaPoint(ie1, ie2);
124  if (P.x() > 1e9) continue;
125 
126  float r2 = P.x()*P.x()+P.y()*P.y()+P.z()*P.z();
127 
128  r2Vector.push_back(r2);
129  }
130 
131  return r2Vector;
132 
133 }
T y() const
Definition: PV3DBase.h:63
#define P
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
const GlobalPoint dcaPoint(unsigned ie1, unsigned ie2) const
T z() const
Definition: PV3DBase.h:64
T x() const
Definition: PV3DBase.h:62
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 17 of file PFDisplacedVertexCandidate.cc.

References assert(), reco::PFDisplacedVertexCandidate::VertexLink::dcaPoint_, reco::PFDisplacedVertexCandidate::VertexLink::distance_, cmsHarvester::index, prof2calltree::l, convertSQLiteXML::ok, run_regression::test, and reco::PFDisplacedVertexCandidate::VertexLink::test_.

Referenced by PFDisplacedVertexCandidateFinder::packLinks().

21  {
22 
23 
25 
26  unsigned index = 0;
27  bool ok = matrix2vector(i1,i2, index);
28 
29  if(ok) {
30  //ignore the -1, -1 pair
31  if ( dist > -0.5 ) {
32  VertexLink & l = vertexLinkData_[index];
33  l.distance_ = dist;
34  l.dcaPoint_ = dcaPoint;
35  l.test_ |= (1 << test);
36  } else //delete if existing
37  {
38  VertexLinkData::iterator it = vertexLinkData_.find(index);
39  if(it!=vertexLinkData_.end()) vertexLinkData_.erase(it);
40  }
41 
42  } else {
43  assert(0);
44  }
45 
46 }
assert(m_qm.get())
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
const GlobalPoint dcaPoint(unsigned ie1, unsigned ie2) const
const float dist(unsigned ie1, unsigned ie2) const
--—— Internal tools --—— ///
VertexLinkData vertexLinkData_
map of links between tracks
bool PFDisplacedVertexCandidate::testLink ( unsigned  ie1,
unsigned  ie2 
) const
private

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

Definition at line 171 of file PFDisplacedVertexCandidate.cc.

References ztail::d.

171  {
172  float d = dist( ie1, ie2);
173  if (d < -0.5) return false;
174  return true;
175 }
tuple d
Definition: ztail.py:151
const float dist(unsigned ie1, unsigned ie2) const
--—— Internal tools --—— ///
const TrackBaseRef& reco::PFDisplacedVertexCandidate::tref ( unsigned  ie) const
inline
Returns
the reference to a given tracks

Definition at line 106 of file PFDisplacedVertexCandidate.h.

References elements_.

Referenced by PFDisplacedVertexFinder::findSeedsFromCandidate().

107  {return elements_[ie];}
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///
const VertexLinkData& reco::PFDisplacedVertexCandidate::vertexLinkData ( ) const
inline
Returns
the map of link data

Definition at line 119 of file PFDisplacedVertexCandidate.h.

References vertexLinkData_.

120  {return vertexLinkData_;}
VertexLinkData vertexLinkData_
map of links between tracks
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 202 of file PFDisplacedVertexCandidate.cc.

References gen::n.

202  {
203  unsigned n = elements_.size();
204 
205  // number of possible undirected links between n elements.
206  // reflective links impossible.
207 
208  return n*(n-1)/2;
209 }
std::vector< TrackBaseRef > elements_
--—— MEMBERS --—— ///

Friends And Related Function Documentation

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

cout function

Member Data Documentation

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

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

vector of refs to the associated tracks

Definition at line 153 of file PFDisplacedVertexCandidate.h.

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

VertexLinkData reco::PFDisplacedVertexCandidate::vertexLinkData_
private

map of links between tracks

Definition at line 156 of file PFDisplacedVertexCandidate.h.

Referenced by vertexLinkData().