00001 #ifndef Candidate_CompositeCandidate_h
00002 #define Candidate_CompositeCandidate_h
00003 #include "DataFormats/Candidate/interface/Candidate.h"
00004 #include <memory>
00016 #include "DataFormats/Candidate/interface/iterator_imp_specific.h"
00017 #include "DataFormats/Candidate/interface/CompositeCandidateFwd.h"
00018 #include <string>
00019 #include <vector>
00020
00021 namespace reco {
00022
00023 class CompositeCandidate : public Candidate {
00024 public:
00026 typedef CandidateCollection daughters;
00027 typedef std::vector<std::string> role_collection;
00029 CompositeCandidate(std::string name="") : Candidate(), name_(name) { }
00031 CompositeCandidate( Charge q, const LorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
00032 int pdgId = 0, int status = 0, bool integerCharge = true,
00033 std::string name="") :
00034 Candidate( q, p4, vtx, pdgId, status, integerCharge ), name_(name) { }
00036 CompositeCandidate( Charge q, const PolarLorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ),
00037 int pdgId = 0, int status = 0, bool integerCharge = true,
00038 std::string name="" ) :
00039 Candidate( q, p4, vtx, pdgId, status, integerCharge ), name_(name) { }
00041 explicit CompositeCandidate( const Particle & p, const std::string& name="" ) :
00042 Candidate( p ), name_(name) { }
00044 explicit CompositeCandidate( const Candidate & p, const std::string& name="" );
00046 explicit CompositeCandidate( const Candidate & p, const std::string& name, role_collection const & roles );
00048 virtual ~CompositeCandidate();
00050 std::string name() const { return name_;}
00052 void setName(std::string name) { name_ = name;}
00054 role_collection const & roles() const { return roles_; }
00056 void setRoles( const role_collection & roles ) { roles_.clear(); roles_ = roles; }
00058 virtual CompositeCandidate * clone() const;
00060 virtual const_iterator begin() const;
00062 virtual const_iterator end() const;
00064 virtual iterator begin();
00066 virtual iterator end();
00068 virtual size_type numberOfDaughters() const;
00070 virtual const Candidate * daughter( size_type ) const;
00072 virtual Candidate * daughter( size_type );
00073
00074 virtual Candidate * daughter(const std::string& s );
00075 virtual const Candidate * daughter(const std::string& s ) const;
00077 void addDaughter( const Candidate &, const std::string& s="" );
00079 void addDaughter( std::auto_ptr<Candidate>, const std::string& s="" );
00081 void clearDaughters() { dau.clear(); }
00082
00083 void clearRoles() { roles_.clear(); }
00084
00085 void applyRoles();
00087 virtual size_type numberOfMothers() const;
00089 virtual const Candidate * mother( size_type i = 0 ) const;
00090
00091 private:
00092
00093 typedef candidate::const_iterator_imp_specific<daughters> const_iterator_imp_specific;
00094
00095 typedef candidate::iterator_imp_specific<daughters> iterator_imp_specific;
00097 daughters dau;
00099 virtual bool overlap( const Candidate & ) const;
00101 std::string name_;
00103 role_collection roles_;
00104 };
00105
00106 }
00107
00108 #endif