test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
CandCombinerBase< OutputCollection, CandPtr > Class Template Referenceabstract

#include <CandCombinerBase.h>

Public Types

typedef std::vector< std::string > vstring
 
typedef std::vector< std::string > vstring
 

Public Member Functions

 CandCombinerBase (const std::string="")
 default construct More...
 
 CandCombinerBase (const std::string="")
 default construct More...
 
 CandCombinerBase (int, int, const std::string="")
 construct from two charge values More...
 
 CandCombinerBase (int, int, const std::string="")
 construct from two charge values More...
 
 CandCombinerBase (int, int, int, const std::string="")
 construct from three charge values More...
 
 CandCombinerBase (int, int, int, const std::string="")
 construct from three charge values More...
 
 CandCombinerBase (int, int, int, int, const std::string="")
 construct from four charge values More...
 
 CandCombinerBase (int, int, int, int, const std::string="")
 construct from four charge values More...
 
 CandCombinerBase (bool checkCharge, const std::vector< int > &, const std::string="")
 constructor from a selector, specifying optionally to check for charge More...
 
 CandCombinerBase (bool checkCharge, bool checkOverlap, const std::vector< int > &, const std::string="")
 constructor from a selector, specifying optionally to check for charge More...
 
std::auto_ptr< OutputCollection > combine (const std::vector< edm::Handle< reco::CandidateView > > &, const vstring=vstring()) const
 return all selected candidate pairs More...
 
