CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/DataFormats/Candidate/interface/CompositeCandidate.h

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     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       LeafCandidate( 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       LeafCandidate( q, p4, vtx, pdgId, status, integerCharge ), name_(name) { }
00041     explicit CompositeCandidate( const Candidate & p, const std::string& name="" );
00043     explicit CompositeCandidate( const Candidate & p, const std::string& name, role_collection const & roles );
00045     virtual ~CompositeCandidate();
00047     std::string name() const { return name_;}
00049     void        setName(std::string name) { name_ = name;}
00051     role_collection const & roles() const { return roles_; }
00053     void                    setRoles( const role_collection & roles ) { roles_.clear(); roles_ = roles; }
00055     virtual CompositeCandidate * clone() const;
00057     virtual const_iterator begin() const;
00059     virtual const_iterator end() const;
00061     virtual iterator begin();
00063     virtual iterator end();
00065     virtual size_type numberOfDaughters() const;
00067     virtual const Candidate * daughter( size_type ) const;
00069     virtual Candidate * daughter( size_type );
00070     // Get candidate based on role
00071     virtual Candidate *       daughter(const std::string& s );
00072     virtual const Candidate * daughter(const std::string& s ) const;
00074     void addDaughter( const Candidate &, const std::string& s="" );
00076     void addDaughter( std::auto_ptr<Candidate>, const std::string& s="" );
00078     void clearDaughters() { dau.clear(); }
00079     // clear roles
00080     void clearRoles() { roles_.clear(); }
00081     // Apply the roles to the objects
00082     void applyRoles();
00084     virtual size_type numberOfMothers() const;
00086     virtual const Candidate * mother( size_type i = 0 ) const;
00087 
00088   private:
00089     // const iterator implementation
00090     typedef candidate::const_iterator_imp_specific<daughters> const_iterator_imp_specific;
00091     // iterator implementation
00092     typedef candidate::iterator_imp_specific<daughters> iterator_imp_specific;
00094     daughters dau;
00096     virtual bool overlap( const Candidate & ) const;
00098     std::string name_;
00100     role_collection roles_;
00101   };
00102 
00103 }
00104 
00105 #endif