CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
BPHKinematicFit Class Reference

#include <BPHKinematicFit.h>

Inheritance diagram for BPHKinematicFit:
BPHDecayVertex BPHDecayMomentum BPHRecoCandidate BPHPlusMinusCandidate

Classes

struct  FlyingParticle
 

Public Member Functions

 BPHKinematicFit (const BPHKinematicFit &x)=delete
 
double constrMass () const
 retrieve the constraint More...
 
double constrSigma () const
 
virtual const RefCountedKinematicVertex currentDecayVertex () const
 
virtual const RefCountedKinematicParticle currentParticle () const
 get current particle More...
 
bool getIndependentFit (const std::string &name, double &mass, double &sigma) const
 retrieve independent fit flag More...
 
double getMassSigma (const reco::Candidate *cand) const
 retrieve particle mass sigma More...
 
virtual bool isEmpty () const
 get fit status More...
 
virtual bool isValidFit () const
 
virtual const RefCountedKinematicTreekinematicTree () const
 perform the kinematic fit and get the result More...
 
virtual const RefCountedKinematicTreekinematicTree (const std::string &name, double mass, double sigma) const
 
virtual const RefCountedKinematicTreekinematicTree (const std::string &name, double mass) const
 
virtual const RefCountedKinematicTreekinematicTree (const std::string &name) const
 
virtual const RefCountedKinematicTreekinematicTree (const std::string &name, KinematicConstraint *kc) const
 
virtual const RefCountedKinematicTreekinematicTree (const std::string &name, MultiTrackKinematicConstraint *kc) const
 
virtual const std::vector< RefCountedKinematicParticle > & kinParticles () const
 get kinematic particles More...
 
virtual std::vector< RefCountedKinematicParticlekinParticles (const std::vector< std::string > &names) const
 
virtual ParticleMass mass () const
 
BPHKinematicFitoperator= (const BPHKinematicFit &x)=delete
 
virtual const math::XYZTLorentzVectorp4 () const
 compute total momentum after the fit More...
 
virtual void resetKinematicFit () const
 reset the kinematic fit More...
 
void setConstraint (double mass, double sigma)
 apply a mass constraint More...
 
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 More...
 
virtual const RefCountedKinematicVertex topDecayVertex () const
 
virtual const RefCountedKinematicParticle topParticle () const
 get top particle More...
 
 ~BPHKinematicFit () override=default
 
- Public Member Functions inherited from BPHDecayVertex
 BPHDecayVertex (const BPHDecayVertex &x)=delete
 
const BPHEventSetupWrappergetEventSetup () const
 retrieve EventSetup More...
 
char getTMode (const reco::Candidate *cand) const
 get Track mode for a daughter More...
 
const reco::TrackgetTrack (const reco::Candidate *cand) const
 get Track for a daughter More...
 
const std::string & getTrackSearchList (const reco::Candidate *cand) const
 retrieve track search list More...
 
reco::TransientTrackgetTransientTrack (const reco::Candidate *cand) const
 get TransientTrack for a daughter More...
 
BPHDecayVertexoperator= (const BPHDecayVertex &x)=delete
 
const std::vector< const reco::Track * > & tracks () const
 get list of Tracks More...
 
const std::vector< reco::TransientTrack > & transientTracks () const
 get list of TransientTracks More...
 
virtual bool validTracks () const
 check for valid reconstructed vertex More...
 
virtual bool validVertex () const
 
virtual const reco::Vertexvertex (VertexFitter< 5 > *fitter=nullptr, const reco::BeamSpot *bs=nullptr, const GlobalPoint *priorPos=nullptr, const GlobalError *priorError=nullptr) const
 get reconstructed vertex More...
 
 ~BPHDecayVertex () override
 
- Public Member Functions inherited from BPHDecayMomentum
 BPHDecayMomentum (const BPHDecayMomentum &x)=delete
 
const std::map< std::string, BPHRecoConstCandPtr > & compMap () const
 
virtual const std::vector< std::string > & compNames () const
 
virtual const pat::CompositeCandidatecomposite () const
 get a composite by the simple sum of simple particles More...
 
virtual const std::vector< BPHRecoConstCandPtr > & daughComp () const
 
virtual const std::vector< const reco::Candidate * > & daughFull () const
 
virtual const std::vector< const reco::Candidate * > & daughters () const
 
const std::map< std::string, const reco::Candidate * > & daugMap () const
 
virtual const std::vector< std::string > & daugNames () const
 
virtual BPHRecoConstCandPtr getComp (const std::string &name) const
 
virtual const reco::CandidategetDaug (const std::string &name) const
 
BPHDecayMomentumoperator= (const BPHDecayMomentum &x)=delete
 
virtual const reco::CandidateoriginalReco (const reco::Candidate *daug) const
 get the original particle from the clone More...
 
virtual ~BPHDecayMomentum ()
 

Protected Member Functions

virtual void addK (const std::string &name, const reco::Candidate *daug, double mass=-1.0, double sigma=-1.0)
 
