7 checkCharge_(
false), checkOverlap_(
true), dauCharge_(), overlap_(), name_(name) {
41 bool matchCharge = (q1 == dq1 &&
q2 == dq2) || (q1 == -dq1 && q2 == -dq2);
42 if (!matchCharge)
return false;
55 unique_ptr<NamedCompositeCandidateCollection>
58 size_t srcSize = src.size();
61 <<
"NamedCandCombiner: trying to combine " << srcSize <<
" collections" 62 <<
" but configured to check against " <<
dauCharge_.size() <<
" charges.";
64 if ( names.size() < 2 )
66 <<
"NamedCandCombiner: need to add 2 names, but size is " << names.size();
72 const int n = src1.
size();
73 for(
int i1 = 0; i1 <
n; ++i1) {
75 for(
int i2 = i1 + 1; i2 <
n; ++i2) {
79 combine(c, src1[i1], src1[i2], names[0], names[1]);
86 const int n1 = src1.
size(), n2 = src2.size();
87 for(
int i1 = 0; i1 < n1; ++i1) {
89 for(
int i2 = 0; i2 < n2; ++i2) {
93 combine(c, src1[i1], src2[i2], names[0], names[1]);
103 combine(0, stack, qStack, names, src.begin(), src.end(), comps);
109 unique_ptr<NamedCompositeCandidateCollection>
113 <<
"NamedCandCombiner: trying to combine 2 collections" 114 <<
" but configured to check against " <<
dauCharge_.size() <<
" charges.";
116 if ( names.size() < 2 )
118 <<
"NamedCandCombiner: need to add 2 names, but size is " << names.size();
121 const int n = src.
size();
122 for(
int i1 = 0; i1 <
n; ++i1) {
124 for(
int i2 = i1 + 1; i2 <
n; ++i2) {
128 combine(c, src[i1], src[i2], names[0], names[1]);
138 unique_ptr<NamedCompositeCandidateCollection>
140 vector<CandidatePtrVector>
src;
146 unique_ptr<NamedCompositeCandidateCollection>
149 vector<CandidatePtrVector>
src;
156 unique_ptr<NamedCompositeCandidateCollection>
160 vector<CandidatePtrVector>
src;
170 vector<CandidatePtrVector>::const_iterator collBegin,
171 vector<CandidatePtrVector>::const_iterator collEnd,
172 unique_ptr<NamedCompositeCandidateCollection> & comps)
const {
173 if(collBegin == collEnd) {
174 static const int undetermined = 0, sameDecay = 1, conjDecay = -1, wrongDecay = 2;
175 int decayType = undetermined;
177 assert(qStack.size() == stack.size());
178 for(
size_t i = 0;
i < qStack.size(); ++
i) {
180 if(decayType == undetermined) {
181 if(q != 0 && dq != 0) {
182 if(q == dq) decayType = sameDecay;
183 else if(q == -dq) decayType = conjDecay;
184 else decayType = wrongDecay;
186 }
else if((decayType == sameDecay && q != dq) ||
187 (decayType == conjDecay && q != -dq)) {
188 decayType = wrongDecay;
190 if(decayType == wrongDecay)
break;
193 if(decayType != wrongDecay) {
196 for(CandStack::const_iterator
i = stack.begin();
i != stack.end(); ++
i, ++
ii) {
205 size_t candBegin = 0, candEnd = src.
size();
206 for(CandStack::const_iterator
i = stack.begin();
i != stack.end(); ++
i)
207 if(src == *
i->second)
208 candBegin =
i->first.second + 1;
209 for(
size_t candIndex = candBegin; candIndex != candEnd; ++ candIndex) {
212 bool noOverlap =
true;
214 for(CandStack::const_iterator
i = stack.begin();
i != stack.end(); ++
i)
220 stack.push_back(make_pair(make_pair(candPtr, candIndex), collBegin));
222 combine(collectionIndex + 1, stack, qStack, names, collBegin + 1, collEnd, comps);
NamedCandCombinerBase(std::string name)
default construct
size_type size() const
Size of the RefVector.
std::vector< NamedCompositeCandidate > NamedCompositeCandidateCollection
collection of Candidate objects
const std::string names[nVars_]
virtual void setup(reco::NamedCompositeCandidate &) const =0
set kinematics to reconstructed composite
std::vector< int > ChargeStack
virtual bool select(const reco::Candidate &) const =0
select a candidate
std::vector< std::pair< std::pair< reco::CandidatePtr, size_t >, std::vector< reco::CandidatePtrVector >::const_iterator > > CandStack
temporary candidate stack
OverlapChecker overlap_
utility to check candidate daughters overlap
virtual bool selectPair(const reco::Candidate &c1, const reco::Candidate &c2) const =0
select a candidate pair
bool preselect(const reco::Candidate &, const reco::Candidate &) const
verify that the two candidate don't overlap and check charge
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)
virtual int charge() const =0
electric charge
std::unique_ptr< reco::NamedCompositeCandidateCollection > combine(const std::vector< reco::CandidatePtrVector > &, string_coll const &) const
return all selected candidate pairs
std::vector< std::string > string_coll
virtual void addDaughter(reco::NamedCompositeCandidate &cmp, const reco::CandidatePtr &c, std::string name) const =0
add candidate daughter
virtual ~NamedCandCombinerBase()
destructor