Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef HeavyFlavorAnalysis_RecoDecay_BPHRecoCandidate_h
0002 #define HeavyFlavorAnalysis_RecoDecay_BPHRecoCandidate_h
0003 /** \class BPHRecoCandidate
0004  *
0005  *  Description: 
0006  *     High level class for reconstructed decay candidates:
0007  *     - only constructor interfaces are defined in this class
0008  *     - functions returning results are defined in base classes:
0009  *       BPHDecayMomentum : decay products simple momentum sum
0010  *       BPHDecayVertex   : vertex reconstruction
0011  *       BPHKinematicFit  : kinematic fit and fitted momentum sum
0012  *
0013  *  \author Paolo Ronchese INFN Padova
0014  *
0015  */
0016 
0017 //----------------------
0018 // Base Class Headers --
0019 //----------------------
0020 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHKinematicFit.h"
0021 
0022 //------------------------------------
0023 // Collaborating Class Declarations --
0024 //------------------------------------
0025 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoBuilder.h"
0026 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHGenericPtr.h"
0027 #include "DataFormats/PatCandidates/interface/CompositeCandidate.h"
0028 
0029 namespace edm {
0030   class EventSetup;
0031 }
0032 
0033 namespace reco {
0034   class Candidate;
0035 }
0036 
0037 //---------------
0038 // C++ Headers --
0039 //---------------
0040 #include <vector>
0041 
0042 //              ---------------------
0043 //              -- Class Interface --
0044 //              ---------------------
0045 
0046 class BPHRecoCandidate : public virtual BPHKinematicFit {
0047 public:
0048   /** Constructor
0049    */
0050   /// create an "empty" object to add daughters later
0051   /// (see BPHDecayMomentum)
0052   BPHRecoCandidate(const edm::EventSetup* es);
0053   // create an object with daughters as specified in the ComponentSet
0054   BPHRecoCandidate(const edm::EventSetup* es, const BPHRecoBuilder::ComponentSet& compSet);
0055 
0056   // deleted copy constructor and assignment operator
0057   BPHRecoCandidate(const BPHRecoCandidate& x) = delete;
0058   BPHRecoCandidate& operator=(const BPHRecoCandidate& x) = delete;
0059 
0060   /** Destructor
0061    */
0062   ~BPHRecoCandidate() override;
0063 
0064   /** Operations
0065    */
0066   /// add a simple particle giving it a name
0067   /// particles are cloned, eventually specifying a different mass
0068   /// and a sigma
0069   virtual void add(const std::string& name, const reco::Candidate* daug, double mass = -1.0, double sigma = -1.0) {
0070     addK(name, daug, "cfhpmig", mass, sigma);
0071     return;
0072   }
0073   virtual void add(const std::string& name,
0074                    const reco::Candidate* daug,
0075                    const std::string& searchList,
0076                    double mass = -1.0,
0077                    double sigma = -1.0) {
0078     addK(name, daug, searchList, mass, sigma);
0079     return;
0080   }
0081   virtual void add(const std::string& name, const BPHRecoConstCandPtr& comp) {
0082     addK(name, comp);
0083     return;
0084   }
0085 
0086   /// look for candidates starting from particle collections as
0087   /// specified in the BPHRecoBuilder
0088   static std::vector<BPHRecoConstCandPtr> build(const BPHRecoBuilder& builder, double mass = -1, double msig = -1);
0089 
0090   /// clone object, cloning daughters as well up to required depth
0091   /// level = -1 to clone all levels
0092   virtual BPHRecoCandidate* clone(int level = -1) const;
0093 
0094 protected:
0095   // function doing the job to clone reconstructed decays:
0096   // copy stable particles and clone cascade decays up to chosen level
0097   void fill(BPHRecoCandidate* ptr, int level) const override;
0098 
0099   // template function called by "build" to allow
0100   // the creation of derived objects
0101   template <class T>
0102   static void fill(std::vector<typename BPHGenericPtr<const T>::type>& cList,
0103                    const BPHRecoBuilder& builder,
0104                    double mass = -1,
0105                    double msig = -1);
0106 };
0107 
0108 template <class T>
0109 void BPHRecoCandidate::fill(std::vector<typename BPHGenericPtr<const T>::type>& cList,
0110                             const BPHRecoBuilder& builder,
0111                             double mass,
0112                             double msig) {
0113   // create particle combinations
0114   const std::vector<BPHRecoBuilder::ComponentSet> dll = builder.build();
0115   // loop over combinations and create reconstructed particles
0116   int i;
0117   int n = dll.size();
0118   cList.reserve(n);
0119   T* rc = nullptr;
0120   for (i = 0; i < n; ++i) {
0121     // create reconstructed particle
0122     rc = new T(builder.eventSetup(), dll[i]);
0123     // apply mass constraint, if requested
0124     if (mass > 0)
0125       rc->setConstraint(mass, msig);
0126     // apply post selection
0127     if (builder.accept(*rc))
0128       cList.push_back(typename BPHGenericPtr<const T>::type(rc));
0129     else
0130       delete rc;
0131   }
0132   return;
0133 }
0134 
0135 #endif