CMS 3D CMS Logo

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>

List of all members.

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
void associatedElements (const unsigned i, const VertexLinkData &vertexLinkData, std::multimap< float, unsigned > &sortedAssociates, const VertexLinkTest test=LINKTEST_DCA) const
 associate 2 elements
const GlobalPoint dcaPoint (unsigned ie1, unsigned ie2) const
DistVector distVector () const
void Dump (std::ostream &out=std::cout) const
 cout function
const std::vector< TrackBaseRef > & elements () const
bool isValid () const
 A Vertex Candidate is valid if it has at least two tracks.
unsigned nTracks () const
 PFDisplacedVertexCandidate ()
 Default constructor.
DistMap r2Map () const
 -------- Provide useful information -------- ///
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 -------- ///
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
unsigned vertexLinkDataSize () const
 -------- Storage of the information -------- ///

Private Attributes

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

Friends

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

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.

{}

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

                                                                      {
  elements_.push_back( element ); 
}
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 75 of file PFBlock.cc.

References getHLTprescales::index, and NONE.

                                                        {

  sortedAssociates.clear();
  
  // i is too large
  if( i > elements_.size() ) return;
  // assert(i>=0); i >= 0, since i is unsigned
  
  for(unsigned ie=0; ie<elements_.size(); ie++) {
    
    // considered element itself
    if( ie == i ) {
      continue;
    }
    // not the right type
    if(type !=  PFBlockElement::NONE && 
       elements_[ie].type() != type ) {
      continue;
    }

    // Order the elements by increasing distance !

    unsigned index = 0;
    if( !matrix2vector(i, ie, index) ) continue;

    double c2=-1;
    LinkData::const_iterator it =  linkData.find(index);
    if ( it!=linkData.end() && 
         ( ( (1 << test ) & it->second.test) !=0 || (test == LINKTEST_ALL) ) ) 
      c2= it->second.distance;

    // not associated
    if( c2 < 0 ) { 
      continue;
    }

    sortedAssociates.insert( pair<double,unsigned>(c2, ie) );
  }
} 
const GlobalPoint PFDisplacedVertexCandidate::dcaPoint ( unsigned  ie1,
unsigned  ie2 
) const
Returns:
DCA point between two tracks

Definition at line 155 of file PFDisplacedVertexCandidate.cc.

Referenced by PFDisplacedVertexFinder::findSeedsFromCandidate().

                                                                                        {

  GlobalPoint dcaPoint(1e10,1e10,1e10);

  unsigned index = 0;
  if( !matrix2vector(ie1, ie2, index) ) return dcaPoint;
  VertexLinkData::const_iterator it =  vertexLinkData_.find(index);
  if( it!=vertexLinkData_.end() ) dcaPoint = it->second.dcaPoint_;

  return dcaPoint;

}
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.

                                                                              {

  float dist = -1;

  unsigned index = 0;
  if( !matrix2vector(ie1, ie2, index) ) return dist;
  VertexLinkData::const_iterator it =  vertexLinkData_.find(index);
  if( it!=vertexLinkData_.end() ) dist= it->second.distance_;

  return dist;

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

Definition at line 136 of file PFDisplacedVertexCandidate.cc.

                                                                                  {

  DistVector distVector;


  for (unsigned ie1 = 0; ie1<elements_.size(); ie1++)
    for (unsigned ie2 = ie1+1; ie2<elements_.size(); ie2++){

      float d = dist(ie1, ie2);
      if (d < -0.5) continue;

      distVector.push_back(d);

    }

  return distVector;

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

cout function

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_.

      {return elements_;}
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().

      {return elements_.size()>1;}    
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().

                                                                        {

  unsigned size = elements_.size();
  if( iindex == jindex || 
      iindex >=  size ||
      jindex >=  size ) {
    return false;
  }
  
  if( iindex > jindex ) 
    swap( iindex, jindex);

  
  index = jindex-iindex-1;

  if(iindex>0) {
    index += iindex*size;
    unsigned missing = iindex*(iindex+1)/2;
    index -= missing;
  }
  
  return true;
}
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_.

      {return elements_.size();}
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.

Referenced by PFDisplacedVertexFinder::findSeedsFromCandidate().

                                                                          {

  DistMap r2Map;

  for (unsigned ie1 = 0; ie1<elements_.size(); ie1++)
    for (unsigned ie2 = ie1+1; ie2<elements_.size(); ie2++){

      GlobalPoint P = dcaPoint(ie1, ie2);
      if (P.x() > 1e9) continue;

      float r2 = P.x()*P.x()+P.y()*P.y()+P.z()*P.z();

      r2Map.insert(pair<float, pair<int,int> >(r2, pair <int, int>(ie1, ie2)));
    }

  return r2Map;

}
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.

                                                                                {

  DistVector r2Vector;

  for (unsigned ie1 = 0; ie1<elements_.size(); ie1++)
    for (unsigned ie2 = ie1+1; ie2<elements_.size(); ie2++){

      GlobalPoint P = dcaPoint(ie1, ie2);
      if (P.x() > 1e9) continue;

      float r2 = P.x()*P.x()+P.y()*P.y()+P.z()*P.z();

      r2Vector.push_back(r2);
    }

  return r2Vector;

}
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 reco::PFDisplacedVertexCandidate::VertexLink::dcaPoint_, reco::PFDisplacedVertexCandidate::VertexLink::distance_, getHLTprescales::index, prof2calltree::l, convertSQLiteXML::ok, and reco::PFDisplacedVertexCandidate::VertexLink::test_.

                                                                   {

  
  assert( test<LINKTEST_ALL );
  
  unsigned index = 0;
  bool ok =  matrix2vector(i1,i2, index);

  if(ok) {
    //ignore the  -1, -1 pair
    if ( dist > -0.5 ) {
      VertexLink & l = vertexLinkData_[index];
      l.distance_ = dist;
      l.dcaPoint_ = dcaPoint;
      l.test_ |= (1 << test);
    }     else  //delete if existing
      {
        VertexLinkData::iterator it = vertexLinkData_.find(index);
        if(it!=vertexLinkData_.end()) vertexLinkData_.erase(it);
      }

  } else {
    assert(0);
  }
  
}
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.

                                                                          {
  float d = dist( ie1, ie2);
  if (d < -0.5) return false;
  return true;
}
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().

      {return elements_[ie];}
const VertexLinkData& reco::PFDisplacedVertexCandidate::vertexLinkData ( ) const [inline]
Returns:
the map of link data

Definition at line 119 of file PFDisplacedVertexCandidate.h.

References vertexLinkData_.

      {return vertexLinkData_;}
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 n.

                                                              {
  unsigned n = elements_.size();
  
  // number of possible undirected links between n elements.
  // reflective links impossible.
 
  return n*(n-1)/2; 
}

Friends And Related Function Documentation

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

cout function


Member Data Documentation

-------- MEMBERS -------- ///

vector of refs to the associated tracks

Definition at line 153 of file PFDisplacedVertexCandidate.h.

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

map of links between tracks

Definition at line 156 of file PFDisplacedVertexCandidate.h.

Referenced by vertexLinkData().