virtual void addK (const std::string &name, const reco::Candidate *daug, const std::string &searchList, double mass=-1.0, double sigma=-1.0)
 
virtual void addK (const std::string &name, const BPHRecoConstCandPtr &comp)
 
 BPHKinematicFit (int daugNum=2, int compNum=2)
 
 BPHKinematicFit (const BPHKinematicFit *ptr)
 
void setNotUpdated () const override
 
- Protected Member Functions inherited from BPHDecayVertex
virtual void addV (const std::string &name, const reco::Candidate *daug, const std::string &searchList, double mass)
 
virtual void addV (const std::string &name, const BPHRecoConstCandPtr &comp)
 
 BPHDecayVertex (const BPHEventSetupWrapper *es, int daugNum=2, int compNum=2)
 
 BPHDecayVertex (const BPHDecayVertex *ptr, const BPHEventSetupWrapper *es)
 
- Protected Member Functions inherited from BPHDecayMomentum
virtual void addP (const std::string &name, const reco::Candidate *daug, double mass=-1.0)
 
virtual void addP (const std::string &name, const BPHRecoConstCandPtr &comp)
 
 BPHDecayMomentum (int daugNum=2, int compNum=2)
 
 BPHDecayMomentum (const std::map< std::string, Component > &daugMap, int compNum=2)
 
 BPHDecayMomentum (const std::map< std::string, Component > &daugMap, const std::map< std::string, BPHRecoConstCandPtr > compMap)
 
const std::vector< Component > & componentList () const
 
virtual void fill (BPHRecoCandidate *ptr, int level) const =0
 

Private Member Functions

virtual void addParticles (std::vector< RefCountedKinematicParticle > &kl, std::map< const reco::Candidate *, RefCountedKinematicParticle > &km, std::map< const BPHRecoCandidate *, RefCountedKinematicParticle > &cm) const
 
virtual void buildParticles () const
 
virtual void fitMomentum () const
 
virtual void getParticles (const std::string &moth, const std::string &daug, std::vector< RefCountedKinematicParticle > &kl, std::set< RefCountedKinematicParticle > &ks, const BPHKinematicFit *curr) const
 
virtual void getParticles (const std::string &moth, const std::vector< std::string > &daug, std::vector< RefCountedKinematicParticle > &kl, std::set< RefCountedKinematicParticle > &ks, const BPHKinematicFit *curr) const
 
virtual const RefCountedKinematicTreekinematicTree (const std::vector< RefCountedKinematicParticle > &kPart, MultiTrackKinematicConstraint *kc) const
 
virtual unsigned int numParticles (const BPHKinematicFit *cand=nullptr) const
 
virtual const BPHKinematicFitsplitKP (const std::string &name, std::vector< RefCountedKinematicParticle > *kComp, std::vector< RefCountedKinematicParticle > *kTail=nullptr) const
 

Static Private Member Functions

static void insertParticle (RefCountedKinematicParticle &kp, std::vector< RefCountedKinematicParticle > &kl, std::set< RefCountedKinematicParticle > &ks)
 

Private Attributes

std::vector< RefCountedKinematicParticleallParticles
 
std::map< const BPHRecoCandidate *, FlyingParticlecKinP
 
std::map< const reco::Candidate *, double > dMSig
 
std::map< const BPHRecoCandidate *, RefCountedKinematicParticlekCDMap
 
std::map< const reco::Candidate *, RefCountedKinematicParticlekinMap
 
RefCountedKinematicTree kinTree
 
double massConst
 
double massSigma
 
bool oldFit
 
bool oldKPs
 
bool oldMom
 
std::vector< BPHRecoConstCandPtrtmpList
 
math::XYZTLorentzVector totalMomentum
 

Detailed Description

Description: Highest-level base class to encapsulate kinematic fit operations

Author
Paolo Ronchese INFN Padova high-level base class to perform a kinematic fit

Definition at line 38 of file BPHKinematicFit.h.

Constructor & Destructor Documentation

◆ BPHKinematicFit() [1/3]

BPHKinematicFit::BPHKinematicFit ( const BPHKinematicFit x)
delete

Constructors are protected this object can exist only as part of a derived class

◆ ~BPHKinematicFit()

BPHKinematicFit::~BPHKinematicFit ( )
overridedefault

Destructor

◆ BPHKinematicFit() [2/3]

BPHKinematicFit::BPHKinematicFit ( int  daugNum = 2,
int  compNum = 2 
)
protected

Definition at line 39 of file BPHKinematicFit.cc.

40  : BPHDecayMomentum(daugNum, compNum),
41  BPHDecayVertex(nullptr),
42  massConst(-1.0),
43  massSigma(-1.0),
44  oldKPs(true),
45  oldFit(true),
46  oldMom(true),
47  kinTree(nullptr) {}
BPHDecayMomentum(const BPHDecayMomentum &x)=delete
BPHDecayVertex(const BPHDecayVertex &x)=delete
RefCountedKinematicTree kinTree

