Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:33

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/BPHRecoCandidatePtr.h"
0027 #include "DataFormats/PatCandidates/interface/CompositeCandidate.h"
0028 
0029 class BPHEventSetupWrapper;
0030 
0031 namespace reco {
0032   class Candidate;
0033 }
0034 
0035 //---------------
0036 // C++ Headers --
0037 //---------------
0038 #include <vector>
0039 
0040 //              ---------------------
0041 //              -- Class Interface --
0042 //              ---------------------
0043 
0044 class BPHRecoCandidate : public virtual BPHKinematicFit {
0045 public:
0046   typedef BPHRecoCandidatePtr pointer;
0047   typedef BPHRecoConstCandPtr const_pointer;
0048 
0049   /** Constructor
0050    */
0051   /// create an "empty" object to add daughters later
0052   /// (see BPHDecayMomentum)
0053   BPHRecoCandidate(const BPHEventSetupWrapper* es, int daugNum = 2, int compNum = 2);
0054   /// create an object with daughters as specified in the ComponentSet
0055   BPHRecoCandidate(const BPHEventSetupWrapper* es, const BPHRecoBuilder::ComponentSet& compSet);
0056 
0057   // deleted copy constructor and assignment operator
0058   BPHRecoCandidate(const BPHRecoCandidate& x) = delete;
0059   BPHRecoCandidate& operator=(const BPHRecoCandidate& x) = delete;
0060 
0061   /** Destructor
0062    */
0063   ~BPHRecoCandidate() override = default;
0064 
0065   /** Operations
0066    */
0067   /// add a simple particle giving it a name
0068   /// particles are cloned, eventually specifying a different mass
0069   /// and a sigma
0070   virtual void add(const std::string& name, const reco::Candidate* daug, double mass = -1.0, double sigma = -1.0) {
0071     addK(name, daug, "cfhpmig", mass, sigma);
0072     return;
0073   }
0074   virtual void add(const std::string& name,
0075                    const reco::Candidate* daug,
0076                    const std::string& searchList,
0077                    double mass = -1.0,
0078                    double sigma = -1.0) {
0079     addK(name, daug, searchList, mass, sigma);
0080     return;
0081   }
0082   virtual void add(const std::string& name, const BPHRecoConstCandPtr& comp) {
0083     addK(name, comp);
0084     return;
0085   }
0086 
0087   /// look for candidates starting from particle collections as
0088   /// specified in the BPHRecoBuilder
0089   struct BuilderParameters {
0090     double constrMass;
0091     double constrSigma;
0092   };
0093   static std::vector<BPHRecoConstCandPtr> build(const BPHRecoBuilder& builder, const BuilderParameters& par) {
0094     return build(builder, par.constrMass, par.constrSigma);
0095   }
0096   static std::vector<BPHRecoConstCandPtr> build(const BPHRecoBuilder& builder, double mass = -1, double msig = -1);
0097 
0098   /// clone object, cloning daughters as well up to required depth
0099   /// level = -1 to clone all levels
0100   virtual BPHRecoCandidate* clone(int level = -1) const;
0101 
0102   enum esType { transientTrackBuilder };
0103 
0104 protected:
0105   // function doing the job to clone reconstructed decays:
0106   // copy stable particles and clone cascade decays up to chosen level
0107   void fill(BPHRecoCandidate* ptr, int level) const override;
0108 
0109   // template function called by "build" to allow
0110   // the creation of derived objects
0111   template <class T>
0112   static void fill(std::vector<typename BPHGenericPtr<const T>::type>& cList,
0113                    const BPHRecoBuilder& builder,
0114                    double mass = -1,
0115                    double msig = -1);
0116 };
0117 
0118 template <class T>
0119 void BPHRecoCandidate::fill(std::vector<typename BPHGenericPtr<const T>::type>& cList,
0120                             const BPHRecoBuilder& builder,
0121                             double mass,
0122                             double msig) {
0123   // create particle combinations
0124   const std::vector<BPHRecoBuilder::ComponentSet> dll = builder.build();
0125   // loop over combinations and create reconstructed particles
0126   int i;
0127   int n = dll.size();
0128   cList.reserve(n);
0129   T* rc = nullptr;
0130   for (i = 0; i < n; ++i) {
0131     // create reconstructed particle
0132     rc = new T(builder.eventSetup(), dll[i]);
0133     // apply mass constraint, if requested
0134     if (mass > 0)
0135       rc->setConstraint(mass, msig);
0136     // apply post selection
0137     if (builder.accept(*rc))
0138       cList.push_back(typename BPHGenericPtr<const T>::type(rc));
0139     else
0140       delete rc;
0141   }
0142   return;
0143 }
0144 
0145 #endif