CMS 3D CMS Logo

NamedCandCombinerBase Class Reference

#include <PhysicsTools/CandUtils/interface/NamedCandCombinerBase.h>

Inheritance diagram for NamedCandCombinerBase:

NamedCandCombiner< Selector, PairSelector, Cloner, Setup >

List of all members.

Public Types

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

Public Member Functions

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

Private Types

typedef std::vector< std::pair
< std::pair
< reco::CandidatePtr, size_t >,
std::vector
< reco::CandidatePtrVector >
::const_iterator > > 
CandStack
 temporary candidate stack
typedef std::vector< intChargeStack

Private Member Functions

virtual void addDaughter (reco::NamedCompositeCandidate &cmp, const reco::CandidatePtr &c, std::string name) const =0
 add candidate daughter
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::auto_ptr< reco::NamedCompositeCandidateCollection > &comps) const
 returns a composite candidate combined from two daughters
void combine (reco::NamedCompositeCandidate &, const reco::CandidatePtr &, const reco::CandidatePtr &, std::string, std::string) const
 returns a composite candidate combined from two daughters
bool preselect (const reco::Candidate &, const reco::Candidate &) const
 verify that the two candidate don't overlap and check charge
virtual bool select (const reco::Candidate &) const =0
 select a candidate
virtual bool selectPair (const reco::Candidate &c1, const reco::Candidate &c2) const =0
 select a candidate pair
virtual void setup (reco::NamedCompositeCandidate &) const =0
 set kinematics to reconstructed composite

Private Attributes

bool checkCharge_
 flag to specify the checking of electric charge
std::vector< intdauCharge_
 electric charges of the daughters
std::string name_
 Name.
OverlapChecker overlap_
 utility to check candidate daughters overlap


Detailed Description

Definition at line 13 of file NamedCandCombinerBase.h.


Member Typedef Documentation

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 65 of file NamedCandCombinerBase.h.

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

Definition at line 66 of file NamedCandCombinerBase.h.

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

Definition at line 15 of file NamedCandCombinerBase.h.


Constructor & Destructor Documentation

NamedCandCombinerBase::NamedCandCombinerBase ( std::string  name  ) 

default construct

Definition at line 6 of file NamedCandCombinerBase.cc.

00006                                                            :
00007   checkCharge_(false), dauCharge_(), overlap_(), name_(name) {
00008 }

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

construct from two charge values

Definition at line 10 of file NamedCandCombinerBase.cc.

References dauCharge_.

00010                                                                            :
00011   checkCharge_(true), dauCharge_(2), overlap_(), name_(name) {
00012   dauCharge_[0] = q1;
00013   dauCharge_[1] = q2;
00014 }

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

construct from three charge values

Definition at line 16 of file NamedCandCombinerBase.cc.

References dauCharge_.

00016                                                                                    :
00017   checkCharge_(true), dauCharge_(3), overlap_(), name_(name) {
00018   dauCharge_[0] = q1;
00019   dauCharge_[1] = q2;
00020   dauCharge_[2] = q3;
00021 }

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

construct from four charge values

Definition at line 23 of file NamedCandCombinerBase.cc.

References dauCharge_.

00023                                                                                            :
00024   checkCharge_(true), dauCharge_(4), overlap_(), name_(name) {
00025   dauCharge_[0] = q1;
00026   dauCharge_[1] = q2;
00027   dauCharge_[2] = q3;
00028   dauCharge_[3] = q4;
00029 }

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

constructor from a selector, specifying optionally to check for charge

NamedCandCombinerBase::~NamedCandCombinerBase (  )  [virtual]

destructor

Definition at line 35 of file NamedCandCombinerBase.cc.

00035                                               {
00036 }


Member Function Documentation

virtual void NamedCandCombinerBase::addDaughter ( reco::NamedCompositeCandidate cmp,
const reco::CandidatePtr c,
std::string  name 
) const [private, pure virtual]

add candidate daughter

Implemented in NamedCandCombiner< Selector, PairSelector, Cloner, Setup >.

Referenced by combine().

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::auto_ptr< reco::NamedCompositeCandidateCollection > &  comps 
) const [private]

returns a composite candidate combined from two daughters

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 48 of file NamedCandCombinerBase.cc.

References addDaughter(), and setup().

00049                                                                        {
00050   addDaughter(cmp, c1, n1);
00051   addDaughter(cmp, c2, n2);
00052   setup(cmp);
00053 }

