CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
NamedCandCombinerBase Class Referenceabstract

#include <NamedCandCombinerBase.h>

Public Types

typedef std::vector< std::string > string_coll
 

Public Member Functions

std::unique_ptr< reco::NamedCompositeCandidateCollectioncombine (const std::vector< reco::CandidatePtrVector > &, string_coll const &) const
 return all selected candidate pairs More...
 
std::unique_ptr< reco::NamedCompositeCandidateCollectioncombine (const reco::CandidatePtrVector &, string_coll const &) const
 return all selected candidate pairs More...
 
std::unique_ptr< reco::NamedCompositeCandidateCollectioncombine (const reco::CandidatePtrVector &, const reco::CandidatePtrVector &, string_coll const &) const
 return all selected candidate pairs More...
 
std::unique_ptr< reco::NamedCompositeCandidateCollectioncombine (const reco::CandidatePtrVector &, const reco::CandidatePtrVector &, const reco::CandidatePtrVector &, string_coll const &) const
 return all selected candidate pairs More...
 
std::unique_ptr< reco::NamedCompositeCandidateCollectioncombine (const reco::CandidatePtrVector &, const reco::CandidatePtrVector &, const reco::CandidatePtrVector &, const reco::CandidatePtrVector &, string_coll const &) const
 return all selected candidate pairs More...
 
 NamedCandCombinerBase (std::string name)
 default construct More...
 
 NamedCandCombinerBase (std::string name, int, int)
 construct from two charge values More...
 
 NamedCandCombinerBase (std::string name, int, int, int)
 construct from three charge values More...
 
 NamedCandCombinerBase (std::string name, int, int, int, int)
 construct from four charge values More...
 
 NamedCandCombinerBase (std::string name, bool checkCharge, bool checkOverlap, const std::vector< int > &)
 constructor from a selector, specifying optionally to check for charge More...
 
virtual ~NamedCandCombinerBase ()
 destructor More...
 

Private Types

typedef std::vector< std::pair< std::pair< reco::CandidatePtr, size_t >, std::vector< reco::CandidatePtrVector >::const_iterator > > CandStack
 temporary candidate stack More...
 
typedef std::vector< int > ChargeStack
 

Private Member Functions

virtual void addDaughter (reco::NamedCompositeCandidate &cmp, const reco::CandidatePtr &c, std::string name) const =0
 add candidate daughter More...
 
void combine (reco::NamedCompositeCandidate &, const reco::CandidatePtr &, const reco::CandidatePtr &, std::string, std::string) const
 returns a composite candidate combined from two daughters More...
 
void combine (size_t collectionIndex, CandStack &, ChargeStack &, string_coll const &names, std::vector< reco::CandidatePtrVector >::const_iterator begin, std::vector< reco::CandidatePtrVector >::const_iterator end, std::unique_ptr< reco::NamedCompositeCandidateCollection > &comps) const
 returns a composite candidate combined from two daughters More...
 
bool preselect (const reco::Candidate &, const reco::Candidate &) const
 verify that the two candidate don't overlap and check charge More...
 
virtual bool select (const reco::Candidate &) const =0
 select a candidate More...
 
virtual bool selectPair (const reco::Candidate &c1, const reco::Candidate &c2) const =0
 select a candidate pair More...
 
virtual void setup (reco::NamedCompositeCandidate &) const =0
 set kinematics to reconstructed composite More...
 

Private Attributes

bool checkCharge_
 flag to specify the checking of electric charge More...
 
bool checkOverlap_
 flag to specify the checking of overlaps More...
 
std::vector< int > dauCharge_
 electric charges of the daughters More...
 
std::string name_
 Name. More...
 
OverlapChecker overlap_
 utility to check candidate daughters overlap More...
 

Detailed Description

Definition at line 13 of file NamedCandCombinerBase.h.

Member Typedef Documentation

◆ CandStack

typedef std::vector< std::pair<std::pair<reco::CandidatePtr, size_t>, std::vector<reco::CandidatePtrVector>::const_iterator> > NamedCandCombinerBase::CandStack
private

temporary candidate stack

Definition at line 62 of file NamedCandCombinerBase.h.

◆ ChargeStack

