Belle II Software  release-05-02-19
TrackFitter.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFitting/measurementCreator/adder/MeasurementAdder.h>
13 #include <framework/gearbox/Const.h>
14 
15 #include <TError.h>
16 
17 #include <string>
18 #include <memory>
19 
20 namespace genfit {
21  class AbsFitter;
22  class AbsTrackRep;
23 }
24 
25 namespace Belle2 {
31  class RecoTrack;
32 
116  class TrackFitter {
117  public:
119  static constexpr double s_defaultDeltaPValue = 1.0;
121  static constexpr double s_defaultProbCut = 0.001;
123  static constexpr unsigned int s_defaultMaxFailedHits = 5;
124 
126  TrackFitter(const std::string& storeArrayNameOfPXDHits = "",
127  const std::string& storeArrayNameOfSVDHits = "",
128  const std::string& storeArrayNameOfCDCHits = "",
129  const std::string& storeArrayNameOfBKLMHits = "",
130  const std::string& storeArrayNameOfEKLMHits = "",
131  const bool initializeCDCTranslators = true):
132  m_measurementAdder(storeArrayNameOfPXDHits, storeArrayNameOfSVDHits, storeArrayNameOfCDCHits,
133  storeArrayNameOfBKLMHits, storeArrayNameOfEKLMHits, initializeCDCTranslators)
134  {
136  }
137 
139  static int createCorrectPDGCodeForChargedStable(const Const::ChargedStable& particleType, const RecoTrack& recoTrack);
140 
147  void resetFitter(const std::shared_ptr<genfit::AbsFitter>& fitter);
148 
154 
168  bool fit(RecoTrack& recoTrack, genfit::AbsTrackRep* trackRepresentation) const;
169 
183  bool fit(RecoTrack& recoTrack, const Const::ChargedStable& particleType) const;
184 
188  bool fit(RecoTrack& recoTrack, const int pdgCode) const;
189 
203  bool fit(RecoTrack& recoTrack) const;
204 
210  {
212  }
213 
225  const std::vector<std::shared_ptr<PXDBaseMeasurementCreator>>& pxdMeasurementCreators,
226  const std::vector<std::shared_ptr<SVDBaseMeasurementCreator>>& svdMeasurementCreators,
227  const std::vector<std::shared_ptr<CDCBaseMeasurementCreator>>& cdcMeasurementCreators,
228  const std::vector<std::shared_ptr<BKLMBaseMeasurementCreator>>& bklmMeasurementCreators,
229  const std::vector<std::shared_ptr<EKLMBaseMeasurementCreator>>& eklmMeasurementCreators,
230  const std::vector<std::shared_ptr<BaseMeasurementCreator>>& additionalMeasurementCreators)
231  {
232  m_measurementAdder.resetMeasurementCreators(pxdMeasurementCreators,
233  svdMeasurementCreators,
234  cdcMeasurementCreators,
235  bklmMeasurementCreators,
236  eklmMeasurementCreators,
237  additionalMeasurementCreators);
238  }
239 
258  const std::map<std::string, std::map<std::string, std::string>>& pxdMeasurementCreators,
259  const std::map<std::string, std::map<std::string, std::string>>& svdMeasurementCreators,
260  const std::map<std::string, std::map<std::string, std::string>>& cdcMeasurementCreators,
261  const std::map<std::string, std::map<std::string, std::string>>& bklmMeasurementCreators,
262  const std::map<std::string, std::map<std::string, std::string>>& eklmMeasurementCreators,
263  const std::map<std::string, std::map<std::string, std::string>>& additionalMeasurementCreators)
264  {
266  svdMeasurementCreators,
267  cdcMeasurementCreators,
268  bklmMeasurementCreators,
269  eklmMeasurementCreators,
270  additionalMeasurementCreators);
271  }
272 
274  void setgErrorIgnoreLevel(Int_t errorIgnoreLevel) { m_gErrorIgnoreLevel = errorIgnoreLevel; }
277 
278  private:
280  std::shared_ptr<genfit::AbsFitter> m_fitter;
282  bool m_skipDirtyCheck = false;
283 
286 
288  Int_t m_gErrorIgnoreLevel = kFatal;
289 
299  bool fitWithoutCheck(RecoTrack& recoTrack, const genfit::AbsTrackRep& trackRepresentation) const;
300  };
302 }
303 
Belle2::TrackFitter::m_fitter
std::shared_ptr< genfit::AbsFitter > m_fitter
The internal storage of the used fitting algorithms.
Definition: TrackFitter.h:280
Belle2::TrackFitter::resetFitterToDefaultSettings
void resetFitterToDefaultSettings()
Use the default settings of the fitter to fit the reco tracks.
Definition: TrackFitter.cc:139
Belle2::TrackFitter::fit
bool fit(RecoTrack &recoTrack, genfit::AbsTrackRep *trackRepresentation) const
Fit a reco track with a given non-default track representation.
Definition: TrackFitter.cc:109
Belle2::TrackFitter::m_measurementAdder
MeasurementAdder m_measurementAdder
The measurement adder algorithm class.
Definition: TrackFitter.h:285
Belle2::MeasurementAdder::resetMeasurementCreatorsToDefaultSettings
void resetMeasurementCreatorsToDefaultSettings()
Reset the internal measurement creator storage to the default settings.
Definition: MeasurementAdder.cc:93
genfit
Defines for I/O streams used for error and debug printing.
Definition: AlignablePXDRecoHit.h:19
genfit::AbsTrackRep
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
Belle2::TrackFitter::createCorrectPDGCodeForChargedStable
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:26
Belle2::TrackFitter::s_defaultMaxFailedHits
static constexpr unsigned int s_defaultMaxFailedHits
Default maxFailedHits for the default DAF fitter.
Definition: TrackFitter.h:123
Belle2::TrackFitter::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)
If you want to use non-default settings for the store arrays, you can create your own instances of th...
Definition: TrackFitter.h:224
Belle2::TrackFitter::TrackFitter
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:126
Belle2::MeasurementAdder::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)
If you want to use non-default settings for the store arrays, you can create your own instances of th...
Definition: MeasurementAdder.cc:123
Belle2::MeasurementAdder::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)
If you want to use non-default settings for the store arrays, you can create your own instances of th...
Definition: MeasurementAdder.cc:105
Belle2::TrackFitter
Algorithm class to handle the fitting of RecoTrack objects.
Definition: TrackFitter.h:116
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2::TrackFitter::fitWithoutCheck
bool fitWithoutCheck(RecoTrack &recoTrack, const genfit::AbsTrackRep &trackRepresentation) const
Helper function to do the fit.
Definition: TrackFitter.cc:73
Belle2::TrackFitter::getgErrorIgnoreLevel
Int_t getgErrorIgnoreLevel()
Return the currently set gErrorIgnoreLevel for the fitter.
Definition: TrackFitter.h:276
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFitter::s_defaultProbCut
static constexpr double s_defaultProbCut
Default probCut for the default DAF fitter.
Definition: TrackFitter.h:121
Belle2::MeasurementAdder
Algorithm class to translate the added detector hits (e.g.
Definition: MeasurementAdder.h:78
Belle2::TrackFitter::m_skipDirtyCheck
bool m_skipDirtyCheck
Flag to skip the dirty flag check which is needed when using non-default fitters.
Definition: TrackFitter.h:282
Belle2::TrackFitter::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)
If you want to use non-default settings for the store arrays, you can create your own instances of th...
Definition: TrackFitter.h:257
Belle2::Const::ChargedStable
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:465
Belle2::TrackFitter::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.
Definition: TrackFitter.cc:150
Belle2::TrackFitter::resetMeasurementCreatorsToDefaultSettings
void resetMeasurementCreatorsToDefaultSettings()
Reset the internal measurement creator storage to the default settings.
Definition: TrackFitter.h:209
Belle2::TrackFitter::setgErrorIgnoreLevel
void setgErrorIgnoreLevel(Int_t errorIgnoreLevel)
Set the gErrorIgnoreLevel for the fitter.
Definition: TrackFitter.h:274
Belle2::TrackFitter::m_gErrorIgnoreLevel
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:288
Belle2::TrackFitter::s_defaultDeltaPValue
static constexpr double s_defaultDeltaPValue
Default deltaPValue for the default DAF fitter.
Definition: TrackFitter.h:119