Belle II Software development
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#include <framework/core/Environment.h>
13#include <tracking/dbobjects/DAFparameters.h>
14
15#include <TError.h>
16
17#include <string>
18#include <memory>
19
20namespace genfit {
21 class AbsFitter;
22 class AbsTrackRep;
23}
24
25namespace Belle2 {
31 class RecoTrack;
32
122 public:
124 static constexpr double s_defaultDeltaPValue = 1.0;
126 static constexpr double s_defaultProbCut = 0.001;
128 static constexpr unsigned int s_defaultMaxFailedHits = 5;
129
131 TrackFitter(const std::string& storeArrayNameOfPXDHits = "",
132 const std::string& storeArrayNameOfSVDHits = "",
133 const std::string& storeArrayNameOfCDCHits = "",
134 const std::string& storeArrayNameOfBKLMHits = "",
135 const std::string& storeArrayNameOfEKLMHits = "",
136 const bool initializeCDCTranslators = true):
137 m_measurementAdder(storeArrayNameOfPXDHits, storeArrayNameOfSVDHits, storeArrayNameOfCDCHits,
138 storeArrayNameOfBKLMHits, storeArrayNameOfEKLMHits, initializeCDCTranslators)
139 {
140 if (Environment::Instance().isCosmicRun()) {
141 // Resetting with parameters for cosmics data
143 } else {
144 // Resetting with parameters for beam data
146 }
147 }
148
150 static int createCorrectPDGCodeForChargedStable(const Const::ChargedStable& particleType, const RecoTrack& recoTrack);
151
158 void resetFitter(const std::shared_ptr<genfit::AbsFitter>& fitter);
159
166
172
180
197 bool fit(RecoTrack& recoTrack, genfit::AbsTrackRep* trackRepresentation, bool resortHits = false) const;
198
215 bool fit(RecoTrack& recoTrack, const Const::ChargedStable& particleType, bool resortHits = false) const;
216
220 bool fit(RecoTrack& recoTrack, const int pdgCode, bool resortHits = false) const;
221
238 bool fit(RecoTrack& recoTrack, bool resortHits = false) const;
239
245 {
247 }
248
260 const std::vector<std::shared_ptr<PXDBaseMeasurementCreator>>& pxdMeasurementCreators,
261 const std::vector<std::shared_ptr<SVDBaseMeasurementCreator>>& svdMeasurementCreators,
262 const std::vector<std::shared_ptr<CDCBaseMeasurementCreator>>& cdcMeasurementCreators,
263 const std::vector<std::shared_ptr<BKLMBaseMeasurementCreator>>& bklmMeasurementCreators,
264 const std::vector<std::shared_ptr<EKLMBaseMeasurementCreator>>& eklmMeasurementCreators,
265 const std::vector<std::shared_ptr<BaseMeasurementCreator>>& additionalMeasurementCreators)
266 {
267 m_measurementAdder.resetMeasurementCreators(pxdMeasurementCreators,
268 svdMeasurementCreators,
269 cdcMeasurementCreators,
270 bklmMeasurementCreators,
271 eklmMeasurementCreators,
272 additionalMeasurementCreators);
273 }
274
293 const std::map<std::string, std::map<std::string, std::string>>& pxdMeasurementCreators,
294 const std::map<std::string, std::map<std::string, std::string>>& svdMeasurementCreators,
295 const std::map<std::string, std::map<std::string, std::string>>& cdcMeasurementCreators,
296 const std::map<std::string, std::map<std::string, std::string>>& bklmMeasurementCreators,
297 const std::map<std::string, std::map<std::string, std::string>>& eklmMeasurementCreators,
298 const std::map<std::string, std::map<std::string, std::string>>& additionalMeasurementCreators)
299 {
301 svdMeasurementCreators,
302 cdcMeasurementCreators,
303 bklmMeasurementCreators,
304 eklmMeasurementCreators,
305 additionalMeasurementCreators);
306 }
307
309 void setgErrorIgnoreLevel(Int_t errorIgnoreLevel) { m_gErrorIgnoreLevel = errorIgnoreLevel; }
310
313
314 private:
316 std::shared_ptr<genfit::AbsFitter> m_fitter;
317
319 bool m_skipDirtyCheck = false;
320
323
325 Int_t m_gErrorIgnoreLevel = kFatal;
326
329
342 bool fitWithoutCheck(RecoTrack& recoTrack, const genfit::AbsTrackRep& trackRepresentation, bool resortHits = false) const;
343 };
345}
346
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:589
The payload containing the DAF parameters.
Definition: DAFparameters.h:21
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28
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:79
Algorithm class to handle the fitting of RecoTrack objects.
Definition: TrackFitter.h:121
DBObjPtr< DAFparameters > m_DAFparameters
DAF parameters Database OjbPtr.
Definition: TrackFitter.h:328
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:131
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:292
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
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:259
static constexpr double s_defaultProbCut
Default probCut for the default DAF fitter.
Definition: TrackFitter.h:126
void resetFitterToUserSettings(DAFparameters *DAFparams)
Use the user settings of the fitter to fit the reco tracks.
Definition: TrackFitter.cc:155
void setgErrorIgnoreLevel(Int_t errorIgnoreLevel)
Set the gErrorIgnoreLevel for the fitter.
Definition: TrackFitter.h:309
Int_t getgErrorIgnoreLevel()
Return the currently set gErrorIgnoreLevel for the fitter.
Definition: TrackFitter.h:312
void resetMeasurementCreatorsToDefaultSettings()
Reset the internal measurement creator storage to the default settings.
Definition: TrackFitter.h:244
bool fitWithoutCheck(RecoTrack &recoTrack, const genfit::AbsTrackRep &trackRepresentation, bool resortHits=false) const
Helper function to do the fit.
Definition: TrackFitter.cc:71
static constexpr double s_defaultDeltaPValue
Default deltaPValue for the default DAF fitter.
Definition: TrackFitter.h:124
void resetFitterToDBSettings()
Use the DB settings of the fitter to fit the reco tracks.
Definition: TrackFitter.cc:138
bool fit(RecoTrack &recoTrack, genfit::AbsTrackRep *trackRepresentation, bool resortHits=false) const
Fit a reco track with a given non-default track representation.
Definition: TrackFitter.cc:108
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:180
MeasurementAdder m_measurementAdder
The measurement adder algorithm class.
Definition: TrackFitter.h:322
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:325
static constexpr unsigned int s_defaultMaxFailedHits
Default maxFailedHits for the default DAF fitter.
Definition: TrackFitter.h:128
std::shared_ptr< genfit::AbsFitter > m_fitter
The internal storage of the used fitting algorithms.
Definition: TrackFitter.h:316
bool m_skipDirtyCheck
Flag to skip the dirty flag check which is needed when using non-default fitters.
Definition: TrackFitter.h:319
void resetFitterToCosmicsSettings()
Use the settings of the fitter to fit the reco tracks for cosmics data.
Definition: TrackFitter.cc:172
Abstract base class for different kinds of events.