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#include <tracking/dbobjects/DAFConfiguration.h>
15
16#include <TError.h>
17
18#include <string>
19#include <memory>
20
21namespace genfit {
22 class AbsFitter;
23 class AbsTrackRep;
24}
25
26namespace Belle2 {
31
32 class RecoTrack;
33
142 public:
144 static constexpr double s_defaultDeltaPValue = 1.0;
146 static constexpr double s_defaultProbCut = 0.001;
148 static constexpr unsigned int s_defaultMaxFailedHits = 5;
149
152 const std::string& storeArrayNameOfPXDHits = "",
153 const std::string& storeArrayNameOfSVDHits = "",
154 const std::string& storeArrayNameOfCDCHits = "",
155 const std::string& storeArrayNameOfBKLMHits = "",
156 const std::string& storeArrayNameOfEKLMHits = "",
157 const bool initializeCDCTranslators = true,
158 bool fromTrackCreator = false):
159 m_measurementAdder(storeArrayNameOfPXDHits, storeArrayNameOfSVDHits, storeArrayNameOfCDCHits,
160 storeArrayNameOfBKLMHits, storeArrayNameOfEKLMHits, initializeCDCTranslators, fromTrackCreator)
161 {
162 if (Environment::Instance().isCosmicRun()) {
163 // Resetting with parameters for cosmics data
165 } else {
166 // Resetting with parameters for beam data
167 resetFitterToDBSettings(trackFitType);
168 }
169 }
170
172 static int createCorrectPDGCodeForChargedStable(const Const::ChargedStable& particleType, const RecoTrack& recoTrack);
173
180 void resetFitter(const std::shared_ptr<genfit::AbsFitter>& fitter);
181
189
194 void resetFitterToUserSettings(const DAFParameters* DAFParams);
195
203
220 bool fit(RecoTrack& recoTrack, genfit::AbsTrackRep* trackRepresentation, bool resortHits = false) const;
221
238 bool fit(RecoTrack& recoTrack, const Const::ChargedStable& particleType, bool resortHits = false) const;
239
243 bool fit(RecoTrack& recoTrack, const int pdgCode, bool resortHits = false) const;
244
261 bool fit(RecoTrack& recoTrack, bool resortHits = false) const;
262
268 {
269 m_measurementAdder.resetMeasurementCreatorsToDefaultSettings();
270 }
271
283 const std::vector<std::shared_ptr<PXDBaseMeasurementCreator>>& pxdMeasurementCreators,
284 const std::vector<std::shared_ptr<SVDBaseMeasurementCreator>>& svdMeasurementCreators,
285 const std::vector<std::shared_ptr<CDCBaseMeasurementCreator>>& cdcMeasurementCreators,
286 const std::vector<std::shared_ptr<BKLMBaseMeasurementCreator>>& bklmMeasurementCreators,
287 const std::vector<std::shared_ptr<EKLMBaseMeasurementCreator>>& eklmMeasurementCreators,
288 const std::vector<std::shared_ptr<BaseMeasurementCreator>>& additionalMeasurementCreators)
289 {
290 m_measurementAdder.resetMeasurementCreators(pxdMeasurementCreators,
291 svdMeasurementCreators,
292 cdcMeasurementCreators,
293 bklmMeasurementCreators,
294 eklmMeasurementCreators,
295 additionalMeasurementCreators);
296 }
297
316 const std::map<std::string, std::map<std::string, std::string>>& pxdMeasurementCreators,
317 const std::map<std::string, std::map<std::string, std::string>>& svdMeasurementCreators,
318 const std::map<std::string, std::map<std::string, std::string>>& cdcMeasurementCreators,
319 const std::map<std::string, std::map<std::string, std::string>>& bklmMeasurementCreators,
320 const std::map<std::string, std::map<std::string, std::string>>& eklmMeasurementCreators,
321 const std::map<std::string, std::map<std::string, std::string>>& additionalMeasurementCreators)
322 {
323 m_measurementAdder.resetMeasurementCreatorsUsingFactories(pxdMeasurementCreators,
324 svdMeasurementCreators,
325 cdcMeasurementCreators,
326 bklmMeasurementCreators,
327 eklmMeasurementCreators,
328 additionalMeasurementCreators);
329 }
330
332 void setgErrorIgnoreLevel(Int_t errorIgnoreLevel) { m_gErrorIgnoreLevel = errorIgnoreLevel; }
333
336
337 private:
339 std::shared_ptr<genfit::AbsFitter> m_fitter;
340
342 bool m_skipDirtyCheck = false;
343
346
348 Int_t m_gErrorIgnoreLevel = kFatal;
349
352
365 bool fitWithoutCheck(RecoTrack& recoTrack, const genfit::AbsTrackRep& trackRepresentation, bool resortHits = false) const;
366 };
367
368}
369
Provides a type-safe way to pass members of the chargedStableSet set.
Definition Const.h:590
ETrackFitType
Enum for identifying the type of track fit algorythm ( or cosmic)
@ c_Default
default configuration
The payload containing the DAF parameters.
Class for accessing objects in the database.
Definition DBObjPtr.h:21
static Environment & Instance()
Static method to get a reference to the Environment instance.
Algorithm class to translate the added detector hits (e.g.
This is the Reconstruction Event-Data Model Track.
Definition RecoTrack.h:79
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...
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...
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...
static constexpr double s_defaultProbCut
Default probCut for the default DAF fitter.
DBObjPtr< DAFConfiguration > m_DAFConfiguration
DAF configuration Database OjbPtr.
void setgErrorIgnoreLevel(Int_t errorIgnoreLevel)
Set the gErrorIgnoreLevel for the fitter.
Int_t getgErrorIgnoreLevel()
Return the currently set gErrorIgnoreLevel for the fitter.
void resetMeasurementCreatorsToDefaultSettings()
Reset the internal measurement creator storage to the default settings.
bool fitWithoutCheck(RecoTrack &recoTrack, const genfit::AbsTrackRep &trackRepresentation, bool resortHits=false) const
Helper function to do the fit.
static constexpr double s_defaultDeltaPValue
Default deltaPValue for the default DAF fitter.
void resetFitterToDBSettings(const DAFConfiguration::ETrackFitType trackFitType=DAFConfiguration::c_Default)
Use the DB settings of the fitter to fit the reco tracks.
bool fit(RecoTrack &recoTrack, genfit::AbsTrackRep *trackRepresentation, bool resortHits=false) const
Fit a reco track with a given non-default track representation.
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.
MeasurementAdder m_measurementAdder
The measurement adder algorithm class.
void resetFitterToUserSettings(const DAFParameters *DAFParams)
Use the user settings of the fitter to fit the reco tracks.
Int_t m_gErrorIgnoreLevel
Control the output level of the ROOT functions used by the GenFit fitter. Default is increased from k...
static constexpr unsigned int s_defaultMaxFailedHits
Default maxFailedHits for the default DAF fitter.
std::shared_ptr< genfit::AbsFitter > m_fitter
The internal storage of the used fitting algorithms.
bool m_skipDirtyCheck
Flag to skip the dirty flag check which is needed when using non-default fitters.
TrackFitter(const DAFConfiguration::ETrackFitType trackFitType=DAFConfiguration::c_Default, const std::string &storeArrayNameOfPXDHits="", const std::string &storeArrayNameOfSVDHits="", const std::string &storeArrayNameOfCDCHits="", const std::string &storeArrayNameOfBKLMHits="", const std::string &storeArrayNameOfEKLMHits="", const bool initializeCDCTranslators=true, bool fromTrackCreator=false)
Create a new fitter instance.
void resetFitterToCosmicsSettings()
Use the settings of the fitter to fit the reco tracks for cosmics data.
Abstract base class for different kinds of events.