Belle II Software  release-08-01-10
TrackFitter Class Reference

Algorithm class to handle the fitting of RecoTrack objects. More...

#include <TrackFitter.h>

Collaboration diagram for TrackFitter:

Public Member Functions

 TrackFitter (const std::string &storeArrayNameOfPXDHits="", const std::string &storeArrayNameOfSVDHits="", const std::string &storeArrayNameOfCDCHits="", const std::string &storeArrayNameOfBKLMHits="", const std::string &storeArrayNameOfEKLMHits="", const bool initializeCDCTranslators=true)
 Create a new fitter instance.
 
void resetFitter (const std::shared_ptr< genfit::AbsFitter > &fitter)
 Set the internal storage of the fitter to a provided one, if you want to use non-default settings. More...
 
void resetFitterToDefaultSettings ()
 Use the default settings of the fitter to fit the reco tracks. More...
 
bool fit (RecoTrack &recoTrack, genfit::AbsTrackRep *trackRepresentation) const
 Fit a reco track with a given non-default track representation. More...
 
bool fit (RecoTrack &recoTrack, const Const::ChargedStable &particleType) const
 Fit a reco track with the given particle hypothesis, or with pion as default. More...
 
bool fit (RecoTrack &recoTrack, const int pdgCode) const
 Same as above, but hypothesis set by pdg code.
 
bool fit (RecoTrack &recoTrack) const
 Fit a reco track with the already present cardinal representation or with pion as default. More...
 
void resetMeasurementCreatorsToDefaultSettings ()
 Reset the internal measurement creator storage to the default settings. More...
 
void resetMeasurementCreators (const std::vector< std::shared_ptr< PXDBaseMeasurementCreator >> &pxdMeasurementCreators, const std::vector< std::shared_ptr< SVDBaseMeasurementCreator >> &svdMeasurementCreators, const std::vector< std::shared_ptr< CDCBaseMeasurementCreator >> &cdcMeasurementCreators, const std::vector< std::shared_ptr< BKLMBaseMeasurementCreator >> &bklmMeasurementCreators, const std::vector< std::shared_ptr< EKLMBaseMeasurementCreator >> &eklmMeasurementCreators, const std::vector< std::shared_ptr< BaseMeasurementCreator >> &additionalMeasurementCreators)
 If you want to use non-default settings for the store arrays, you can create your own instances of the measurement creators for the different detectors and use them here. More...
 
void resetMeasurementCreatorsUsingFactories (const std::map< std::string, std::map< std::string, std::string >> &pxdMeasurementCreators, const std::map< std::string, std::map< std::string, std::string >> &svdMeasurementCreators, const std::map< std::string, std::map< std::string, std::string >> &cdcMeasurementCreators, const std::map< std::string, std::map< std::string, std::string >> &bklmMeasurementCreators, const std::map< std::string, std::map< std::string, std::string >> &eklmMeasurementCreators, const std::map< std::string, std::map< std::string, std::string >> &additionalMeasurementCreators)
 If you want to use non-default settings for the store arrays, you can create your own instances of the measurement creators for the different detectors and use them here. More...
 
void setgErrorIgnoreLevel (Int_t errorIgnoreLevel)
 Set the gErrorIgnoreLevel for the fitter.
 
Int_t getgErrorIgnoreLevel ()
 Return the currently set gErrorIgnoreLevel for the fitter.
 

Static Public Member Functions

static int createCorrectPDGCodeForChargedStable (const Const::ChargedStable &particleType, const RecoTrack &recoTrack)
 Helper function to multiply the PDG code of a charged stable with the charge of the reco track (if needed)
 

Static Public Attributes

static constexpr double s_defaultDeltaPValue = 1.0
 Default deltaPValue for the default DAF fitter.
 
static constexpr double s_defaultProbCut = 0.001
 Default probCut for the default DAF fitter.
 
static constexpr unsigned int s_defaultMaxFailedHits = 5
 Default maxFailedHits for the default DAF fitter.
 