typedef std::vector<int> NamedCandCombinerBase::ChargeStack
private

Definition at line 63 of file NamedCandCombinerBase.h.

◆ string_coll

typedef std::vector<std::string> NamedCandCombinerBase::string_coll

Definition at line 15 of file NamedCandCombinerBase.h.

Constructor & Destructor Documentation

◆ NamedCandCombinerBase() [1/5]

NamedCandCombinerBase::NamedCandCombinerBase ( std::string  name)

default construct

Definition at line 6 of file NamedCandCombinerBase.cc.

7  : checkCharge_(false), checkOverlap_(true), dauCharge_(), overlap_(), name_(name) {}
OverlapChecker overlap_
utility to check candidate daughters overlap
bool checkCharge_
flag to specify the checking of electric charge
bool checkOverlap_
flag to specify the checking of overlaps
std::vector< int > dauCharge_
electric charges of the daughters

◆ NamedCandCombinerBase() [2/5]

NamedCandCombinerBase::NamedCandCombinerBase ( std::string  name,
int  q1,
int  q2 
)

construct from two charge values

Definition at line 9 of file NamedCandCombinerBase.cc.

References dauCharge_.

10  : checkCharge_(true), checkOverlap_(true), dauCharge_(2), overlap_(), name_(name) {
11  dauCharge_[0] = q1;
12  dauCharge_[1] = q2;
13 }
OverlapChecker overlap_
utility to check candidate daughters overlap
bool checkCharge_
flag to specify the checking of electric charge
bool checkOverlap_
flag to specify the checking of overlaps
std::vector< int > dauCharge_
electric charges of the daughters

◆ NamedCandCombinerBase() [3/5]

NamedCandCombinerBase::NamedCandCombinerBase ( std::string  name,
int  q1,
int  q2,
int  q3 
)

construct from three charge values

Definition at line 15 of file NamedCandCombinerBase.cc.

References dauCharge_.

16  : checkCharge_(true), checkOverlap_(true), dauCharge_(3), overlap_(), name_(name) {
17  dauCharge_[0] = q1;
18  dauCharge_[1] = q2;
19  dauCharge_[2] = q3;
20 }
OverlapChecker overlap_
utility to check candidate daughters overlap
bool checkCharge_
flag to specify the checking of electric charge
bool checkOverlap_
flag to specify the checking of overlaps
std::vector< int > dauCharge_
electric charges of the daughters

◆ NamedCandCombinerBase() [4/5]

NamedCandCombinerBase::NamedCandCombinerBase ( std::string  name,
int  q1,
int  q2,
int  q3,
int  q4 
)

construct from four charge values

Definition at line 22 of file NamedCandCombinerBase.cc.

References dauCharge_.

23  : checkCharge_(true), checkOverlap_(true), dauCharge_(4), overlap_(), name_(name) {
24  dauCharge_[0] = q1;
25  dauCharge_[1] = q2;
26  dauCharge_[2] = q3;
27  dauCharge_[3] = q4;
28 }
OverlapChecker overlap_
utility to check candidate daughters overlap
bool checkCharge_
flag to specify the checking of electric charge
bool checkOverlap_
flag to specify the checking of overlaps
std::vector< int > dauCharge_
electric charges of the daughters

◆ NamedCandCombinerBase() [5/5]

NamedCandCombinerBase::NamedCandCombinerBase ( std::string  name,
bool  checkCharge,
bool  checkOverlap,
const std::vector< int > &  dauCharge 
)

constructor from a selector, specifying optionally to check for charge

Definition at line 30 of file NamedCandCombinerBase.cc.

OverlapChecker overlap_
utility to check candidate daughters overlap
bool checkCharge_
flag to specify the checking of electric charge
bool checkOverlap_
flag to specify the checking of overlaps
std::vector< int > dauCharge_
electric charges of the daughters
def checkOverlap(process)

◆ ~NamedCandCombinerBase()

NamedCandCombinerBase::~NamedCandCombinerBase ( )
virtual

destructor

Definition at line 36 of file NamedCandCombinerBase.cc.

36 {}

Member Function Documentation

◆ addDaughter()

