Belle II Software development
MeasurementAdder.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
12#include <tracking/trackFitting/measurementCreator/factories/CDCMeasurementCreatorFactory.h>
13#include <tracking/trackFitting/measurementCreator/factories/SVDMeasurementCreatorFactory.h>
14#include <tracking/trackFitting/measurementCreator/factories/PXDMeasurementCreatorFactory.h>
15#include <tracking/trackFitting/measurementCreator/factories/BKLMMeasurementCreatorFactory.h>
16#include <tracking/trackFitting/measurementCreator/factories/EKLMMeasurementCreatorFactory.h>
17#include <tracking/trackFitting/measurementCreator/factories/AdditionalMeasurementCreatorFactory.h>
18
19#include <genfit/MeasurementFactory.h>
20#include <string>
21#include <map>
22
23
24namespace genfit {
25 class AbsMeasurement;
26}
27
28
29namespace Belle2 {
35 class RecoTrack;
36
77 public:
82 MeasurementAdder(const std::string& storeArrayNameOfPXDHits,
83 const std::string& storeArrayNameOfSVDHits,
84 const std::string& storeArrayNameOfCDCHits,
85 const std::string& storeArrayNameOfBKLMHits,
86 const std::string& storeArrayNameOfEKLMHits,
87 const bool initializeCDCTranslators = true);
88
94
106 const std::vector<std::shared_ptr<PXDBaseMeasurementCreator>>& pxdMeasurementCreators,
107 const std::vector<std::shared_ptr<SVDBaseMeasurementCreator>>& svdMeasurementCreators,
108 const std::vector<std::shared_ptr<CDCBaseMeasurementCreator>>& cdcMeasurementCreators,
109 const std::vector<std::shared_ptr<BKLMBaseMeasurementCreator>>& bklmMeasurementCreators,
110 const std::vector<std::shared_ptr<EKLMBaseMeasurementCreator>>& eklmMeasurementCreators,
111 const std::vector<std::shared_ptr<BaseMeasurementCreator>>& additionalMeasurementCreators);
112
131 const std::map<std::string, std::map<std::string, std::string>>& pxdMeasurementCreators,
132 const std::map<std::string, std::map<std::string, std::string>>& svdMeasurementCreators,
133 const std::map<std::string, std::map<std::string, std::string>>& cdcMeasurementCreators,
134 const std::map<std::string, std::map<std::string, std::string>>& bklmMeasurementCreators,
135 const std::map<std::string, std::map<std::string, std::string>>& eklmMeasurementCreators,
136 const std::map<std::string, std::map<std::string, std::string>>& additionalMeasurementCreators);
137
150 bool addMeasurements(RecoTrack& recoTrack) const;
151
152 private:
164 bool m_skipDirtyCheck = false;
165
167 std::vector<std::shared_ptr<PXDBaseMeasurementCreator>> m_pxdMeasurementCreators;
169 std::vector<std::shared_ptr<SVDBaseMeasurementCreator>> m_svdMeasurementCreators;
171 std::vector<std::shared_ptr<CDCBaseMeasurementCreator>> m_cdcMeasurementCreators;
173 std::vector<std::shared_ptr<BKLMBaseMeasurementCreator>> m_bklmMeasurementCreators;
175 std::vector<std::shared_ptr<EKLMBaseMeasurementCreator>> m_eklmMeasurementCreators;
177 std::vector<std::shared_ptr<BaseMeasurementCreator>> m_additionalMeasurementCreators;
178
180 genfit::MeasurementFactory<genfit::AbsMeasurement> m_genfitMeasurementFactory;
181
184
186 template <class HitType, Const::EDetector detector>
187 void addMeasurementsFromHitToRecoTrack(RecoTrack& recoTrack, RecoHitInformation& recoHitInformation, HitType* hit,
188 const std::vector<std::shared_ptr<BaseMeasurementCreatorFromHit<HitType, detector>>>& measurementCreators,
189 std::map<genfit::TrackPoint*, RecoHitInformation*>& trackPointHitMapping) const
190 {
191 if (not recoHitInformation.useInFit()) {
192 return;
193 }
194
195 genfit::Track& genfitTrack = RecoTrackGenfitAccess::getGenfitTrack(recoTrack);
196
197 for (const auto& measurementCreator : measurementCreators) {
198 const std::vector<genfit::TrackPoint*>& trackPoints = measurementCreator->createMeasurementPoints(hit, recoTrack,
199 recoHitInformation);
200 for (genfit::TrackPoint* trackPoint : trackPoints) {
201 genfitTrack.insertPoint(trackPoint);
202 // FIXME: hotfix: to get a correct mapping between reco hit information and the track point.
203 // We are not able to store the TrackPoint in the RecoHitInformation directly because of problems in streaming
204 // the genfit::TrackPoint. So what we do is store the index of the track points in the vector of the genfit::Track.
205 // As this vector is sorted after this function, we can not set it here directly.
206 trackPointHitMapping[trackPoint] = &recoHitInformation;
207 }
208 }
209 }
210
213 const std::vector<std::shared_ptr<BaseMeasurementCreator>>& measurementCreators) const;
214 };
216}
217
Base Class to create measurements based on a given hit related to the RecoTrack.
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...
std::vector< std::shared_ptr< BKLMBaseMeasurementCreator > > m_bklmMeasurementCreators
Internal storage of the BKLM measurement creators.
std::vector< std::shared_ptr< CDCBaseMeasurementCreator > > m_cdcMeasurementCreators
Internal storage of the CDC measurement creators.
void createGenfitMeasurementFactory()
Helper function to create a genfit::MeasurementFactory, needed in the MeasurementCreators.
std::vector< std::shared_ptr< PXDBaseMeasurementCreator > > m_pxdMeasurementCreators
Internal storage of the PXD measurement creators.
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...
std::vector< std::shared_ptr< EKLMBaseMeasurementCreator > > m_eklmMeasurementCreators
Internal storage of the EKLM measurement creators.
std::string m_param_storeArrayNameOfPXDHits
The name of the store array for the PXD hits.
std::string m_param_storeArrayNameOfBKLMHits
The name of the store array for the BKLM hits.
genfit::MeasurementFactory< genfit::AbsMeasurement > m_genfitMeasurementFactory
Internal storage of the genfit measurement factory;.
void resetMeasurementCreatorsToDefaultSettings()
Reset the internal measurement creator storage to the default settings.
std::string m_param_storeArrayNameOfSVDHits
The name of the store array for the SVD hits.
std::vector< std::shared_ptr< BaseMeasurementCreator > > m_additionalMeasurementCreators
Internal storage of the additional measurement creators.
std::string m_param_storeArrayNameOfEKLMHits
The name of the store array for the EKLM hits.
std::string m_param_storeArrayNameOfCDCHits
The name of the store array for the CDC hits.
bool m_skipDirtyCheck
Flag to skip the dirty check. Useful when using non default measurement creators.
void addMeasurementsFromHitToRecoTrack(RecoTrack &recoTrack, RecoHitInformation &recoHitInformation, HitType *hit, const std::vector< std::shared_ptr< BaseMeasurementCreatorFromHit< HitType, detector > > > &measurementCreators, std::map< genfit::TrackPoint *, RecoHitInformation * > &trackPointHitMapping) const
Helper: Go through all measurement creators in the given list and create the measurement with a given...
std::vector< std::shared_ptr< SVDBaseMeasurementCreator > > m_svdMeasurementCreators
Internal storage of the SVD measurement creators.
bool addMeasurements(RecoTrack &recoTrack) const
After you have filled the internal storage with measurement creators (either by providing your own or...
void addMeasurementsToRecoTrack(RecoTrack &recoTrack, const std::vector< std::shared_ptr< BaseMeasurementCreator > > &measurementCreators) const
Helper: Go through all measurement creators in the given list and create the measurement without a gi...
This class stores additional information to every CDC/SVD/PXD hit stored in a RecoTrack.
bool useInFit() const
Get the flag, whether this his should be used in a fit or not.
static genfit::Track & getGenfitTrack(RecoTrack &recoTrack)
Give access to the RecoTrack's genfit::Track.
Definition: RecoTrack.cc:404
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
Abstract base class for different kinds of events.