9 #include <tracking/spacePointCreation/SpacePoint.h>
10 #include <vxd/dataobjects/VxdID.h>
11 #include <pxd/reconstruction/PXDRecoHit.h>
12 #include <svd/reconstruction/SVDRecoHit.h>
19 const VXD::SensorInfoBase* aSensorInfo) : m_clustersAssigned( {
true,
true}), m_vxdID(pxdCluster->getSensorID())
23 if (aSensorInfo ==
nullptr) {
28 m_position = aSensorInfo->
pointToGlobal(TVector3(pxdCluster->getU(), pxdCluster->getV(), 0),
true);
30 setPositionError(pxdCluster->getUSigma(), pxdCluster->getVSigma(), aSensorInfo);
32 m_normalizedLocal = convertLocalToNormalizedCoordinates({ pxdCluster->getU(), pxdCluster->getV() },
33 m_vxdID, aSensorInfo);
35 m_sensorType = aSensorInfo->getType();
45 B2ASSERT(
"You have to insert 1 or two SVD Clusters, but gave: " << clusters.size(), ((clusters.size() == 1)
46 || (clusters.size() == 2)));
49 for (
auto && cluster : clusters) {
50 B2ASSERT(
"An SVDCluster Pointer is a nullptr!", cluster !=
nullptr);
54 if (clusters.size() == 2) {
55 B2ASSERT(
"Clusters are on different Sensors.", clusters[0]->getSensorID() == clusters[1]->getSensorID());
56 B2ASSERT(
"Clusters are of same direction type.", clusters[0]->isUCluster() != clusters[1]->isUCluster());
60 m_vxdID = clusters[0]->getSensorID();
63 if (aSensorInfo ==
nullptr) {
75 const SVDCluster* vCluster(
nullptr), *uCluster(
nullptr);
77 if (aCluster->isUCluster() ==
true) {
79 uCoord = aCluster->getPosition();
80 uSigma = aCluster->getPositionSigma();
84 vCoord = aCluster->getPosition();
85 vSigma = aCluster->getPositionSigma();
91 vCluster !=
nullptr && uCluster !=
nullptr)
100 uSigma = aSensorInfo->
getUSize(vCoord) / sqrt(12.);
103 vSigma = aSensorInfo->
getVSize() / sqrt(12.);
110 if (aCluster->isUCluster() ==
true)
121 vector< genfit::PlanarMeasurement > collectedMeasurements;
125 if (
getType() == VXD::SensorInfoBase::SensorType::SVD) {
127 auto relatedClusters = this->getRelationsTo<SVDCluster>(
"ALL");
128 for (
unsigned i = 0; i < relatedClusters.size(); i++) {
129 collectedMeasurements.push_back(
SVDRecoHit(relatedClusters[i]));
132 }
else if (
getType() == VXD::SensorInfoBase::SensorType::PXD) {
135 auto relatedClusters = this->getRelationsTo<PXDCluster>(
"ALL");
136 for (
unsigned i = 0; i < relatedClusters.size(); i++) {
137 collectedMeasurements.push_back(
PXDRecoHit(relatedClusters[i]));
141 B2FATAL(
"unknown detector type");
144 B2DEBUG(50,
"SpacePoint::getGenfitCompatible(): collected " << collectedMeasurements.size() <<
" meaturements");
146 return collectedMeasurements;
151 const std::pair<double, double>& hitLocal,
VxdID vxdID,
156 if (aSensorInfo ==
nullptr) {
164 double sensorSizeU = aSensorInfo->
getUSize(hitLocal.second);
165 double sensorSizeV = aSensorInfo->
getVSize();
167 double normalizedUPosition = (hitLocal.first + 0.5 * sensorSizeU) /
169 double normalizedVPosition = (hitLocal.second + 0.5 * sensorSizeV) / sensorSizeV;
171 boundaryEnforce(normalizedUPosition, normalizedVPosition, 0, 1 , 0, vxdID);
172 boundaryEnforce(normalizedVPosition, normalizedUPosition, 0, 1, 1, vxdID);
174 return { normalizedUPosition, normalizedVPosition };
180 const std::pair<double, double>& hitNormalized,
VxdID vxdID,
185 if (aSensorInfo ==
nullptr) {
191 double localVPosition = (hitNormalized.second - 0.5) * aSensorInfo->
getVSize();
192 double uSizeAtHit = aSensorInfo->
getUSize(localVPosition);
193 double localUPosition = (hitNormalized.first - 0.5) * uSizeAtHit;
198 boundaryEnforce(localUPosition, localVPosition, -0.5 * uSizeAtHit, 0.5 * uSizeAtHit,
201 return { localUPosition, localVPosition };
209 if (aSensorInfo ==
nullptr) {
214 return aSensorInfo->
pointToGlobal(TVector3(hitLocal.first, hitLocal.second, 0),
true);
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
PXDRecoHit - an extended form of PXDCluster containing geometry information.
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
float getPosition(double v=0) const
Get the coordinate of reconstructed hit.
SVDRecoHit - an extended form of SVDHit containing geometry information.
double m_VClusterTime
Time of the cluster on the V side in ns.
static void boundaryEnforce(double &value, const double &otherValue, double lower=0, double higher=1, unsigned int side=0, VxdID vxdID=VxdID())
Enforce 'value' in the range ['lower', 'higher'].
std::pair< bool, bool > m_clustersAssigned
The bool value is true, when correct information of the coordinate exists.
VXD::SensorInfoBase::SensorType m_sensorType
Stores the SensorType using the scheme of SensorInfoBase.
B2Vector3< double > m_position
Global position vector.
double m_UClusterTime
Time of the cluster on the U side in ns.
SpacePoint()
Default constructor for the ROOT IO.
void setPositionError(double uSigma, double vSigma, const VXD::SensorInfoBase *aSensorInfo)
Setter for global position error from on-sensor sigmas.
static std::pair< double, double > convertLocalToNormalizedCoordinates(const std::pair< double, double > &hitLocal, VxdID vxdID, const VXD::SensorInfoBase *aSensorInfo=nullptr)
converts a local hit into sensor-independent relative coordinates.
VxdID::baseType m_vxdID
Stores the VxdID.
Belle2::VXD::SensorInfoBase::SensorType getType() const
Return SensorType (PXD, SVD, ...) on which the SpacePoint lives.
static std::pair< double, double > convertNormalizedToLocalCoordinates(const std::pair< double, double > &hitNormalized, Belle2::VxdID vxdID, const Belle2::VXD::SensorInfoBase *aSensorInfo=nullptr)
converts a hit in sensor-independent relative coordinates into local coordinate of given sensor.
static B2Vector3< double > getGlobalCoordinates(const std::pair< double, double > &hitLocal, VxdID vxdID, const VXD::SensorInfoBase *aSensorInfo=nullptr)
converts a local hit on a given sensor into global coordinates.
virtual std::vector< genfit::PlanarMeasurement > getGenfitCompatible() const
returns a vector of genfit::PlanarMeasurement, which is needed for genfit::track.
std::pair< double, double > m_normalizedLocal
Local position vector normalized to sensor size (0 <= x <= 1).
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Base class to provide Sensor Information for PXD and SVD.
double getVSize() const
Return the length of the sensor.
SensorType getType() const
Return the Type of the Sensor.
double getForwardWidth() const
Convinience Wrapper to return width at forward side.
double getBackwardWidth() const
Convinience Wrapper to return width at backward side.
TVector3 pointToGlobal(const TVector3 &local, bool reco=false) const
Convert a point from local to global coordinates.
double getUSize(double v=0) const
Return the width of the sensor.
Class to uniquely identify a any structure of the PXD and SVD.
Abstract base class for different kinds of events.