Belle II Software prerelease-11-00-00a
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 {
34
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 bool fromTrackCreator = false);
89
95
107 const std::vector<std::shared_ptr<PXDBaseMeasurementCreator>>& pxdMeasurementCreators,
108 const std::vector<std::shared_ptr<SVDBaseMeasurementCreator>>& svdMeasurementCreators,
109 const std::vector<std::shared_ptr<CDCBaseMeasurementCreator>>& cdcMeasurementCreators,
110 const std::vector<std::shared_ptr<BKLMBaseMeasurementCreator>>& bklmMeasurementCreators,
111 const std::vector<std::shared_ptr<EKLMBaseMeasurementCreator>>& eklmMeasurementCreators,
112 const std::vector<std::shared_ptr<BaseMeasurementCreator>>& additionalMeasurementCreators);
113
132 const std::map<std::string, std::map<std::string, std::string>>& pxdMeasurementCreators,
133 const std::map<std::string, std::map<std::string, std::string>>& svdMeasurementCreators,
134 const std::map<std::string, std::map<std::string, std::string>>& cdcMeasurementCreators,
135 const std::map<std::string, std::map<std::string, std::string>>& bklmMeasurementCreators,
136 const std::map<std::string, std::map<std::string, std::string>>& eklmMeasurementCreators,
137 const std::map<std::string, std::map<std::string, std::string>>& additionalMeasurementCreators);
138
151 bool addMeasurements(RecoTrack& recoTrack) const;
152
153 private:
165 bool m_skipDirtyCheck = false;
166
168 std::vector<std::shared_ptr<PXDBaseMeasurementCreator>> m_pxdMeasurementCreators;
170 std::vector<std::shared_ptr<SVDBaseMeasurementCreator>> m_svdMeasurementCreators;
172 std::vector<std::shared_ptr<CDCBaseMeasurementCreator>> m_cdcMeasurementCreators;
174 std::vector<std::shared_ptr<BKLMBaseMeasurementCreator>> m_bklmMeasurementCreators;
176 std::vector<std::shared_ptr<EKLMBaseMeasurementCreator>> m_eklmMeasurementCreators;
178 std::vector<std::shared_ptr<BaseMeasurementCreator>> m_additionalMeasurementCreators;
179
181 genfit::MeasurementFactory<genfit::AbsMeasurement> m_genfitMeasurementFactory;
182
185
187 template <class HitType, Const::EDetector detector>
188 void addMeasurementsFromHitToRecoTrack(RecoTrack& recoTrack, RecoHitInformation& recoHitInformation, HitType* hit,
189 const std::vector<std::shared_ptr<BaseMeasurementCreatorFromHit<HitType, detector>>>& measurementCreators,
190 std::map<genfit::TrackPoint*, RecoHitInformation*>& trackPointHitMapping) const
191 {
192 if (not recoHitInformation.useInFit()) {
193 return;
194 }
195
196 genfit::Track& genfitTrack = RecoTrackGenfitAccess::getGenfitTrack(recoTrack);
197
198 for (const auto& measurementCreator : measurementCreators) {
199 const std::vector<genfit::TrackPoint*>& trackPoints = measurementCreator->createMeasurementPoints(hit, recoTrack,
200 recoHitInformation);
201 for (genfit::TrackPoint* trackPoint : trackPoints) {
202 genfitTrack.insertPoint(trackPoint);
203 // FIXME: hotfix: to get a correct mapping between reco hit information and the track point.
204 // We are not able to store the TrackPoint in the RecoHitInformation directly because of problems in streaming
205 // the genfit::TrackPoint. So what we do is store the index of the track points in the vector of the genfit::Track.
206 // As this vector is sorted after this function, we can not set it here directly.
207 trackPointHitMapping[trackPoint] = &recoHitInformation;
208 }
209 }
210 }
211
214 const std::vector<std::shared_ptr<BaseMeasurementCreator>>& measurementCreators) const;
215 };
216
217}
218
Base Class to create measurements based on a given hit related to the RecoTrack.
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.
MeasurementAdder(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 instance of the measurement adder.
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.