virtual void NamedCandCombinerBase::addDaughter ( reco::NamedCompositeCandidate cmp,
const reco::CandidatePtr c,
std::string  name 
) const
privatepure virtual

add candidate daughter

Referenced by combine().

◆ combine() [1/7]

unique_ptr< NamedCompositeCandidateCollection > NamedCandCombinerBase::combine ( const std::vector< reco::CandidatePtrVector > &  src,
string_coll const &  names 
) const

return all selected candidate pairs

Definition at line 60 of file NamedCandCombinerBase.cc.

References DummyCfis::c, alignmentValidation::c1, checkCharge_, edm::errors::Configuration, dauCharge_, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, dqmiodumpmetadata::n, names, preselect(), select(), edm::PtrVectorBase::size(), TrackRefitter_38T_cff::src, and svgfig::stack.

Referenced by combine().

61  {
62  size_t srcSize = src.size();
63  if (checkCharge_ && dauCharge_.size() != srcSize)
65  << "NamedCandCombiner: trying to combine " << srcSize << " collections"
66  << " but configured to check against " << dauCharge_.size() << " charges.";
67 
68  if (names.size() < 2)
70  << "NamedCandCombiner: need to add 2 names, but size is " << names.size();
71 
72  unique_ptr<NamedCompositeCandidateCollection> comps(new NamedCompositeCandidateCollection);
73  if (srcSize == 2) {
74  CandidatePtrVector src1 = src[0], src2 = src[1];
75  if (src1 == src2) {
76  const int n = src1.size();
77  for (int i1 = 0; i1 < n; ++i1) {
78  const Candidate& c1 = *(src1[i1]);
79  for (int i2 = i1 + 1; i2 < n; ++i2) {
80  const Candidate& c2 = *(src1[i2]);
81  if (preselect(c1, c2)) {
83  combine(c, src1[i1], src1[i2], names[0], names[1]);
84  if (select(c))
85  comps->push_back(c);
86  }
87  }
88  }
89  } else {
90  const int n1 = src1.size(), n2 = src2.size();
91  for (int i1 = 0; i1 < n1; ++i1) {
92  const Candidate& c1 = *(src1[i1]);
93  for (int i2 = 0; i2 < n2; ++i2) {
94  const Candidate& c2 = *(src2[i2]);
95  if (preselect(c1, c2)) {
97  combine(c, src1[i1], src2[i2], names[0], names[1]);
98  if (select(c))
99  comps->push_back(c);
100  }
101  }
102  }
103  }
104  } else {
106  ChargeStack qStack;
107  combine(0, stack, qStack, names, src.begin(), src.end(), comps);
108  }
109 
110  return comps;
111 }
size_type size() const
Size of the RefVector.
Definition: PtrVectorBase.h:75
std::vector< NamedCompositeCandidate > NamedCompositeCandidateCollection
collection of Candidate objects
const std::string names[nVars_]
std::vector< int > ChargeStack
stack
Definition: svgfig.py:559
bool preselect(const reco::Candidate &, const reco::Candidate &) const
verify that the two candidate don&#39;t overlap and check charge
bool checkCharge_
flag to specify the checking of electric charge
std::vector< int > dauCharge_
electric charges of the daughters
std::vector< std::pair< std::pair< reco::CandidatePtr, size_t >, std::vector< reco::CandidatePtrVector >::const_iterator > > CandStack
temporary candidate stack
virtual bool select(const reco::Candidate &) const =0
select a candidate
std::unique_ptr< reco::NamedCompositeCandidateCollection > combine(const std::vector< reco::CandidatePtrVector > &, string_coll const &) const
return all selected candidate pairs

◆ combine() [2/7]

unique_ptr< NamedCompositeCandidateCollection > NamedCandCombinerBase::combine ( const reco::CandidatePtrVector src,
string_coll const &  names 
) const

return all selected candidate pairs

Definition at line 113 of file NamedCandCombinerBase.cc.

References DummyCfis::c, alignmentValidation::c1, checkCharge_, combine(), edm::errors::Configuration, dauCharge_, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, dqmiodumpmetadata::n, names, preselect(), select(), and TrackRefitter_38T_cff::src.

