CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends

reco::PFBlock Class Reference

Block of elements. More...

#include <PFBlock.h>

List of all members.

Classes

struct  Link

Public Types

typedef edm::OwnVector
< reco::PFBlockElement >
::const_iterator 
IE
typedef std::map< unsigned int,
Link
LinkData
enum  LinkTest { LINKTEST_RECHIT, LINKTEST_NLINKTEST, LINKTEST_ALL }

Public Member Functions

void addElement (reco::PFBlockElement *element)
void associatedElements (unsigned i, const LinkData &linkData, std::multimap< double, unsigned > &sortedAssociates, reco::PFBlockElement::Type type=PFBlockElement::NONE, LinkTest test=LINKTEST_RECHIT) const
void bookLinkData ()
double dist (unsigned ie1, unsigned ie2, const LinkData &linkData) const
double dist (unsigned ie1, unsigned ie2, const LinkData &linkData, LinkTest test) const
const edm::OwnVector
< reco::PFBlockElement > & 
elements () const
const LinkDatalinkData () const
LinkDatalinkData ()
bool matrix2vector (unsigned i, unsigned j, unsigned &index) const
 PFBlock ()
void setLink (unsigned i1, unsigned i2, double dist, LinkData &linkData, LinkTest test=LINKTEST_RECHIT) const

Private Member Functions

unsigned linkDataSize () const

Private Attributes

edm::OwnVector
< reco::PFBlockElement
elements_
 all elements
LinkData linkData_
 link data (permanent)

Friends

std::ostream & operator<< (std::ostream &out, const PFBlock &co)

Detailed Description

Block of elements.

Author:
Colin Bernet
Date:
January 2006

A PFBlock is:

Definition at line 30 of file PFBlock.h.


Member Typedef Documentation

Definition at line 42 of file PFBlock.h.

typedef std::map< unsigned int, Link > reco::PFBlock::LinkData

Definition at line 46 of file PFBlock.h.


Member Enumeration Documentation

Enumerator:
LINKTEST_RECHIT 
LINKTEST_NLINKTEST 
LINKTEST_ALL 

Definition at line 48 of file PFBlock.h.


Constructor & Destructor Documentation

reco::PFBlock::PFBlock ( ) [inline]

Definition at line 54 of file PFBlock.h.

{}

Member Function Documentation

void PFBlock::addElement ( reco::PFBlockElement element)

add an element to the current PFBlock the block will keep a copy.

Definition at line 12 of file PFBlock.cc.

References reco::PFBlockElement::clone(), reco::PFBlockElement::lock(), and reco::PFBlockElement::setIndex().

                                                   {
  element->setIndex( elements_.size() );
  element->lock();
  elements_.push_back( element->clone() ); 

}
void reco::PFBlock::associatedElements ( unsigned  i,
const LinkData linkData,
std::multimap< double, unsigned > &  sortedAssociates,
reco::PFBlockElement::Type  type = PFBlockElement::NONE,
LinkTest  test = LINKTEST_RECHIT 
) const

lock an element ( unlink it from the others ) Colin: this function is misleading void lock(unsigned i, LinkData& linkData ) const; fills a map with the elements associated to element i. elements are sorted by increasing distance. if specified, only the elements of type "type" will be considered if specified, only the link calculated from a certain "test" will be considered: distance test, etc..

Referenced by PFAlgo::associatePSClusters(), PFPhotonAlgo::EvaluateSingleLegMVA(), PFRootEventManagerColin::processHIGH_E_TAUS(), PFElectronAlgo::SetActive(), PFElectronAlgo::SetCandidates(), PFElectronAlgo::SetIDOutputs(), and PFElectronAlgo::SetLinks().

void PFBlock::bookLinkData ( )

Definition at line 20 of file PFBlock.cc.

Referenced by PFDisplacedVertexCandidateFinder::packLinks().

                           {

}
double reco::PFBlock::dist ( unsigned  ie1,
unsigned  ie2,
const LinkData linkData,
LinkTest  test 
) const [inline]
Returns:
distance of link

Definition at line 94 of file PFBlock.h.

Referenced by PFElectronAlgo::SetLinks().

                                       {
      return dist(ie1,ie2,linkData);
    }
double PFBlock::dist ( unsigned  ie1,
unsigned  ie2,
const LinkData linkData 
) const
Returns:
distance of link

Definition at line 146 of file PFBlock.cc.

References getHLTprescales::index.

                                                      {

  double Dist = -1;

  unsigned index = 0;
  if( !matrix2vector(ie1, ie2, index) ) return Dist;
  LinkData::const_iterator it =  linkData.find(index);
  if( it!=linkData.end() ) Dist= it->second.distance;

  return Dist;

}
const edm::OwnVector< reco::PFBlockElement >& reco::PFBlock::elements ( ) const [inline]
const LinkData& reco::PFBlock::linkData ( ) const [inline]
LinkData& reco::PFBlock::linkData ( ) [inline]
Returns:
link data

Definition at line 117 of file PFBlock.h.

References linkData_.

                         {
      return linkData_;
    }
unsigned PFBlock::linkDataSize ( ) const [private]
Returns:
size of linkData_, calculated from the number of elements

Definition at line 349 of file PFBlock.cc.

References n.

                                     {
  unsigned n = elements_.size();
  
  // number of possible undirected links between n elements.
  // reflective links impossible.
 
  return n*(n-1)/2; 
}
bool PFBlock::matrix2vector ( unsigned  i,
unsigned  j,
unsigned &  index 
) const

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 119 of file PFBlock.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 ) 
    std::swap( iindex, jindex);

  
  index = jindex-iindex-1;

  if(iindex>0) {
    index += iindex*size;
    unsigned missing = iindex*(iindex+1)/2;
    index -= missing;
  }
  
  return true;
}
void PFBlock::setLink ( unsigned  i1,
unsigned  i2,
double  dist,
LinkData linkData,
LinkTest  test = LINKTEST_RECHIT 
) const

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 26 of file PFBlock.cc.

References reco::PFBlock::Link::distance, getHLTprescales::index, prof2calltree::l, convertSQLiteXML::ok, reco::PFBlock::Link::test, and run_regression::test.

Referenced by PFDisplacedVertexCandidateFinder::packLinks().

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

  if(ok) {
    //ignore the  -1, -1 pair
    if ( Dist > -0.5 ) {
      Link & l = linkData[index];
      l.distance=Dist;
      l.test |= (1 << test);
    }     else  //delete if existing
      {
        LinkData::iterator it = linkData.find(index);
        if(it!=linkData.end()) linkData.erase(it);
      }

  } else {
    assert(0);
  }
  
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const PFBlock co 
) [friend]

Member Data Documentation

all elements

Definition at line 132 of file PFBlock.h.

Referenced by elements().

link data (permanent)

Definition at line 129 of file PFBlock.h.

Referenced by linkData().