CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
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, LinkLinkData
 
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::PFBlockElementelements_
 all elements More...
 
LinkData linkData_
 link data (permanent) More...
 

Detailed Description

Block of elements.

Author
Colin Bernet
Date
January 2006

A PFBlock is:

Definition at line 26 of file PFBlock.h.

Member Typedef Documentation

Definition at line 35 of file PFBlock.h.

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

Definition at line 39 of file PFBlock.h.

Member Enumeration Documentation

Enumerator
LINKTEST_RECHIT 
LINKTEST_NLINKTEST 
LINKTEST_ALL 

Definition at line 41 of file PFBlock.h.

Constructor & Destructor Documentation

reco::PFBlock::PFBlock ( )
inline

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

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

Referenced by PFBlock().

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

References NONE, and ctpps_dqm_sourceclient-live_cfg::test.

Referenced by PFAlgo::associatePSClusters(), PFAlgo::createCandidatesHCAL(), PFAlgo::createCandidatesHCALUnlinked(), PFAlgo::createCandidatesHF(), PFAlgo::elementLoop(), PFEGammaAlgo::evaluateSingleLegMVA(), PFEGammaFilters::isElectronSafeForJetMET(), PFBlock(), PFAlgo::recoTracksNotHCAL(), and PFAlgo::relinkTrackToHcal().

64  {
65  sortedAssociates.clear();
66 
67  // i is too large
68  if (i > elements_.size())
69  return;
70  // assert(i>=0); i >= 0, since i is unsigned
71 
72  for (unsigned ie = 0; ie < elements_.size(); ie++) {
73  // considered element itself
74  if (ie == i) {
75  continue;
76  }
77  // not the right type
78  if (type != PFBlockElement::NONE && elements_[ie].type() != type) {
79  continue;
80  }
81 
82  // Order the elements by increasing distance !
83 
84  unsigned index = 0;
85  if (!matrix2vector(i, ie, index))
86  continue;
87 
88  double c2 = -1;
89  LinkData::const_iterator it = linkData.find(index);
90  if (it != linkData.end() && (((1 << test) & it->second.test) != 0 || (test == LINKTEST_ALL)))
91  c2 = it->second.distance;
92 
93  // not associated
94  if (c2 < 0) {
95  continue;
96  }
97 
98  sortedAssociates.insert(pair<double, unsigned>(c2, ie));
99  }
100 }
type
Definition: HCALResponse.h:21
edm::OwnVector< reco::PFBlockElement > elements_
all elements
Definition: PFBlock.h:101
const LinkData & linkData() const
Definition: PFBlock.h:88
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
Definition: PFBlock.cc:102
void PFBlock::bookLinkData ( )

Definition at line 17 of file PFBlock.cc.

Referenced by PFBlockAlgo::packLinks(), and PFBlock().

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

Definition at line 77 of file PFBlock.h.

Referenced by PFAlgo::createCandidatesHCAL(), PFAlgo::createCandidatesHF(), PFAlgo::elementLoop(), and PFBlock().

77  {
78  return dist(ie1, ie2, linkData);
79  }
const LinkData & linkData() const
Definition: PFBlock.h:88
double dist(unsigned ie1, unsigned ie2, const LinkData &linkData, LinkTest test) const
Definition: PFBlock.h:77
double PFBlock::dist ( unsigned  ie1,
unsigned  ie2,
const LinkData linkData 
) const
Returns
distance of link

Definition at line 122 of file PFBlock.cc.

122  {
123  double Dist = -1;
124 
125  unsigned index = 0;
126  if (!matrix2vector(ie1, ie2, index))
127  return Dist;
128  LinkData::const_iterator it = linkData.find(index);
129  if (it != linkData.end())
130  Dist = it->second.distance;
131 
132  return Dist;
133 }
const LinkData & linkData() const
Definition: PFBlock.h:88
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
Definition: PFBlock.cc:102
const edm::OwnVector<reco::PFBlockElement>& reco::PFBlock::elements ( ) const
inline
const LinkData& reco::PFBlock::linkData ( ) const
inline
Returns
link data

Definition at line 88 of file PFBlock.h.

References linkData_.

Referenced by PFEGammaAlgo::evaluateSingleLegMVA(), PFEGammaFilters::isElectronSafeForJetMET(), PFBlockAlgo::packLinks(), and PFBlock().

88 { return linkData_; }
LinkData linkData_
link data (permanent)
Definition: PFBlock.h:98
LinkData& reco::PFBlock::linkData ( )
inline
Returns
link data

Definition at line 91 of file PFBlock.h.

References linkData_, and linkDataSize().

91 { return linkData_; }
LinkData linkData_
link data (permanent)
Definition: PFBlock.h:98
unsigned PFBlock::linkDataSize ( ) const
private
Returns
size of linkData_, calculated from the number of elements

Definition at line 323 of file PFBlock.cc.

References dqmiodumpmetadata::n.

Referenced by linkData().

323  {
324  unsigned n = elements_.size();
325 
326  // number of possible undirected links between n elements.
327  // reflective links impossible.
328 
329  return n * (n - 1) / 2;
330 }
edm::OwnVector< reco::PFBlockElement > elements_
all elements
Definition: PFBlock.h:101
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 102 of file PFBlock.cc.

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

Referenced by PFBlock().

102  {
103  unsigned size = elements_.size();
104  if (iindex == jindex || iindex >= size || jindex >= size) {
105  return false;
106  }
107 
108  if (iindex > jindex)
109  std::swap(iindex, jindex);
110 
111  index = jindex - iindex - 1;
112 
113  if (iindex > 0) {
114  index += iindex * size;
115  unsigned missing = iindex * (iindex + 1) / 2;
116  index -= missing;
117  }
118 
119  return true;
120 }
size
Write out results.
edm::OwnVector< reco::PFBlockElement > elements_
all elements
Definition: PFBlock.h:101
missing
Definition: combine.py:5
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
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 19 of file PFBlock.cc.

References reco::PFBlock::Link::distance, cmsLHEtoEOSManager::l, convertSQLiteXML::ok, ctpps_dqm_sourceclient-live_cfg::test, and reco::PFBlock::Link::test.

Referenced by PFAlgo::elementLoop(), PFBlockAlgo::packLinks(), PFBlock(), and PFAlgo::relinkTrackToHcal().

19  {
20  assert(test < LINKTEST_ALL);
21 
22  unsigned index = 0;
23  bool ok = matrix2vector(i1, i2, index);
24 
25  if (ok) {
26  //ignore the -1, -1 pair
27  if (Dist > -0.5) {
28  Link& l = linkData[index];
29  l.distance = Dist;
30  l.test |= (1 << test);
31  } else //delete if existing
32  {
33  LinkData::iterator it = linkData.find(index);
34  if (it != linkData.end())
35  linkData.erase(it);
36  }
37 
38  } else {
39  assert(0);
40  }
41 }
const LinkData & linkData() const
Definition: PFBlock.h:88
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
Definition: PFBlock.cc:102

Member Data Documentation

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

all elements

Definition at line 101 of file PFBlock.h.

Referenced by elements().

LinkData reco::PFBlock::linkData_
private

link data (permanent)

Definition at line 98 of file PFBlock.h.

Referenced by linkData().