Go to the documentation of this file.00001 #ifndef Candidate_CompositeCandidate_h
00002 #define Candidate_CompositeCandidate_h
00003 #include "DataFormats/Candidate/interface/LeafCandidate.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 LeafCandidate {
00024 public:
00026 typedef CandidateCollection daughters;
00027 typedef std::vector<std::string> role_collection;
00029 CompositeCandidate(std::string name="") : LeafCandidate(), name_(name) { }
00031 template<typename P4>
00032 CompositeCandidate( Charge q, const P4 & p4, const Point & vtx = Point( 0, 0, 0 ),
00033 int pdgId = 0, int status = 0, bool integerCharge = true,
00034 std::string name="") :
00035 LeafCandidate( q, p4, vtx, pdgId, status, integerCharge ), name_(name) { }
00037 explicit CompositeCandidate( const Candidate & p, const std::string& name="" );
00039 explicit CompositeCandidate( const Candidate & p, const std::string& name, role_collection const & roles );
00041 virtual ~CompositeCandidate();
00043 std::string name() const { return name_;}
00045 void setName(std::string name) { name_ = name;}
00047 role_collection const & roles() const { return roles_; }
00049 void setRoles( const role_collection & roles ) { roles_.clear(); roles_ = roles; }
00051 virtual CompositeCandidate * clone() const;
00053 virtual const_iterator begin() const;
00055 virtual const_iterator end() const;
00057 virtual iterator begin();
00059 virtual iterator end();
00061 virtual size_type numberOfDaughters() const;
00063 virtual const Candidate * daughter( size_type ) const;
00065 virtual Candidate * daughter( size_type );
00066
00067 virtual Candidate * daughter(const std::string& s );
00068 virtual const Candidate * daughter(const std::string& s ) const;
00070 void addDaughter( const Candidate &, const std::string& s="" );
00072 void addDaughter( std::auto_ptr<Candidate>, const std::string& s="" );
00074 void clearDaughters() { dau.clear(); }
00075
00076 void clearRoles() { roles_.clear(); }
00077
00078 void applyRoles();
00080 virtual size_type numberOfMothers() const;
00082 virtual const Candidate * mother( size_type i = 0 ) const;
00083
00084 private:
00085
00086 typedef candidate::const_iterator_imp_specific<daughters> const_iterator_imp_specific;
00087
00088 typedef candidate::iterator_imp_specific<daughters> iterator_imp_specific;
00090 daughters dau;
00092 virtual bool overlap( const Candidate & ) const;
00094 std::string name_;
00096 role_collection roles_;
00097 };
00098
00099 }
00100
00101 #endif