 |
Belle II Software
release-05-02-19
|
TrackBuilder class to create the Track/TrackFitResult mdst output from the RecoTrack.
More...
#include <TrackBuilder.h>
|
| TrackBuilder (const std::string &trackColName, const std::string &trackFitResultColName, const std::string &mcParticleColName, const TVector3 &beamSpot=TVector3(0., 0., 0.), const TVector3 &beamAxis=TVector3(0., 0., 1.)) |
| Constructor of the class. More...
|
|
bool | storeTrackFromRecoTrack (RecoTrack &recoTrack, const bool useClosestHitToIP=false, const bool useBFieldAtHit=false) |
| Stores a Belle2 Track from a Reco Track. More...
|
|
TrackBuilder class to create the Track/TrackFitResult mdst output from the RecoTrack.
To use this class, iterate over all Reco tracks and call trackBuilder.storeTrackFromRecoTrack. All fitted hypotheses will be stored into one Track with the TrackFitResult array indices stored in the Track. for (auto& recoTrack : recoTracks) { trackBuilder.storeTrackFromRecoTrack(recoTrack); }
If you want to make sure that all hypotheses are fitted and stored, call the fitter again. If the tracks are fitted already, this produces no overhead. TrackFitter trackFitter; TrackBuilder trackBuilder; for (auto& recoTrack : recoTracks) { for (const auto& pdg : m_pdgCodes) { trackFitter.fit(recoTrack, Const::ParticleType(abs(pdg))); } trackBuilder.storeTrackFromRecoTrack(recoTrack); }
Definition at line 50 of file TrackBuilder.h.
◆ TrackBuilder()
TrackBuilder |
( |
const std::string & |
trackColName, |
|
|
const std::string & |
trackFitResultColName, |
|
|
const std::string & |
mcParticleColName, |
|
|
const TVector3 & |
beamSpot = TVector3(0., 0., 0.) , |
|
|
const TVector3 & |
beamAxis = TVector3(0., 0., 1.) |
|
) |
| |
|
inline |
Constructor of the class.
- Parameters
-
trackColName | Name of the store array for tracks (output). |
trackFitResultColName | Name of the store array for track fit results (output). |
mcParticleColName | Name of the store array for MC particles (input, optional). If given, the tracks are matched to MCParticles. |
beamSpot | Origin. |
beamAxis | Positive z-direction. |
Definition at line 61 of file TrackBuilder.h.
◆ storeTrackFromRecoTrack()
bool storeTrackFromRecoTrack |
( |
RecoTrack & |
recoTrack, |
|
|
const bool |
useClosestHitToIP = false , |
|
|
const bool |
useBFieldAtHit = false |
|
) |
| |
Stores a Belle2 Track from a Reco Track.
Every fitted hypothesis will be extrapolated to the perigee and stored as a TrackFitResult when the fit and the extrapolation were successful. We will only create a Track mdst object, when we are sure that we have at least one valid hypothesis available. If we do not have this, we discard the track no matter what.
The StoreArrayIndex is stored in the Belle2 Track, no relation is set.
- Parameters
-
recoTrack | The reco track the fit results are stored for |
useClosestHitInIP | Flag to turn on special handling which measurement to choose; especially useful for Cosmics |
useBFiledAtHit | Flag to calculate the BField at the used hit (closest to IP or first one), instead of the one at the POCA. This is also useful for cosmics only. |
- Returns
Definition at line 28 of file TrackBuilder.cc.
35 B2DEBUG(100, trackReps.size() <<
" track representations available.");
38 bool repAlreadySet =
false;
39 unsigned int repIDPlusOne = 0;
40 for (
const auto& trackRep : trackReps) {
46 B2DEBUG(100,
"Track fitted with hypothesis that is not a ChargedStable (PDG code = " << particleType.getPDGCode() <<
")");
52 B2DEBUG(100,
"The fit with the given track representation (" << std::abs(trackRep->getPDG()) <<
53 ") was not successful. Skipping ...");
57 if (not repAlreadySet) {
65 if (useClosestHitToIP) {
71 B2WARNING(exception.
what());
79 B2WARNING(
"Could not extrapolate the fit result for pdg " << particleType.getPDGCode() <<
80 " to the perigee point. Why, I don't know.");
86 TVector3
poca(0., 0., 0.);
87 TVector3 dirInPoca(0., 0., 0.);
89 extrapolatedMSoP.getPosMomCov(poca, dirInPoca, cov);
90 B2DEBUG(149,
"Point of closest approach: " <<
poca.x() <<
" " <<
poca.y() <<
" " <<
poca.z());
91 B2DEBUG(149,
"Track direction in POCA: " << dirInPoca.x() <<
" " << dirInPoca.y() <<
" " << dirInPoca.z());
99 const TVector3& hitPosition = msop.getPos();
109 const auto newTrackFitResult = trackFitResults.appendNew(
110 poca, dirInPoca, cov, charge, particleType, pValue, Bz,
111 hitPatternCDCInitializer, hitPatternVXDInitializer, nDF
114 const int newTrackFitResultArrayIndex = newTrackFitResult->getArrayIndex();
115 newTrack.setTrackFitResultIndex(particleType, newTrackFitResultArrayIndex);
118 B2DEBUG(100,
"Number of fitted hypothesis = " << newTrack.getNumberOfFittedHypotheses());
119 if (newTrack.getNumberOfFittedHypotheses() > 0) {
120 Track* addedTrack = tracks.appendNew(newTrack);
123 const MCParticle* mcParticle = mcParticleWithWeight.first;
125 B2DEBUG(200,
"Relation to MCParticle set.");
126 addedTrack->
addRelationTo(mcParticle, mcParticleWithWeight.second);
128 B2DEBUG(200,
"Relation to MCParticle not set. No related MCParticle to RecoTrack.");
132 B2DEBUG(200,
"Relation to MCParticle not set. No related MCParticle to RecoTrack.");
The documentation for this class was generated from the following files:
double getCharge() const
Get the fitted charge.
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
std::string m_mcParticleColName
MCParticleColName (input, optional).
Exception class for error handling in GENFIT (provides storage for diagnostic information)
const genfit::FitStatus * getTrackFitStatus(const genfit::AbsTrackRep *representation=nullptr) const
Return the track fit status for the given representation or for the cardinal one. You are not allowed...
float getQualityIndicator() const
Get the quality index attached to this RecoTrack given by one of the reconstruction algorithms....
bool wasFitSuccessful(const genfit::AbsTrackRep *representation=nullptr) const
Returns true if the last fit with the given representation was successful.
#StateOnPlane with additional covariance matrix.
static genfit::Track & getGenfitTrack(RecoTrack &recoTrack)
Give access to the RecoTrack's genfit::Track.
const genfit::MeasuredStateOnPlane & getMeasuredStateOnPlaneFromFirstHit(const genfit::AbsTrackRep *representation=nullptr) const
Return genfit's MeasuredStateOnPlane for the first hit in a fit useful for extrapolation of measureme...
std::string m_trackFitResultColName
TrackFitResultColName (output).
TVector3 getFieldVal(const TVector3 &position)
This does NOT use the cache!
static const ParticleSet chargedStableSet
set of charged stable particles
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
const std::vector< genfit::AbsTrackRep * > & getRepresentations() const
Return a list of track representations. You are not allowed to modify or delete them!
TVector3 m_beamAxis
Extrapolation target, positive z direction.
static uint64_t getHitPatternCDCInitializer(const RecoTrack &recoTrack)
Get the HitPattern in the CDC.
virtual double getPVal() const
Get the p value of the fit.
std::pair< TO *, float > getRelatedToWithWeight(const std::string &name="", const std::string &namedRelation="") const
Get first related object & weight of relation pointing to an array.
std::string m_trackColName
TrackColName (output).
static uint32_t getHitPatternVXDInitializer(const RecoTrack &recoTrack)
Get the HitPattern in the VXD.
const genfit::MeasuredStateOnPlane & getMeasuredStateOnPlaneClosestTo(const TVector3 &closestPoint, const genfit::AbsTrackRep *representation=nullptr)
Return genfit's MasuredStateOnPlane, that is closest to the given point useful for extrapolation of m...
double getNdf() const
Get the degrees of freedom of the fit.
TVector3 m_beamSpot
Extrapolation target, origin.
The ParticleType class for identifying different particle types.
Class that bundles various TrackFitResults.
A Class to store the Monte Carlo particle information.
Accessor to arrays stored in the data store.
virtual const char * what() const noexcept
Standard error message handling for exceptions. use like "std::cerr << e.what();".
static FieldManager * getInstance()
Get singleton instance.