Belle II Software  release-05-02-19
SPTC2RTConverterModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Jonas Wagner *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <tracking/modules/vxdtfRedesign/SPTC2RTConverterModule.h>
12 #include <framework/logging/Logger.h>
13 
14 using namespace Belle2;
15 
16 REG_MODULE(SPTC2RTConverter)
17 
18 SPTC2RTConverterModule::SPTC2RTConverterModule() : Module()
19 {
20  setDescription("Converts the given SpacePointTrackCandidates to RecoTracks and stores them in the given RecoTracksStoreArray");
22 
23  addParam("spacePointsTCsStoreArrayName", m_param_spacePointTCsStoreArrayName,
24  "StoreArray name of the input SpacePointTrackCandidates.", std::string(""));
25  addParam("recoTracksStoreArrayName", m_param_recoTracksStoreArrayName,
26  "StoreArray name of the output RecoTracks.", std::string(""));
27 
28  addParam("recoHitInformationStoreArrayName", m_param_recoHitInformationStoreArrayName,
29  "StoreArray name of the output RecoHitInformation.", std::string(""));
30  addParam("pxdHitsStoreArrayName", m_param_pxdHitsStoreArrayName, "StoreArray name of the related pxd hits.",
31  std::string(""));
32  addParam("svdHitsStoreArrayName", m_param_svdHitsStoreArrayName, "StoreArray name of the related svd hits.",
33  std::string(""));
34 
35  addParam("pxdClustersName", m_param_pxdClustersName, "StoreArray name of PXDClusters related to SpacePoints.",
36  std::string(""));
37  addParam("svdClustersName", m_param_svdClustersName, "StoreArray name of SVDClusters related to SpacePoints.",
38  std::string(""));
39 
40  initializeCounters();
41 }
42 
44 {
45  // Reset Counters
47 
48  // Read in SpacePointTrackCandidates
50  m_spacePointTCs.isRequired();
51 
52  // Write out RecoTracks
54  m_recoTracks.registerInDataStore();
56  "",
59  "",
60  "",
62  m_recoTracks.registerRelationTo(m_spacePointTCs);
63 
64  StoreArray<PXDCluster> PXDClusters; PXDClusters.isOptional(m_param_pxdClustersName);
65  StoreArray<SVDCluster> SVDClusters; SVDClusters.isOptional(m_param_svdClustersName);
66 }
67 
69 {
70 
71  for (const SpacePointTrackCand& spacePointTC : m_spacePointTCs) {
72  m_SPTCCtr++;
73  if (spacePointTC.getRefereeStatus() < SpacePointTrackCand::c_isActive) {
74  B2DEBUG(100, "SPTC2RTConverter::event: SpacePointTrackCandidate not active or reserved. RefereeStatus: " <<
75  spacePointTC.getRefereeStatus());
76  continue; // Ignore SpacePointTrackCandidate
77  } else if (spacePointTC.getNHits() < 3) {
78  B2WARNING("SPTC2RTConverter::event: Number of SpacePoints of track candidate is smaller than 3. Not creating RecoTrack out of it.");
79  continue; // Ignore SpacePointTrackCandidate
80  }
81  createRecoTrack(spacePointTC);
82  m_RTCtr++;
83  }
84 }
85 
87 {
88 
89  // Determine the tracking parameters
90  const TVector3& position = spacePointTC.getPosSeed();
91  const TVector3& momentum = spacePointTC.getMomSeed();
92  const short int charge = spacePointTC.getChargeSeed();
93  const TMatrixDSym& covSeed = spacePointTC.getCovSeed();
94  const float qi = spacePointTC.getQualityIndicator();
95 
96  // Create and append new RecoTrack
97  RecoTrack* newRecoTrack = m_recoTracks.appendNew(position, momentum, charge,
100 
101  // Set information not required by constructor
102  newRecoTrack->setSeedCovariance(covSeed);
103 
104  // Transfer quality indicator from SPTC to RecoTrack
105  newRecoTrack->setQualityIndicator(qi);
106 
107  // Add individual Hits/Clusters
108  unsigned int sortingParameter = 0; // Recreate sorting since there are two cluster per SVD hit.
109  for (auto spacePoint : spacePointTC.getSortedHits()) {
110  B2DEBUG(110, "SPTC2RTConverter::event: Converting spacepoint: " << spacePoint->getArrayIndex());
111 
112  int detID = spacePoint->getType();
113 
114  if (detID == VXD::SensorInfoBase::PXD) {
115  RelationVector<PXDCluster> relatedClusters = spacePoint->getRelationsTo<PXDCluster>(m_param_pxdClustersName);
116  B2DEBUG(110, "SPTC2RTConverter::event: Number of related PXD Clusters: " << relatedClusters.size());
117  // relatedClusters should only contain 1 cluster for pxdHits. Loop over them to be robust against missing relations.
118  for (const PXDCluster& cluster : relatedClusters) {
119  newRecoTrack->addPXDHit(&cluster, sortingParameter, Belle2::RecoHitInformation::c_VXDTrackFinder);
120  sortingParameter++;
121  }
122  } else if (detID == VXD::SensorInfoBase::SVD) {
123  RelationVector<SVDCluster> relatedClusters = spacePoint->getRelationsTo<SVDCluster>(m_param_svdClustersName);
124  B2DEBUG(110, "SPTC2RTConverter::event: Number of related SVD Clusters: " << relatedClusters.size());
125  // relatedClusters should contain 2 clusters for svdHits. Loop over them to be robust against missing relations.
126  for (const SVDCluster& cluster : relatedClusters) {
127  newRecoTrack->addSVDHit(&cluster, sortingParameter, Belle2::RecoHitInformation::c_VXDTrackFinder);
128  sortingParameter++;
129  }
130  } else {
131  B2WARNING("SPTC2RTConverter::event: SpacePointTrackCandidate containing SpacePoint of unrecognised detector ID: " << detID <<
132  ". Created RecoTrack doesn't contain these SpacePoints!");
133  }
134 
135  spacePoint->setAssignmentState(true);
136  }
137 
138  // Add relation to SpacePointTrackCandidate
139  newRecoTrack->addRelationTo(&spacePointTC);
140 
141  B2DEBUG(110, "SPTC2RTConverter::event: nHits: " << spacePointTC.getNHits() <<
142  " ChargeSeed: " << charge <<
143  " PositionSeed: " << position.X() << ", " << position.Y() << ", " << position.Z() <<
144  " MomentumSeed: " << momentum.X() << ", " << momentum.Y() << ", " << momentum.Z());
145 }
146 
148 {
149  B2DEBUG(100, "SPTC2RTConverter::terminate: Got " << m_SPTCCtr << " SpacePointTrackCands and created " << m_RTCtr << " RecoTracks";);
150 }
151 
153 {
154  m_SPTCCtr = 0;
155  m_RTCtr = 0;
156 }
Belle2::RelationVector::size
size_t size() const
Get number of relations.
Definition: RelationVector.h:98
Belle2::RecoTrack::registerRequiredRelations
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:42
Belle2::SPTC2RTConverterModule::m_param_pxdHitsStoreArrayName
std::string m_param_pxdHitsStoreArrayName
StoreArray name of PXDhits.
Definition: SPTC2RTConverterModule.h:54
Belle2::SpacePointTrackCand::getSortedHits
const std::vector< const Belle2::SpacePoint * > getSortedHits() const
get hits (space points) sorted by their respective sorting parameter
Definition: SpacePointTrackCand.cc:103
Belle2::SPTC2RTConverterModule::event
void event() override
This method is the core of the module.
Definition: SPTC2RTConverterModule.cc:68
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::SpacePointTrackCand::getQualityIndicator
double getQualityIndicator() const
returns the current status of the estimated quality of this track candidate.
Definition: SpacePointTrackCand.h:222
Belle2::RecoTrack::setSeedCovariance
void setSeedCovariance(const TMatrixDSym &seedCovariance)
Set the covariance of the seed. ATTENTION: This is not the fitted covariance.
Definition: RecoTrack.h:530
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module::c_ParallelProcessingCertified
@ 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:82
Belle2::SPTC2RTConverterModule::m_recoTracks
StoreArray< RecoTrack > m_recoTracks
StoreArray as class member to prevent relinking for every SPTC.
Definition: SPTC2RTConverterModule.h:61
Belle2::SPTC2RTConverterModule::m_RTCtr
unsigned int m_RTCtr
Counter for RecoTracks that were actually created by the module.
Definition: SPTC2RTConverterModule.h:66
Belle2::SpacePointTrackCand::getMomSeed
const TVector3 getMomSeed() const
get momentum seed as TVector3
Definition: SpacePointTrackCand.h:181
Belle2::RelationsInterface::addRelationTo
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).
Definition: RelationsObject.h:144
Belle2::SpacePointTrackCand::c_isActive
@ c_isActive
bit 11: SPTC is active (i.e.
Definition: SpacePointTrackCand.h:94
Belle2::RecoTrack::setQualityIndicator
void setQualityIndicator(const float qualityIndicator)
Set the quality index attached to this RecoTrack. 0 means likely fake.
Definition: RecoTrack.h:736
Belle2::SPTC2RTConverterModule::m_SPTCCtr
unsigned int m_SPTCCtr
Counter for SpacePointTrackCands presented to the module.
Definition: SPTC2RTConverterModule.h:65
Belle2::SPTC2RTConverterModule::m_param_recoHitInformationStoreArrayName
std::string m_param_recoHitInformationStoreArrayName
StoreArray name of RecoHitInformation.
Definition: SPTC2RTConverterModule.h:53
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::SpacePointTrackCand::getNHits
unsigned int getNHits() const
get the number of hits (space points) in the track candidate
Definition: SpacePointTrackCand.h:154
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2::SPTC2RTConverterModule::m_param_recoTracksStoreArrayName
std::string m_param_recoTracksStoreArrayName
Output RecoTracks StoreArray name.
Definition: SPTC2RTConverterModule.h:51
Belle2::SPTC2RTConverterModule::createRecoTrack
void createRecoTrack(const SpacePointTrackCand &spacePointTC)
Creates a RecoTrack corresponding to the given SpacePointTrackCand and appends it to the RecoTracks S...
Definition: SPTC2RTConverterModule.cc:86
Belle2::RelationVector
Class for type safe access to objects that are referred to in relations.
Definition: DataStore.h:38
Belle2::RecoTrack::addSVDHit
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:269
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SPTC2RTConverterModule::m_param_spacePointTCsStoreArrayName
std::string m_param_spacePointTCsStoreArrayName
Input SpacePointTrackCands StoreArray name.
Definition: SPTC2RTConverterModule.h:50
Belle2::SPTC2RTConverterModule::m_param_pxdClustersName
std::string m_param_pxdClustersName
StoreArray name of PXDClusters.
Definition: SPTC2RTConverterModule.h:57
Belle2::SPTC2RTConverterModule::m_param_svdClustersName
std::string m_param_svdClustersName
StoreArray name of SVDClusters.
Definition: SPTC2RTConverterModule.h:58
Belle2::PXDCluster
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:41
Belle2::VXD::SensorInfoBase::SVD
@ SVD
SVD Sensor.
Definition: SensorInfoBase.h:45
Belle2::SpacePointTrackCand::getChargeSeed
double getChargeSeed() const
get charge
Definition: SpacePointTrackCand.h:169
Belle2::SPTC2RTConverterModule::initializeCounters
void initializeCounters()
reset counters to 0 to avoid indeterministic behaviour
Definition: SPTC2RTConverterModule.cc:152
Belle2::SpacePointTrackCand::getPosSeed
const TVector3 getPosSeed() const
get position seed as TVector3
Definition: SpacePointTrackCand.h:178
Belle2::SPTC2RTConverterModule::m_param_svdHitsStoreArrayName
std::string m_param_svdHitsStoreArrayName
StoreArray name of SVDhits.
Definition: SPTC2RTConverterModule.h:55
Belle2::SVDCluster
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition: SVDCluster.h:38
Belle2::VXD::SensorInfoBase::PXD
@ PXD
PXD Sensor.
Definition: SensorInfoBase.h:44
Belle2::Module::addParam
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:562
Belle2::StoreArray< SpacePointTrackCand >
Belle2::SpacePointTrackCand::getCovSeed
const TMatrixDSym & getCovSeed() const
get the covariance matrix seed (6D).
Definition: SpacePointTrackCand.h:172
Belle2::SPTC2RTConverterModule::terminate
void terminate() override
This method is called at the end of the event processing.
Definition: SPTC2RTConverterModule.cc:147
Belle2::SPTC2RTConverterModule::initialize
void initialize() override
Initialize the Module.
Definition: SPTC2RTConverterModule.cc:43
Belle2::SPTC2RTConverterModule::m_spacePointTCs
StoreArray< SpacePointTrackCand > m_spacePointTCs
StoreArray as class member to prevent relinking for every event.
Definition: SPTC2RTConverterModule.h:62
Belle2::SpacePointTrackCand
Storage for (VXD) SpacePoint-based track candidates.
Definition: SpacePointTrackCand.h:51
Belle2::RecoTrack::addPXDHit
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:255