std::auto_ptr< OutputCollection > combine (const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
 return all selected candidate pairs More...
 
std::auto_ptr< OutputCollection > combine (const edm::Handle< reco::CandidateView > &, const vstring &=vstring()) const
 return all selected candidate pairs More...
 
std::auto_ptr< OutputCollection > combine (const edm::Handle< reco::CandidateView > &, const vstring=vstring()) const
 return all selected candidate pairs More...
 
std::auto_ptr< OutputCollection > combine (const edm::Handle< reco::CandidateView > &, const edm::Handle< reco::CandidateView > &, const vstring &=vstring()) const
 return all selected candidate pairs More...
 
std::auto_ptr< OutputCollection > combine (const edm::Handle< reco::CandidateView > &, const edm::Handle< reco::CandidateView > &, const vstring=vstring()) const
 return all selected candidate pairs More...
 
std::auto_ptr< OutputCollection > combine (const edm::Handle< reco::CandidateView > &, const edm::Handle< reco::CandidateView > &, const edm::Handle< reco::CandidateView > &, const vstring=vstring()) const
 return all selected candidate pairs More...
 
std::auto_ptr< OutputCollection > combine (const edm::Handle< reco::CandidateView > &, const edm::Handle< reco::CandidateView > &, const edm::Handle< reco::CandidateView > &, const vstring &=vstring()) const
 return all selected candidate pairs More...
 
std::auto_ptr< OutputCollection > combine (const edm::Handle< reco::CandidateView > &, const edm::Handle< reco::CandidateView > &, const edm::Handle< reco::CandidateView > &, const edm::Handle< reco::CandidateView > &, const vstring=vstring()) const
 return all selected candidate pairs More...
 
std::auto_ptr< OutputCollection > combine (const edm::Handle< reco::CandidateView > &, const edm::Handle< reco::CandidateView > &, const edm::Handle< reco::CandidateView > &, const edm::Handle< reco::CandidateView > &, const vstring &=vstring()) const
 return all selected candidate pairs More...
 
virtual ~CandCombinerBase ()
 destructor More...
 
virtual ~CandCombinerBase ()
 destructor More...
 

Private Types

typedef std::vector< std::pair
< std::pair< CandPtr, size_t >
, std::vector< edm::Handle
< reco::CandidateView >
>::const_iterator > > 
CandStack
 temporary candidate stack More...
 
typedef std::vector< std::pair
< std::pair< CandPtr, size_t >
, std::vector< edm::Handle
< reco::CandidateView >
>::const_iterator > > 
CandStack
 temporary candidate stack More...
 
typedef std::vector< int > ChargeStack
 
typedef std::vector< int > ChargeStack
 

Private Member Functions

virtual void addDaughter (typename OutputCollection::value_type &cmp, const CandPtr &c, const std::string="") const =0
 add candidate daughter More...
 
virtual void addDaughter (typename OutputCollection::value_type &cmp, const CandPtr &c, const std::string="") const =0
 add candidate daughter More...
 
void combine (typename OutputCollection::value_type &, const CandPtr &, const CandPtr &, const std::string="", const std::string="") const
 returns a composite candidate combined from two daughters More...
 
void combine (typename OutputCollection::value_type &, const CandPtr &, const CandPtr &, const std::string="", const std::string="") const
 returns a composite candidate combined from two daughters More...
 
void combine (size_t collectionIndex, CandStack &, ChargeStack &, std::vector< edm::Handle< reco::CandidateView > >::const_iterator begin, std::vector< edm::Handle< reco::CandidateView > >::const_iterator end, std::auto_ptr< OutputCollection > &comps, const vstring name=vstring()) const
 returns a composite candidate combined from two daughters More...
 
void combine (size_t collectionIndex, CandStack &, ChargeStack &, std::vector< edm::Handle< reco::CandidateView > >::const_iterator begin, std::vector< edm::Handle< reco::CandidateView > >::const_iterator end, std::auto_ptr< OutputCollection > &comps, const vstring &name=vstring()) 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...
 
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 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 bool selectPair (const reco::Candidate &c1, const reco::Candidate &c2) const =0
 select a candidate pair More...
 
virtual void setup (typename OutputCollection::value_type &) const =0
 set kinematics to reconstructed composite More...
 
virtual void setup (typename OutputCollection::value_type &) 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_
 composite name (if applies) More...
 
OverlapChecker overlap_
 utility to check candidate daughters overlap More...
 

Detailed Description

template<typename OutputCollection, typename CandPtr>
class CandCombinerBase< OutputCollection, CandPtr >

Author
Luca Lista, INFN

Definition at line 14 of file CandCombinerBase.h.

Member Typedef Documentation

template<typename OutputCollection, typename CandPtr>
typedef std::vector<std::pair<std::pair<CandPtr, size_t>, std::vector<edm::Handle<reco::CandidateView> >::const_iterator> > CandCombinerBase< OutputCollection, CandPtr >::CandStack
private

temporary candidate stack

Definition at line 60 of file CandCombinerBase.h.

template<typename OutputCollection, typename CandPtr>
typedef std::vector<std::pair<std::pair<CandPtr, size_t>, std::vector<edm::Handle<reco::CandidateView> >::const_iterator> > CandCombinerBase< OutputCollection, CandPtr >::CandStack
private

temporary candidate stack

Definition at line 60 of file CandCombinerBase.h.

template<typename OutputCollection, typename CandPtr>
typedef std::vector<int> CandCombinerBase< OutputCollection, CandPtr >::ChargeStack
private

Definition at line 61 of file CandCombinerBase.h.

template<typename OutputCollection, typename CandPtr>
typedef std::vector<int> CandCombinerBase< OutputCollection, CandPtr >::ChargeStack
private

Definition at line 61 of file CandCombinerBase.h.

template<typename OutputCollection, typename CandPtr>
typedef std::vector<std::string> CandCombinerBase< OutputCollection, CandPtr >::vstring

Definition at line 16 of file CandCombinerBase.h.

template<typename OutputCollection, typename CandPtr>
typedef std::vector<std::string> CandCombinerBase< OutputCollection, CandPtr >::vstring

Definition at line 16 of file CandCombinerBase.h.

Constructor & Destructor Documentation

template<typename OutputCollection , typename CandPtr >
CandCombinerBase< OutputCollection, CandPtr >::CandCombinerBase ( const std::string  name = "")
explicit

default construct

Definition at line 89 of file CandCombinerBase.h.

89  :
90  checkCharge_(false), checkOverlap_(true), dauCharge_(), overlap_(), name_(name) {
91 }
bool checkOverlap_
flag to specify the checking of overlaps
bool checkCharge_
flag to specify the checking of electric charge
OverlapChecker overlap_
utility to check candidate daughters overlap
std::vector< int > dauCharge_
electric charges of the daughters
std::string name_
composite name (if applies)
template<typename OutputCollection , typename CandPtr >
CandCombinerBase< OutputCollection, CandPtr >::CandCombinerBase ( int  q1,
int  q2,
const std::string  name = "" 
)

construct from two charge values

Definition at line 94 of file CandCombinerBase.h.

References CandCombinerBase< OutputCollection, CandPtr >::dauCharge_, q1, and q2.

94  :
95  checkCharge_(true), checkOverlap_(true), dauCharge_(2), overlap_(), name_(name) {
96  dauCharge_[0] = q1;
97  dauCharge_[1] = q2;
98 }
bool checkOverlap_
flag to specify the checking of overlaps
bool checkCharge_
flag to specify the checking of electric charge
OverlapChecker overlap_
utility to check candidate daughters overlap
double q2[4]
Definition: TauolaWrapper.h:88
double q1[4]
Definition: TauolaWrapper.h:87
std::vector< int > dauCharge_
electric charges of the daughters
std::string name_
composite name (if applies)
template<typename OutputCollection , typename CandPtr >
CandCombinerBase< OutputCollection, CandPtr >::CandCombinerBase ( int  q1,
int  q2,
int  q3,
const std::string  name = "" 
)

construct from three charge values

Definition at line 101 of file CandCombinerBase.h.

References CandCombinerBase< OutputCollection, CandPtr >::dauCharge_, q1, and q2.

101  :
102  checkCharge_(true), checkOverlap_(true), dauCharge_(3), overlap_(), name_(name) {
103  dauCharge_[0] = q1;
104  dauCharge_[1] = q2;
105  dauCharge_[2] = q3;
106 }
bool checkOverlap_
flag to specify the checking of overlaps
bool checkCharge_
flag to specify the checking of electric charge
OverlapChecker overlap_
utility to check candidate daughters overlap
double q2[4]
Definition: TauolaWrapper.h:88
double q1[4]
Definition: TauolaWrapper.h:87
std::vector< int > dauCharge_
electric charges of the daughters
std::string name_
composite name (if applies)
template<typename OutputCollection , typename CandPtr >
CandCombinerBase< OutputCollection, CandPtr >::CandCombinerBase ( int  q1,
int  q2,
int  q3,
int  q4,
const std::string  name = "" 
)

construct from four charge values

Definition at line 109 of file CandCombinerBase.h.

References CandCombinerBase< OutputCollection, CandPtr >::dauCharge_, q1, and q2.

109  :
110  checkCharge_(true), checkOverlap_(true), dauCharge_(4), overlap_(), name_(name) {
111  dauCharge_[0] = q1;
112  dauCharge_[1] = q2;
113  dauCharge_[2] = q3;
114  dauCharge_[3] = q4;
115 }
bool checkOverlap_
flag to specify the checking of overlaps
bool checkCharge_
flag to specify the checking of electric charge
OverlapChecker overlap_
utility to check candidate daughters overlap
double q2[4]
Definition: TauolaWrapper.h:88
double q1[4]
Definition: TauolaWrapper.h:87
std::vector< int > dauCharge_
electric charges of the daughters
std::string name_
composite name (if applies)
template<typename OutputCollection , typename CandPtr >
CandCombinerBase< OutputCollection, CandPtr >::CandCombinerBase ( bool  checkCharge,
bool  checkOverlap,
const std::vector< int > &  dauCharge,
const std::string  name = "" 
)

constructor from a selector, specifying optionally to check for charge

Definition at line 118 of file CandCombinerBase.h.

118  :
120 }
bool checkOverlap_
flag to specify the checking of overlaps
bool checkCharge_
flag to specify the checking of electric charge
OverlapChecker overlap_
utility to check candidate daughters overlap
std::vector< int > dauCharge_
electric charges of the daughters
std::string name_
composite name (if applies)
template<typename OutputCollection , typename CandPtr >
CandCombinerBase< OutputCollection, CandPtr >::~CandCombinerBase ( )
virtual

