17 tree_ = fitter_.fit(particles);
19 std::cerr <<
">>> exception thrown by KinematicParticleVertexFitter:\n"
21 <<
">>> candidate not fitted to common vertex" << std::endl;
33 if (bField_ ==
nullptr)
35 <<
"B-Field was not set up CandKinematicVertexFitter.\n"
36 <<
"the following method must be called before fitting a candidate:\n"
37 <<
" CandKinematicVertexFitter:.set( const MagneticField * )" << endl;
38 vector<RefCountedKinematicParticle> particles;
39 vector<Candidate *> daughters;
40 vector<RecoCandidate::TrackType> trackTypes;
42 fill(particles, daughters, trackTypes, c);
43 assert(particles.size() == daughters.size());
48 tree_->movePointerToTheTop();
51 if (vertex->vertexIsValid()) {
54 vector<RefCountedKinematicParticle> treeParticles = tree_->daughterParticles();
55 vector<RefCountedKinematicParticle>::const_iterator particleIt = treeParticles.begin();
56 vector<Candidate *>::const_iterator daughterIt = daughters.begin(), daughtersEnd = daughters.end();
57 vector<RecoCandidate::TrackType>::const_iterator trackTypeIt = trackTypes.begin();
59 for (; daughterIt != daughtersEnd; ++particleIt, ++daughterIt, ++trackTypeIt) {
61 GlobalVector p3 = (*particleIt)->currentState().globalMomentum();
62 double px = p3.
x(), py = p3.
y(), pz = p3.
z(),
p = p3.
mag();
68 switch (*trackTypeIt) {
71 energy = daughter.
energy();
78 double mass = (*particleIt)->currentState().mass();
79 energy =
sqrt(
p *
p + mass * mass);
86 c.
setChi2AndNdof(chi2_ = vertex->chiSquared(), ndof_ = vertex->degreesOfFreedom());
88 cov_(0, 0) = err.
cxx();
89 cov_(0, 1) = err.
cyx();
90 cov_(0, 2) = err.
czx();
91 cov_(1, 2) = err.
czy();
92 cov_(1, 1) = err.
cyy();
93 cov_(2, 2) = err.
czz();
104 vector<Candidate *> &daughters,
105 vector<RecoCandidate::TrackType> &trackTypes,
109 for (
unsigned int j = 0;
j < nDau; ++
j) {
112 ostringstream message;
113 message <<
"Can't access in write mode candidate daughters. "
114 <<
"pdgId = " << c.
pdgId() <<
".\n";
117 message <<
"Null daughter also found in read-only mode\n";
119 message <<
"Daughter found in read-only mode with id: " << d1->
pdgId() <<
"\n";
126 if (vtxDau !=
nullptr && vtxDau->
vertexChi2() > 0) {
128 (*this).set(*vtxDau);
135 float mass_sigma = mass * 0.000001;
140 tree_ = csFitter.
fit(mass_c, tree_);
146 particles.push_back(current);
147 daughters.push_back(d);
150 fill(particles, daughters, trackTypes, *d);
160 float sigma = mass * 1.e-6;
161 particles.push_back(factory_.particle(trTrk, mass, chi2,
ndof, sigma));
162 daughters.push_back(d);
163 trackTypes.push_back(type);
165 cerr <<
">>> warning: candidate of type " << d->
pdgId() <<
" has no track reference." << endl;
double vertexChi2() const override
chi-squares
virtual double energy() const =0
energy
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
const edm::EventSetup & c
virtual void setP4(const LorentzVector &p4)=0
set 4-momentum
virtual double mass() const =0
mass
math::Error< 5 >::type CovarianceMatrix
std::vector< RefCountedKinematicTree > fit(KinematicConstraint *cs, const std::vector< RefCountedKinematicTree > &trees) const
void setVertex(const Point &vertex) override
set vertex
int pdgId() const final
PDG identifier.
virtual size_type numberOfDaughters() const =0
number of daughters
bool fit(const std::vector< RefCountedKinematicParticle > &tracks) const
void setChi2AndNdof(double chi2, double ndof)
set chi2 and ndof
bool massConstraint() const final
do mass constraint?
virtual void setVertex(const Point &vertex)=0
set vertex
void setCovariance(const CovarianceMatrix &m)
set covariance matrix
HepPDT::ParticleData ParticleData
bool isNull() const
Checks for null.
virtual int pdgId() const =0
PDG identifier.
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
void fill(std::vector< RefCountedKinematicParticle > &, std::vector< reco::Candidate * > &, std::vector< reco::RecoCandidate::TrackType > &, reco::Candidate &) const
void set(const MagneticField *bField)
char data[epos_bytes_allocation]
T get() const
get a component
math::XYZPoint Point
point in the space
virtual bool longLived() const =0
is long lived?
static constexpr float d1
void setP4(const LorentzVector &p4) final
set 4-momentum