12 #include <TDatabasePDG.h>
14 #include <analysis/VertexFitting/TreeFitter/ParticleBase.h>
15 #include <analysis/VertexFitting/TreeFitter/InternalParticle.h>
16 #include <analysis/VertexFitting/TreeFitter/RecoComposite.h>
17 #include <analysis/VertexFitting/TreeFitter/RecoResonance.h>
18 #include <analysis/VertexFitting/TreeFitter/RecoTrack.h>
20 #include <analysis/VertexFitting/TreeFitter/RecoPhoton.h>
21 #include <analysis/VertexFitting/TreeFitter/RecoKlong.h>
22 #include <analysis/VertexFitting/TreeFitter/Resonance.h>
23 #include <analysis/VertexFitting/TreeFitter/Origin.h>
24 #include <analysis/VertexFitting/TreeFitter/FitParams.h>
26 #include <framework/geometry/BFieldManager.h>
28 namespace TreeFitter {
33 m_isStronglyDecayingResonance(false),
50 m_isStronglyDecayingResonance(false),
67 m_isStronglyDecayingResonance(false),
97 B2ERROR(
"Cannot remove particle, because not found ...");
104 daughter->updateIndex(offset);
116 return new Origin(daughter, config, forceFitAll);
213 particles.push_back(
this);
217 daughter->collectVertexDaughters(particles, posindex);
228 for (
int i = 0; i < 3; ++i) {
236 for (
int i = 0; i < maxrow; ++i) {
252 case 0: rc +=
"_x ";
break;
253 case 1: rc +=
"_y ";
break;
254 case 2: rc +=
"_z ";
break;
255 case 3: rc +=
"_tau";
break;
256 case 4: rc +=
"_px ";
break;
257 case 5: rc +=
"_py ";
break;
258 case 6: rc +=
"_pz ";
break;
259 case 7: rc +=
"_E ";
break;
279 map.push_back(std::pair<const ParticleBase*, int>(
this,
index()));
281 daughter->retrieveIndexMap(map);
289 rc += daughter->chiSquare(fitparams);
298 rc += daughter->nFinalChargedCandidates();
314 Eigen::Matrix < double, 1, -1, 1, 1, 3 > x_vec = fitparams.
getStateVector().segment(posindex,
dim);
315 Eigen::Matrix < double, 1, -1, 1, 1, 3 > x_m = fitparams.
getStateVector().segment(posindexmother,
dim);
316 Eigen::Matrix < double, 1, -1, 1, 1, 3 > p_vec = fitparams.
getStateVector().segment(momindex,
dim);
317 const double mom = p_vec.norm();
318 const double mom3 = mom * mom * mom;
323 p.getH()(0, momindex) = tau * (p_vec(1) * p_vec(1) + p_vec(2) * p_vec(2)) / mom3 ;
324 p.getH()(1, momindex + 1) = tau * (p_vec(0) * p_vec(0) + p_vec(2) * p_vec(2)) / mom3 ;
325 p.getH()(2, momindex + 2) = tau * (p_vec(0) * p_vec(0) + p_vec(1) * p_vec(1)) / mom3 ;
328 p.getH()(0, momindex + 1) = - tau * p_vec(0) * p_vec(1) / mom3 ;
329 p.getH()(0, momindex + 2) = - tau * p_vec(0) * p_vec(2) / mom3 ;
331 p.getH()(1, momindex + 0) = - tau * p_vec(1) * p_vec(0) / mom3 ;
332 p.getH()(1, momindex + 2) = - tau * p_vec(1) * p_vec(2) / mom3 ;
334 p.getH()(2, momindex + 0) = - tau * p_vec(2) * p_vec(0) / mom3 ;
335 p.getH()(2, momindex + 1) = - tau * p_vec(2) * p_vec(1) / mom3 ;
337 }
else if (2 ==
dim) {
340 p.getH()(0, momindex) = tau * (p_vec(1) * p_vec(1)) / mom3 ;
341 p.getH()(1, momindex + 1) = tau * (p_vec(0) * p_vec(0)) / mom3 ;
344 p.getH()(0, momindex + 1) = - tau * p_vec(0) * p_vec(1) / mom3 ;
345 p.getH()(1, momindex + 0) = - tau * p_vec(1) * p_vec(0) / mom3 ;
347 B2FATAL(
"Dimension of Geometric constraint is not 2 or 3. This will crash many things. You should feel bad.");
350 for (
int row = 0; row <
dim; ++row) {
352 double posxmother = x_m(row);
353 double posx = x_vec(row);
354 double momx = p_vec(row);
359 p.getResiduals()(row) = posxmother + tau * momx / mom - posx ;
360 p.getH()(row, posindexmother + row) = 1;
361 p.getH()(row, posindex + row) = -1;
362 p.getH()(row, tauindex) = momx / mom;
365 return ErrCode(ErrCode::Status::success);
368 void inline setExtraInfo(
Belle2::Particle* part,
const std::string& name,
const double value)
383 const double mass2 = mass * mass;
391 const int momindex = daughter->momIndex();
394 const double py_daughter = fitparams.
getStateVector()(momindex + 1);
395 const double pz_daughter = fitparams.
getStateVector()(momindex + 2);
400 if (daughter->hasEnergy()) {
404 const double m = daughter->particle()->getPDGMass();
405 E += std::sqrt(m * m + px_daughter * px_daughter + py_daughter * py_daughter + pz_daughter * pz_daughter);
412 p.getResiduals()(0) = mass2 - E * E + px * px + py * py + pz * pz;
416 const int momindex = daughter->momIndex();
417 p.getH()(0, momindex) = 2.0 * px;
418 p.getH()(0, momindex + 1) = 2.0 * py;
419 p.getH()(0, momindex + 2) = 2.0 * pz;
421 if (daughter->hasEnergy()) {
422 p.getH()(0, momindex + 3) = -2.0 * E;
425 const double py_daughter = fitparams.
getStateVector()(momindex + 1);
426 const double pz_daughter = fitparams.
getStateVector()(momindex + 2);
427 const double m = daughter->particle()->getPDGMass();
429 const double E_daughter = std::sqrt(m * m + px_daughter * px_daughter + py_daughter * py_daughter + pz_daughter * pz_daughter);
430 const double E_by_E_daughter = E / E_daughter;
431 p.getH()(0, momindex) -= 2.0 * E_by_E_daughter * px_daughter;
432 p.getH()(0, momindex + 1) -= 2.0 * E_by_E_daughter * py_daughter;
433 p.getH()(0, momindex + 2) -= 2.0 * E_by_E_daughter * pz_daughter;
437 return ErrCode(ErrCode::Status::success);
444 const double mass2 = mass * mass;
454 p.getResiduals()(0) = mass2 - E * E + px * px + py * py + pz * pz;
456 p.getH()(0, momindex) = 2.0 * px;
457 p.getH()(0, momindex + 1) = 2.0 * py;
458 p.getH()(0, momindex + 2) = 2.0 * pz;
459 p.getH()(0, momindex + 3) = -2.0 * E;
467 return ErrCode(ErrCode::Status::success);
483 if (
type == Constraint::mass) {
486 B2FATAL(
"Trying to project constraint of ParticleBase type. This is undefined.");
488 return ErrCode(ErrCode::Status::badsetup);
502 const Eigen::Matrix < double, 1, -1, 1, 1, 3 > vertex_dist =
504 const Eigen::Matrix < double, 1, -1, 1, 1, 3 >
510 const double mom_norm = mom.norm();
511 const double dot = std::abs(vertex_dist.dot(mom));
512 const double tau = dot / mom_norm;
513 if (0 == mom_norm || 0 == dot) {
524 return ErrCode(ErrCode::Status::success);
static const double speedOfLight
[cm/ns]
Class to store reconstructed particles.
const KLMCluster * getKLMCluster() const
Returns the pointer to the KLMCluster object that was used to create this Particle (ParticleType == c...
const Track * getTrack() const
Returns the pointer to the Track object that was used to create this Particle (ParticleType == c_Trac...
const ECLCluster * getECLCluster() const
Returns the pointer to the ECLCluster object that was used to create this Particle (if ParticleType =...
void setExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
std::string getName() const override
Return name of this particle.
bool hasExtraInfo(const std::string &name) const
Return whether the extra info with the given name is set.
unsigned getMdstArrayIndex(void) const
Returns 0-based index of MDST store array object (0 for composite particles)
int getPDGCode(void) const
Returns PDG code.
double getPDGMass(void) const
Returns uncertainty on the invariant mass (requires valid momentum error matrix)
void addExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
double getPDGLifetime() const
Returns particle nominal lifetime.
double getExtraInfo(const std::string &name) const
Return given value if set.
const int m_originDimension
dimension of the origin constraint and ALL geometric gcosntraints
int m_headOfTreePDG
PDG code of the head particle.
const bool m_massConstraintType
const flag for the type of the mass constraint
Type
type of constraints the order of these constraints is important: it is the order in which they are ap...
abstract errorocode be aware that the default is success
Class to store and manage fitparams (statevector)
Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > & getCovariance()
getter for the states covariance
Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector()
getter for the fit parameters/statevector
another unnecessary layer of abstraction
representation of the beamspot as a particle
base class for all particles
ParticleBase(Belle2::Particle *particle, const ParticleBase *mother, const ConstraintConfiguration *config)
default constructor
Belle2::Particle * particle() const
get basf2 particle
virtual void updateIndex(int &offset)
this sets the index for momentum, position, etc.
virtual ErrCode projectMassConstraintParticle(const FitParams &, Projection &) const
project mass constraint using the particles parameters
ErrCode initTau(FitParams &par) const
initialises tau as a length
virtual ParticleBase * addDaughter(Belle2::Particle *, const ConstraintConfiguration &config, bool forceFitAll=false)
add daughter
static ParticleBase * createOrigin(Belle2::Particle *daughter, const ConstraintConfiguration &config, bool forceFitAll)
create a custom origin particle or a beamspot
static ParticleBase * createParticle(Belle2::Particle *particle, const ParticleBase *mother, const ConstraintConfiguration &config, bool forceFitAll=false)
create the according treeFitter particle obj for a basf2 particle type
virtual int dim() const =0
get dimension of constraint
virtual int nFinalChargedCandidates() const
number of charged candidates
virtual void retrieveIndexMap(indexmap &anindexmap) const
get index map
virtual ErrCode projectMassConstraint(const FitParams &, Projection &) const
project mass constraint abstract
const ConstraintConfiguration * m_config
has all the constraint config
virtual std::string parname(int index) const
get name of parameter i
static bool isAResonance(Belle2::Particle *particle)
controls if a particle is treated as a resonance(lifetime=0) or a particle that has a finite lifetime...
virtual ErrCode projectConstraint(Constraint::Type, const FitParams &, Projection &) const
project constraint.
virtual ErrCode projectMassConstraintDaughters(const FitParams &, Projection &) const
project mass constraint using the parameters of the daughters
const ParticleBase * locate(Belle2::Particle *particle) const
get particle base from basf2 particle
virtual void removeDaughter(const ParticleBase *pb)
remove daughter
bool m_isStronglyDecayingResonance
decay length less than 1 micron
virtual ErrCode initCovariance(FitParams &) const
init covariance matrix
virtual int type() const =0
get particle type
Belle2::Particle * m_particle
pointer to framework type
virtual ErrCode projectGeoConstraint(const FitParams &, Projection &) const
project geometrical constraint
virtual double chiSquare(const FitParams &) const
get chi2
virtual int posIndex() const
get vertex index (in statevector!)
std::vector< std::pair< const ParticleBase *, int > > indexmap
alias
virtual int momIndex() const
get momentum index
int index() const
get index
virtual bool hasEnergy() const
get momentum dimension
std::vector< ParticleBase * > m_daughters
daughter container
virtual ~ParticleBase()
destructor, actually does something
void collectVertexDaughters(std::vector< ParticleBase * > &particles, int posindex)
get vertex daughters
virtual int tauIndex() const
get tau index
virtual bool hasPosition() const
get false
const ParticleBase * mother() const
getMother() / hasMother()
class to store the projected residuals and the corresponding jacobian as well as the covariance matri...
A class for composite particles.
representation of the Klong constraint
representation of the photon constraint
representation of all charged final states FIXME rename since this name is taken in tracking
class for resonances as internal particles