114  {
115  if (checkCharge_ && dauCharge_.size() != 2)
117  << "NamedCandCombiner: trying to combine 2 collections"
118  << " but configured to check against " << dauCharge_.size() << " charges.";
119 
120  if (names.size() < 2)
122  << "NamedCandCombiner: need to add 2 names, but size is " << names.size();
123 
124  unique_ptr<NamedCompositeCandidateCollection> comps(new NamedCompositeCandidateCollection);
125  const int n = src.size();
126  for (int i1 = 0; i1 < n; ++i1) {
127  const Candidate& c1 = *(src[i1]);
128  for (int i2 = i1 + 1; i2 < n; ++i2) {
129  const Candidate& c2 = *(src[i2]);
130  if (preselect(c1, c2)) {
132  combine(c, src[i1], src[i2], names[0], names[1]);
133  if (select(c))
134  comps->push_back(c);
135  }
136  }
137  }
138 
139  return comps;
140 }
std::vector< NamedCompositeCandidate > NamedCompositeCandidateCollection
collection of Candidate objects
const std::string names[nVars_]
bool preselect(const reco::Candidate &, const reco::Candidate &) const
verify that the two candidate don&#39;t overlap and check charge
bool checkCharge_
flag to specify the checking of electric charge
std::vector< int > dauCharge_
electric charges of the daughters
virtual bool select(const reco::Candidate &) const =0
select a candidate
std::unique_ptr< reco::NamedCompositeCandidateCollection > combine(const std::vector< reco::CandidatePtrVector > &, string_coll const &) const
return all selected candidate pairs

◆ combine() [3/7]

unique_ptr< NamedCompositeCandidateCollection > NamedCandCombinerBase::combine ( const reco::CandidatePtrVector src1,
const reco::CandidatePtrVector src2,
string_coll const &  names 
) const

return all selected candidate pairs

Definition at line 142 of file NamedCandCombinerBase.cc.

References combine(), names, and TrackRefitter_38T_cff::src.

144  {
145  vector<CandidatePtrVector> src;
146  src.push_back(src1);
147  src.push_back(src2);
148  return combine(src, names);
149 }
const std::string names[nVars_]
std::unique_ptr< reco::NamedCompositeCandidateCollection > combine(const std::vector< reco::CandidatePtrVector > &, string_coll const &) const
return all selected candidate pairs

◆ combine() [4/7]

unique_ptr< NamedCompositeCandidateCollection > NamedCandCombinerBase::combine ( const reco::CandidatePtrVector src1,
const reco::CandidatePtrVector src2,
const reco::CandidatePtrVector src3,
string_coll const &  names 
) const

return all selected candidate pairs

Definition at line 151 of file NamedCandCombinerBase.cc.

References combine(), names, and TrackRefitter_38T_cff::src.

154  {
155  vector<CandidatePtrVector> src;
156  src.push_back(src1);
157  src.push_back(src2);
158  src.push_back(src3);
159  return combine(src, names);
160 }
const std::string names[nVars_]
std::unique_ptr< reco::NamedCompositeCandidateCollection > combine(const std::vector< reco::CandidatePtrVector > &, string_coll const &) const
return all selected candidate pairs

◆ combine() [5/7]

unique_ptr< NamedCompositeCandidateCollection > NamedCandCombinerBase::combine ( const reco::CandidatePtrVector src1,
const reco::CandidatePtrVector src2,
const reco::CandidatePtrVector src3,
const reco::CandidatePtrVector src4,
string_coll const &  names 
) const

return all selected candidate pairs

Definition at line 162 of file NamedCandCombinerBase.cc.

References combine(), names, and TrackRefitter_38T_cff::src.

166  {
167  vector<CandidatePtrVector> src;
168  src.push_back(src1);
169  src.push_back(src2);
170  src.push_back(src3);
171  src.push_back(src4);
172  return combine(src, names);
173 }
const std::string names[nVars_]
std::unique_ptr< reco::NamedCompositeCandidateCollection > combine(const std::vector< reco::CandidatePtrVector > &, string_coll const &) const
return all selected candidate pairs

◆ combine() [6/7]