◆ BPHKinematicFit() [3/3]

BPHKinematicFit::BPHKinematicFit ( const BPHKinematicFit ptr)
protected

Definition at line 49 of file BPHKinematicFit.cc.

References c, cKinP, BPHDecayMomentum::cMap, BPHDecayMomentum::componentList(), BPHDecayMomentum::daughComp(), BPHDecayMomentum::daughters(), BPHDecayMomentum::dMap, dMSig, mps_fire::i, dqmiolumiharvest::j, visualization-live-secondInstance_cfg::m, dqmiodumpmetadata::n, and BPHDecayMomentum::originalReco().

50  : BPHDecayVertex(ptr, nullptr),
51  massConst(-1.0),
52  massSigma(-1.0),
53  oldKPs(true),
54  oldFit(true),
55  oldMom(true),
56  kinTree(nullptr) {
57  map<const reco::Candidate*, const reco::Candidate*> iMap;
58  const vector<const reco::Candidate*>& daug = daughters();
59  const vector<Component>& list = ptr->componentList();
60  int i;
61  int n = daug.size();
62  for (i = 0; i < n; ++i) {
63  const reco::Candidate* cand = daug[i];
64  iMap[originalReco(cand)] = cand;
65  }
66  for (i = 0; i < n; ++i) {
67  const Component& c = list[i];
68  dMSig[iMap[c.cand]] = c.msig;
69  }
70  const vector<BPHRecoConstCandPtr>& dComp = daughComp();
71  int j;
72  int m = dComp.size();
73  for (j = 0; j < m; ++j) {
74  const BPHRecoCandidate* rc = dComp[j].get();
75  const map<const reco::Candidate*, double>& dMap = rc->dMSig;
76  const map<const BPHRecoCandidate*, FlyingParticle>& cMap = rc->cKinP;
77  dMSig.insert(dMap.begin(), dMap.end());
78  cKinP.insert(cMap.begin(), cMap.end());
79  cKinP[rc];
80  }
81 }
virtual const reco::Candidate * originalReco(const reco::Candidate *daug) const
get the original particle from the clone
const std::vector< Component > & componentList() const
std::map< std::string, const reco::Candidate * > dMap
std::map< const reco::Candidate *, double > dMSig
BPHDecayVertex(const BPHDecayVertex &x)=delete
virtual const std::vector< BPHRecoConstCandPtr > & daughComp() const
RefCountedKinematicTree kinTree
std::map< const BPHRecoCandidate *, FlyingParticle > cKinP
virtual const std::vector< const reco::Candidate * > & daughters() const
std::map< std::string, BPHRecoConstCandPtr > cMap

Member Function Documentation

◆ addK() [1/3]

virtual void BPHKinematicFit::addK ( const std::string &  name,
const reco::Candidate daug,
double  mass = -1.0,
double  sigma = -1.0 
)
protectedvirtual

Referenced by BPHRecoCandidate::add().

◆ addK() [2/3]

virtual void BPHKinematicFit::addK ( const std::string &  name,
const reco::Candidate daug,
const std::string &  searchList,
double  mass = -1.0,
double  sigma = -1.0 
)
protectedvirtual

◆ addK() [3/3]

virtual void BPHKinematicFit::addK ( const std::string &  name,
const BPHRecoConstCandPtr comp 
)
protectedvirtual

◆ addParticles()

void BPHKinematicFit::addParticles ( std::vector< RefCountedKinematicParticle > &  kl,
std::map< const reco::Candidate *, RefCountedKinematicParticle > &  km,
std::map< const BPHRecoCandidate *, RefCountedKinematicParticle > &  cm 
) const
privatevirtual

Definition at line 371 of file BPHKinematicFit.cc.

References cKinP, BPHRecoCandidate::clone(), AlCaHLTBitMon_QueryRunRegistry::comp, BPHDecayMomentum::daughComp(), BPHDecayMomentum::daughters(), dMSig, personalPlayback::fp, BPHDecayVertex::getTransientTrack(), isEmpty(), isValidFit(), visualization-live-secondInstance_cfg::m, mass(), dqmiodumpmetadata::n, KinematicParticleFactoryFromTransientTrack::particle(), setConstraint(), tmpList, topParticle(), and groupFilesInBlocks::tt.

Referenced by buildParticles().

