 |
Belle II Software
release-05-02-19
|
1 #include <tracking/trackFitting/trackBuilder/factories/TrackBuilder.h>
4 #include <framework/datastore/StoreArray.h>
5 #include <mdst/dataobjects/MCParticle.h>
6 #include <mdst/dataobjects/HitPatternVXD.h>
7 #include <mdst/dataobjects/HitPatternCDC.h>
8 #include <mdst/dataobjects/Track.h>
9 #include <mdst/dataobjects/TrackFitResult.h>
10 #include <cdc/dataobjects/CDCRecoHit.h>
11 #include <pxd/reconstruction/PXDRecoHit.h>
12 #include <svd/reconstruction/SVDRecoHit.h>
13 #include <svd/reconstruction/SVDRecoHit2D.h>
14 #include <tracking/dataobjects/RecoTrack.h>
17 #include <TMatrixDSym.h>
19 #include <genfit/FitStatus.h>
20 #include <genfit/KalmanFitterInfo.h>
21 #include <genfit/Track.h>
22 #include <genfit/TrackPoint.h>
23 #include <genfit/MeasuredStateOnPlane.h>
24 #include <genfit/FieldManager.h>
29 const bool useClosestHitToIP,
const bool useBFieldAtHit)
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();
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.");
143 int nNotFittedVXDhits = 0;
145 for (
const auto& trackPoint : hitPointsWithMeasurements) {
147 for (
size_t measurementId = 0; measurementId < trackPoint->getNumRawMeasurements(); measurementId++) {
153 const double weight = kalmanInfo->
getWeights().at(measurementId);
164 const int currentHits = hitPatternVXD.
getPXDLayer(layerNumber, HitPatternVXD::PXDMode::normal);
165 hitPatternVXD.
setPXDLayer(layerNumber, currentHits + 1, HitPatternVXD::PXDMode::normal);
172 const auto& currentHits = hitPatternVXD.
getSVDLayer(layerNumber);
173 hitPatternVXD.
setSVDLayer(layerNumber, currentHits.first + 1, currentHits.second + 1);
176 const auto& currentHits = hitPatternVXD.
getSVDLayer(layerNumber);
179 hitPatternVXD.
setSVDLayer(layerNumber, currentHits.first + 1, currentHits.second);
181 hitPatternVXD.
setSVDLayer(layerNumber, currentHits.first , currentHits.second + 1);
187 if (nNotFittedVXDhits > 0) {
188 B2DEBUG(100,
" No KalmanFitterInfo associated to some TrackPoints with VXD hits, not filling the HitPatternVXD");
189 B2DEBUG(100, nNotFittedVXDhits <<
" had no FitterInfo");
200 int nNotFittedCDChits = 0;
204 for (
const auto& trackPoint : hitPointsWithMeasurements) {
206 for (
size_t measurementId = 0; measurementId < trackPoint->getNumRawMeasurements(); measurementId++) {
212 const double weight = kalmanInfo->
getWeights().at(measurementId);
230 if (nNotFittedCDChits > 0) {
231 B2DEBUG(100,
" No KalmanFitterInfo associated to some TrackPoints with CDC hits, not filling the HitPatternCDC");
232 B2DEBUG(100, nNotFittedCDChits <<
" out of " << nCDChits <<
" had no FitterInfo");
double getCharge() const
Get the fitted charge.
T * appendNew()
Construct a new T object at the end of the array.
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...
Class to identify a wire inside the CDC.
SVDRecoHit - an extended form of SVDHit containing geometry information.
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.
unsigned int getNumberOfFittedHypotheses() const
Returns the number of fitted hypothesis which are stored in this track.
#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).
int getPDGCode() const
PDG code.
const std::vector< genfit::AbsTrackRep * > & getRepresentations() const
Return a list of track representations. You are not allowed to modify or delete them!
PXDRecoHit - an extended form of PXDCluster containing geometry information.
This class is used to transfer CDC information to the track fit.
const std::vector< genfit::TrackPoint * > & getHitPointsWithMeasurement() const
Return a list of measurements and track points, which can be used e.g. to extrapolate....
TVector3 m_beamAxis
Extrapolation target, positive z direction.
Contains the measurement and covariance in raw detector coordinates.
This is the Reconstruction Event-Data Model Track.
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< const unsigned short, const unsigned short > getSVDLayer(const unsigned short layerId) const
Get the number of hits in a specific layer of the SVD.
WireID getWireID() const
Getter for WireID object.
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.
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
VxdID getSensorID() const
Get the compact ID.
void setTrackFitResultIndex(const Const::ChargedStable &chargedStable, short index)
Set an index (for positive values) or unavailability-code (with negative values) for a specific mass ...
Abstract base class for different kinds of events.
void setPXDLayer(const unsigned short layerId, unsigned short nHits, const PXDMode &mode=PXDMode::normal)
Set the number of hits in a specific layer of the PXD.
void setNHits(unsigned short nHits)
Sets the 8 MSBs to the total number of hits in the CDC.
bool isU() const
Is the coordinate u or v?
void setSVDLayer(const unsigned short layerId, unsigned short uHits, unsigned short vHits)
Set the number of hits in a specific layer of the SVD.
std::string m_trackColName
TrackColName (output).
static uint32_t getHitPatternVXDInitializer(const RecoTrack &recoTrack)
Get the HitPattern in the VXD.
unsigned short getPXDLayer(const unsigned short layerId, const PXDMode &mode=PXDMode::normal) const
Get the number of hits in a specific layer of the PXD.
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...
VxdID getSensorID() const
Get the compact ID.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
double getNdf() const
Get the degrees of freedom of the fit.
SVDRecoHit - an extended form of SVDHit containing geometry information.
void setLayer(const unsigned short layer)
Set bit corresponding to layer to true.
TVector3 m_beamSpot
Extrapolation target, origin.
The ParticleType class for identifying different particle types.
ULong64_t getInteger() const
Getter for underlying integer type.
Class that bundles various TrackFitResults.
A Class to store the Monte Carlo particle information.
std::vector< double > getWeights() const
Get weights of measurements.
Accessor to arrays stored in the data store.
baseType getLayerNumber() const
Get the layer id.
virtual const char * what() const noexcept
Standard error message handling for exceptions. use like "std::cerr << e.what();".
static FieldManager * getInstance()
Get singleton instance.
unsigned short getICLayer() const
Getter for continuous layer numbering.
unsigned int getInteger() const
Getter for the underlying integer.
VxdID getSensorID() const
Get the compact ID.
bool storeTrackFromRecoTrack(RecoTrack &recoTrack, const bool useClosestHitToIP=false, const bool useBFieldAtHit=false)
Stores a Belle2 Track from a Reco Track.
Hit pattern of the VXD within a track.
Hit pattern of CDC hits within a track.