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

◆ IE

Definition at line 35 of file PFBlock.h.

◆ LinkData

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

Definition at line 39 of file PFBlock.h.

Member Enumeration Documentation

◆ LinkTest

Enumerator
LINKTEST_RECHIT 
LINKTEST_NLINKTEST 
LINKTEST_ALL 

Definition at line 41 of file PFBlock.h.

Constructor & Destructor Documentation

◆ PFBlock()

reco::PFBlock::PFBlock ( )
inline

Definition at line 43 of file PFBlock.h.

43 {}

Member Function Documentation

◆ addElement()

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

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 push_back(D *&d)
Definition: OwnVector.h:326
void setIndex(unsigned index)
set index
size_type size() const
Definition: OwnVector.h:300
void lock()
lock element

◆ associatedElements()

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 mps_fire::i, caHitNtupletGeneratorKernels::if(), NONE, and ctpps_dqm_sourceclient-live_cfg::test.

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 }
edm::OwnVector< reco::PFBlockElement > elements_
all elements
Definition: PFBlock.h:101
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
Definition: PFBlock.cc:102
size_type size() const
Definition: OwnVector.h:300
const LinkData & linkData() const
Definition: PFBlock.h:88

◆ bookLinkData()

void PFBlock::bookLinkData ( )

Definition at line 17 of file PFBlock.cc.

17 {}

◆ dist() [1/2]

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.

References linkData().

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

◆ dist() [2/2]

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 }
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
Definition: PFBlock.cc:102
const LinkData & linkData() const
Definition: PFBlock.h:88

◆ elements()

const edm::OwnVector<reco::PFBlockElement>& reco::PFBlock::elements ( ) const
inline
Returns
elements

Definition at line 85 of file PFBlock.h.

References elements_.

Referenced by FWPFBlockProxyBuilder::buildViewType().

85 { return elements_; }
edm::OwnVector< reco::PFBlockElement > elements_
all elements
Definition: PFBlock.h:101

◆ linkData() [1/2]

const LinkData& reco::PFBlock::linkData ( ) const
inline
Returns
link data

Definition at line 88 of file PFBlock.h.

References linkData_.

Referenced by dist().

88 { return linkData_; }
LinkData linkData_
link data (permanent)
Definition: PFBlock.h:98

◆ linkData() [2/2]

LinkData& reco::PFBlock::linkData ( )
inline
Returns
link data

Definition at line 91 of file PFBlock.h.

References linkData_.

91 { return linkData_; }
LinkData linkData_
link data (permanent)
Definition: PFBlock.h:98

◆ linkDataSize()

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.

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
size_type size() const
Definition: OwnVector.h:300

◆ matrix2vector()

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

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)
size_type size() const
Definition: OwnVector.h:300

◆ setLink()

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 cms::cuda::assert(), testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, cmsLHEtoEOSManager::l, convertSQLiteXML::ok, and ctpps_dqm_sourceclient-live_cfg::test.

19  {
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 }
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
Definition: PFBlock.cc:102
assert(be >=bs)
const LinkData & linkData() const
Definition: PFBlock.h:88

Member Data Documentation

◆ elements_

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

all elements

Definition at line 101 of file PFBlock.h.

Referenced by elements().

◆ linkData_

LinkData reco::PFBlock::linkData_
private

link data (permanent)

Definition at line 98 of file PFBlock.h.

Referenced by linkData().