Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:54

0001 #ifndef Candidate_NamedCompositeCandidate_H
0002 #define Candidate_NamedCompositeCandidate_H
0003 #include "DataFormats/Candidate/interface/CompositeCandidate.h"
0004 #include <memory>
0005 /** \class reco::NamedCompositeCandidate
0006  *
0007  * A Candidate composed of daughters. 
0008  * The daughters are owned by the composite candidate.
0009  *
0010  * \author Luca Lista, INFN
0011  *
0012  *
0013  */
0014 
0015 #include "DataFormats/Candidate/interface/NamedCompositeCandidateFwd.h"
0016 #include <string>
0017 #include <map>
0018 
0019 namespace reco {
0020 
0021   class NamedCompositeCandidate : public CompositeCandidate {
0022   public:
0023     typedef std::vector<std::string> role_collection;
0024 
0025     /// default constructor
0026     NamedCompositeCandidate(std::string name = "") : CompositeCandidate(), name_(name) {}
0027     NamedCompositeCandidate(std::string name, const role_collection& roles)
0028         : CompositeCandidate(), name_(name), roles_(roles) {}
0029     /// constructor from values
0030     NamedCompositeCandidate(std::string name,
0031                             const role_collection& roles,
0032                             Charge q,
0033                             const LorentzVector& p4,
0034                             const Point& vtx = Point(0, 0, 0),
0035                             int pdgId = 0,
0036                             int status = 0,
0037                             bool integerCharge = true)
0038         : CompositeCandidate(q, p4, vtx, pdgId, status, integerCharge), name_(name), roles_(roles) {}
0039     /// constructor from values
0040     NamedCompositeCandidate(std::string name, const role_collection& roles, const Candidate& p);
0041 
0042     /// destructor
0043     ~NamedCompositeCandidate() override;
0044     /// returns a clone of the candidate
0045     NamedCompositeCandidate* clone() const override;
0046     // get name
0047     std::string name() const { return name_; }
0048     // set name
0049     void setName(std::string n) { name_ = n; }
0050     // get roles
0051     const NamedCompositeCandidate::role_collection& roles() const { return roles_; }
0052     // set roles
0053     void setRoles(const NamedCompositeCandidate::role_collection& roles) {
0054       roles_.clear();
0055       roles_ = roles;
0056     }
0057     // Get candidate based on role
0058     Candidate* daughter(const std::string& s) override;
0059     const Candidate* daughter(const std::string& s) const override;
0060     // Get candidate based on index
0061     Candidate* daughter(size_type i) override { return CompositeCandidate::daughter(i); }
0062     const Candidate* daughter(size_type i) const override { return CompositeCandidate::daughter(i); }
0063     // Add daughters
0064     void addDaughter(const Candidate&, const std::string& s);
0065     void addDaughter(std::unique_ptr<Candidate>, const std::string& s);
0066     // Clear daughters and roles
0067     void clearDaughters() { CompositeCandidate::clearDaughters(); }
0068     void clearRoles() { roles_.clear(); }
0069     // Apply the roles to the objects
0070     void applyRoles();
0071 
0072   private:
0073     std::string name_;
0074     role_collection roles_;
0075   };
0076 
0077 }  // namespace reco
0078 
0079 #endif