Belle II Software development
QualityEstimatorVXDModule.cc
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
9#include <tracking/modules/vxdtfQualityEstimator/QualityEstimatorVXDModule.h>
10
11#include <tracking/trackFindingVXD/trackQualityEstimators/QualityEstimatorTripletFit.h>
12#include <tracking/trackFindingVXD/trackQualityEstimators/QualityEstimatorMC.h>
13#include <tracking/trackFindingVXD/trackQualityEstimators/QualityEstimatorCircleFit.h>
14#include <tracking/trackFindingVXD/trackQualityEstimators/QualityEstimatorRiemannHelixFit.h>
15#include <tracking/trackFindingVXD/trackQualityEstimators/QualityEstimatorRandom.h>
16
17#include <framework/geometry/BFieldManager.h>
18
19using namespace Belle2;
20
21
22REG_MODULE(QualityEstimatorVXD);
23
25{
26 //Set module properties
27 setDescription("The quality estimator module for SpacePointTrackCandidates.");
29
30 addParam("EstimationMethod", m_EstimationMethod,
31 "Identifier which estimation method to use. Valid identifiers are: [mcInfo, circleFit, tripletFit, helixFit, random]",
32 std::string("tripletFit"));
33
34 addParam("SpacePointTrackCandsStoreArrayName", m_SpacePointTrackCandsStoreArrayName,
35 "Name of StoreArray containing the SpacePointTrackCandidates to be estimated.", std::string(""));
36
37 addParam("MCRecoTracksStoreArrayName", m_MCRecoTracksStoreArrayName,
38 "Only required for MCInfo method. Name of StoreArray containing MCRecoTracks.", std::string("MCRecoTracks"));
39
40 addParam("MCStrictQualityEstimator", m_MCStrictQualityEstimator,
41 "Only required for MCInfo method. If false combining several MCTracks is allowed.", bool(true));
42}
43
45{
47
48 // create pointer to chosen estimator
49 if (m_EstimationMethod == "mcInfo") {
50 // needs the mc Reco tracks so initialize them here
51 StoreArray<RecoTrack> mcRecoTracks;
53 m_estimator = std::make_unique<QualityEstimatorMC>(m_MCRecoTracksStoreArrayName, m_MCStrictQualityEstimator);
54 } else if (m_EstimationMethod == "tripletFit") {
55 m_estimator = std::make_unique<QualityEstimatorTripletFit>();
56 } else if (m_EstimationMethod == "circleFit") {
57 m_estimator = std::make_unique<QualityEstimatorCircleFit>();
58 } else if (m_EstimationMethod == "helixFit") {
59 m_estimator = std::make_unique<QualityEstimatorRiemannHelixFit>();
60 } else if (m_EstimationMethod == "random") {
61 m_estimator = std::make_unique<QualityEstimatorRandom>();
62 }
63 B2ASSERT("QualityEstimator could not be initialized with method: " << m_EstimationMethod, m_estimator);
64}
65
67{
68 // BField is required by all QualityEstimators
69 double bFieldZ = BFieldManager::getField(0, 0, 0).Z() / Unit::T;
70 m_estimator->setMagneticFieldStrength(bFieldZ);
71
72 if (m_EstimationMethod == "mcInfo") {
73 QualityEstimatorMC* MCestimator = static_cast<QualityEstimatorMC*>(m_estimator.get());
74 MCestimator->forceUpdateClusterNames();
75 }
76}
77
79{
80
81 // assign a QI computed using the selected QualityEstimator for each given SpacePointTrackCand
83
84 double qi = m_estimator->estimateQuality(aTC.getSortedHits());
85
86 aTC.setQualityIndicator(qi);
87 }
88}
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
Class implementing the algorithm used for the MC based quality estimation.
void forceUpdateClusterNames()
Setter to force the class to update its cluster names.
QualityEstimatorVXDModule()
Constructor of the module.
std::string m_SpacePointTrackCandsStoreArrayName
sets the name of the expected StoreArray containing SpacePointTrackCands
bool m_MCStrictQualityEstimator
Only required for MCInfo method.
void initialize() override
Initializes the Module.
void event() override
Applies the selected quality estimation method for a given set of TCs.
std::string m_EstimationMethod
Identifier which estimation method to use.
void beginRun() override
Called when entering a new run.
std::string m_MCRecoTracksStoreArrayName
sets the name of the expected StoreArray containing MCRecoTracks.
std::unique_ptr< QualityEstimatorBase > m_estimator
pointer to the selected QualityEstimator
StoreArray< SpacePointTrackCand > m_spacePointTrackCands
the storeArray for SpacePointTrackCands as member, is faster than recreating link for each event
Storage for (VXD) SpacePoint-based track candidates.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
static const double T
[tesla]
Definition: Unit.h:120
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Definition: BFieldManager.h:91
Abstract base class for different kinds of events.