Belle II Software  release-08-01-10
QualityIndicatorFilter.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 #include <tracking/vxdHoughTracking/filters/pathFilters/QualityIndicatorFilter.h>
9 #include <tracking/trackFindingCDC/filters/base/Filter.icc.h>
10 #include <tracking/trackFindingVXD/trackQualityEstimators/QualityEstimatorCircleFit.h>
11 #include <tracking/trackFindingVXD/trackQualityEstimators/QualityEstimatorMC.h>
12 #include <tracking/trackFindingVXD/trackQualityEstimators/QualityEstimatorRiemannHelixFit.h>
13 #include <tracking/trackFindingVXD/trackQualityEstimators/QualityEstimatorTripletFit.h>
14 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
15 #include <framework/core/ModuleParamList.templateDetails.h>
16 #include <framework/geometry/BFieldManager.h>
17 
18 using namespace Belle2;
19 using namespace TrackFindingCDC;
20 using namespace vxdHoughTracking;
21 
22 void QualityIndicatorFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
23 {
24  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "trackQualityEstimationMethod"), m_EstimationMethod,
25  "Identifier which estimation method to use. Valid identifiers are: [mcInfo, circleFit, tripletFit, helixFit]",
26  m_EstimationMethod);
27 
28  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "MCRecoTracksStoreArrayName"), m_MCRecoTracksStoreArrayName,
29  "Only required for MCInfo method. Name of StoreArray containing MCRecoTracks.",
30  m_MCRecoTracksStoreArrayName);
31 
32  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "MCStrictQualityEstimator"), m_MCStrictQualityEstimator,
33  "Only required for MCInfo method. If false combining several MCTracks is allowed.",
34  m_MCStrictQualityEstimator);
35 
36  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "QICut"), m_QIcut,
37  "Cut on the quality indicator. Only process QI values larger than this.", m_QIcut);
38 }
39 
40 void QualityIndicatorFilter::beginRun()
41 {
42  const double bFieldZ = BFieldManager::getField(0, 0, 0).Z() / Unit::T;
43  m_estimator->setMagneticFieldStrength(bFieldZ);
44 
45  if (m_EstimationMethod == "mcInfo") {
46  QualityEstimatorMC* MCestimator = static_cast<QualityEstimatorMC*>(m_estimator.get());
47  MCestimator->forceUpdateClusterNames();
48  }
49 }
50 
51 void QualityIndicatorFilter::initialize()
52 {
53  // create pointer to chosen estimator
54  if (m_EstimationMethod == "mcInfo") {
55  StoreArray<RecoTrack> mcRecoTracks;
56  mcRecoTracks.isRequired(m_MCRecoTracksStoreArrayName);
57  m_estimator = std::make_unique<QualityEstimatorMC>(m_MCRecoTracksStoreArrayName, m_MCStrictQualityEstimator);
58  } else if (m_EstimationMethod == "tripletFit") {
59  m_estimator = std::make_unique<QualityEstimatorTripletFit>();
60  } else if (m_EstimationMethod == "circleFit") {
61  m_estimator = std::make_unique<QualityEstimatorCircleFit>();
62  } else if (m_EstimationMethod == "helixFit") {
63  m_estimator = std::make_unique<QualityEstimatorRiemannHelixFit>();
64  }
65  B2ASSERT("QualityEstimator could not be initialized with method: " << m_EstimationMethod, m_estimator);
66 }
67 
68 TrackFindingCDC::Weight
69 QualityIndicatorFilter::operator()(const BasePathFilter::Object& pair)
70 {
71  const std::vector<TrackFindingCDC::WithWeight<const VXDHoughState*>>& previousHits = pair.first;
72 
73  std::vector<const SpacePoint*> spacePoints;
74  spacePoints.reserve(previousHits.size() + 1);
75  for (auto& hit : previousHits) {
76  spacePoints.emplace_back(hit->getHit());
77  }
78  spacePoints.emplace_back(pair.second->getHit());
79 
80  // The path is outwards-in, and thus the SPs are added outwards-in, too.
81  // The tripletFit only works with hits inside-out, so reverse the SP vector
82  std::reverse(spacePoints.begin(), spacePoints.end());
83 
84  const auto& estimatorResult = m_estimator->estimateQualityAndProperties(spacePoints);
85 
86  if (estimatorResult.qualityIndicator < m_QIcut) {
87  return NAN;
88  }
89 
90  return estimatorResult.qualityIndicator;
91 }
The Module parameter list class.
Class implementing the algorithm used for the MC based quality estimation.
void forceUpdateClusterNames()
Setter to force the class to update its cluster names.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
AObject Object
Type of the object to be analysed.
Definition: Filter.dcl.h:33
static const double T
[tesla]
Definition: Unit.h:120
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
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.