Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:50:17

0001 #ifndef HeavyFlavorAnalysis_RecoDecay_BPHDecayMomentum_h
0002 #define HeavyFlavorAnalysis_RecoDecay_BPHDecayMomentum_h
0003 /** \class BPHDecayMomentum
0004  *
0005  *  Description: 
0006  *     Lowest-level base class to contain decay products and
0007  *     compute total momentum
0008  *
0009  *  \author Paolo Ronchese INFN Padova
0010  *
0011  */
0012 
0013 //----------------------
0014 // Base Class Headers --
0015 //----------------------
0016 
0017 //------------------------------------
0018 // Collaborating Class Declarations --
0019 //------------------------------------
0020 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoCandidatePtr.h"
0021 #include "DataFormats/PatCandidates/interface/CompositeCandidate.h"
0022 class BPHRecoBuilder;
0023 
0024 //---------------
0025 // C++ Headers --
0026 //---------------
0027 #include <vector>
0028 #include <map>
0029 #include <string>
0030 
0031 //              ---------------------
0032 //              -- Class Interface --
0033 //              ---------------------
0034 
0035 class BPHDecayMomentum {
0036 public:
0037   /** Constructors are protected
0038    *  this object can exist only as part of a derived class
0039    */
0040   // deleted copy constructor and assignment operator
0041   BPHDecayMomentum(const BPHDecayMomentum& x) = delete;
0042   BPHDecayMomentum& operator=(const BPHDecayMomentum& x) = delete;
0043 
0044   /** Destructor
0045    */
0046   virtual ~BPHDecayMomentum();
0047 
0048   /** Operations
0049    */
0050 
0051   /// get a composite by the simple sum of simple particles
0052   virtual const pat::CompositeCandidate& composite() const;
0053 
0054   /// get the list of names of simple particles directly produced in the decay
0055   /// e.g. in JPsi -> mu+mu-   returns the two names used for muons
0056   ///      in B+   -> JPsi K+  returns the name used for the K+
0057   ///      in Bs   -> JPsi Phi returns an empty list
0058   virtual const std::vector<std::string>& daugNames() const;
0059 
0060   /// get the list of names of previously reconstructed particles
0061   /// e.g. in JPsi -> mu+mu-   returns an empty list
0062   ///      in B+   -> JPsi K+  returns the name used for the JPsi
0063   ///      in Bs   -> JPsi Phi returns the two names used for JPsi and Phi
0064   virtual const std::vector<std::string>& compNames() const;
0065 
0066   /// get the list of simple particles directly produced in the decay
0067   /// e.g. in JPsi -> mu+mu-   returns the two muons
0068   ///      in B+   -> JPsi K+  returns the K+
0069   ///      in Bs   -> JPsi Phi returns an empty list
0070   /// (clones are actually returned)
0071   virtual const std::vector<const reco::Candidate*>& daughters() const;
0072 
0073   /// get the full list of simple particles produced in the decay,
0074   /// directly or through cascade decays
0075   /// e.g. in B+   -> JPsi K+ ; JPsi -> mu+mu- returns the mu+, mu-, K+
0076   ///      in Bs   -> JPsi Phi; JPsi -> mu+mu-; Phi -> K+K-
0077   ///                                          returns the mu+, mu-, K+, K-
0078   /// (clones are actually returned)
0079   virtual const std::vector<const reco::Candidate*>& daughFull() const;
0080 
0081   /// get the original particle from the clone
0082   virtual const reco::Candidate* originalReco(const reco::Candidate* daug) const;
0083 
0084   /// get the list of previously reconstructed particles
0085   /// e.g. in JPsi -> mu+mu-   returns an empty list
0086   ///      in B+   -> JPsi K+  returns the JPsi
0087   ///      in Bs   -> JPsi Phi returns the JPsi and Phi
0088   virtual const std::vector<BPHRecoConstCandPtr>& daughComp() const;
0089 
0090   /// get a simple particle from the name
0091   /// return null pointer if not found
0092   virtual const reco::Candidate* getDaug(const std::string& name) const;
0093 
0094   /// get a previously reconstructed particle from the name
0095   /// return null pointer if not found
0096   virtual BPHRecoConstCandPtr getComp(const std::string& name) const;
0097 
0098   const std::map<std::string, const reco::Candidate*>& daugMap() const { return dMap; }
0099 
0100   const std::map<std::string, BPHRecoConstCandPtr>& compMap() const { return cMap; }
0101 
0102   struct Component {
0103     const reco::Candidate* cand;
0104     double mass;
0105     double msig;
0106     std::string searchList;
0107   };
0108 
0109 protected:
0110   // constructors
0111   BPHDecayMomentum(int daugNum = 2, int compNum = 2);
0112   BPHDecayMomentum(const std::map<std::string, Component>& daugMap, int compNum = 2);
0113   BPHDecayMomentum(const std::map<std::string, Component>& daugMap,
0114                    const std::map<std::string, BPHRecoConstCandPtr> compMap);
0115 
0116   // get an object filled in the constructor
0117   // to be used in the creation of other bases of BPHRecoCandidate
0118   const std::vector<Component>& componentList() const;
0119 
0120   // add a simple particle giving it a name
0121   // particles are cloned, eventually specifying a different mass
0122   virtual void addP(const std::string& name, const reco::Candidate* daug, double mass = -1.0);
0123   // add a previously reconstructed particle giving it a name
0124   virtual void addP(const std::string& name, const BPHRecoConstCandPtr& comp);
0125 
0126   // utility function used to cash reconstruction results
0127   virtual void setNotUpdated() const;
0128 
0129   // function doing the job to clone reconstructed decays:
0130   // copy stable particles and clone cascade decays up to chosen level
0131   virtual void fill(BPHRecoCandidate* ptr, int level) const = 0;
0132 
0133 private:
0134   // object filled in the constructor
0135   // to be used in the creation of other bases of BPHRecoCandidate
0136   std::vector<Component> compList;
0137 
0138   // names used for simple and previously reconstructed particles
0139   std::vector<std::string> nList;
0140   std::vector<std::string> nComp;
0141 
0142   // pointers to simple and previously reconstructed particles
0143   // (clones stored for simple particles)
0144   std::vector<const reco::Candidate*> dList;
0145   std::vector<BPHRecoConstCandPtr> cList;
0146 
0147   // maps linking names to decay products
0148   // (simple and previously reconstructed particles)
0149   std::map<std::string, const reco::Candidate*> dMap;
0150   std::map<std::string, BPHRecoConstCandPtr> cMap;
0151 
0152   // map linking cloned particles to original ones
0153   std::map<const reco::Candidate*, const reco::Candidate*> clonesMap;
0154 
0155   // reconstruction results cache
0156   mutable bool oldMom;
0157   mutable std::vector<const reco::Candidate*> dFull;
0158   mutable pat::CompositeCandidate compCand;
0159 
0160   // create clones of simple particles, store them and their names
0161   void clonesList(const std::map<std::string, Component>& daugMap);
0162 
0163   // fill lists of previously reconstructed particles and their names
0164   // and retrieve cascade decay products
0165   void dCompList();
0166 
0167   // compute the total momentum of simple particles, produced
0168   // directly or in cascade decays
0169   virtual void sumMomentum(const std::vector<const reco::Candidate*>& dl, const std::vector<std::string>& dn) const;
0170 
0171   // recursively fill the list of simple particles, produced
0172   // directly or in cascade decays
0173   virtual void fillDaug(std::vector<const reco::Candidate*>& ad,
0174                         const std::string& name,
0175                         std::vector<std::string>& an) const;
0176 
0177   // compute the total momentum and cache it
0178   virtual void computeMomentum() const;
0179 };
0180 
0181 #endif