Belle II Software development
SPTC2RTConverterModule.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/vxdtfRedesign/SPTC2RTConverterModule.h>
10#include <framework/logging/Logger.h>
11
12using namespace Belle2;
13
14REG_MODULE(SPTC2RTConverter);
15
17{
18 setDescription("Converts the given SpacePointTrackCandidates to RecoTracks and stores them in the given RecoTracksStoreArray");
20
21 addParam("spacePointsTCsStoreArrayName", m_param_spacePointTCsStoreArrayName,
22 "StoreArray name of the input SpacePointTrackCandidates.", std::string(""));
23 addParam("recoTracksStoreArrayName", m_param_recoTracksStoreArrayName,
24 "StoreArray name of the output RecoTracks.", std::string(""));
25
26 addParam("recoHitInformationStoreArrayName", m_param_recoHitInformationStoreArrayName,
27 "StoreArray name of the output RecoHitInformation.", std::string(""));
28 addParam("pxdHitsStoreArrayName", m_param_pxdHitsStoreArrayName, "StoreArray name of the related pxd hits.",
29 std::string(""));
30 addParam("svdHitsStoreArrayName", m_param_svdHitsStoreArrayName, "StoreArray name of the related svd hits.",
31 std::string(""));
32
33 addParam("pxdClustersName", m_param_pxdClustersName, "StoreArray name of PXDClusters related to SpacePoints.",
34 std::string(""));
35 addParam("svdClustersName", m_param_svdClustersName, "StoreArray name of SVDClusters related to SpacePoints.",
36 std::string(""));
37
39}
40
42{
43 // Reset Counters
45
46 // Read in SpacePointTrackCandidates
49
50 // Write out RecoTracks
56 "",
57 "",
58 "",
61
62 StoreArray<PXDCluster> PXDClusters; PXDClusters.isOptional(m_param_pxdClustersName);
63 StoreArray<SVDCluster> SVDClusters; SVDClusters.isOptional(m_param_svdClustersName);
64}
65
67{
68
69 for (const SpacePointTrackCand& spacePointTC : m_spacePointTCs) {
70 m_SPTCCtr++;
71 if (spacePointTC.getRefereeStatus() < SpacePointTrackCand::c_isActive) {
72 B2DEBUG(29, "SPTC2RTConverter::event: SpacePointTrackCandidate not active or reserved. RefereeStatus: " <<
73 spacePointTC.getRefereeStatus());
74 continue; // Ignore SpacePointTrackCandidate
75 } else if (spacePointTC.getNHits() < 3) {
76 B2WARNING("SPTC2RTConverter::event: Number of SpacePoints of track candidate is smaller than 3. Not creating RecoTrack out of it.");
77 continue; // Ignore SpacePointTrackCandidate
78 }
79 createRecoTrack(spacePointTC);
80 m_RTCtr++;
81 }
82}
83
85{
86
87 // Determine the tracking parameters
88 const ROOT::Math::XYZVector& position = spacePointTC.getPosSeed();
89 const ROOT::Math::XYZVector& momentum = spacePointTC.getMomSeed();
90 const short int charge = spacePointTC.getChargeSeed();
91 const TMatrixDSym& covSeed = spacePointTC.getCovSeed();
92 const float qi = spacePointTC.getQualityIndicator();
93
94 // Create and append new RecoTrack
95 RecoTrack* newRecoTrack = m_recoTracks.appendNew(position, momentum, charge,
98
99 // Set information not required by constructor
100 newRecoTrack->setSeedCovariance(covSeed);
101
102 // Transfer quality indicator from SPTC to RecoTrack
103 newRecoTrack->setQualityIndicator(qi);
104
105 // Add individual Hits/Clusters
106 unsigned int sortingParameter = 0; // Recreate sorting since there are two cluster per SVD hit.
107 for (auto spacePoint : spacePointTC.getSortedHits()) {
108 B2DEBUG(29, "SPTC2RTConverter::event: Converting spacepoint: " << spacePoint->getArrayIndex());
109
110 int detID = spacePoint->getType();
111
112 if (detID == VXD::SensorInfoBase::PXD) {
113 RelationVector<PXDCluster> relatedClusters = spacePoint->getRelationsTo<PXDCluster>(m_param_pxdClustersName);
114 B2DEBUG(29, "SPTC2RTConverter::event: Number of related PXD Clusters: " << relatedClusters.size());
115 // relatedClusters should only contain 1 cluster for pxdHits. Loop over them to be robust against missing relations.
116 for (const PXDCluster& cluster : relatedClusters) {
117 newRecoTrack->addPXDHit(&cluster, sortingParameter, Belle2::RecoHitInformation::c_VXDTrackFinder);
118 sortingParameter++;
119 }
120 } else if (detID == VXD::SensorInfoBase::SVD) {
121 RelationVector<SVDCluster> relatedClusters = spacePoint->getRelationsTo<SVDCluster>(m_param_svdClustersName);
122 B2DEBUG(29, "SPTC2RTConverter::event: Number of related SVD Clusters: " << relatedClusters.size());
123 // relatedClusters should contain 2 clusters for svdHits. Loop over them to be robust against missing relations.
124 for (const SVDCluster& cluster : relatedClusters) {
125 newRecoTrack->addSVDHit(&cluster, sortingParameter, Belle2::RecoHitInformation::c_VXDTrackFinder);
126 sortingParameter++;
127 }
128 } else {
129 B2WARNING("SPTC2RTConverter::event: SpacePointTrackCandidate containing SpacePoint of unrecognised detector ID: " << detID <<
130 ". Created RecoTrack doesn't contain these SpacePoints!");
131 }
132
133 spacePoint->setAssignmentState(true);
134 }
135
136 // Add relation to SpacePointTrackCandidate
137 newRecoTrack->addRelationTo(&spacePointTC);
138
139 B2DEBUG(29, "SPTC2RTConverter::event: nHits: " << spacePointTC.getNHits() <<
140 " ChargeSeed: " << charge <<
141 " PositionSeed: " << position.X() << ", " << position.Y() << ", " << position.Z() <<
142 " MomentumSeed: " << momentum.X() << ", " << momentum.Y() << ", " << momentum.Z());
143}
144
146{
147 B2DEBUG(29, "SPTC2RTConverter::terminate: Got " << m_SPTCCtr << " SpacePointTrackCands and created " << m_RTCtr << " RecoTracks");
148}
149
151{
152 m_SPTCCtr = 0;
153 m_RTCtr = 0;
154}
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
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
bool addPXDHit(const UsedPXDHit *pxdHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a pxd hit with the given information to the reco track.
Definition: RecoTrack.h:258
void setSeedCovariance(const TMatrixDSym &seedCovariance)
Set the covariance of the seed. ATTENTION: This is not the fitted covariance.
Definition: RecoTrack.h:614
void setQualityIndicator(const float qualityIndicator)
Set the quality index attached to this RecoTrack. 0 means likely fake.
Definition: RecoTrack.h:847
static void registerRequiredRelations(StoreArray< RecoTrack > &recoTracks, std::string const &pxdHitsStoreArrayName="", std::string const &svdHitsStoreArrayName="", std::string const &cdcHitsStoreArrayName="", std::string const &bklmHitsStoreArrayName="", std::string const &eklmHitsStoreArrayName="", std::string const &recoHitInformationStoreArrayName="")
Convenience method which registers all relations required to fully use a RecoTrack.
Definition: RecoTrack.cc:53
bool addSVDHit(const UsedSVDHit *svdHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a svd hit with the given information to the reco track.
Definition: RecoTrack.h:272
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
StoreArray< SpacePointTrackCand > m_spacePointTCs
StoreArray as class member to prevent relinking for every event.
std::string m_param_pxdHitsStoreArrayName
StoreArray name of PXDhits.
void initialize() override
Initializer.
void event() override
This method is called for each event.
std::string m_param_spacePointTCsStoreArrayName
Input SpacePointTrackCands StoreArray name.
std::string m_param_pxdClustersName
StoreArray name of PXDClusters.
void terminate() override
This method is called at the end of the event processing.
void createRecoTrack(const SpacePointTrackCand &spacePointTC)
Creates a RecoTrack corresponding to the given SpacePointTrackCand and appends it to the RecoTracks S...
std::string m_param_recoTracksStoreArrayName
Output RecoTracks StoreArray name.
std::string m_param_svdHitsStoreArrayName
StoreArray name of SVDhits.
unsigned int m_SPTCCtr
Counter for SpacePointTrackCands presented to the module.
std::string m_param_svdClustersName
StoreArray name of SVDClusters.
StoreArray< RecoTrack > m_recoTracks
StoreArray as class member to prevent relinking for every SPTC.
unsigned int m_RTCtr
Counter for RecoTracks that were actually created by the module.
std::string m_param_recoHitInformationStoreArrayName
StoreArray name of RecoHitInformation.
void initializeCounters()
reset counters to 0 to avoid indeterministic behaviour
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition: SVDCluster.h:29
Storage for (VXD) SpacePoint-based track candidates.
const ROOT::Math::XYZVector getPosSeed() const
get position seed as ROOT::Math::XYZVector
const ROOT::Math::XYZVector getMomSeed() const
get momentum seed as ROOT::Math::XYZVector
unsigned int getNHits() const
get the number of hits (space points) in the track candidate
const TMatrixDSym & getCovSeed() const
get the covariance matrix seed (6D).
double getQualityIndicator() const
returns the current status of the estimated quality of this track candidate.
@ c_isActive
bit 11: SPTC is active (i.e.
double getChargeSeed() const
get charge
const std::vector< const Belle2::SpacePoint * > getSortedHits() const
get hits (space points) sorted by their respective sorting parameter
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:140
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
Abstract base class for different kinds of events.