destructor

Definition at line 123 of file CandCombinerBase.h.

123  {
124 }
template<typename OutputCollection, typename CandPtr>
CandCombinerBase< OutputCollection, CandPtr >::CandCombinerBase ( const std::string  = "")
explicit

default construct

template<typename OutputCollection, typename CandPtr>
CandCombinerBase< OutputCollection, CandPtr >::CandCombinerBase ( int  ,
int  ,
const std::string  = "" 
)

construct from two charge values

template<typename OutputCollection, typename CandPtr>
CandCombinerBase< OutputCollection, CandPtr >::CandCombinerBase ( int  ,
int  ,
int  ,
const std::string  = "" 
)

construct from three charge values

template<typename OutputCollection, typename CandPtr>
CandCombinerBase< OutputCollection, CandPtr >::CandCombinerBase ( int  ,
int  ,
int  ,
int  ,
const std::string  = "" 
)

construct from four charge values

template<typename OutputCollection , typename CandPtr >
CandCombinerBase< OutputCollection, CandPtr >::CandCombinerBase ( bool  checkCharge,
const std::vector< int > &  dauCharge,
const std::string  name = "" 
)

constructor from a selector, specifying optionally to check for charge

Definition at line 116 of file CandCombinerBase.h.

116  :
118 }
bool checkCharge_
flag to specify the checking of electric charge
OverlapChecker overlap_
utility to check candidate daughters overlap
std::vector< int > dauCharge_
electric charges of the daughters
std::string name_
composite name (if applies)
template<typename OutputCollection, typename CandPtr>
virtual CandCombinerBase< OutputCollection, CandPtr >::~CandCombinerBase ( )
virtual

destructor

Member Function Documentation

template<typename OutputCollection, typename CandPtr>
virtual void CandCombinerBase< OutputCollection, CandPtr >::addDaughter ( typename OutputCollection::value_type &  cmp,
const CandPtr &  c,
const std::string  = "" 
) const
privatepure virtual
template<typename OutputCollection, typename CandPtr>
virtual void CandCombinerBase< OutputCollection, CandPtr >::addDaughter ( typename OutputCollection::value_type &  cmp,
const CandPtr &  c,
const std::string  = "" 
) const
privatepure virtual
template<typename OutputCollection , typename CandPtr >
std::auto_ptr< OutputCollection > CandCombinerBase< OutputCollection, CandPtr >::combine ( const std::vector< edm::Handle< reco::CandidateView > > &  src,
const vstring names = vstring() 
) const

return all selected candidate pairs

Definition at line 148 of file CandCombinerBase.h.

References EnergyCorrector::c, alignmentValidation::c1, funct::combine(), edm::errors::Configuration, Exception, edm::ProductID::id(), edm::HandleBase::id(), gen::n, cscdqm::h::names, cscdqm::h::namesSize, TrackingRecHitProducer_cfi::select, edm::View< T >::size(), alcazmumu_cfi::src, readCalibrations2004_v2_cff::src1, readConfiguration2006_v0_cff::src2, svgfig::stack, and AlCaHLTBitMon_QueryRunRegistry::string.

