Belle II Software  release-06-01-15
TrackFitter.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #pragma once
9 
10 #include <tracking/trackFitting/measurementCreator/adder/MeasurementAdder.h>
11 #include <framework/gearbox/Const.h>
12 
13 #include <TError.h>
14 
15 #include <string>
16 #include <memory>
17 
18 namespace genfit {
19  class AbsFitter;
20  class AbsTrackRep;
21 }
22 
23 namespace Belle2 {
29  class RecoTrack;
30 
114  class TrackFitter {
115  public:
117  static constexpr double s_defaultDeltaPValue = 1.0;
119  static constexpr double s_defaultProbCut = 0.001;
121  static constexpr unsigned int s_defaultMaxFailedHits = 5;
122 
124  TrackFitter(const std::string& storeArrayNameOfPXDHits = "",
125  const std::string& storeArrayNameOfSVDHits = "",
126  const std::string& storeArrayNameOfCDCHits = "",
127  const std::string& storeArrayNameOfBKLMHits = "",
128  const std::string& storeArrayNameOfEKLMHits = "",
129  const bool initializeCDCTranslators = true):
130  m_measurementAdder(storeArrayNameOfPXDHits, storeArrayNameOfSVDHits, storeArrayNameOfCDCHits,
131  storeArrayNameOfBKLMHits, storeArrayNameOfEKLMHits, initializeCDCTranslators)
132  {
134  }
135 
137  static int createCorrectPDGCodeForChargedStable(const Const::ChargedStable& particleType, const RecoTrack& recoTrack);
138 
145  void resetFitter(const std::shared_ptr<genfit::AbsFitter>& fitter);
146 
152 
166  bool fit(RecoTrack& recoTrack, genfit::AbsTrackRep* trackRepresentation) const;
167 
181  bool fit(RecoTrack& recoTrack, const Const::ChargedStable& particleType) const;
182 
186  bool fit(RecoTrack& recoTrack, const int pdgCode) const;
187 
201  bool fit(RecoTrack& recoTrack) const;
202 
208  {
210  }
211 
223  const std::vector<std::shared_ptr<PXDBaseMeasurementCreator>>& pxdMeasurementCreators,
224  const std::vector<std::shared_ptr<SVDBaseMeasurementCreator>>& svdMeasurementCreators,
225  const std::vector<std::shared_ptr<CDCBaseMeasurementCreator>>& cdcMeasurementCreators,
226  const std::vector<std::shared_ptr<BKLMBaseMeasurementCreator>>& bklmMeasurementCreators,
227  const std::vector<std::shared_ptr<EKLMBaseMeasurementCreator>>& eklmMeasurementCreators,
228  const std::vector<std::shared_ptr<BaseMeasurementCreator>>& additionalMeasurementCreators)
229  {
230  m_measurementAdder.resetMeasurementCreators(pxdMeasurementCreators,
231  svdMeasurementCreators,
232  cdcMeasurementCreators,
233  bklmMeasurementCreators,
234  eklmMeasurementCreators,
235  additionalMeasurementCreators);
236  }
237 
256  const std::map<std::string, std::map<std::string, std::string>>& pxdMeasurementCreators,
257  const std::map<std::string, std::map<std::string, std::string>>& svdMeasurementCreators,
258  const std::map<std::string, std::map<std::string, std::string>>& cdcMeasurementCreators,
259  const std::map<std::string, std::map<std::string, std::string>>& bklmMeasurementCreators,
260  const std::map<std::string, std::map<std::string, std::string>>& eklmMeasurementCreators,
261  const std::map<std::string, std::map<std::string, std::string>>& additionalMeasurementCreators)
262  {
264  svdMeasurementCreators,
265  cdcMeasurementCreators,
266  bklmMeasurementCreators,
267  eklmMeasurementCreators,
268  additionalMeasurementCreators);
269  }
270 
272  void setgErrorIgnoreLevel(Int_t errorIgnoreLevel) { m_gErrorIgnoreLevel = errorIgnoreLevel; }
275 
276  private:
278  std::shared_ptr<genfit::AbsFitter> m_fitter;
280  bool m_skipDirtyCheck = false;
281 
284 
286  Int_t m_gErrorIgnoreLevel = kFatal;
287 
297  bool fitWithoutCheck(RecoTrack& recoTrack, const genfit::AbsTrackRep& trackRepresentation) const;
298  };
300 }
301 
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:470
Algorithm class to translate the added detector hits (e.g.
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 th...
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...
void resetMeasurementCreatorsToDefaultSettings()
Reset the internal measurement creator storage to the default settings.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:76
Algorithm class to handle the fitting of RecoTrack objects.
Definition: TrackFitter.h:114
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.
Definition: TrackFitter.h:124
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 ne...
Definition: TrackFitter.cc:24
static constexpr double s_defaultProbCut
Default probCut for the default DAF fitter.
Definition: TrackFitter.h:119
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 th...
Definition: TrackFitter.h:255
void setgErrorIgnoreLevel(Int_t errorIgnoreLevel)
Set the gErrorIgnoreLevel for the fitter.
Definition: TrackFitter.h:272
Int_t getgErrorIgnoreLevel()
Return the currently set gErrorIgnoreLevel for the fitter.
Definition: TrackFitter.h:274
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...
Definition: TrackFitter.h:222
bool fit(RecoTrack &recoTrack, genfit::AbsTrackRep *trackRepresentation) const
Fit a reco track with a given non-default track representation.
Definition: TrackFitter.cc:107
void resetMeasurementCreatorsToDefaultSettings()
Reset the internal measurement creator storage to the default settings.
Definition: TrackFitter.h:207
static constexpr double s_defaultDeltaPValue
Default deltaPValue for the default DAF fitter.
Definition: TrackFitter.h:117
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.
Definition: TrackFitter.cc:148
MeasurementAdder m_measurementAdder
The measurement adder algorithm class.
Definition: TrackFitter.h:283
void resetFitterToDefaultSettings()
Use the default settings of the fitter to fit the reco tracks.
Definition: TrackFitter.cc:137
Int_t m_gErrorIgnoreLevel
Control the output level of the ROOT functions used by the GenFit fitter. Default is increased from k...
Definition: TrackFitter.h:286
static constexpr unsigned int s_defaultMaxFailedHits
Default maxFailedHits for the default DAF fitter.
Definition: TrackFitter.h:121
std::shared_ptr< genfit::AbsFitter > m_fitter
The internal storage of the used fitting algorithms.
Definition: TrackFitter.h:278
bool m_skipDirtyCheck
Flag to skip the dirty flag check which is needed when using non-default fitters.
Definition: TrackFitter.h:280
bool fitWithoutCheck(RecoTrack &recoTrack, const genfit::AbsTrackRep &trackRepresentation) const
Helper function to do the fit.
Definition: TrackFitter.cc:71
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
Abstract base class for different kinds of events.
Defines for I/O streams used for error and debug printing.