Private Member Functions

bool fitWithoutCheck (RecoTrack &recoTrack, const genfit::AbsTrackRep &trackRepresentation) const
 Helper function to do the fit. More...
 

Private Attributes

std::shared_ptr< genfit::AbsFitterm_fitter
 The internal storage of the used fitting algorithms.
 
bool m_skipDirtyCheck = false
 Flag to skip the dirty flag check which is needed when using non-default fitters.
 
MeasurementAdder m_measurementAdder
 The measurement adder algorithm class.
 
Int_t m_gErrorIgnoreLevel = kFatal
 Control the output level of the ROOT functions used by the GenFit fitter. Default is increased from kError to kFatal;.
 
DBObjPtr< DAFparametersm_DAFparameters
 DAF parameters Database OjbPtr.
 

Detailed Description

Algorithm class to handle the fitting of RecoTrack objects.

The fitting of reco tracks implies non-trivial synchronisation, so you should only use this class for fitting RecoTrack instances.

After having created a RecoTrack and added hits to it, you can fit the RecoTrack.

RecoTrack recoTrack; ... add CDC hits etc. ... ... set seeds etc. ...

The standard case

Typical use case if you do not use the fitter modules but want to fit in your own module.

TrackFitter trackFitter; trackFitter.fit(recoTrack);

-> Create measurements if hit content has changed (dirty flag) -> Fit (again) if (a) no fit result present or (b) hit content has changed (dirty flag)

Non-default fitter

May be used if you know that the default fitting algorithm is not suited for your use case. Please be aware, that the following modules may use your fit results, if the hit content is not changed, although they may expect a "default"-fit. Because the currently present fit results were probably created with the default fitter, the fit is executed always (and not only when the hit content has changed).

ATTENTION: If the hit content did not change (the dirty flag is not set), the track will not be refitted later! Future modules may expect a default fit!

TrackFitter trackFitter; trackFitter.resetFitter( ... ); trackFitter.fit(recoTrack);

-> Create measurements if hit content has changed (dirty flag) -> Always fitted

Non-default track representations

Useful if you know you have an electron/etc. instead of a pion. Please make sure that the cardinal representation points to the correct representation - especially when you try out non-RKTrackRep objects. ATTENTION: Once a track representation is added to the track, it will always be also used when fitting! If you do not want this, remove this track representation again.

TrackFitter trackFitter; // Maybe set other fit algorithm. trackFitter.fit(recoTrack, particleType); or trackFitter.fit(recoTrack, trackRep);

-> Create measurements if hit content has changed (dirty flag) -> Fit (again) if (a) added track representation is new or (b) hit content has changed (dirty flag) or (c) you use a non-default fitter.

Non-default measurements

This is only needed in very rare cases, when you want to transform the added hits into measurement points for your special use case e.g. alignment or VXD-dEdX-momentum estimation.

ATTENTION: Again, please be aware that future modules may expect fit results from a default fit!

TrackFitter trackFitter; // Possibility 1 trackFitter.resetMeasurementCreators({ cdcMeasurementCreatorSharedPointer1, cdcMeasurementCreatorSharedPointer2, ...}, { svdMeasurementCreatorSharedPointer1, ...}, { pxdMeasurementCreatorSharedPointer1, ...}, { additionalMeasurementCreatorSharedPointer1, ...}) // Possibility 2 measurementAdder.resetMeasurementCreatorsUsingFactories( mapOfCreatorNamesAndSettingsForCDC, mapOfCreatorNamesAndSettingsForSVD, mapOfCreatorNamesAndSettingsForPXD, mapOfCreatorNamesAndSettingsForAdditionalMeasurements )

// Maybe set other fit algorithm. trackFitter.fit(recoTrack); // or maybe use a different track representation/particle hypothesis.

-> Always recreate all measurements (not only when hit content has changed). -> Always refit (not only when using non default parameters or hit content has changed or track representation is new).

Because the different cases are rather complicated, there is a flow chart available. TODO: Create flow chart.

