CMS 3D CMS Logo

BPHKinematicFit.h
Go to the documentation of this file.
1 #ifndef HeavyFlavorAnalysis_RecoDecay_BPHKinematicFit_h
2 #define HeavyFlavorAnalysis_RecoDecay_BPHKinematicFit_h
3 
12 //----------------------
13 // Base Class Headers --
14 //----------------------
16 
17 //------------------------------------
18 // Collaborating Class Declarations --
19 //------------------------------------
22 
25 
26 //---------------
27 // C++ Headers --
28 //---------------
29 #include <string>
30 #include <vector>
31 #include <map>
32 #include <set>
33 
34 // ---------------------
35 // -- Class Interface --
36 // ---------------------
37 
38 class BPHKinematicFit : public virtual BPHDecayVertex {
39 public:
43  // deleted copy constructor and assignment operator
44  BPHKinematicFit(const BPHKinematicFit& x) = delete;
45  BPHKinematicFit& operator=(const BPHKinematicFit& x) = delete;
46 
49  ~BPHKinematicFit() override;
50 
54  void setConstraint(double mass, double sigma);
57  double constrMass() const;
58  double constrSigma() const;
60  void setIndependentFit(const std::string& name, bool flag = true, double mass = -1.0, double sigma = -1.0);
61 
63  virtual const std::vector<RefCountedKinematicParticle>& kinParticles() const;
64  virtual std::vector<RefCountedKinematicParticle> kinParticles(const std::vector<std::string>& names) const;
65 
67  virtual const RefCountedKinematicTree& kinematicTree() const;
68  virtual const RefCountedKinematicTree& kinematicTree(const std::string& name, double mass, double sigma) const;
69  virtual const RefCountedKinematicTree& kinematicTree(const std::string& name, double mass) const;
70  virtual const RefCountedKinematicTree& kinematicTree(const std::string& name) const;
74 
76  virtual void resetKinematicFit() const;
77 
79  virtual bool isEmpty() const;
80  virtual bool isValidFit() const;
81 
83  virtual const RefCountedKinematicParticle currentParticle() const;
84  virtual const RefCountedKinematicVertex currentDecayVertex() const;
85 
87  virtual const RefCountedKinematicParticle topParticle() const;
88  virtual const RefCountedKinematicVertex topDecayVertex() const;
89  virtual ParticleMass mass() const;
90 
92  virtual const math::XYZTLorentzVector& p4() const;
93 
95  double getMassSigma(const reco::Candidate* cand) const;
96 
98  bool getIndependentFit(const std::string& name) const;
99 
100 protected:
101  // constructors
102  BPHKinematicFit();
103  // pointer used to retrieve informations from other bases
104  BPHKinematicFit(const BPHKinematicFit* ptr);
105 
109  virtual void addK(const std::string& name, const reco::Candidate* daug, double mass = -1.0, double sigma = -1.0);
112  virtual void addK(const std::string& name,
113  const reco::Candidate* daug,
114  const std::string& searchList,
115  double mass = -1.0,
116  double sigma = -1.0);
118  virtual void addK(const std::string& name, const BPHRecoConstCandPtr& comp);
119 
120  // utility function used to cash reconstruction results
121  void setNotUpdated() const override;
122 
123 private:
124  // mass constraint
125  double massConst;
126  double massSigma;
127 
128  // map linking daughters to mass sigma
129  std::map<const reco::Candidate*, double> dMSig;
130 
131  // map to handle composite daughters as single particles
132  struct FlyingParticle {
133  bool flag = false;
134  double mass = -1.0;
135  double sigma = -1.0;
136  };
137  std::map<const BPHRecoCandidate*, FlyingParticle> cKinP;
138 
139  // temporary particle set
140  mutable std::vector<BPHRecoConstCandPtr> tmpList;
141 
142  // reconstruction results cache
143  mutable bool oldKPs;
144  mutable bool oldFit;
145  mutable bool oldMom;
146  mutable std::map<const reco::Candidate*, RefCountedKinematicParticle> kinMap;
147  mutable std::map<const BPHRecoCandidate*, RefCountedKinematicParticle> kCDMap;
148  mutable std::vector<RefCountedKinematicParticle> allParticles;
151 
152  // build kin particles, perform the fit and compute the total momentum
153  virtual void buildParticles() const;
154  virtual void addParticles(std::vector<RefCountedKinematicParticle>& kl,
155  std::map<const reco::Candidate*, RefCountedKinematicParticle>& km,
156  std::map<const BPHRecoCandidate*, RefCountedKinematicParticle>& cm) const;
157  virtual void getParticles(const std::string& moth,
158  const std::string& daug,
159  std::vector<RefCountedKinematicParticle>& kl,
160  std::set<RefCountedKinematicParticle>& ks) const;
161  virtual void getParticles(const std::string& moth,
162  const std::vector<std::string>& daug,
163  std::vector<RefCountedKinematicParticle>& kl,
164  std::set<RefCountedKinematicParticle>& ks) const;
165  virtual unsigned int numParticles(const BPHKinematicFit* cand = nullptr) const;
167  std::vector<RefCountedKinematicParticle>& kl,
168  std::set<RefCountedKinematicParticle>& ks);
169  virtual const BPHKinematicFit* splitKP(const std::string& name,
170  std::vector<RefCountedKinematicParticle>* kComp,
171  std::vector<RefCountedKinematicParticle>* kTail = nullptr) const;
172  virtual const RefCountedKinematicTree& kinematicTree(const std::vector<RefCountedKinematicParticle>& kPart,
174  virtual void fitMomentum() const;
175 };
176 
177 #endif
BPHKinematicFit::currentDecayVertex
virtual const RefCountedKinematicVertex currentDecayVertex() const
Definition: BPHKinematicFit.cc:277
AlCaHLTBitMon_QueryRunRegistry.comp
string comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
BPHKinematicFit::FlyingParticle
Definition: BPHKinematicFit.h:132
BPHKinematicFit::isEmpty
virtual bool isEmpty() const
get fit status
Definition: BPHKinematicFit.cc:256
BPHKinematicFit::getMassSigma
double getMassSigma(const reco::Candidate *cand) const
retrieve particle mass sigma
Definition: BPHKinematicFit.cc:315
BPHKinematicFit::dMSig
std::map< const reco::Candidate *, double > dMSig
Definition: BPHKinematicFit.h:129
BPHKinematicFit::numParticles
virtual unsigned int numParticles(const BPHKinematicFit *cand=nullptr) const
Definition: BPHKinematicFit.cc:461
ParticleMass
double ParticleMass
Definition: ParticleMass.h:4
BPHKinematicFit::oldKPs
bool oldKPs
Definition: BPHKinematicFit.h:143
BPHKinematicFit::oldMom
bool oldMom
Definition: BPHKinematicFit.h:145
BPHKinematicFit::FlyingParticle::sigma
double sigma
Definition: BPHKinematicFit.h:135
MultiTrackKinematicConstraint
Definition: MultiTrackKinematicConstraint.h:23
BPHKinematicFit::buildParticles
virtual void buildParticles() const
Definition: BPHKinematicFit.cc:361
BPHKinematicFit::allParticles
std::vector< RefCountedKinematicParticle > allParticles
Definition: BPHKinematicFit.h:148
ReferenceCountingPointer< KinematicTree >
DDAxes::x
BPHKinematicFit::currentParticle
virtual const RefCountedKinematicParticle currentParticle() const
get current particle
Definition: BPHKinematicFit.cc:271
BPHKinematicFit::constrMass
double constrMass() const
retrieve the constraint
Definition: BPHKinematicFit.cc:99
BPHKinematicFit::FlyingParticle::flag
bool flag
Definition: BPHKinematicFit.h:133
BPHKinematicFit::massSigma
double massSigma
Definition: BPHKinematicFit.h:126
BPHKinematicFit::BPHKinematicFit
BPHKinematicFit()
Definition: BPHKinematicFit.cc:39
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
BPHKinematicFit::getParticles
virtual void getParticles(const std::string &moth, const std::string &daug, std::vector< RefCountedKinematicParticle > &kl, std::set< RefCountedKinematicParticle > &ks) const
KinematicConstraint
Definition: KinematicConstraint.h:21
BPHKinematicFit::addParticles
virtual void addParticles(std::vector< RefCountedKinematicParticle > &kl, std::map< const reco::Candidate *, RefCountedKinematicParticle > &km, std::map< const BPHRecoCandidate *, RefCountedKinematicParticle > &cm) const
Definition: BPHKinematicFit.cc:371
BPHKinematicFit::isValidFit
virtual bool isValidFit() const
Definition: BPHKinematicFit.cc:263
BPHKinematicFit::p4
virtual const math::XYZTLorentzVector & p4() const
compute total momentum after the fit
Definition: BPHKinematicFit.cc:308
BPHDecayVertex
Definition: BPHDecayVertex.h:43
BPHKinematicFit::totalMomentum
math::XYZTLorentzVector totalMomentum
Definition: BPHKinematicFit.h:150
BPHKinematicFit::~BPHKinematicFit
~BPHKinematicFit() override
Definition: BPHKinematicFit.cc:85
BPHKinematicFit::topDecayVertex
virtual const RefCountedKinematicVertex topDecayVertex() const
Definition: BPHKinematicFit.cc:290
BPHKinematicFit::topParticle
virtual const RefCountedKinematicParticle topParticle() const
get top particle
Definition: BPHKinematicFit.cc:284
BPHKinematicFit::insertParticle
static void insertParticle(RefCountedKinematicParticle &kp, std::vector< RefCountedKinematicParticle > &kl, std::set< RefCountedKinematicParticle > &ks)
Definition: BPHKinematicFit.cc:477
cand
Definition: decayParser.h:32
BPHKinematicFit::kinMap
std::map< const reco::Candidate *, RefCountedKinematicParticle > kinMap
Definition: BPHKinematicFit.h:146
BPHKinematicFit::kCDMap
std::map< const BPHRecoCandidate *, RefCountedKinematicParticle > kCDMap
Definition: BPHKinematicFit.h:147
BPHKinematicFit::constrSigma
double constrSigma() const
Definition: BPHKinematicFit.cc:101
newFWLiteAna.searchList
searchList
Definition: newFWLiteAna.py:119
BPHKinematicFit::massConst
double massConst
Definition: BPHKinematicFit.h:125
BPHKinematicFit::mass
virtual ParticleMass mass() const
Definition: BPHKinematicFit.cc:297
BPHKinematicFit::tmpList
std::vector< BPHRecoConstCandPtr > tmpList
Definition: BPHKinematicFit.h:140
BPHKinematicFit::kinematicTree
virtual const RefCountedKinematicTree & kinematicTree() const
perform the kinematic fit and get the result
Definition: BPHKinematicFit.cc:160
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BPHKinematicFit::setConstraint
void setConstraint(double mass, double sigma)
apply a mass constraint
Definition: BPHKinematicFit.cc:91
BPHKinematicFit::FlyingParticle::mass
double mass
Definition: BPHKinematicFit.h:134
reco::Candidate
Definition: Candidate.h:27
BPHKinematicFit::addK
virtual void addK(const std::string &name, const reco::Candidate *daug, double mass=-1.0, double sigma=-1.0)
BPHKinematicFit::setNotUpdated
void setNotUpdated() const override
Definition: BPHKinematicFit.cc:354
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
BPHKinematicFit::fitMomentum
virtual void fitMomentum() const
Definition: BPHKinematicFit.cc:538
BPHKinematicFit::oldFit
bool oldFit
Definition: BPHKinematicFit.h:144
RefCountedKinematicTree.h
BPHKinematicFit::operator=
BPHKinematicFit & operator=(const BPHKinematicFit &x)=delete
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
BPHKinematicFit::resetKinematicFit
virtual void resetKinematicFit() const
reset the kinematic fit
Definition: BPHKinematicFit.cc:250
BPHDecayVertex.h
BPHKinematicFit
Definition: BPHKinematicFit.h:38
BPHKinematicFit::cKinP
std::map< const BPHRecoCandidate *, FlyingParticle > cKinP
Definition: BPHKinematicFit.h:137
RefCountedKinematicParticle.h
BPHKinematicFit::getIndependentFit
bool getIndependentFit(const std::string &name) const
retrieve independent fit flag
Definition: BPHKinematicFit.cc:321
BPHKinematicFit::kinTree
RefCountedKinematicTree kinTree
Definition: BPHKinematicFit.h:149
kp
int kp
Definition: CascadeWrapper.h:13
BPHKinematicFit::splitKP
virtual const BPHKinematicFit * splitKP(const std::string &name, std::vector< RefCountedKinematicParticle > *kComp, std::vector< RefCountedKinematicParticle > *kTail=nullptr) const
Definition: BPHKinematicFit.cc:487
BPHKinematicFit::setIndependentFit
void setIndependentFit(const std::string &name, bool flag=true, double mass=-1.0, double sigma=-1.0)
set a decaying daughter as an unique particle fitted independently
Definition: BPHKinematicFit.cc:104
BPHRecoConstCandPtr
BPHGenericPtr< const BPHRecoCandidate >::type BPHRecoConstCandPtr
Definition: BPHRecoCandidatePtr.h:9
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:117
BPHKinematicFit::kinParticles
virtual const std::vector< RefCountedKinematicParticle > & kinParticles() const
get kinematic particles
Definition: BPHKinematicFit.cc:125