373  {
374  const vector<const reco::Candidate*>& daug = daughters();
376  int n = daug.size();
377  float chi = 0.0;
378  float ndf = 0.0;
379  while (n--) {
380  const reco::Candidate* cand = daug[n];
381  ParticleMass mass = cand->mass();
382  float sigma = dMSig.find(cand)->second;
383  if (sigma < 0)
384  sigma = 1.0e-7;
386  if (tt != nullptr)
387  kl.push_back(km[cand] = pFactory.particle(*tt, mass, chi, ndf, sigma));
388  }
389  const vector<BPHRecoConstCandPtr>& comp = daughComp();
390  int m = comp.size();
391  while (m--) {
392  const BPHRecoCandidate* cptr = comp[m].get();
393  const FlyingParticle& fp = cKinP.at(cptr);
394  if (fp.flag) {
395  BPHRecoCandidate* tptr = cptr->clone();
396  double mass = fp.mass;
397  double sigma = fp.sigma;
398  if (mass > 0.0)
399  tptr->setConstraint(mass, sigma);
400  tmpList.push_back(BPHRecoConstCandPtr(tptr));
401  if (tptr->isEmpty())
402  return;
403  if (!tptr->isValidFit())
404  return;
405  kl.push_back(cm[cptr] = tptr->topParticle());
406  } else {
407  cptr->addParticles(kl, km, cm);
408  }
409  }
410  return;
411 }
virtual const RefCountedKinematicParticle topParticle() const
get top particle
virtual BPHRecoCandidate * clone(int level=-1) const
BPHGenericPtr< const BPHRecoCandidate >::type BPHRecoConstCandPtr
double ParticleMass
Definition: ParticleMass.h:4
reco::TransientTrack * getTransientTrack(const reco::Candidate *cand) const
get TransientTrack for a daughter
std::vector< BPHRecoConstCandPtr > tmpList
std::map< const reco::Candidate *, double > dMSig
RefCountedKinematicParticle particle(const reco::TransientTrack &initialTrack, const ParticleMass &massGuess, float chiSquared, float degreesOfFr, float &m_sigma) const
virtual bool isValidFit() const
virtual const std::vector< BPHRecoConstCandPtr > & daughComp() const
std::map< const BPHRecoCandidate *, FlyingParticle > cKinP
virtual bool isEmpty() const
get fit status
virtual const std::vector< const reco::Candidate * > & daughters() const
void setConstraint(double mass, double sigma)
apply a mass constraint
virtual ParticleMass mass() const

◆ buildParticles()

void BPHKinematicFit::buildParticles ( ) const
privatevirtual

Definition at line 361 of file BPHKinematicFit.cc.

References addParticles(), allParticles, BPHDecayMomentum::daughFull(), kCDMap, kinMap, oldKPs, and findQualityFiles::size.

Referenced by kinParticles().

361  {
362  kinMap.clear();
363  kCDMap.clear();
364  allParticles.clear();
365  allParticles.reserve(daughFull().size());
367  oldKPs = false;
368  return;
369 }
size
Write out results.
std::map< const BPHRecoCandidate *, RefCountedKinematicParticle > kCDMap
virtual void addParticles(std::vector< RefCountedKinematicParticle > &kl, std::map< const reco::Candidate *, RefCountedKinematicParticle > &km, std::map< const BPHRecoCandidate *, RefCountedKinematicParticle > &cm) const
virtual const std::vector< const reco::Candidate * > & daughFull() const
std::map< const reco::Candidate *, RefCountedKinematicParticle > kinMap
std::vector< RefCountedKinematicParticle > allParticles

◆ constrMass()

double BPHKinematicFit::constrMass ( ) const

retrieve the constraint

Definition at line 95 of file BPHKinematicFit.cc.

References massConst.

Referenced by BPHRecoCandidate::fill().

95 { return massConst; }

◆ constrSigma()

double BPHKinematicFit::constrSigma ( ) const

Definition at line 97 of file BPHKinematicFit.cc.

References massSigma.

Referenced by BPHRecoCandidate::fill().

97 { return massSigma; }

◆ currentDecayVertex()

const RefCountedKinematicVertex BPHKinematicFit::currentDecayVertex ( ) const
virtual

Definition at line 272 of file BPHKinematicFit.cc.

References isEmpty(), and kinTree.

272  {
273  if (isEmpty())
274  return RefCountedKinematicVertex(nullptr);
275  return kinTree->currentDecayVertex();
276 }
ReferenceCountingPointer< KinematicVertex > RefCountedKinematicVertex
RefCountedKinematicTree kinTree
virtual bool isEmpty() const
get fit status

◆ currentParticle()

const RefCountedKinematicParticle BPHKinematicFit::currentParticle ( ) const
virtual

get current particle

Definition at line 266 of file BPHKinematicFit.cc.

References isEmpty(), and kinTree.

266  {
267  if (isEmpty())
268  return RefCountedKinematicParticle(nullptr);
269  return kinTree->currentParticle();
270 }
RefCountedKinematicTree kinTree
ReferenceCountingPointer< KinematicParticle > RefCountedKinematicParticle
virtual bool isEmpty() const
get fit status

◆ fitMomentum()

void BPHKinematicFit::fitMomentum ( ) const
privatevirtual

Definition at line 540 of file BPHKinematicFit.cc.

References AlCaHLTBitMon_QueryRunRegistry::comp, BPHDecayMomentum::daughComp(), BPHDecayMomentum::daughters(), MillePedeFileConverter_cfg::e, KinematicState::globalMomentum(), isValidFit(), visualization-live-secondInstance_cfg::m, KinematicState::mass(), dqmiodumpmetadata::n, oldMom, mathSSE::sqrt(), topParticle(), totalMomentum, x, PV3DBase< T, PVType, FrameType >::x(), y, PV3DBase< T, PVType, FrameType >::y(), z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by p4().