auto_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 157 of file NamedCandCombinerBase.cc.

References combine().

00159                                                                 {
00160   vector<CandidatePtrVector> src;
00161   src.push_back(src1);
00162   src.push_back(src2);
00163   src.push_back(src3);
00164   src.push_back(src4);
00165   return combine(src, names);
00166 }

auto_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 147 of file NamedCandCombinerBase.cc.

References combine().

00148                                                                 {
00149   vector<CandidatePtrVector> src;
00150   src.push_back(src1);
00151   src.push_back(src2);
00152   src.push_back(src3);
00153   return combine(src, names);
00154 }

auto_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 139 of file NamedCandCombinerBase.cc.

References combine().

00139                                                                                                                                 {
00140   vector<CandidatePtrVector> src;
00141   src.push_back(src1);
00142   src.push_back(src2);
00143   return combine(src, names);
00144 }

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

return all selected candidate pairs

Definition at line 110 of file NamedCandCombinerBase.cc.

References c, checkCharge_, combine(), edm::errors::Configuration, dauCharge_, i1, i2, preselect(), select(), and edm::PtrVectorBase::size().

00110                                                                                               {
00111   if(checkCharge_ && dauCharge_.size() != 2)
00112     throw edm::Exception(edm::errors::Configuration) 
00113       << "NamedCandCombiner: trying to combine 2 collections"
00114       << " but configured to check against " << dauCharge_.size() << " charges.";
00115 
00116   if ( names.size() < 2 )
00117     throw edm::Exception(edm::errors::Configuration)
00118       << "NamedCandCombiner: need to add 2 names, but size is " << names.size();
00119 
00120   auto_ptr<NamedCompositeCandidateCollection> comps(new NamedCompositeCandidateCollection);
00121   const int n = src.size();
00122   for(int i1 = 0; i1 < n; ++i1) {
00123     const Candidate & c1 = *(src[i1]);
00124     for(int i2 = i1 + 1; i2 < n; ++i2) {
00125       const Candidate & c2 = *(src[i2]);
00126       if(preselect(c1, c2)) {
00127         NamedCompositeCandidate c;
00128         combine(c, src[i1], src[i2], names[0], names[1]);
00129         if(select(c))
00130           comps->push_back(c);
00131       }
00132     } 
00133   }
00134 
00135   return comps;
00136 }

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

return all selected candidate pairs

Referenced by combine().

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 reco::Particle::charge(), checkCharge_, dauCharge_, overlap_, and selectPair().

Referenced by combine().

00038                                                                                       {
00039   if (checkCharge_) {
00040     int dq1 = dauCharge_[0], dq2 = dauCharge_[1], q1 = c1.charge(), q2 = c2.charge();
00041     bool matchCharge = (q1 == dq1 && q2 == dq2) || (q1 == -dq1 && q2 == -dq2); 
00042     if (!matchCharge) return false; 
00043   }
00044   if (overlap_(c1, c2)) return false;
00045   return selectPair(c1, c2);
00046 }

virtual bool NamedCandCombinerBase::select ( const reco::Candidate  )  const [private, pure virtual]

select a candidate

Implemented in NamedCandCombiner< Selector, PairSelector, Cloner, Setup >.

Referenced by combine().

virtual bool NamedCandCombinerBase::selectPair ( const reco::Candidate c1,
const reco::Candidate c2 
) const [private, pure virtual]

select a candidate pair

Implemented in NamedCandCombiner< Selector, PairSelector, Cloner, Setup >.

Referenced by preselect().

virtual void NamedCandCombinerBase::setup ( reco::NamedCompositeCandidate  )  const [private, pure virtual]

set kinematics to reconstructed composite

Implemented in NamedCandCombiner< Selector, PairSelector, Cloner, Setup >.

Referenced by combine().


Member Data Documentation

bool NamedCandCombinerBase::checkCharge_ [private]

flag to specify the checking of electric charge

Definition at line 83 of file NamedCandCombinerBase.h.

Referenced by combine(), and preselect().

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

std::string NamedCandCombinerBase::name_ [private]

Name.

Reimplemented in NamedCandCombiner< Selector, PairSelector, Cloner, Setup >.

Definition at line 89 of file NamedCandCombinerBase.h.

OverlapChecker NamedCandCombinerBase::overlap_ [private]

utility to check candidate daughters overlap

Definition at line 87 of file NamedCandCombinerBase.h.

Referenced by preselect().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:28:58 2009 for CMSSW by  doxygen 1.5.4