9#include <tracking/spacePointCreation/SpacePoint.h>
10#include <vxd/dataobjects/VxdID.h>
11#include <pxd/reconstruction/PXDRecoHit.h>
12#include <svd/reconstruction/SVDRecoHit.h>
18 const VXD::SensorInfoBase* aSensorInfo) : m_clustersAssigned({
true,
true}), m_vxdID(pxdCluster->getSensorID())
22 if (aSensorInfo ==
nullptr) {
27 m_position = aSensorInfo->
pointToGlobal(ROOT::Math::XYZVector(pxdCluster->getU(), pxdCluster->getV(), 0),
true);
29 setPositionError(pxdCluster->getUSigma(), pxdCluster->getVSigma(), aSensorInfo);
31 m_normalizedLocal = convertLocalToNormalizedCoordinates({ pxdCluster->getU(), pxdCluster->getV() },
32 m_vxdID, aSensorInfo);
34 m_sensorType = aSensorInfo->getType();
44 B2ASSERT(
"You have to insert 1 or two SVD Clusters, but gave: " << clusters.size(), ((clusters.size() == 1)
45 || (clusters.size() == 2)));
48 for (
auto&& cluster : clusters) {
49 B2ASSERT(
"An SVDCluster Pointer is a nullptr!", cluster !=
nullptr);
53 if (clusters.size() == 2) {
54 B2ASSERT(
"Clusters are on different Sensors.", clusters[0]->getSensorID() == clusters[1]->getSensorID());
55 B2ASSERT(
"Clusters are of same direction type.", clusters[0]->isUCluster() != clusters[1]->isUCluster());
59 m_vxdID = clusters[0]->getSensorID();
62 if (aSensorInfo ==
nullptr) {
74 const SVDCluster* vCluster(
nullptr), *uCluster(
nullptr);
76 if (aCluster->isUCluster() ==
true) {
78 uCoord = aCluster->getPosition();
79 uSigma = aCluster->getPositionSigma();
83 vCoord = aCluster->getPosition();
84 vSigma = aCluster->getPositionSigma();
90 vCluster !=
nullptr && uCluster !=
nullptr)
109 if (aCluster->isUCluster() ==
true)
120 std::vector< genfit::PlanarMeasurement > collectedMeasurements;
126 auto relatedClusters = this->getRelationsTo<SVDCluster>(
"ALL");
127 for (
unsigned i = 0; i < relatedClusters.size(); i++) {
128 collectedMeasurements.push_back(
SVDRecoHit(relatedClusters[i]));
134 auto relatedClusters = this->getRelationsTo<PXDCluster>(
"ALL");
135 for (
unsigned i = 0; i < relatedClusters.size(); i++) {
136 collectedMeasurements.push_back(
PXDRecoHit(relatedClusters[i]));
140 B2FATAL(
"unknown detector type");
143 B2DEBUG(20,
"SpacePoint::getGenfitCompatible(): collected " << collectedMeasurements.size() <<
" meaturements");
145 return collectedMeasurements;
150 const std::pair<double, double>& hitLocal,
VxdID vxdID,
155 if (aSensorInfo ==
nullptr) {
163 double sensorSizeU = aSensorInfo->
getUSize(hitLocal.second);
164 double sensorSizeV = aSensorInfo->
getVSize();
166 double normalizedUPosition = (hitLocal.first + 0.5 * sensorSizeU) /
168 double normalizedVPosition = (hitLocal.second + 0.5 * sensorSizeV) / sensorSizeV;
170 boundaryEnforce(normalizedUPosition, normalizedVPosition, 0, 1, 0, vxdID);
171 boundaryEnforce(normalizedVPosition, normalizedUPosition, 0, 1, 1, vxdID);
173 return { normalizedUPosition, normalizedVPosition };
179 const std::pair<double, double>& hitNormalized,
VxdID vxdID,
184 if (aSensorInfo ==
nullptr) {
190 double localVPosition = (hitNormalized.second - 0.5) * aSensorInfo->
getVSize();
191 double uSizeAtHit = aSensorInfo->
getUSize(localVPosition);
192 double localUPosition = (hitNormalized.first - 0.5) * uSizeAtHit;
197 boundaryEnforce(localUPosition, localVPosition, -0.5 * uSizeAtHit, 0.5 * uSizeAtHit,
200 return { localUPosition, localVPosition };
208 if (aSensorInfo ==
nullptr) {
213 return aSensorInfo->
pointToGlobal(ROOT::Math::XYZVector(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.
double m_UClusterTime
Time of the cluster on the U side in ns.
SpacePoint()
Default constructor for the ROOT IO.
virtual std::vector< genfit::PlanarMeasurement > getGenfitCompatible() const
returns a vector of genfit::PlanarMeasurement, which is needed for genfit::track.
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.
std::pair< double, double > m_normalizedLocal
Local position vector normalized to sensor size (0 <= x <= 1).
static B2Vector3D 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.
B2Vector3D m_position
Global position vector.
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.
ROOT::Math::XYZVector pointToGlobal(const ROOT::Math::XYZVector &local, bool reco=false) const
Convert a point from local to global coordinates.
double getForwardWidth() const
Convinience Wrapper to return width at forward side.
double getBackwardWidth() const
Convinience Wrapper to return width at backward side.
double getUSize(double v=0) const
Return the width of the sensor.
Class to uniquely identify a any structure of the PXD and SVD.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.