540  {
541  if (isValidFit()) {
542  const KinematicState& ks = topParticle()->currentState();
543  GlobalVector tm = ks.globalMomentum();
544  double x = tm.x();
545  double y = tm.y();
546  double z = tm.z();
547  double m = ks.mass();
548  double e = sqrt((x * x) + (y * y) + (z * z) + (m * m));
549  totalMomentum.SetPxPyPzE(x, y, z, e);
550  } else {
551  edm::LogPrint("FitNotFound") << "BPHKinematicFit::fitMomentum: "
552  << "simple momentum sum computed";
554  const vector<const reco::Candidate*>& daug = daughters();
555  int n = daug.size();
556  while (n--)
557  tm += daug[n]->p4();
558  const vector<BPHRecoConstCandPtr>& comp = daughComp();
559  int m = comp.size();
560  while (m--)
561  tm += comp[m]->p4();
562  totalMomentum = tm;
563  }
564  oldMom = false;
565  return;
566 }
virtual const RefCountedKinematicParticle topParticle() const
get top particle
T z() const
Definition: PV3DBase.h:61
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
GlobalVector globalMomentum() const
Log< level::Warning, true > LogPrint
virtual bool isValidFit() const
virtual const std::vector< BPHRecoConstCandPtr > & daughComp() const
ParticleMass mass() const
virtual const std::vector< const reco::Candidate * > & daughters() const
math::XYZTLorentzVector totalMomentum

◆ getIndependentFit()

bool BPHKinematicFit::getIndependentFit ( const std::string &  name,
double &  mass,
double &  sigma 
) const

retrieve independent fit flag

Definition at line 316 of file BPHKinematicFit.cc.

References cKinP, AlCaHLTBitMon_QueryRunRegistry::comp, BPHDecayMomentum::getComp(), mass(), and Skims_PA_cff::name.

Referenced by BPHRecoCandidate::fill().

316  {
317  const BPHRecoCandidate* comp = getComp(name).get();
318  map<const BPHRecoCandidate*, FlyingParticle>::const_iterator iter = cKinP.find(comp);
319  if ((iter != cKinP.end()) && iter->second.flag) {
320  mass = iter->second.mass;
321  sigma = iter->second.sigma;
322  return true;
323  }
324  return false;
325 }
virtual BPHRecoConstCandPtr getComp(const std::string &name) const
std::map< const BPHRecoCandidate *, FlyingParticle > cKinP
virtual ParticleMass mass() const

◆ getMassSigma()

double BPHKinematicFit::getMassSigma ( const reco::Candidate cand) const

retrieve particle mass sigma

Definition at line 310 of file BPHKinematicFit.cc.

References dMSig.

Referenced by BPHRecoCandidate::fill().

310  {
311  map<const reco::Candidate*, double>::const_iterator iter = dMSig.find(cand);
312  return (iter != dMSig.end() ? iter->second : -1);
313 }
std::map< const reco::Candidate *, double > dMSig

◆ getParticles() [1/2]

virtual void BPHKinematicFit::getParticles ( const std::string &  moth,
const std::string &  daug,
std::vector< RefCountedKinematicParticle > &  kl,
std::set< RefCountedKinematicParticle > &  ks,
const BPHKinematicFit curr 
) const
privatevirtual

◆ getParticles() [2/2]

virtual void BPHKinematicFit::getParticles ( const std::string &  moth,
const std::vector< std::string > &  daug,
std::vector< RefCountedKinematicParticle > &  kl,
std::set< RefCountedKinematicParticle > &  ks,
const BPHKinematicFit curr 
) const
privatevirtual

◆ insertParticle()

void BPHKinematicFit::insertParticle ( RefCountedKinematicParticle kp,
std::vector< RefCountedKinematicParticle > &  kl,
std::set< RefCountedKinematicParticle > &  ks 
)
staticprivate

Definition at line 479 of file BPHKinematicFit.cc.

481  {
482  if (ks.find(kp) != ks.end())
483  return;
484  kl.push_back(kp);
485  ks.insert(kp);
486  return;
487 }

◆ isEmpty()

bool BPHKinematicFit::isEmpty ( void  ) const
virtual

get fit status

Definition at line 251 of file BPHKinematicFit.cc.

References kinematicTree(), and kinTree.

Referenced by addParticles(), plotting.Plot::clone(), currentDecayVertex(), currentParticle(), topDecayVertex(), and topParticle().

251  {
252  kinematicTree();
253  if (kinTree.get() == nullptr)
254  return true;
255  return kinTree->isEmpty();
256 }
virtual const RefCountedKinematicTree & kinematicTree() const
perform the kinematic fit and get the result
RefCountedKinematicTree kinTree

◆ isValidFit()

