56 map<const reco::Candidate*, const reco::Candidate*> iMap;
57 const vector<const reco::Candidate*>& daug =
daughters();
61 for (i = 0; i <
n; ++
i) {
65 for (i = 0; i <
n; ++
i) {
69 const vector<BPHRecoConstCandPtr>& dComp =
daughComp();
72 for (j = 0; j <
m; ++
j) {
74 const map<const reco::Candidate*, double>&
dMap = rc->dMSig;
75 const map<const BPHRecoCandidate*, FlyingParticle>&
cMap = rc->cKinP;
76 dMSig.insert(dMap.begin(), dMap.end());
77 cKinP.insert(cMap.begin(), cMap.end());
106 if (pos != string::npos) {
107 edm::LogPrint(
"WrongRequest") <<
"BPHKinematicFit::setIndependentFit: "
108 <<
"cascade decay specification not admitted " <<
name;
112 if (comp ==
nullptr) {
113 edm::LogPrint(
"ParticleNotFound") <<
"BPHKinematicFit::setIndependentFit: " << name <<
" daughter not found";
134 vector<RefCountedKinematicParticle> plist;
138 set<RefCountedKinematicParticle>
pset;
140 int n = names.size();
142 for (i = 0; i <
n; ++
i) {
143 const string&
pname = names[
i];
151 if (pos != string::npos)
179 vector<RefCountedKinematicParticle> kPart;
181 if (ptr ==
nullptr) {
182 edm::LogPrint(
"ParticleNotFound") <<
"BPHKinematicFit::kinematicTree: " << name <<
" daughter not found";
203 vector<RefCountedKinematicParticle> kComp;
204 vector<RefCountedKinematicParticle> kTail;
206 if (ptr ==
nullptr) {
207 edm::LogPrint(
"ParticleNotFound") <<
"BPHKinematicFit::kinematicTree: " << name <<
" daughter not found";
213 if (compTree->isEmpty())
217 compTree = kinFitter.
fit(kc, compTree);
218 if (compTree->isEmpty())
221 compTree->movePointerToTheTop();
222 if (!kTail.empty()) {
224 if (!compPart->currentState().isValid())
226 kTail.push_back(compPart);
232 edm::LogPrint(
"FitFailed") <<
"BPHKinematicFit::kinematicTree: "
241 vector<RefCountedKinematicParticle> kPart;
242 if (
splitKP(name, &kPart) ==
nullptr) {
243 edm::LogPrint(
"ParticleNotFound") <<
"BPHKinematicFit::kinematicTree: " << name <<
" daughter not found";
265 if (kPart.get() ==
nullptr)
267 return kPart->currentState().isValid();
274 return kinTree->currentParticle();
280 return kinTree->currentDecayVertex();
293 kinTree->movePointerToTheTop();
294 return kinTree->currentDecayVertex();
299 if (kPart.get() ==
nullptr)
316 map<const reco::Candidate*, double>::const_iterator iter =
dMSig.find(cand);
317 return (iter !=
dMSig.end() ? iter->second : -1);
323 map<const BPHRecoCandidate*, FlyingParticle>::const_iterator iter =
cKinP.find(comp);
324 return (iter !=
cKinP.end() ? iter->second.flag :
false);
330 addK(name, daug,
"cfhpmig", mass, sigma);
337 addV(name, daug, searchList, mass);
345 const map<const reco::Candidate*, double>&
dMap = comp->dMSig;
346 const map<const BPHRecoCandidate*, FlyingParticle>&
cMap = comp->cKinP;
347 dMSig.insert(dMap.begin(), dMap.end());
348 cKinP.insert(cMap.begin(), cMap.end());
372 map<const reco::Candidate*, RefCountedKinematicParticle>& km,
373 map<const BPHRecoCandidate*, RefCountedKinematicParticle>& cm)
const {
374 const vector<const reco::Candidate*>& daug =
daughters();
382 float sigma =
dMSig.find(cand)->second;
387 kl.push_back(km[cand] = pFactory.
particle(*tt, mass, chi, ndf, sigma));
389 const vector<BPHRecoConstCandPtr>& comp =
daughComp();
396 double mass = fp.
mass;
397 double sigma = fp.
sigma;
398 if ((mass > 0.0) && (sigma > 0.0))
407 cptr->addParticles(kl, km, cm);
415 vector<RefCountedKinematicParticle>& kl,
416 set<RefCountedKinematicParticle>& ks)
const {
418 if (cptr !=
nullptr) {
419 if (
cKinP.at(cptr).flag) {
424 list.push_back(daug);
426 const vector<string>& dNames = cptr->
daugNames();
427 const vector<string>& cNames = cptr->
compNames();
428 list.insert(list.end(), dNames.begin(), dNames.end());
429 list.insert(list.end(), cNames.begin(), cNames.end());
436 if (dptr !=
nullptr) {
440 edm::LogPrint(
"ParticleNotFound") <<
"BPHKinematicFit::getParticles: " << moth <<
" not found";
445 const vector<string>& daug,
446 vector<RefCountedKinematicParticle>& kl,
447 set<RefCountedKinematicParticle>& ks)
const {
450 for (i = 0; i <
n; ++
i) {
451 const string& name = daug[
i];
453 if (pos != string::npos)
454 getParticles(moth +
"/" + name.substr(0, pos), name.substr(pos + 1), kl, ks);
464 unsigned int n = cand->
daughters().size();
465 const vector<string>& cnames = cand->
compNames();
466 int i = cnames.size();
469 if (
cKinP.at(comp).flag)
478 vector<RefCountedKinematicParticle>& kl,
479 set<RefCountedKinematicParticle>& ks) {
480 if (ks.find(kp) != ks.end())
488 vector<RefCountedKinematicParticle>* kComp,
489 vector<RefCountedKinematicParticle>* kTail)
const {
496 if (kTail ==
nullptr)
506 if (comp !=
nullptr) {
509 edm::LogPrint(
"ParticleNotFound") <<
"BPHKinematicFit::splitKP: " << name <<
" daughter not found";
513 vector<string> nfull(2);
516 vector<RefCountedKinematicParticle> kPart =
kinParticles(nfull);
517 vector<RefCountedKinematicParticle>::const_iterator iter = kPart.begin();
518 vector<RefCountedKinematicParticle>::const_iterator imid = iter + ns;
519 vector<RefCountedKinematicParticle>::const_iterator iend = kPart.end();
520 kComp->insert(kComp->end(), iter, imid);
521 kTail->insert(kTail->end(), imid, iend);
531 edm::LogPrint(
"FitFailed") <<
"BPHKinematicFit::kinematicTree: "
545 double m = ks.
mass();
546 double e =
sqrt((x * x) + (y * y) + (z * z) + (m * m));
549 edm::LogPrint(
"FitNotFound") <<
"BPHKinematicFit::fitMomentum: "
550 <<
"simple momentum sum computed";
552 const vector<const reco::Candidate*>& daug =
daughters();
556 const vector<BPHRecoConstCandPtr>& comp =
daughComp();
const reco::Candidate * cand
virtual const math::XYZTLorentzVector & p4() const
compute total momentum after the fit
RefCountedKinematicTree fit(const std::vector< RefCountedKinematicParticle > &part)
virtual unsigned int numParticles(const BPHKinematicFit *cand=nullptr) const
const edm::EventSetup & c
virtual void buildParticles() const
virtual void addK(const std::string &name, const reco::Candidate *daug, double mass=-1.0, double sigma=-1.0)
BPHGenericPtr< const BPHRecoCandidate >::type BPHRecoConstCandPtr
std::map< const BPHRecoCandidate *, RefCountedKinematicParticle > kCDMap
reco::TransientTrack * getTransientTrack(const reco::Candidate *cand) const
get TransientTrack for a daughter
virtual double mass() const =0
mass
virtual bool isEmpty() const
get fit status
GlobalVector globalMomentum() const
virtual ParticleMass mass() const
std::map< std::string, const reco::Candidate * > dMap
virtual const BPHKinematicFit * splitKP(const std::string &name, std::vector< RefCountedKinematicParticle > *kComp, std::vector< RefCountedKinematicParticle > *kTail=nullptr) const
virtual void getParticles(const std::string &moth, const std::string &daug, std::vector< RefCountedKinematicParticle > &kl, std::set< RefCountedKinematicParticle > &ks) const
virtual const std::vector< const reco::Candidate * > & daughters() const
const std::string names[nVars_]
virtual const RefCountedKinematicParticle currentParticle() const
get current particle
std::vector< RefCountedKinematicTree > fit(KinematicConstraint *cs, const std::vector< RefCountedKinematicTree > &trees) const
ParticleMass mass() const
std::vector< BPHRecoConstCandPtr > tmpList
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
double constrSigma() const
std::map< const reco::Candidate *, RefCountedKinematicParticle > kinMap
double constrMass() const
retrieve the constraint
void setNotUpdated() const override
virtual void fitMomentum() const
virtual const RefCountedKinematicTree & kinematicTree() const
perform the kinematic fit and get the result
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
std::map< const reco::Candidate *, double > dMSig
virtual void addV(const std::string &name, const reco::Candidate *daug, const std::string &searchList, double mass)
virtual const RefCountedKinematicVertex currentDecayVertex() const
virtual const std::vector< RefCountedKinematicParticle > & kinParticles() const
get kinematic particles
const std::vector< Component > & componentList() const
static void insertParticle(RefCountedKinematicParticle &kp, std::vector< RefCountedKinematicParticle > &kl, std::set< RefCountedKinematicParticle > &ks)
RefCountedKinematicTree fit(const std::vector< RefCountedKinematicParticle > &particles) const
Log< level::Warning, true > LogPrint
virtual const reco::Candidate * originalReco(const reco::Candidate *daug) const
get the original particle from the clone
virtual void resetKinematicFit() const
reset the kinematic fit
ReferenceCountingPointer< KinematicVertex > RefCountedKinematicVertex
ReferenceCountingPointer< KinematicTree > RefCountedKinematicTree
std::vector< RefCountedKinematicParticle > allParticles
virtual bool isValidFit() const
virtual BPHRecoCandidate * clone(int level=-1) const
virtual void addParticles(std::vector< RefCountedKinematicParticle > &kl, std::map< const reco::Candidate *, RefCountedKinematicParticle > &km, std::map< const BPHRecoCandidate *, RefCountedKinematicParticle > &cm) const
RefCountedKinematicTree kinTree
std::map< const BPHRecoCandidate *, FlyingParticle > cKinP
virtual const RefCountedKinematicVertex topDecayVertex() const
ReferenceCountingPointer< KinematicParticle > RefCountedKinematicParticle
virtual BPHRecoConstCandPtr getComp(const std::string &name) const
virtual const std::vector< BPHRecoConstCandPtr > & daughComp() const
void setNotUpdated() const override
virtual const std::vector< const reco::Candidate * > & daughFull() const
RefCountedKinematicParticle particle(const reco::TransientTrack &initialTrack, const ParticleMass &massGuess, float chiSquared, float degreesOfFr, float &m_sigma) const
virtual const std::vector< std::string > & compNames() const
void setConstraint(double mass, double sigma)
apply a mass constraint
math::XYZTLorentzVector totalMomentum
virtual const std::vector< std::string > & daugNames() const
virtual const reco::Candidate * getDaug(const std::string &name) const
virtual const RefCountedKinematicParticle topParticle() const
get top particle
~BPHKinematicFit() override
bool getIndependentFit(const std::string &name) const
retrieve independent fit flag
std::map< std::string, BPHRecoConstCandPtr > cMap
double getMassSigma(const reco::Candidate *cand) const
retrieve particle mass sigma
tuple size
Write out results.