File indexing completed on 2024-04-06 12:15:33
0001 #ifndef HeavyFlavorAnalysis_RecoDecay_BPHKinematicFit_h
0002 #define HeavyFlavorAnalysis_RecoDecay_BPHKinematicFit_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHDecayVertex.h"
0016
0017
0018
0019
0020 #include "RecoVertex/KinematicFitPrimitives/interface/RefCountedKinematicParticle.h"
0021 #include "RecoVertex/KinematicFitPrimitives/interface/RefCountedKinematicTree.h"
0022
0023 class MultiTrackKinematicConstraint;
0024 class KinematicConstraint;
0025
0026
0027
0028
0029 #include <string>
0030 #include <vector>
0031 #include <map>
0032 #include <set>
0033
0034
0035
0036
0037
0038 class BPHKinematicFit : public virtual BPHDecayVertex {
0039 public:
0040
0041
0042
0043
0044 BPHKinematicFit(const BPHKinematicFit& x) = delete;
0045 BPHKinematicFit& operator=(const BPHKinematicFit& x) = delete;
0046
0047
0048
0049 ~BPHKinematicFit() override = default;
0050
0051
0052
0053
0054
0055 void setConstraint(double mass, double sigma);
0056
0057 double constrMass() const;
0058 double constrSigma() const;
0059
0060 void setIndependentFit(const std::string& name, bool flag = true, double mass = -1.0, double sigma = -1.0);
0061
0062
0063 virtual const std::vector<RefCountedKinematicParticle>& kinParticles() const;
0064 virtual std::vector<RefCountedKinematicParticle> kinParticles(const std::vector<std::string>& names) const;
0065
0066
0067 virtual const RefCountedKinematicTree& kinematicTree() const;
0068 virtual const RefCountedKinematicTree& kinematicTree(const std::string& name, double mass, double sigma) const;
0069 virtual const RefCountedKinematicTree& kinematicTree(const std::string& name, double mass) const;
0070 virtual const RefCountedKinematicTree& kinematicTree(const std::string& name) const;
0071 virtual const RefCountedKinematicTree& kinematicTree(const std::string& name, KinematicConstraint* kc) const;
0072 virtual const RefCountedKinematicTree& kinematicTree(const std::string& name,
0073 MultiTrackKinematicConstraint* kc) const;
0074
0075
0076 virtual void resetKinematicFit() const;
0077
0078
0079 virtual bool isEmpty() const;
0080 virtual bool isValidFit() const;
0081
0082
0083 virtual const RefCountedKinematicParticle currentParticle() const;
0084 virtual const RefCountedKinematicVertex currentDecayVertex() const;
0085
0086
0087 virtual const RefCountedKinematicParticle topParticle() const;
0088 virtual const RefCountedKinematicVertex topDecayVertex() const;
0089 virtual ParticleMass mass() const;
0090
0091
0092 virtual const math::XYZTLorentzVector& p4() const;
0093
0094
0095 double getMassSigma(const reco::Candidate* cand) const;
0096
0097
0098 bool getIndependentFit(const std::string& name, double& mass, double& sigma) const;
0099
0100 protected:
0101
0102 BPHKinematicFit(int daugNum = 2, int compNum = 2);
0103
0104 BPHKinematicFit(const BPHKinematicFit* ptr);
0105
0106
0107
0108
0109 virtual void addK(const std::string& name, const reco::Candidate* daug, double mass = -1.0, double sigma = -1.0);
0110
0111
0112 virtual void addK(const std::string& name,
0113 const reco::Candidate* daug,
0114 const std::string& searchList,
0115 double mass = -1.0,
0116 double sigma = -1.0);
0117
0118 virtual void addK(const std::string& name, const BPHRecoConstCandPtr& comp);
0119
0120
0121 void setNotUpdated() const override;
0122
0123 private:
0124
0125 double massConst;
0126 double massSigma;
0127
0128
0129 std::map<const reco::Candidate*, double> dMSig;
0130
0131
0132 struct FlyingParticle {
0133 bool flag = false;
0134 double mass = -1.0;
0135 double sigma = -1.0;
0136 };
0137 std::map<const BPHRecoCandidate*, FlyingParticle> cKinP;
0138
0139
0140 mutable std::vector<BPHRecoConstCandPtr> tmpList;
0141
0142
0143 mutable bool oldKPs;
0144 mutable bool oldFit;
0145 mutable bool oldMom;
0146 mutable std::map<const reco::Candidate*, RefCountedKinematicParticle> kinMap;
0147 mutable std::map<const BPHRecoCandidate*, RefCountedKinematicParticle> kCDMap;
0148 mutable std::vector<RefCountedKinematicParticle> allParticles;
0149 mutable RefCountedKinematicTree kinTree;
0150 mutable math::XYZTLorentzVector totalMomentum;
0151
0152
0153 virtual void buildParticles() const;
0154 virtual void addParticles(std::vector<RefCountedKinematicParticle>& kl,
0155 std::map<const reco::Candidate*, RefCountedKinematicParticle>& km,
0156 std::map<const BPHRecoCandidate*, RefCountedKinematicParticle>& cm) const;
0157 virtual void getParticles(const std::string& moth,
0158 const std::string& daug,
0159 std::vector<RefCountedKinematicParticle>& kl,
0160 std::set<RefCountedKinematicParticle>& ks,
0161 const BPHKinematicFit* curr) const;
0162 virtual void getParticles(const std::string& moth,
0163 const std::vector<std::string>& daug,
0164 std::vector<RefCountedKinematicParticle>& kl,
0165 std::set<RefCountedKinematicParticle>& ks,
0166 const BPHKinematicFit* curr) const;
0167 virtual unsigned int numParticles(const BPHKinematicFit* cand = nullptr) const;
0168 static void insertParticle(RefCountedKinematicParticle& kp,
0169 std::vector<RefCountedKinematicParticle>& kl,
0170 std::set<RefCountedKinematicParticle>& ks);
0171 virtual const BPHKinematicFit* splitKP(const std::string& name,
0172 std::vector<RefCountedKinematicParticle>* kComp,
0173 std::vector<RefCountedKinematicParticle>* kTail = nullptr) const;
0174 virtual const RefCountedKinematicTree& kinematicTree(const std::vector<RefCountedKinematicParticle>& kPart,
0175 MultiTrackKinematicConstraint* kc) const;
0176 virtual void fitMomentum() const;
0177 };
0178
0179 #endif