Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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