9#include <tracking/modules/spacePointCreator/SPTC2GFTCConverterModule.h>
11#include <framework/dataobjects/EventMetaData.h>
12#include <framework/datastore/StoreObjPtr.h>
14#include <framework/gearbox/Const.h>
23 setDescription(
"Module for converting SpacePointTrackCand to genfit::TrackCand.");
26 addParam(
"SpacePointTCName",
m_SPTCName,
"Name of the container containing the SpacePointTrackCands to convert", std::string(
""));
27 addParam(
"genfitTCName",
m_genfitTCName,
"Name of the container of the (output) genfit::TrackCands", std::string(
""));
36 B2INFO(
"SPTC2GFTCConverter --------------- initialize() -------------------");
55 const int eventCounter = eventMetaData->getEvent();
56 B2DEBUG(20,
"SPTC2GFTCConverter::event() processing event " << eventCounter <<
" ----------");
61 for (
int iTC = 0; iTC < nSPTCs; ++iTC) {
65 genfit::TrackCand genfitTC;
66 B2DEBUG(20,
"SpacePointTrackCand " << iTC <<
" contains " << trackCand->
getNHits() <<
" SpacePoints");
68 std::vector<const SpacePoint*> tcSpacePoints = trackCand->
getHits();
72 for (
unsigned int iTCSP = 0; iTCSP < tcSpacePoints.size(); ++iTCSP) {
74 double sortingParam = sortingParams[iTCSP];
78 std::vector<int> clusterInds;
84 else throw SpacePointTrackCand::UnsupportedDetType();
86 }
catch (std::runtime_error& anE) {
87 B2WARNING(
"Caught exception during creation of a genfit::TrackCand: " << anE.what());
91 B2WARNING(
"Caught unknown exception during conversion from SPTC to GFTC!");
95 for (
int hitID : clusterInds) {
96 genfitTC.addHit(detID, hitID, -1, sortingParam);
97 B2DEBUG(29,
"Added Cluster " << hitID <<
" with detID " << detID <<
" to genfit::TrackCand");
109 B2DEBUG(22,
"genfit::TrackCand contains " << genfitTC.getNHits() <<
" TrackCandHits.");
112 B2DEBUG(22,
"Added relation between SPTC " << trackCand->
getArrayIndex() <<
" from Array " << trackCand->
getArrayName() <<
119 std::stringstream output;
121 " genfit::TrackCands";
123 B2INFO(output.str());
127template<
typename ClusterType>
130 std::vector<int> clusterInds;
133 if (relatedClusters.
size() == 0) {
134 B2DEBUG(20,
"Found no related Clusters for SpacePoint " << spacePoint->
getArrayIndex() <<
" from Array " <<
136 throw ClusterNotFound();
137 }
else B2ASSERT(
"Too many clusters!", relatedClusters.
size() < 3);
139 for (
const ClusterType& cluster : relatedClusters) {
140 clusterInds.push_back(cluster.getArrayIndex());
141 B2DEBUG(29,
"Cluster " << cluster.getArrayIndex() <<
" from Array " << cluster.getArrayName() <<
" is related to SpacePoint " <<
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
@ c_Debug
Debug: for code development.
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
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.
unsigned int m_skippedSPsCtr
Counter for SpacePoints that were not converted.
void initialize() override
initialize module
StoreArray< SpacePointTrackCand > m_SpacePointTrackCands
SpacePointTrackCands StoreArray.
std::string m_SVDClustersName
SVD Clusters collection name.
void event() override
event: convert SpacePointTrackCand to genfit::TrackCand
void terminate() override
terminate: some summary information on the processed events
unsigned int m_genfitTCCtr
Counter for genfit::TrackCands that were actually created by the module.
std::vector< int > getRelatedClusters(const Belle2::SpacePoint *spacePoint, const std::string &clusterNames="ALL")
get all related Clusters to a SpacePoint
std::string m_genfitTCName
genfit::TrackCand collection name
StoreArray< genfit::TrackCand > m_GenfitTrackCands
genfit::TrackCands StoreArray
std::string m_PXDClustersName
PXD Clusters collection name.
std::string m_SPTCName
SpacePointTrackCand collection name.
SPTC2GFTCConverterModule()
Constructor.
unsigned int m_SpacePointTCCtr
Counter for SpacePointTrackCands presented to the module.
void initializeCounters()
reset counters to 0 to avoid indeterministic behaviour
Storage for (VXD) SpacePoint-based track candidates.
const std::vector< double > & getSortingParameters() const
get the sorting parameters
unsigned int getNHits() const
get the number of hits (space points) in the track candidate
int getPdgCode() const
get pdg code
const TMatrixDSym & getCovSeed() const
get the covariance matrix seed (6D).
const std::vector< const Belle2::SpacePoint * > & getHits() const
get hits (space points) of track candidate
int getMcTrackID() const
get the MC Track ID
const TVectorD & getStateSeed() const
get state seed as 6D vector
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.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
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.
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.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.