9 #include <tracking/modules/spacePointCreator/SPTC2GFTCConverterModule.h>
10 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
12 #include <genfit/TrackCand.h>
14 #include <framework/dataobjects/EventMetaData.h>
15 #include <framework/datastore/StoreArray.h>
16 #include <framework/datastore/StoreObjPtr.h>
18 #include <framework/gearbox/Const.h>
28 setDescription(
"Module for converting SpacePointTrackCand to genfit::TrackCand.");
29 setPropertyFlags(c_ParallelProcessingCertified);
31 addParam(
"SpacePointTCName", m_SPTCName,
"Name of the container containing the SpacePointTrackCands to convert",
string(
""));
32 addParam(
"genfitTCName", m_genfitTCName,
"Name of the container of the (output) genfit::TrackCands",
string(
""));
33 addParam(
"PXDClusters", m_PXDClustersName,
"Name of the container of the PXD Clusters",
string(
""));
34 addParam(
"SVDClusters", m_SVDClustersName,
"Name of the container of the SVD Clusters",
string(
""));
39 void SPTC2GFTCConverterModule::initialize()
41 B2INFO(
"SPTC2GFTCConverter --------------- initialize() -------------------");
59 void SPTC2GFTCConverterModule::event()
62 const int eventCounter = eventMetaData->getEvent();
63 B2DEBUG(10,
"SPTC2GFTCConverter::event() processing event " << eventCounter <<
" ----------");
69 B2DEBUG(15,
"Found " << nSPTCs <<
" SpacePointTrackCands in StoreArray " << spacePointTCs.
getName());
71 for (
int iTC = 0; iTC < nSPTCs; ++iTC) {
73 m_SpacePointTCCtr += 1;
76 B2DEBUG(20,
"SpacePointTrackCand " << iTC <<
" contains " << trackCand->
getNHits() <<
" SpacePoints");
78 std::vector<const SpacePoint*> tcSpacePoints = trackCand->
getHits();
82 for (
unsigned int iTCSP = 0; iTCSP < tcSpacePoints.size(); ++iTCSP) {
84 double sortingParam = sortingParams[iTCSP];
87 int detID = detType == VXD::SensorInfoBase::SVD ? Const::SVD : Const::PXD;
88 vector<int> clusterInds;
92 if (detType == VXD::SensorInfoBase::PXD) { clusterInds = getRelatedClusters<PXDCluster>(aSP, m_PXDClustersName); }
93 else if (detType == VXD::SensorInfoBase::SVD) { clusterInds = getRelatedClusters<SVDCluster>(aSP, m_SVDClustersName); }
94 else throw SpacePointTrackCand::UnsupportedDetType();
96 }
catch (std::runtime_error& anE) {
97 B2WARNING(
"Caught exception during creation of a genfit::TrackCand: " << anE.what());
101 B2WARNING(
"Caught unknown exception during conversion from SPTC to GFTC!");
105 for (
int hitID : clusterInds) {
106 genfitTC.addHit(detID, hitID, -1, sortingParam);
107 B2DEBUG(60,
"Added Cluster " << hitID <<
" with detID " << detID <<
" to genfit::TrackCand");
118 if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 150, PACKAGENAME())) genfitTC.
Print();
119 B2DEBUG(15,
"genfit::TrackCand contains " << genfitTC.getNHits() <<
" TrackCandHits.");
122 B2DEBUG(15,
"Added relation between SPTC " << trackCand->
getArrayIndex() <<
" from Array " << trackCand->
getArrayName() <<
127 void SPTC2GFTCConverterModule::terminate()
130 output <<
"SPTC2GFTCConverter::terminate: got " << m_SpacePointTCCtr <<
" SpacePointTrackCands and created " << m_genfitTCCtr <<
131 " genfit::TrackCands";
132 if (m_skippedSPsCtr) output <<
". " << m_skippedSPsCtr <<
" SpacePoints were skipped!";
133 B2INFO(output.str());
137 template<
typename ClusterType>
138 std::vector<int> SPTC2GFTCConverterModule::getRelatedClusters(
const Belle2::SpacePoint* spacePoint,
const std::string& clusterNames)
140 std::vector<int> clusterInds;
143 if (relatedClusters.
size() == 0) {
144 B2DEBUG(1,
"Found no related Clusters for SpacePoint " << spacePoint->
getArrayIndex() <<
" from Array " <<
146 throw ClusterNotFound();
147 }
else B2ASSERT(
"Too many clusters!", relatedClusters.
size() < 3);
149 for (
const ClusterType& cluster : relatedClusters) {
150 clusterInds.push_back(cluster.getArrayIndex());
151 B2DEBUG(60,
"Cluster " << cluster.getArrayIndex() <<
" from Array " << cluster.getArrayName() <<
" is related to SpacePoint " <<
158 void SPTC2GFTCConverterModule::initializeCounters()
160 m_SpacePointTCCtr = 0;
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).
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
Module for converting SpacePointTrackCands to genfit::SpacePointTrackCands.
Storage for (VXD) SpacePoint-based track candidates.
unsigned int getNHits() const
get the number of hits (space points) in the track candidate
int getPdgCode() const
get pdg code
int getMcTrackID() const
get the MC Track ID
const std::vector< const Belle2::SpacePoint * > & getHits() const
get hits (space points) of track candidate
const TMatrixDSym & getCovSeed() const
get the covariance matrix seed (6D).
const TVectorD & getStateSeed() const
get state seed as 6D vector
const std::vector< double > & getSortingParameters() const
get the sorting parameters
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Belle2::VXD::SensorInfoBase::SensorType getType() const
Return SensorType (PXD, SVD, ...) on which the SpacePoint lives.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
int getEntries() const
Get the number of objects in the array.
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.
Type-safe access to single objects in the data store.
Track candidate – seed values and indices.
void set6DSeedAndPdgCode(const TVectorD &state6D, const int pdgCode)
This function works the same as set6DSeed but instead of a charge hypothesis you can set a pdg code w...
void Print(const Option_t *="") const
Write the content of all private attributes to the terminal.
void setCovSeed(const TMatrixDSym &cov6D)
set the covariance matrix seed (6D).
void setMcTrackId(int i)
Set the MCT track id, for MC simulations.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.