bool BPHKinematicFit::isValidFit ( ) const
virtual

Definition at line 258 of file BPHKinematicFit.cc.

References topParticle().

Referenced by addParticles(), and fitMomentum().

258  {
260  if (kPart.get() == nullptr)
261  return false;
262  return kPart->currentState().isValid();
263 }
virtual const RefCountedKinematicParticle topParticle() const
get top particle

◆ kinematicTree() [1/7]

const RefCountedKinematicTree & BPHKinematicFit::kinematicTree ( ) const
virtual

perform the kinematic fit and get the result

Definition at line 156 of file BPHKinematicFit.cc.

References kinTree, massConst, massSigma, and oldFit.

Referenced by isEmpty().

156  {
157  if (oldFit)
158  return kinematicTree("", massConst, massSigma);
159  return kinTree;
160 }
virtual const RefCountedKinematicTree & kinematicTree() const
perform the kinematic fit and get the result
RefCountedKinematicTree kinTree

◆ kinematicTree() [2/7]

virtual const RefCountedKinematicTree& BPHKinematicFit::kinematicTree ( const std::string &  name,
double  mass,
double  sigma 
) const
virtual

◆ kinematicTree() [3/7]

virtual const RefCountedKinematicTree& BPHKinematicFit::kinematicTree ( const std::string &  name,
double  mass 
) const
virtual

◆ kinematicTree() [4/7]

virtual const RefCountedKinematicTree& BPHKinematicFit::kinematicTree ( const std::string &  name) const
virtual

◆ kinematicTree() [5/7]

virtual const RefCountedKinematicTree& BPHKinematicFit::kinematicTree ( const std::string &  name,
KinematicConstraint kc 
) const
virtual

◆ kinematicTree() [6/7]

virtual const RefCountedKinematicTree& BPHKinematicFit::kinematicTree ( const std::string &  name,
MultiTrackKinematicConstraint kc 
) const
virtual

◆ kinematicTree() [7/7]

const RefCountedKinematicTree & BPHKinematicFit::kinematicTree ( const std::vector< RefCountedKinematicParticle > &  kPart,
MultiTrackKinematicConstraint kc 
) const
privatevirtual

Definition at line 527 of file BPHKinematicFit.cc.

References cppFunctionSkipper::exception, KinematicConstrainedVertexFitter::fit(), and kinTree.

528  {
529  try {
531  kinTree = cvf.fit(kPart, kc);
532  } catch (std::exception const&) {
533  edm::LogPrint("FitFailed") << "BPHKinematicFit::kinematicTree: "
534  << "kin fit reset";
535  kinTree = RefCountedKinematicTree(nullptr);
536  }
537  return kinTree;
538 }
RefCountedKinematicTree fit(const std::vector< RefCountedKinematicParticle > &part)
Log< level::Warning, true > LogPrint
ReferenceCountingPointer< KinematicTree > RefCountedKinematicTree
RefCountedKinematicTree kinTree

◆ kinParticles() [1/2]

const vector< RefCountedKinematicParticle > & BPHKinematicFit::kinParticles ( ) const
virtual

get kinematic particles

Definition at line 121 of file BPHKinematicFit.cc.

References allParticles, buildParticles(), and oldKPs.

Referenced by splitKP().

121  {
122  if (oldKPs)
123  buildParticles();
124  return allParticles;
125 }
std::vector< RefCountedKinematicParticle > allParticles
virtual void buildParticles() const

◆ kinParticles() [2/2]

virtual std::vector<RefCountedKinematicParticle> BPHKinematicFit::kinParticles ( const std::vector< std::string > &  names) const
virtual

◆ mass()

ParticleMass BPHKinematicFit::mass ( ) const
virtual

Definition at line 292 of file BPHKinematicFit.cc.

References KinematicState::isValid(), KinematicState::mass(), and topParticle().

Referenced by Particle.Particle::__str__(), DiObject.DiMuon::__str__(), BPHRecoCandidate::add(), addParticles(), BPHRecoCandidate::build(), BPHDecayToV0DiffMassBuilder::buildCandidate(), BPHRecoCandidate::fill(), getIndependentFit(), setConstraint(), and setIndependentFit().

292  {
294  if (kPart.get() == nullptr)
295  return -1.0;
296  const KinematicState kStat = kPart->currentState();
297  if (kStat.isValid())
298  return kStat.mass();
299  return -1.0;
300 }
virtual const RefCountedKinematicParticle topParticle() const
get top particle
ParticleMass mass() const
bool isValid() const

◆ numParticles()

unsigned int BPHKinematicFit::numParticles ( const BPHKinematicFit cand = nullptr) const
privatevirtual

Definition at line 463 of file BPHKinematicFit.cc.

References AlCaHLTBitMon_QueryRunRegistry::comp, mps_fire::i, and dqmiodumpmetadata::n.

Referenced by splitKP().