149  {
150  size_t srcSize = src.size();
151  if (checkCharge_ && dauCharge_.size() != srcSize)
153  << "CandCombiner: trying to combine " << srcSize << " collections"
154  << " but configured to check against " << dauCharge_.size() << " charges.";
155  std::auto_ptr<OutputCollection> comps(new OutputCollection);
156  size_t namesSize = names.size();
157  if(srcSize == 2) {
158  std::string name1="", name2="";
159  if(namesSize > 0) {
160  if(namesSize != 2)
162  << "CandCombiner: should specify exactly two "
163  << " names in configuration (" << namesSize << " specified).\n";
164  name1 = names[0];
165  name2 = names[1];
166  }
168  if(src1.id() == src2.id()) {
169  const reco::CandidateView & cands = * src1;
170  const size_t n = cands.size();
171  for(size_t i1 = 0; i1 < n; ++i1) {
172  const reco::Candidate & c1 = cands[i1];
173  CandPtr cr1(src1, i1);
174  for(size_t i2 = i1 + 1; i2 < n; ++i2) {
175  const reco::Candidate & c2 = cands[i2];
176  if(preselect(c1, c2)) {
177  CandPtr cr2(src2, i2);
179  combine(c, cr1, cr2, name1, name2);
180  if(select(c))
181  comps->push_back(c);
182  }
183  }
184  }
185  } else {
186  const reco::CandidateView & cands1 = * src1, & cands2 = * src2;
187  const size_t n1 = cands1.size(), n2 = cands2.size();
188  for(size_t i1 = 0; i1 < n1; ++i1) {
189  const reco::Candidate & c1 = cands1[i1];
190  CandPtr cr1(src1, i1);
191  for(size_t i2 = 0; i2 < n2; ++i2) {
192  const reco::Candidate & c2 = cands2[i2];
193  if(preselect(c1, c2)) {
194  CandPtr cr2(src2, i2);
196  combine(c, cr1, cr2, name1, name2);
197  if(select(c))
198  comps->push_back(c);
199  }
200  }
201  }
202  }
203  } else {
205  ChargeStack qStack;
206  combine(0, stack, qStack, src.begin(), src.end(), comps, names);
207  }
208 
209  return comps;
210 }
virtual bool select(const reco::Candidate &) const =0
select a candidate
static const HistoName names[]
ProductID id() const
Definition: HandleBase.cc:15
bool checkCharge_
flag to specify the checking of electric charge
bool preselect(const reco::Candidate &, const reco::Candidate &) const
verify that the two candidate don&#39;t overlap and check charge
size_type size() const
static const unsigned int namesSize
std::auto_ptr< OutputCollection > combine(const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
return all selected candidate pairs
stack
Definition: svgfig.py:558
std::vector< std::pair< std::pair< CandPtr, size_t >, std::vector< edm::Handle< reco::CandidateView > >::const_iterator > > CandStack
temporary candidate stack
std::vector< int > dauCharge_
electric charges of the daughters
ProductIndex id() const
Definition: ProductID.h:38
std::vector< int > ChargeStack
template<typename OutputCollection, typename CandPtr>
std::auto_ptr< OutputCollection > CandCombinerBase< OutputCollection, CandPtr >::combine ( const std::vector< edm::Handle< reco::CandidateView > > &  src,
const vstring  names = vstring() 
) const

return all selected candidate pairs

Definition at line 146 of file CandCombinerBase.h.

References EnergyCorrector::c, funct::combine(), edm::errors::Configuration, Exception, edm::ProductID::id(), edm::HandleBase::id(), gen::n, cscdqm::h::names, cscdqm::h::namesSize, TrackingRecHitProducer_cfi::select, edm::View< T >::size(), alcazmumu_cfi::src, readCalibrations2004_v2_cff::src1, readConfiguration2006_v0_cff::src2, svgfig::stack, and AlCaHLTBitMon_QueryRunRegistry::string.

147  {
148  size_t srcSize = src.size();
149  if (checkCharge_ && dauCharge_.size() != srcSize)
151  << "CandCombiner: trying to combine " << srcSize << " collections"
152  << " but configured to check against " << dauCharge_.size() << " charges.";
153  std::auto_ptr<OutputCollection> comps(new OutputCollection);
154  size_t namesSize = names.size();
155  if(srcSize == 2) {
156  std::string name1="", name2="";
157  if(namesSize > 0) {
158  if(namesSize != 2)
160  << "CandCombiner: should specify exactly two "
161  << " names in configuration (" << namesSize << " specified).\n";
162  name1 = names[0];
163  name2 = names[1];
164  }
166  if(src1.id() == src2.id()) {
167  const reco::CandidateView & cands = * src1;
168  const size_t n = cands.size();
169  for(size_t i1 = 0; i1 < n; ++i1) {
170  const reco::Candidate & c1 = cands[i1];
171  CandPtr cr1(src1, i1);
172  for(size_t i2 = i1 + 1; i2 < n; ++i2) {
173  const reco::Candidate & c2 = cands[i2];
174  if(preselect(c1, c2)) {
175  CandPtr cr2(src2, i2);
177  combine(c, cr1, cr2, name1, name2);
178  if(select(c))
179  comps->push_back(c);
180  }
181  }
182  }
183  } else {
184  const reco::CandidateView & cands1 = * src1, & cands2 = * src2;
185  const size_t n1 = cands1.size(), n2 = cands2.size();
186  for(size_t i1 = 0; i1 < n1; ++i1) {
187  const reco::Candidate & c1 = cands1[i1];
188  CandPtr cr1(src1, i1);
189  for(size_t i2 = 0; i2 < n2; ++i2) {
190  const reco::Candidate & c2 = cands2[i2];
191  if(preselect(c1, c2)) {
192  CandPtr cr2(src2, i2);
194  combine(c, cr1, cr2, name1, name2);
195  if(select(c))
196  comps->push_back(c);
197  }
198  }
199  }
200  }
201  } else {
203  ChargeStack qStack;
204  combine(0, stack, qStack, src.begin(), src.end(), comps, names);
205  }
206 
207  return comps;
208 }
virtual bool select(const reco::Candidate &) const =0
select a candidate
static const HistoName names[]
ProductID id() const
Definition: HandleBase.cc:15
bool checkCharge_
flag to specify the checking of electric charge
bool preselect(const reco::Candidate &, const reco::Candidate &) const
verify that the two candidate don&#39;t overlap and check charge
size_type size() const
static const unsigned int namesSize
std::auto_ptr< OutputCollection > combine(const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
return all selected candidate pairs
stack
Definition: svgfig.py:558
std::vector< std::pair< std::pair< CandPtr, size_t >, std::vector< edm::Handle< reco::CandidateView > >::const_iterator > > CandStack
temporary candidate stack
std::vector< int > dauCharge_
electric charges of the daughters
ProductIndex id() const
Definition: ProductID.h:38
std::vector< int > ChargeStack
template<typename OutputCollection , typename CandPtr >
std::auto_ptr< OutputCollection > CandCombinerBase< OutputCollection, CandPtr >::combine ( const edm::Handle< reco::CandidateView > &  src,
const vstring names = vstring() 
) const

return all selected candidate pairs

Definition at line 214 of file CandCombinerBase.h.

References EnergyCorrector::c, alignmentValidation::c1, funct::combine(), edm::errors::Configuration, Exception, gen::n, cscdqm::h::namesSize, TrackingRecHitProducer_cfi::select, edm::View< T >::size(), alcazmumu_cfi::src, and AlCaHLTBitMon_QueryRunRegistry::string.

215  {
216  if(checkCharge_ && dauCharge_.size() != 2)
218  << "CandCombiner: trying to combine 2 collections"
219  << " but configured to check against " << dauCharge_.size() << " charges.";
220 
221  std::auto_ptr<OutputCollection> comps(new OutputCollection);
222  size_t namesSize = names.size();
223  std::string name1, name2;
224  if(namesSize > 0) {
225  if(namesSize != 2)
227  << "CandCombiner: should specify exactly two "
228  << " names in configuration (" << namesSize << " specified).\n";
229  name1 = names[0];
230  name2 = names[1];
231  }
232  const reco::CandidateView & cands = * src;
233  const size_t n = cands.size();
234  for(size_t i1 = 0; i1 < n; ++i1) {
235  const reco::Candidate & c1 = cands[i1];
236  CandPtr cr1(src, i1);
237  for(size_t i2 = i1 + 1; i2 < n; ++i2) {
238  const reco::Candidate & c2 = cands[i2];
239  if(preselect(c1, c2)) {
240  CandPtr cr2(src, i2);
242  combine(c, cr1, cr2, name1, name2);
243  if(select(c))
244  comps->push_back(c);
245  }
246  }
247  }
248 
249  return comps;
250 }
virtual bool select(const reco::Candidate &) const =0
select a candidate
static const HistoName names[]
bool checkCharge_
flag to specify the checking of electric charge
bool preselect(const reco::Candidate &, const reco::Candidate &) const
verify that the two candidate don&#39;t overlap and check charge
size_type size() const
static const unsigned int namesSize
std::auto_ptr< OutputCollection > combine(const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
return all selected candidate pairs
std::vector< int > dauCharge_
electric charges of the daughters
template<typename OutputCollection, typename CandPtr>
std::auto_ptr< OutputCollection > CandCombinerBase< OutputCollection, CandPtr >::combine ( const edm::Handle< reco::CandidateView > &  src,
const vstring  names = vstring() 
) const

return all selected candidate pairs

Definition at line 212 of file CandCombinerBase.h.

References EnergyCorrector::c, funct::combine(), edm::errors::Configuration, Exception, gen::n, cscdqm::h::namesSize, TrackingRecHitProducer_cfi::select, edm::View< T >::size(), alcazmumu_cfi::src, and AlCaHLTBitMon_QueryRunRegistry::string.

213  {
214  if(checkCharge_ && dauCharge_.size() != 2)
216  << "CandCombiner: trying to combine 2 collections"
217  << " but configured to check against " << dauCharge_.size() << " charges.";
218 
219  std::auto_ptr<OutputCollection> comps(new OutputCollection);
220  size_t namesSize = names.size();
221  std::string name1, name2;
222  if(namesSize > 0) {
223  if(namesSize != 2)
225  << "CandCombiner: should specify exactly two "
226  << " names in configuration (" << namesSize << " specified).\n";
227  name1 = names[0];
228  name2 = names[1];
229  }
230  const reco::CandidateView & cands = * src;
231  const size_t n = cands.size();
232  for(size_t i1 = 0; i1 < n; ++i1) {
233  const reco::Candidate & c1 = cands[i1];
234  CandPtr cr1(src, i1);
235  for(size_t i2 = i1 + 1; i2 < n; ++i2) {
236  const reco::Candidate & c2 = cands[i2];
237  if(preselect(c1, c2)) {
238  CandPtr cr2(src, i2);
240  combine(c, cr1, cr2, name1, name2);
241  if(select(c))
242  comps->push_back(c);
243  }
244  }
245  }
246 
247  return comps;
248 }
virtual bool select(const reco::Candidate &) const =0
select a candidate
static const HistoName names[]
bool checkCharge_
flag to specify the checking of electric charge
bool preselect(const reco::Candidate &, const reco::Candidate &) const
verify that the two candidate don&#39;t overlap and check charge
size_type size() const
static const unsigned int namesSize
std::auto_ptr< OutputCollection > combine(const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
return all selected candidate pairs
std::vector< int > dauCharge_
electric charges of the daughters
template<typename OutputCollection , typename CandPtr >
std::auto_ptr< OutputCollection > CandCombinerBase< OutputCollection, CandPtr >::combine ( const edm::Handle< reco::CandidateView > &  src1,
const edm::Handle< reco::CandidateView > &  src2,
const vstring names = vstring() 
) const

return all selected candidate pairs

Definition at line 254 of file CandCombinerBase.h.

References funct::combine(), and alcazmumu_cfi::src.

256  {
257  std::vector<edm::Handle<reco::CandidateView> > src;
258  src.push_back(src1);
259  src.push_back(src2);
260  return combine(src, names);
261 }
static const HistoName names[]
std::auto_ptr< OutputCollection > combine(const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
return all selected candidate pairs
template<typename OutputCollection, typename CandPtr>
std::auto_ptr< OutputCollection > CandCombinerBase< OutputCollection, CandPtr >::combine ( const edm::Handle< reco::CandidateView > &  src1,
const edm::Handle< reco::CandidateView > &  src2,
const vstring  names = vstring() 
) const

return all selected candidate pairs

Definition at line 252 of file CandCombinerBase.h.

References funct::combine(), and alcazmumu_cfi::src.

254  {
255  std::vector<edm::Handle<reco::CandidateView> > src;
256  src.push_back(src1);
257  src.push_back(src2);
258  return combine(src, names);
259 }
static const HistoName names[]
std::auto_ptr< OutputCollection > combine(const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
return all selected candidate pairs
template<typename OutputCollection , typename CandPtr >
std::auto_ptr< OutputCollection > CandCombinerBase< OutputCollection, CandPtr >::combine ( const edm::Handle< reco::CandidateView > &  src1,
const edm::Handle< reco::CandidateView > &  src2,
const edm::Handle< reco::CandidateView > &  src3,
const vstring names = vstring() 
) const

return all selected candidate pairs

Definition at line 265 of file CandCombinerBase.h.

References funct::combine(), and alcazmumu_cfi::src.

268  {
269  std::vector<edm::Handle<reco::CandidateView> > src;
270  src.push_back(src1);
271  src.push_back(src2);
272  src.push_back(src3);
273  return combine(src, names);
274 }
static const HistoName names[]
std::auto_ptr< OutputCollection > combine(const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
return all selected candidate pairs
template<typename OutputCollection, typename CandPtr>
std::auto_ptr< OutputCollection > CandCombinerBase< OutputCollection, CandPtr >::combine ( const edm::Handle< reco::CandidateView > &  src1,
const edm::Handle< reco::CandidateView > &  src2,
const edm::Handle< reco::CandidateView > &  src3,
const vstring  names = vstring() 
) const

return all selected candidate pairs

Definition at line 263 of file CandCombinerBase.h.

References funct::combine(), and alcazmumu_cfi::src.

266  {
267  std::vector<edm::Handle<reco::CandidateView> > src;
268  src.push_back(src1);
269  src.push_back(src2);
270  src.push_back(src3);
271  return combine(src, names);
272 }
static const HistoName names[]
std::auto_ptr< OutputCollection > combine(const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
return all selected candidate pairs
template<typename OutputCollection, typename CandPtr>
std::auto_ptr< OutputCollection > CandCombinerBase< OutputCollection, CandPtr >::combine ( const edm::Handle< reco::CandidateView > &  src1,
const edm::Handle< reco::CandidateView > &  src2,
const edm::Handle< reco::CandidateView > &  src3,
const edm::Handle< reco::CandidateView > &  src4,
const vstring  names = vstring() 
) const

return all selected candidate pairs

Definition at line 276 of file CandCombinerBase.h.

References funct::combine(), and alcazmumu_cfi::src.

280  {
281  std::vector<edm::Handle<reco::CandidateView> > src;
282  src.push_back(src1);
283  src.push_back(src2);
284  src.push_back(src3);
285  src.push_back(src4);
286  return combine(src, names);
287 }
static const HistoName names[]
std::auto_ptr< OutputCollection > combine(const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
return all selected candidate pairs
template<typename OutputCollection , typename CandPtr >
std::auto_ptr< OutputCollection > CandCombinerBase< OutputCollection, CandPtr >::combine ( const edm::Handle< reco::CandidateView > &  src1,
const edm::Handle< reco::CandidateView > &  src2,
const edm::Handle< reco::CandidateView > &  src3,
const edm::Handle< reco::CandidateView > &  src4,
const vstring names = vstring() 
) const

return all selected candidate pairs

Definition at line 278 of file CandCombinerBase.h.

References funct::combine(), and alcazmumu_cfi::src.

282  {
283  std::vector<edm::Handle<reco::CandidateView> > src;
284  src.push_back(src1);
285  src.push_back(src2);
286  src.push_back(src3);
287  src.push_back(src4);
288  return combine(src, names);
289 }
static const HistoName names[]
std::auto_ptr< OutputCollection > combine(const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
return all selected candidate pairs
template<typename OutputCollection, typename CandPtr>
void CandCombinerBase< OutputCollection, CandPtr >::combine ( typename OutputCollection::value_type &  ,
const CandPtr &  ,
const CandPtr &  ,
const std::string  = "",
const std::string  = "" 
) const
private

returns a composite candidate combined from two daughters

template<typename OutputCollection, typename CandPtr>
void CandCombinerBase< OutputCollection, CandPtr >::combine ( typename OutputCollection::value_type &  cmp,
const CandPtr &  c1,
const CandPtr &  c2,
const std::string  name1 = "",
const std::string  name2 = "" 
) const
private

returns a composite candidate combined from two daughters

Definition at line 138 of file CandCombinerBase.h.

References GeneralSetup::setup().

140  {
141  addDaughter(cmp, c1, name1);
142  addDaughter(cmp, c2, name2);
143  setup(cmp);
144 }
virtual void addDaughter(typename OutputCollection::value_type &cmp, const CandPtr &c, const std::string="") const =0
add candidate daughter
virtual void setup(typename OutputCollection::value_type &) const =0
set kinematics to reconstructed composite
template<typename OutputCollection, typename CandPtr>
void CandCombinerBase< OutputCollection, CandPtr >::combine ( size_t  collectionIndex,
CandStack stack,
ChargeStack qStack,
std::vector< edm::Handle< reco::CandidateView > >::const_iterator  begin,
std::vector< edm::Handle< reco::CandidateView > >::const_iterator  end,
std::auto_ptr< OutputCollection > &  comps,
const vstring name = vstring() 
) const
private

returns a composite candidate combined from two daughters

Definition at line 292 of file CandCombinerBase.h.

References assert(), EnergyCorrector::c, reco::Candidate::charge(), funct::combine(), i, edm::HandleBase::id(), lumiQueryAPI::q, TrackingRecHitProducer_cfi::select, GeneralSetup::setup(), edm::View< T >::size(), and alcazmumu_cfi::src.

296  {
297  if(collBegin == collEnd) {
298  static const int undetermined = 0, sameDecay = 1, conjDecay = -1, wrongDecay = 2;
299  int decayType = undetermined;
300  if(checkCharge_) {
301  assert(qStack.size() == stack.size());
302  for(size_t i = 0; i < qStack.size(); ++i) {
303  int q = qStack[i], dq = dauCharge_[i];
304  if(decayType == undetermined) {
305  if(q != 0 && dq != 0) {
306  if(q == dq) decayType = sameDecay;
307  else if(q == -dq) decayType = conjDecay;
308  else decayType = wrongDecay;
309  }
310  } else if((decayType == sameDecay && q != dq) ||
311  (decayType == conjDecay && q != -dq)) {
312  decayType = wrongDecay;
313  }
314  if(decayType == wrongDecay) break;
315  }
316  }
317  if(decayType != wrongDecay) {
319  size_t nameIndex = 0;
320  for(typename CandStack::const_iterator i = stack.begin(); i != stack.end(); ++i, ++ nameIndex) {
321  if ( names.size() > 0 )
322  addDaughter(c, i->first.first, names[nameIndex]);
323  else
324  addDaughter(c, i->first.first);
325  }
326  setup(c);
327  if(select(c))
328  comps->push_back(c);
329  }
330  } else {
331  const edm::Handle<reco::CandidateView> & srcRef = * collBegin;
332  const reco::CandidateView & src = * srcRef;
333  size_t candBegin = 0, candEnd = src.size();
334  for(typename CandStack::const_iterator i = stack.begin(); i != stack.end(); ++i)
335  if(srcRef.id() == i->second->id())
336  candBegin = i->first.second + 1;
337  for(size_t candIndex = candBegin; candIndex != candEnd; ++ candIndex) {
338  CandPtr candRef(srcRef, candIndex);
339  bool noOverlap = true;
340  const reco::Candidate & cand = * candRef;
341  for(typename CandStack::const_iterator i = stack.begin(); i != stack.end(); ++i)
342  if(checkOverlap_ && overlap_(cand, *(i->first.first))) {
343  noOverlap = false;
344  break;
345  }
346  if(noOverlap) {
347  stack.push_back(std::make_pair(std::make_pair(candRef, candIndex), collBegin));
348  if(checkCharge_) qStack.push_back(cand.charge());
349  combine(collectionIndex + 1, stack, qStack, collBegin + 1, collEnd, comps, names);
350  stack.pop_back();
351  qStack.pop_back();
352  }
353  }
354  }
355 }
int i
Definition: DBlmapReader.cc:9
virtual bool select(const reco::Candidate &) const =0
select a candidate
static const HistoName names[]
ProductID id() const
Definition: HandleBase.cc:15
bool checkOverlap_
flag to specify the checking of overlaps
bool checkCharge_
flag to specify the checking of electric charge
assert(m_qm.get())
OverlapChecker overlap_
utility to check candidate daughters overlap
size_type size() const
std::auto_ptr< OutputCollection > combine(const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
return all selected candidate pairs
stack
Definition: svgfig.py:558
virtual void addDaughter(typename OutputCollection::value_type &cmp, const CandPtr &c, const std::string="") const =0
add candidate daughter
virtual int charge() const =0
electric charge
std::vector< int > dauCharge_
electric charges of the daughters
virtual void setup(typename OutputCollection::value_type &) const =0
set kinematics to reconstructed composite
template<typename OutputCollection, typename CandPtr>
void CandCombinerBase< OutputCollection, CandPtr >::combine ( size_t  collectionIndex,
CandStack stack,
ChargeStack qStack,
std::vector< edm::Handle< reco::CandidateView > >::const_iterator  begin,
std::vector< edm::Handle< reco::CandidateView > >::const_iterator  end,
std::auto_ptr< OutputCollection > &  comps,
const vstring  name = vstring() 
) const
private

returns a composite candidate combined from two daughters

Definition at line 290 of file CandCombinerBase.h.

References assert(), EnergyCorrector::c, reco::Candidate::charge(), funct::combine(), i, edm::HandleBase::id(), lumiQueryAPI::q, TrackingRecHitProducer_cfi::select, GeneralSetup::setup(), edm::View< T >::size(), and alcazmumu_cfi::src.

294  {
295  if(collBegin == collEnd) {
296  static const int undetermined = 0, sameDecay = 1, conjDecay = -1, wrongDecay = 2;
297  int decayType = undetermined;
298  if(checkCharge_) {
299  assert(qStack.size() == stack.size());
300  for(size_t i = 0; i < qStack.size(); ++i) {
301  int q = qStack[i], dq = dauCharge_[i];
302  if(decayType == undetermined) {
303  if(q != 0 && dq != 0) {
304  if(q == dq) decayType = sameDecay;
305  else if(q == -dq) decayType = conjDecay;
306  else decayType = wrongDecay;
307  }
308  } else if((decayType == sameDecay && q != dq) ||
309  (decayType == conjDecay && q != -dq)) {
310  decayType = wrongDecay;
311  }
312  if(decayType == wrongDecay) break;
313  }
314  }
315  if(decayType != wrongDecay) {
317  size_t nameIndex = 0;
318  for(typename CandStack::const_iterator i = stack.begin(); i != stack.end(); ++i, ++ nameIndex) {
319  if ( names.size() > 0 )
320  addDaughter(c, i->first.first, names[nameIndex]);
321  else
322  addDaughter(c, i->first.first);
323  }
324  setup(c);
325  if(select(c))
326  comps->push_back(c);
327  }
328  } else {
329  const edm::Handle<reco::CandidateView> & srcRef = * collBegin;
330  const reco::CandidateView & src = * srcRef;
331  size_t candBegin = 0, candEnd = src.size();
332  for(typename CandStack::const_iterator i = stack.begin(); i != stack.end(); ++i)
333  if(srcRef.id() == i->second->id())
334  candBegin = i->first.second + 1;
335  for(size_t candIndex = candBegin; candIndex != candEnd; ++ candIndex) {
336  CandPtr candRef(srcRef, candIndex);
337  bool noOverlap = true;
338  const reco::Candidate & cand = * candRef;
339  for(typename CandStack::const_iterator i = stack.begin(); i != stack.end(); ++i)
340  if(overlap_(cand, *(i->first.first))) {
341  noOverlap = false;
342  break;
343  }
344  if(noOverlap) {
345  stack.push_back(std::make_pair(std::make_pair(candRef, candIndex), collBegin));
346  if(checkCharge_) qStack.push_back(cand.charge());
347  combine(collectionIndex + 1, stack, qStack, collBegin + 1, collEnd, comps, names);
348  stack.pop_back();
349  qStack.pop_back();
350  }
351  }
352  }
353 }
int i
Definition: DBlmapReader.cc:9
virtual bool select(const reco::Candidate &) const =0
select a candidate
static const HistoName names[]
ProductID id() const
Definition: HandleBase.cc:15
bool checkCharge_
flag to specify the checking of electric charge
assert(m_qm.get())
OverlapChecker overlap_
utility to check candidate daughters overlap
size_type size() const
std::auto_ptr< OutputCollection > combine(const std::vector< edm::Handle< reco::CandidateView > > &, const vstring &=vstring()) const
return all selected candidate pairs
stack
Definition: svgfig.py:558
virtual void addDaughter(typename OutputCollection::value_type &cmp, const CandPtr &c, const std::string="") const =0
add candidate daughter
virtual int charge() const =0
electric charge
std::vector< int > dauCharge_
electric charges of the daughters
virtual void setup(typename OutputCollection::value_type &) const =0
set kinematics to reconstructed composite
template<typename OutputCollection , typename CandPtr >
bool CandCombinerBase< OutputCollection, CandPtr >::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 127 of file CandCombinerBase.h.

References reco::Candidate::charge(), q1, and q2.

127  {
128  if (checkCharge_) {
129  int dq1 = dauCharge_[0], dq2 = dauCharge_[1], q1 = c1.charge(), q2 = c2.charge();
130  bool matchCharge = (q1 == dq1 && q2 == dq2) || (q1 == -dq1 && q2 == -dq2);
131  if (!matchCharge) return false;
132  }
133  if (checkOverlap_ && overlap_(c1, c2)) return false;
134  return selectPair(c1, c2);
135 }
virtual bool selectPair(const reco::Candidate &c1, const reco::Candidate &c2) const =0
select a candidate pair
bool checkOverlap_
flag to specify the checking of overlaps
bool checkCharge_
flag to specify the checking of electric charge
OverlapChecker overlap_
utility to check candidate daughters overlap
double q2[4]
Definition: TauolaWrapper.h:88
virtual int charge() const =0
electric charge
double q1[4]
Definition: TauolaWrapper.h:87
std::vector< int > dauCharge_
electric charges of the daughters
template<typename OutputCollection, typename CandPtr>
bool CandCombinerBase< OutputCollection, CandPtr >::preselect ( const reco::Candidate ,
const reco::Candidate  
) const
private

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

template<typename OutputCollection, typename CandPtr>
virtual bool CandCombinerBase< OutputCollection, CandPtr >::select ( const reco::Candidate ) const
privatepure virtual
template<typename OutputCollection, typename CandPtr>
virtual bool CandCombinerBase< OutputCollection, CandPtr >::select ( const reco::Candidate ) const
privatepure virtual
template<typename OutputCollection, typename CandPtr>
virtual bool CandCombinerBase< OutputCollection, CandPtr >::selectPair ( const reco::Candidate c1,
const reco::Candidate c2 
) const
privatepure virtual
template<typename OutputCollection, typename CandPtr>
virtual bool CandCombinerBase< OutputCollection, CandPtr >::selectPair ( const reco::Candidate c1,
const reco::Candidate c2 
) const
privatepure virtual
template<typename OutputCollection, typename CandPtr>
virtual void CandCombinerBase< OutputCollection, CandPtr >::setup ( typename OutputCollection::value_type &  ) const
privatepure virtual
template<typename OutputCollection, typename CandPtr>
virtual void CandCombinerBase< OutputCollection, CandPtr >::setup ( typename OutputCollection::value_type &  ) const
privatepure virtual

Member Data Documentation

template<typename OutputCollection, typename CandPtr>
bool CandCombinerBase< OutputCollection, CandPtr >::checkCharge_
private

flag to specify the checking of electric charge

Definition at line 77 of file CandCombinerBase.h.

template<typename OutputCollection, typename CandPtr>
bool CandCombinerBase< OutputCollection, CandPtr >::checkOverlap_
private

flag to specify the checking of overlaps

Definition at line 79 of file CandCombinerBase.h.

template<typename OutputCollection, typename CandPtr>
std::vector< int > CandCombinerBase< OutputCollection, CandPtr >::dauCharge_
private

electric charges of the daughters

Definition at line 81 of file CandCombinerBase.h.

Referenced by CandCombinerBase< OutputCollection, CandPtr >::CandCombinerBase().

template<typename OutputCollection, typename CandPtr>
std::string CandCombinerBase< OutputCollection, CandPtr >::name_
private

composite name (if applies)

Definition at line 85 of file CandCombinerBase.h.

template<typename OutputCollection, typename CandPtr>
OverlapChecker CandCombinerBase< OutputCollection, CandPtr >::overlap_
private

utility to check candidate daughters overlap

Definition at line 83 of file CandCombinerBase.h.