Definition at line 116 of file TrackFitter.h.

Member Function Documentation

◆ fit() [1/3]

bool fit ( RecoTrack recoTrack) const

Fit a reco track with the already present cardinal representation or with pion as default.

If the cardinal particle hypothesis is already in the track representation list and the hit content did not change (the dirty flag is set to false), the track is not refitted. If you still want to refit the track, set the dirty flag.

Internally, a new track representation with the given particle hypothesis is created and added to the reco track, if not already present. For this, a RKTrackRep is used as a base class. The PDG-code-sign is deduced from the reco track charge.

Return bool if the track was successful.

Definition at line 45 of file TrackFitter.cc.

46 {
47  if (not recoTrack.getRepresentations().empty() and recoTrack.getCardinalRepresentation()) {
48  return fit(recoTrack, recoTrack.getCardinalRepresentation());
49  } else {
50  return fit(recoTrack, Const::pion);
51  }
52 }
static const ChargedStable pion
charged pion particle
Definition: Const.h:652
const std::vector< genfit::AbsTrackRep * > & getRepresentations() const
Return a list of track representations. You are not allowed to modify or delete them!
Definition: RecoTrack.h:638
genfit::AbsTrackRep * getCardinalRepresentation() const
Get a pointer to the cardinal track representation. You are not allowed to modify or delete it!
Definition: RecoTrack.h:631
bool fit(RecoTrack &recoTrack, genfit::AbsTrackRep *trackRepresentation) const
Fit a reco track with a given non-default track representation.
Definition: TrackFitter.cc:107

◆ fit() [2/3]

bool fit ( RecoTrack recoTrack,
const Const::ChargedStable particleType 
) const

Fit a reco track with the given particle hypothesis, or with pion as default.

If the particle hypothesis is already in the track representation list and the hit content did not change (the dirty flag is set to false), the track is not refitted. If you still want to refit the track, set the dirty flag.

Internally, a new track representation with the given particle hypothesis is created and added to the reco track, if not already present. For this, a RKTrackRep is used as a base class. The PDG-code-sign is deduced from the reco track charge.

Return bool if the track was successful.

Definition at line 54 of file TrackFitter.cc.

◆ fit() [3/3]

bool fit ( RecoTrack recoTrack,
genfit::AbsTrackRep trackRepresentation 
) const

Fit a reco track with a given non-default track representation.

You have to use a pointer to a track representation already in the reco track (use recoTrack.getRepresentations() to get a list of pointers).

If hit content did not change (indicated by the dirty flag of the reco track), the track will not be refitted.

This fit function is only to be used for non-standard expert use. For the typical use case, please use the other fit function.

Return bool if the track was successful.

Definition at line 107 of file TrackFitter.cc.

◆ fitWithoutCheck()

bool fitWithoutCheck ( RecoTrack recoTrack,
const genfit::AbsTrackRep trackRepresentation 
) const
private

Helper function to do the fit.

This function will neither check the dirty flag nor if the track representation is added to the trackrep list of the reco track. This should only be called internally.

In every fit step, all track representations are fitted with genfit. The given track representation is only used for calculating the time seed for the fit. For this, the track representation needs to have the correct PDG code set (indicating the correct particle AND the correct charge).

Definition at line 71 of file TrackFitter.cc.

◆ resetFitter()

void resetFitter ( const std::shared_ptr< genfit::AbsFitter > &  fitter)

Set the internal storage of the fitter to a provided one, if you want to use non-default settings.

Whenever you call this function, all tracks will be automatically refitted, although they might be already fitted (because you use non-default parameters, so we assume you want other fit results).

Definition at line 156 of file TrackFitter.cc.

◆ resetFitterToDefaultSettings()

void resetFitterToDefaultSettings ( )

Use the default settings of the fitter to fit the reco tracks.

This method is called on construction automatically.

Definition at line 137 of file TrackFitter.cc.

◆ resetMeasurementCreators()

