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) const
 
double dist (unsigned ie1, unsigned ie2, const LinkData &linkData, LinkTest test) const
 
const edm::OwnVector< reco::PFBlockElement > & elements () const
 
LinkDatalinkData ()
 
const LinkDatalinkData () const
 
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.

11  {
12  element->setIndex(elements_.size());
13  element->lock();
14  elements_.push_back(element->clone());
15 }

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

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

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 }

References mps_fire::i, NONE, and ctpps_dqm_sourceclient-live_cfg::test.

◆ bookLinkData()

void PFBlock::bookLinkData ( )

Definition at line 17 of file PFBlock.cc.

17 {}

◆ dist() [1/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 }

◆ dist() [2/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.

77  {
78  return dist(ie1, ie2, linkData);
79  }

References linkData().

◆ elements()

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

Definition at line 85 of file PFBlock.h.

85 { return elements_; }

References elements_.

Referenced by FWPFBlockProxyBuilder::buildViewType().

◆ linkData() [1/2]

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

Definition at line 91 of file PFBlock.h.

91 { return linkData_; }

References linkData_.

◆ linkData() [2/2]

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

Definition at line 88 of file PFBlock.h.

88 { return linkData_; }

References linkData_.

Referenced by dist().

◆ linkDataSize()

unsigned PFBlock::linkDataSize ( ) const
private
Returns
size of linkData_, calculated from the number of elements

Definition at line 323 of file PFBlock.cc.

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 }

References dqmiodumpmetadata::n.

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

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 }

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

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

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 }

References cms::cuda::assert(), testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, cmsLHEtoEOSManager::l, convertSQLiteXML::ok, and ctpps_dqm_sourceclient-live_cfg::test.

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

testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
reco::PFBlockElement::setIndex
void setIndex(unsigned index)
set index
Definition: PFBlockElement.h:83
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
reco::PFBlock::linkData
const LinkData & linkData() const
Definition: PFBlock.h:88
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
cms::cuda::assert
assert(be >=bs)
reco::PFBlock::LINKTEST_RECHIT
Definition: PFBlock.h:41
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
test
Definition: SmallWORMDict.h:13
ctpps_dqm_sourceclient-live_cfg.test
test
Definition: ctpps_dqm_sourceclient-live_cfg.py:7
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
reco::PFBlockElement::NONE
Definition: PFBlockElement.h:31
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:39
reco::PFBlockElement::clone
virtual PFBlockElement * clone() const =0
necessary to have the edm::OwnVector<PFBlockElement> working
reco::PFBlock::LINKTEST_ALL
Definition: PFBlock.h:41
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
edm::OwnVector::push_back
void push_back(D *&d)
Definition: OwnVector.h:326
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
reco::PFBlock::elements_
edm::OwnVector< reco::PFBlockElement > elements_
all elements
Definition: PFBlock.h:101
reco::PFBlock::dist
double dist(unsigned ie1, unsigned ie2, const LinkData &linkData, LinkTest test) const
Definition: PFBlock.h:77
reco::PFBlock::linkData_
LinkData linkData_
link data (permanent)
Definition: PFBlock.h:98
combine.missing
missing
Definition: combine.py:5
edm::OwnVector::size
size_type size() const
Definition: OwnVector.h:300
reco::PFBlockElement::lock
void lock()
lock element
Definition: PFBlockElement.h:63
reco::PFBlock::LINKTEST_NLINKTEST
Definition: PFBlock.h:41
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
reco::PFBlock::matrix2vector
bool matrix2vector(unsigned i, unsigned j, unsigned &index) const
Definition: PFBlock.cc:102