463  {
464  if (cand == nullptr)
465  cand = this;
466  unsigned int n = cand->daughters().size();
467  const vector<string>& cnames = cand->compNames();
468  int i = cnames.size();
469  while (i) {
470  const BPHRecoCandidate* comp = cand->getComp(cnames[--i]).get();
471  if (cand->cKinP.at(comp).flag)
472  ++n;
473  else
474  n += numParticles(comp);
475  }
476  return n;
477 }
virtual unsigned int numParticles(const BPHKinematicFit *cand=nullptr) const

◆ operator=()

BPHKinematicFit& BPHKinematicFit::operator= ( const BPHKinematicFit x)
delete

◆ p4()

const math::XYZTLorentzVector & BPHKinematicFit::p4 ( ) const
virtual

compute total momentum after the fit

Definition at line 303 of file BPHKinematicFit.cc.

References fitMomentum(), oldMom, and totalMomentum.

Referenced by Tau.Tau::dxy_approx(), Tau.Tau::dz(), and Lepton.Lepton::p4WithFSR().

303  {
304  if (oldMom)
305  fitMomentum();
306  return totalMomentum;
307 }
virtual void fitMomentum() const
math::XYZTLorentzVector totalMomentum

◆ resetKinematicFit()

void BPHKinematicFit::resetKinematicFit ( ) const
virtual

reset the kinematic fit

Definition at line 245 of file BPHKinematicFit.cc.

References oldFit, oldKPs, and oldMom.

Referenced by setNotUpdated().

245  {
246  oldKPs = oldFit = oldMom = true;
247  return;
248 }

◆ setConstraint()

void BPHKinematicFit::setConstraint ( double  mass,
double  sigma 
)

apply a mass constraint

Operations

Definition at line 87 of file BPHKinematicFit.cc.

References mass(), massConst, massSigma, oldFit, oldKPs, and oldMom.

Referenced by addParticles(), and BPHRecoCandidate::fill().

87  {
88  oldKPs = oldFit = oldMom = true;
89  massConst = mass;
90  massSigma = sigma;
91  return;
92 }
virtual ParticleMass mass() const

◆ setIndependentFit()

void BPHKinematicFit::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 at line 100 of file BPHKinematicFit.cc.

References cKinP, AlCaHLTBitMon_QueryRunRegistry::comp, RemoveAddSevLevel::flag, personalPlayback::fp, BPHDecayMomentum::getComp(), mass(), Skims_PA_cff::name, oldFit, oldKPs, and oldMom.

Referenced by BPHRecoCandidate::fill().

100  {
101  string::size_type pos = name.find('/');
102  if (pos != string::npos) {
103  edm::LogPrint("WrongRequest") << "BPHKinematicFit::setIndependentFit: "
104  << "cascade decay specification not admitted " << name;
105  return;
106  }
107  const BPHRecoCandidate* comp = getComp(name).get();
108  if (comp == nullptr) {
109  edm::LogPrint("ParticleNotFound") << "BPHKinematicFit::setIndependentFit: " << name << " daughter not found";
110  return;
111  }
112  oldKPs = oldFit = oldMom = true;
113  FlyingParticle& fp = cKinP[comp];
114  fp.flag = flag;
115  fp.mass = mass;
116  fp.sigma = sigma;
117  return;
118 }
uint16_t size_type
Log< level::Warning, true > LogPrint
virtual BPHRecoConstCandPtr getComp(const std::string &name) const
std::map< const BPHRecoCandidate *, FlyingParticle > cKinP
virtual ParticleMass mass() const

◆ setNotUpdated()

void BPHKinematicFit::setNotUpdated ( ) const
overrideprotectedvirtual

Reimplemented from BPHDecayVertex.

Reimplemented in BPHPlusMinusCandidate.

Definition at line 354 of file BPHKinematicFit.cc.

References resetKinematicFit(), and BPHDecayVertex::setNotUpdated().

Referenced by BPHPlusMinusCandidate::setNotUpdated().

354  {
357  return;
358 }
virtual void resetKinematicFit() const
reset the kinematic fit
void setNotUpdated() const override

◆ splitKP()

const BPHKinematicFit * BPHKinematicFit::splitKP ( const std::string &  name,
std::vector< RefCountedKinematicParticle > *  kComp,
std::vector< RefCountedKinematicParticle > *  kTail = nullptr 
) const
privatevirtual

Definition at line 489 of file BPHKinematicFit.cc.

References allParticles, cKinP, AlCaHLTBitMon_QueryRunRegistry::comp, BPHDecayMomentum::getComp(), kinParticles(), kinTree, Skims_PA_cff::name, numParticles(), and oldFit.

