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::PFBlock Class Reference

Block of elements. More...

#include <PFBlock.h>

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, LinkTest test) const
 
double dist (unsigned ie1, unsigned ie2, const LinkData &linkData) 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 More...
 
LinkData linkData_
 link data (permanent) More...
 

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.

54 {}

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

12  {
13  element->setIndex( elements_.size() );
14  element->lock();
15  elements_.push_back( element->clone() );
16 
17 }
virtual PFBlockElement * clone() const =0
necessary to have the edm::OwnVector&lt;PFBlockElement&gt; working
void setIndex(unsigned index)
set index
void lock()
lock element
edm::OwnVector< reco::PFBlockElement > elements_
all elements
Definition: PFBlock.h:132
void 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..

Definition at line 75 of file PFBlock.cc.

References getHLTprescales::index, NONE, and run_regression::test.

Referenced by PFAlgo::associatePSClusters(), PFPhotonAlgo::EvaluateSingleLegMVA(), PFEGammaAlgo::EvaluateSingleLegMVA(), PFEGammaFilters::isElectronSafeForJetMET(), PFAlgoTestBenchElectrons::processBlock(), PFRootEventManagerColin::processHIGH_E_TAUS(), PFElectronAlgo::SetActive(), PFElectronAlgo::SetCandidates(), PFElectronAlgo::SetIDOutputs(), and PFElectronAlgo::SetLinks().

79  {
80 
81  sortedAssociates.clear();
82 
83  // i is too large
84  if( i > elements_.size() ) return;
85  // assert(i>=0); i >= 0, since i is unsigned
86 
87  for(unsigned ie=0; ie<elements_.size(); ie++) {
88 
89  // considered element itself
90  if( ie == i ) {
91  continue;
92  }
93  // not the right type
94  if(type != PFBlockElement::NONE &&
95  elements_[ie].type() != type ) {
96  continue;
97  }
98 
99  // Order the elements by increasing distance !
100 
101  unsigned index = 0;
102  if( !matrix2vector(i, ie, index) ) continue;
103 
104  double c2=-1;
105  LinkData::const_iterator it = linkData.find(index);
106  if ( it!=linkData.end() &&
107  ( ( (1 << test ) & it->second.test) !=0 || (test == LINKTEST_ALL) ) )
108  c2= it->second.distance;
109 
110  // not associated
111  if( c2 < 0 ) {
112  continue;
113  }
114 
115  sortedAssociates.insert( pair<double,unsigned>(c2, ie) );
116  }
117 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
const LinkData & linkData() const
Definition: PFBlock.h:112
edm::OwnVector< reco::PFBlockElement > elements_
all elements
Definition: PFBlock.h:132
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
Definition: PFBlock.cc:119
void PFBlock::bookLinkData ( )

Definition at line 20 of file PFBlock.cc.

Referenced by PFBlockAlgo::packLinks().

20  {
21 
22 }
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().

97  {
98  return dist(ie1,ie2,linkData);
99  }
const LinkData & linkData() const
Definition: PFBlock.h:112
double dist(unsigned ie1, unsigned ie2, const LinkData &linkData, LinkTest test) const
Definition: PFBlock.h:94
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.

147  {
148 
149  double Dist = -1;
150 
151  unsigned index = 0;
152  if( !matrix2vector(ie1, ie2, index) ) return Dist;
153  LinkData::const_iterator it = linkData.find(index);
154  if( it!=linkData.end() ) Dist= it->second.distance;
155 
156  return Dist;
157 
158 }
const LinkData & linkData() const
Definition: PFBlock.h:112
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
Definition: PFBlock.cc:119
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_.

117  {
118  return linkData_;
119  }
LinkData linkData_
link data (permanent)
Definition: PFBlock.h:129
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.

349  {
350  unsigned n = elements_.size();
351 
352  // number of possible undirected links between n elements.
353  // reflective links impossible.
354 
355  return n*(n-1)/2;
356 }
edm::OwnVector< reco::PFBlockElement > elements_
all elements
Definition: PFBlock.h:132
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().

121  {
122 
123  unsigned size = elements_.size();
124  if( iindex == jindex ||
125  iindex >= size ||
126  jindex >= size ) {
127  return false;
128  }
129 
130  if( iindex > jindex )
131  std::swap( iindex, jindex);
132 
133 
134  index = jindex-iindex-1;
135 
136  if(iindex>0) {
137  index += iindex*size;
138  unsigned missing = iindex*(iindex+1)/2;
139  index -= missing;
140  }
141 
142  return true;
143 }
dictionary missing
Definition: combine.py:4
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
edm::OwnVector< reco::PFBlockElement > elements_
all elements
Definition: PFBlock.h:132
tuple size
Write out results.
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, ConfigFiles::l, convertSQLiteXML::ok, reco::PFBlock::Link::test, and run_regression::test.

Referenced by PFBlockAlgo::packLinks().

30  {
31 
32  assert( test<LINKTEST_ALL );
33 
34  unsigned index = 0;
35  bool ok = matrix2vector(i1,i2, index);
36 
37  if(ok) {
38  //ignore the -1, -1 pair
39  if ( Dist > -0.5 ) {
40  Link & l = linkData[index];
41  l.distance=Dist;
42  l.test |= (1 << test);
43  } else //delete if existing
44  {
45  LinkData::iterator it = linkData.find(index);
46  if(it!=linkData.end()) linkData.erase(it);
47  }
48 
49  } else {
50  assert(0);
51  }
52 
53 }
const LinkData & linkData() const
Definition: PFBlock.h:112
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
Definition: PFBlock.cc:119

Friends And Related Function Documentation

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

Member Data Documentation

edm::OwnVector< reco::PFBlockElement > reco::PFBlock::elements_
private

all elements

Definition at line 132 of file PFBlock.h.

Referenced by elements().

LinkData reco::PFBlock::linkData_
private

link data (permanent)

Definition at line 129 of file PFBlock.h.

Referenced by linkData().