Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:56

0001 #ifndef CommonTools_CandUtils_CandCombinerBase_h
0002 #define CommonTools_CandUtils_CandCombinerBase_h
0003 /** \class CandCombinerBase

0004  *

0005  * \author Luca Lista, INFN

0006  *

0007  */
0008 #include "DataFormats/Candidate/interface/OverlapChecker.h"
0009 #include "DataFormats/Candidate/interface/NamedCompositeCandidate.h"
0010 #include <vector>
0011 #include <string>
0012 
0013 class NamedCandCombinerBase {
0014 public:
0015   typedef std::vector<std::string> string_coll;
0016   /// default construct

0017   NamedCandCombinerBase(std::string name);
0018   /// construct from two charge values

0019   NamedCandCombinerBase(std::string name, int, int);
0020   /// construct from three charge values

0021   NamedCandCombinerBase(std::string name, int, int, int);
0022   /// construct from four charge values

0023   NamedCandCombinerBase(std::string name, int, int, int, int);
0024   /// constructor from a selector, specifying optionally to check for charge

0025   NamedCandCombinerBase(std::string name, bool checkCharge, bool checkOverlap, const std::vector<int> &);
0026   /// destructor

0027   virtual ~NamedCandCombinerBase();
0028   /// return all selected candidate pairs

0029   std::unique_ptr<reco::NamedCompositeCandidateCollection> combine(const std::vector<reco::CandidatePtrVector> &,
0030                                                                    string_coll const &) const;
0031   /// return all selected candidate pairs

0032   std::unique_ptr<reco::NamedCompositeCandidateCollection> combine(const reco::CandidatePtrVector &,
0033                                                                    string_coll const &) const;
0034   /// return all selected candidate pairs

0035   std::unique_ptr<reco::NamedCompositeCandidateCollection> combine(const reco::CandidatePtrVector &,
0036                                                                    const reco::CandidatePtrVector &,
0037                                                                    string_coll const &) const;
0038   /// return all selected candidate pairs

0039   std::unique_ptr<reco::NamedCompositeCandidateCollection> combine(const reco::CandidatePtrVector &,
0040                                                                    const reco::CandidatePtrVector &,
0041                                                                    const reco::CandidatePtrVector &,
0042                                                                    string_coll const &) const;
0043   /// return all selected candidate pairs

0044   std::unique_ptr<reco::NamedCompositeCandidateCollection> combine(const reco::CandidatePtrVector &,
0045                                                                    const reco::CandidatePtrVector &,
0046                                                                    const reco::CandidatePtrVector &,
0047                                                                    const reco::CandidatePtrVector &,
0048                                                                    string_coll const &) const;
0049 
0050 private:
0051   /// verify that the two candidate don't overlap and check charge

0052   bool preselect(const reco::Candidate &, const reco::Candidate &) const;
0053   /// returns a composite candidate combined from two daughters

0054   void combine(reco::NamedCompositeCandidate &,
0055                const reco::CandidatePtr &,
0056                const reco::CandidatePtr &,
0057                std::string,
0058                std::string) const;
0059   /// temporary candidate stack

0060   typedef std::vector<
0061       std::pair<std::pair<reco::CandidatePtr, size_t>, std::vector<reco::CandidatePtrVector>::const_iterator> >
0062       CandStack;
0063   typedef std::vector<int> ChargeStack;
0064   /// returns a composite candidate combined from two daughters

0065   void combine(size_t collectionIndex,
0066                CandStack &,
0067                ChargeStack &,
0068                string_coll const &names,
0069                std::vector<reco::CandidatePtrVector>::const_iterator begin,
0070                std::vector<reco::CandidatePtrVector>::const_iterator end,
0071                std::unique_ptr<reco::NamedCompositeCandidateCollection> &comps) const;
0072   /// select a candidate

0073   virtual bool select(const reco::Candidate &) const = 0;
0074   /// select a candidate pair

0075   virtual bool selectPair(const reco::Candidate &c1, const reco::Candidate &c2) const = 0;
0076   /// set kinematics to reconstructed composite

0077   virtual void setup(reco::NamedCompositeCandidate &) const = 0;
0078   /// add candidate daughter

0079   virtual void addDaughter(reco::NamedCompositeCandidate &cmp, const reco::CandidatePtr &c, std::string name) const = 0;
0080   /// flag to specify the checking of electric charge

0081   bool checkCharge_;
0082   /// flag to specify the checking of overlaps

0083   bool checkOverlap_;
0084   /// electric charges of the daughters

0085   std::vector<int> dauCharge_;
0086   /// utility to check candidate daughters overlap

0087   OverlapChecker overlap_;
0088   /// Name

0089   std::string name_;
0090 };
0091 
0092 #endif