491  {
492  kinTree = RefCountedKinematicTree(nullptr);
493  oldFit = false;
494  kinParticles();
495  if (allParticles.size() != numParticles())
496  return nullptr;
497  kComp->clear();
498  if (kTail == nullptr)
499  kTail = kComp;
500  else
501  kTail->clear();
502  if (name.empty()) {
503  *kComp = allParticles;
504  return this;
505  }
506  const BPHRecoCandidate* comp = getComp(name).get();
507  int ns;
508  if (comp != nullptr) {
509  ns = (cKinP.at(comp).flag ? 1 : numParticles(comp));
510  } else {
511  edm::LogPrint("ParticleNotFound") << "BPHKinematicFit::splitKP: " << name << " daughter not found";
512  *kTail = allParticles;
513  return nullptr;
514  }
515  vector<string> nfull(2);
516  nfull[0] = name;
517  nfull[1] = "*";
518  vector<RefCountedKinematicParticle> kPart = kinParticles(nfull);
519  vector<RefCountedKinematicParticle>::const_iterator iter = kPart.begin();
520  vector<RefCountedKinematicParticle>::const_iterator imid = iter + ns;
521  vector<RefCountedKinematicParticle>::const_iterator iend = kPart.end();
522  kComp->insert(kComp->end(), iter, imid);
523  kTail->insert(kTail->end(), imid, iend);
524  return comp;
525 }
virtual unsigned int numParticles(const BPHKinematicFit *cand=nullptr) const
virtual const std::vector< RefCountedKinematicParticle > & kinParticles() const
get kinematic particles
Log< level::Warning, true > LogPrint
ReferenceCountingPointer< KinematicTree > RefCountedKinematicTree
virtual BPHRecoConstCandPtr getComp(const std::string &name) const
std::vector< RefCountedKinematicParticle > allParticles
RefCountedKinematicTree kinTree
std::map< const BPHRecoCandidate *, FlyingParticle > cKinP

◆ topDecayVertex()

const RefCountedKinematicVertex BPHKinematicFit::topDecayVertex ( ) const
virtual

Definition at line 285 of file BPHKinematicFit.cc.

References isEmpty(), and kinTree.

285  {
286  if (isEmpty())
287  return RefCountedKinematicVertex(nullptr);
288  kinTree->movePointerToTheTop();
289  return kinTree->currentDecayVertex();
290 }
ReferenceCountingPointer< KinematicVertex > RefCountedKinematicVertex
RefCountedKinematicTree kinTree
virtual bool isEmpty() const
get fit status

◆ topParticle()

const RefCountedKinematicParticle BPHKinematicFit::topParticle ( ) const
virtual

get top particle

Definition at line 279 of file BPHKinematicFit.cc.

References isEmpty(), and kinTree.

Referenced by addParticles(), fitMomentum(), isValidFit(), and mass().

279  {
280  if (isEmpty())
281  return RefCountedKinematicParticle(nullptr);
282  return kinTree->topParticle();
283 }
RefCountedKinematicTree kinTree
ReferenceCountingPointer< KinematicParticle > RefCountedKinematicParticle
virtual bool isEmpty() const
get fit status

Member Data Documentation

◆ allParticles

std::vector<RefCountedKinematicParticle> BPHKinematicFit::allParticles
mutableprivate

Definition at line 148 of file BPHKinematicFit.h.

Referenced by buildParticles(), kinParticles(), and splitKP().

◆ cKinP

std::map<const BPHRecoCandidate*, FlyingParticle> BPHKinematicFit::cKinP
private

◆ dMSig

std::map<const reco::Candidate*, double> BPHKinematicFit::dMSig
private

Definition at line 129 of file BPHKinematicFit.h.

Referenced by addParticles(), BPHKinematicFit(), and getMassSigma().

◆ kCDMap

std::map<const BPHRecoCandidate*, RefCountedKinematicParticle> BPHKinematicFit::kCDMap
mutableprivate

Definition at line 147 of file BPHKinematicFit.h.

Referenced by buildParticles().

◆ kinMap

std::map<const reco::Candidate*, RefCountedKinematicParticle> BPHKinematicFit::kinMap
mutableprivate

Definition at line 146 of file BPHKinematicFit.h.

Referenced by buildParticles().

◆ kinTree

RefCountedKinematicTree BPHKinematicFit::kinTree
mutableprivate

◆ massConst

double BPHKinematicFit::massConst
private

Definition at line 125 of file BPHKinematicFit.h.

Referenced by constrMass(), kinematicTree(), and setConstraint().

◆ massSigma

double BPHKinematicFit::massSigma
private

Definition at line 126 of file BPHKinematicFit.h.

Referenced by constrSigma(), kinematicTree(), and setConstraint().

◆ oldFit

bool BPHKinematicFit::oldFit
mutableprivate

◆ oldKPs

bool BPHKinematicFit::oldKPs
mutableprivate

◆ oldMom

bool BPHKinematicFit::oldMom
mutableprivate

◆ tmpList

std::vector<BPHRecoConstCandPtr> BPHKinematicFit::tmpList
mutableprivate

Definition at line 140 of file BPHKinematicFit.h.

Referenced by addParticles().

◆ totalMomentum

math::XYZTLorentzVector BPHKinematicFit::totalMomentum
mutableprivate

Definition at line 150 of file BPHKinematicFit.h.

Referenced by fitMomentum(), and p4().