Belle II Software  release-06-01-15
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 
19 using namespace Belle2;
20 
21 
22 REG_MODULE(QualityEstimatorVXD)
23 
25 {
26  //Set module properties
27  setDescription("The quality estimator module for SpacePointTrackCandidates.");
28  setPropertyFlags(c_ParallelProcessingCertified);
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  m_estimator = std::make_unique<QualityEstimatorMC>(m_MCRecoTracksStoreArrayName, m_MCStrictQualityEstimator);
51  } else if (m_EstimationMethod == "tripletFit") {
52  m_estimator = std::make_unique<QualityEstimatorTripletFit>();
53  } else if (m_EstimationMethod == "circleFit") {
54  m_estimator = std::make_unique<QualityEstimatorCircleFit>();
55  } else if (m_EstimationMethod == "helixFit") {
56  m_estimator = std::make_unique<QualityEstimatorRiemannHelixFit>();
57  } else if (m_EstimationMethod == "random") {
58  m_estimator = std::make_unique<QualityEstimatorRandom>();
59  }
60  B2ASSERT("QualityEstimator could not be initialized with method: " << m_EstimationMethod, m_estimator);
61 }
62 
64 {
65  // BField is required by all QualityEstimators
66  double bFieldZ = BFieldManager::getField(0, 0, 0).Z() / Unit::T;
67  m_estimator->setMagneticFieldStrength(bFieldZ);
68 
69  if (m_EstimationMethod == "mcInfo") {
70  StoreArray<RecoTrack> mcRecoTracks;
72  std::string svdClustersName = ""; std::string pxdClustersName = "";
73 
74  if (mcRecoTracks.getEntries() > 0) {
75  svdClustersName = mcRecoTracks[0]->getStoreArrayNameOfSVDHits();
76  pxdClustersName = mcRecoTracks[0]->getStoreArrayNameOfPXDHits();
77  } else {
78  B2WARNING("No Entries in mcRecoTracksStoreArray: using empty cluster name for svd and pxd");
79  }
80 
81  QualityEstimatorMC* MCestimator = static_cast<QualityEstimatorMC*>(m_estimator.get());
82  MCestimator->setClustersNames(svdClustersName, pxdClustersName);
83  }
84 }
85 
87 {
88  // assign a QI computed using the selected QualityEstimator for each given SpacePointTrackCand
90 
91  double qi = m_estimator->estimateQuality(aTC.getSortedHits());
92 
93  aTC.setQualityIndicator(qi);
94  }
95 }
Base class for Modules.
Definition: Module.h:72
Class implementing the algorithm used for the MC based quality estimation.
void setClustersNames(const std::string &svdClustersName, const std::string &pxdClustersName)
Setter for StoreArray names of SVD and PXD clusters.
Quality estimation module for SpacePointTrackCandidates.
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
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
static const double T
[tesla]
Definition: Unit.h:120
#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.
Abstract base class for different kinds of events.