void NamedCandCombinerBase::combine ( reco::NamedCompositeCandidate cmp,
const reco::CandidatePtr c1,
const reco::CandidatePtr c2,
std::string  n1,
std::string  n2 
) const
private

returns a composite candidate combined from two daughters

Definition at line 50 of file NamedCandCombinerBase.cc.

References addDaughter(), alignmentValidation::c1, fileCollector::cmp, and setup().

54  {
55  addDaughter(cmp, c1, n1);
56  addDaughter(cmp, c2, n2);
57  setup(cmp);
58 }
virtual void setup(reco::NamedCompositeCandidate &) const =0
set kinematics to reconstructed composite
virtual void addDaughter(reco::NamedCompositeCandidate &cmp, const reco::CandidatePtr &c, std::string name) const =0
add candidate daughter

◆ combine() [7/7]

void NamedCandCombinerBase::combine ( size_t  collectionIndex,
CandStack ,
ChargeStack ,
string_coll const &  names,
std::vector< reco::CandidatePtrVector >::const_iterator  begin,
std::vector< reco::CandidatePtrVector >::const_iterator  end,
std::unique_ptr< reco::NamedCompositeCandidateCollection > &  comps 
) const
private

returns a composite candidate combined from two daughters

◆ preselect()

bool NamedCandCombinerBase::preselect ( const reco::Candidate c1,
const reco::Candidate c2 
) const
private

verify that the two candidate don't overlap and check charge

Definition at line 38 of file NamedCandCombinerBase.cc.

References alignmentValidation::c1, reco::Candidate::charge(), checkCharge_, checkOverlap_, dauCharge_, pfCandidateManager_cfi::matchCharge, overlap_, and selectPair().

Referenced by combine().

38  {
39  if (checkCharge_) {
40  int dq1 = dauCharge_[0], dq2 = dauCharge_[1], q1 = c1.charge(), q2 = c2.charge();
41  bool matchCharge = (q1 == dq1 && q2 == dq2) || (q1 == -dq1 && q2 == -dq2);
42  if (!matchCharge)
43  return false;
44  }
45  if (checkOverlap_ && overlap_(c1, c2))
46  return false;
47  return selectPair(c1, c2);
48 }
virtual int charge() const =0
electric charge
OverlapChecker overlap_
utility to check candidate daughters overlap
bool checkCharge_
flag to specify the checking of electric charge
bool checkOverlap_
flag to specify the checking of overlaps
std::vector< int > dauCharge_
electric charges of the daughters
virtual bool selectPair(const reco::Candidate &c1, const reco::Candidate &c2) const =0
select a candidate pair

◆ select()

virtual bool NamedCandCombinerBase::select ( const reco::Candidate ) const
privatepure virtual

select a candidate

Referenced by combine().

◆ selectPair()

virtual bool NamedCandCombinerBase::selectPair ( const reco::Candidate c1,
const reco::Candidate c2 
) const
privatepure virtual

select a candidate pair

Referenced by preselect().

◆ setup()

virtual void NamedCandCombinerBase::setup ( reco::NamedCompositeCandidate ) const
privatepure virtual

set kinematics to reconstructed composite

Referenced by combine(), and o2olib.O2OTool::execute().

Member Data Documentation

◆ checkCharge_

bool NamedCandCombinerBase::checkCharge_
private

flag to specify the checking of electric charge

Definition at line 81 of file NamedCandCombinerBase.h.

Referenced by combine(), and preselect().

◆ checkOverlap_

bool NamedCandCombinerBase::checkOverlap_
private

flag to specify the checking of overlaps

Definition at line 83 of file NamedCandCombinerBase.h.

Referenced by preselect().

◆ dauCharge_

std::vector<int> NamedCandCombinerBase::dauCharge_
private

electric charges of the daughters

Definition at line 85 of file NamedCandCombinerBase.h.

Referenced by combine(), NamedCandCombinerBase(), and preselect().

◆ name_

std::string NamedCandCombinerBase::name_
private

Name.

Definition at line 89 of file NamedCandCombinerBase.h.

◆ overlap_

OverlapChecker NamedCandCombinerBase::overlap_
private

utility to check candidate daughters overlap

Definition at line 87 of file NamedCandCombinerBase.h.

Referenced by preselect().