void resetMeasurementCreators ( const std::vector< std::shared_ptr< PXDBaseMeasurementCreator >> &  pxdMeasurementCreators,
const std::vector< std::shared_ptr< SVDBaseMeasurementCreator >> &  svdMeasurementCreators,
const std::vector< std::shared_ptr< CDCBaseMeasurementCreator >> &  cdcMeasurementCreators,
const std::vector< std::shared_ptr< BKLMBaseMeasurementCreator >> &  bklmMeasurementCreators,
const std::vector< std::shared_ptr< EKLMBaseMeasurementCreator >> &  eklmMeasurementCreators,
const std::vector< std::shared_ptr< BaseMeasurementCreator >> &  additionalMeasurementCreators 
)
inline

If you want to use non-default settings for the store arrays, you can create your own instances of the measurement creators for the different detectors and use them here.

For this method, you have to create the measurement creators by yourself.

It is assumed, that you only do this for non-default settings. This is why all measurement points will be recreated (independent on the dirty flag) and the track must be refitted afterwards.

Definition at line 224 of file TrackFitter.h.

231  {
232  m_measurementAdder.resetMeasurementCreators(pxdMeasurementCreators,
233  svdMeasurementCreators,
234  cdcMeasurementCreators,
235  bklmMeasurementCreators,
236  eklmMeasurementCreators,
237  additionalMeasurementCreators);
238  }
void resetMeasurementCreators(const std::vector< std::shared_ptr< PXDBaseMeasurementCreator >> &pxdMeasurementCreators, const std::vector< std::shared_ptr< SVDBaseMeasurementCreator >> &svdMeasurementCreators, const std::vector< std::shared_ptr< CDCBaseMeasurementCreator >> &cdcMeasurementCreators, const std::vector< std::shared_ptr< BKLMBaseMeasurementCreator >> &bklmMeasurementCreators, const std::vector< std::shared_ptr< EKLMBaseMeasurementCreator >> &eklmMeasurementCreators, const std::vector< std::shared_ptr< BaseMeasurementCreator >> &additionalMeasurementCreators)
If you want to use non-default settings for the store arrays, you can create your own instances of th...
MeasurementAdder m_measurementAdder
The measurement adder algorithm class.
Definition: TrackFitter.h:285

◆ resetMeasurementCreatorsToDefaultSettings()

void resetMeasurementCreatorsToDefaultSettings ( )
inline

Reset the internal measurement creator storage to the default settings.

The measurements will not be recreated if the dirty flag is not set (the hit content did not change).

Definition at line 209 of file TrackFitter.h.

◆ resetMeasurementCreatorsUsingFactories()

void resetMeasurementCreatorsUsingFactories ( const std::map< std::string, std::map< std::string, std::string >> &  pxdMeasurementCreators,
const std::map< std::string, std::map< std::string, std::string >> &  svdMeasurementCreators,
const std::map< std::string, std::map< std::string, std::string >> &  cdcMeasurementCreators,
const std::map< std::string, std::map< std::string, std::string >> &  bklmMeasurementCreators,
const std::map< std::string, std::map< std::string, std::string >> &  eklmMeasurementCreators,
const std::map< std::string, std::map< std::string, std::string >> &  additionalMeasurementCreators 
)
inline

If you want to use non-default settings for the store arrays, you can create your own instances of the measurement creators for the different detectors and use them here.

In this method, the measurement creators are created by MeasurementCreatorFactories. For this, you have to give a map in the form { "creatorName" : { "parameterName1": parameterValue1, "parameterName2": parameterValue2, ... }, "otherCreatorName" : { "otherParameterName1": otherParameterValue1, ... }, ... } for each detector and for additional measurements. See the MeasurementCreatorFactories for more details.

It is assumed, that you only do this for non-default settings. This is why all measurement points will be recreated (independent on the dirty flag) and the track must be refitted afterwards.

Definition at line 257 of file TrackFitter.h.


The documentation for this class was generated from the following files: