Belle II Software development
SpacePoint.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <framework/geometry/B2Vector3.h>
11#include <framework/datastore/RelationsObject.h>
12#include <framework/logging/Logger.h>
13
14#include <vxd/geometry/GeoCache.h>
15#include <vxd/geometry/SensorInfoBase.h>
16
17#include <pxd/dataobjects/PXDCluster.h>
18
19#include <svd/dataobjects/SVDCluster.h>
20
21#include <genfit/PlanarMeasurement.h>
22
23#include <vector>
24#include <string>
25#include <utility> // std::pair
26
27namespace Belle2 {
43
44 public:
45 //--- C'tors and D'tors -------------------------------------------------------------------------------------------
51 explicit SpacePoint(const PXDCluster* pxdCluster,
52 const VXD::SensorInfoBase* aSensorInfo = nullptr);
53
59 explicit SpacePoint(std::vector<SVDCluster const*>& clusters,
60 VXD::SensorInfoBase const* aSensorInfo = nullptr);
61
64 m_positionError(1., 1., 1.), //TODO: Describe Design Decision for not using the default (0.,0.,0.)
66 m_vxdID(0), m_sensorType(VXD::SensorInfoBase::SensorType::VXD) // type is set to generic VXD
67 {}
68
80 SpacePoint(const B2Vector3D& pos, const B2Vector3D& posError, std::pair<double, double> normalizedLocal,
81 std::pair<bool, bool> clustersAssigned, VxdID sensorID, Belle2::VXD::SensorInfoBase::SensorType detID,
82 double UClusterTime = 0., double VClusterTime = 0.) :
83 m_position(pos), m_positionError(posError),
84 m_normalizedLocal(normalizedLocal),
85 m_UClusterTime(UClusterTime), m_VClusterTime(VClusterTime),
86 m_clustersAssigned(clustersAssigned),
87 m_vxdID(sensorID), m_sensorType(detID)
88 {}
89
91 virtual ~SpacePoint() {}
92 //-----------------------------------------------------------------------------------------------------------------
93
95 friend std::ostream& operator<< (std::ostream& out, const SpacePoint& aSP) { return out << aSP.getName();}
96
103 bool operator == (const SpacePoint& b) const
104 {
105 return getArrayIndex() == b.getArrayIndex();
106 }
107
109 bool operator != (const SpacePoint& b) const
110 {
111 return !(*this == b);
112 }
113
115 std::string getName() const override
116 {
117 return "SpacePoint with index: " + std::to_string(getArrayIndex()) +
118 "and VxdID: " + std::to_string(VxdID(m_vxdID));
119 }
120
121 //--- Global Coordinate Getters -----------------------------------------------------------------------------------
123 double X() const { return m_position.X(); }
124
126 double Y() const { return m_position.Y(); }
127
129 double Z() const { return m_position.Z(); }
130
132 double TimeU() const { return m_UClusterTime; }
133
135 double TimeV() const { return m_VClusterTime; }
136
138 const B2Vector3D& getPosition() const { return m_position; }
139
141 const B2Vector3D& getPositionError() const { return m_positionError; }
142
143 //---- Sensor Level Information Getters ---------------------------------------------------------------------------
146
148 VxdID getVxdID() const { return m_vxdID; }
149
151 double getNormalizedLocalU() const { return m_normalizedLocal.first; }
152
154 double getNormalizedLocalV() const { return m_normalizedLocal.second; }
155 //-----------------------------------------------------------------------------------------------------------------
156
162 std::pair<bool, bool> getIfClustersAssigned() const { return m_clustersAssigned; }
163
165 unsigned short getNClustersAssigned() const
166 {
168 m_clustersAssigned.first && m_clustersAssigned.second) {
169 return 2;
170 }
171 return 1;
172 }
173
175 void setAssignmentState(bool isAssigned) const { m_isAssigned = isAssigned; }
176
178 bool isUOnly() const { return m_clustersAssigned.first and not m_clustersAssigned.second; }
180 bool isVOnly() const { return not m_clustersAssigned.first and m_clustersAssigned.second; }
182 bool isUAndV() const { return m_clustersAssigned.first and m_clustersAssigned.second; }
183
185 bool getAssignmentState() const { return m_isAssigned; }
186
188 void setQualityEstimation(float qualityIndicator) {m_qualityIndicator = qualityIndicator; }
189
191 float getQualityEstimation() const { return m_qualityIndicator; }
192
194 void setQualityEstimationError(double qualityIndicatorError) {m_qualityIndicatorError = qualityIndicatorError;}
195
198
199
200//---------------------------------------------------------------------------------------------------------------------
201//TODO: Some clarification, if the following conversions and especially the staticness of the functions below is needed
202//in the version 2 of the VXDTF.
211 virtual std::vector<genfit::PlanarMeasurement> getGenfitCompatible() const ;
212
213
214// static converter functions:
215
226 static B2Vector3D getGlobalCoordinates(const std::pair<double, double>& hitLocal, VxdID vxdID,
227 const VXD::SensorInfoBase* aSensorInfo = nullptr);
228
229
240 static std::pair<double, double> convertLocalToNormalizedCoordinates(const std::pair<double, double>& hitLocal,
241 VxdID vxdID, const VXD::SensorInfoBase* aSensorInfo = nullptr);
242
243
251 static std::pair<double, double> convertNormalizedToLocalCoordinates(const std::pair<double, double>& hitNormalized,
252 Belle2::VxdID vxdID, const Belle2::VXD::SensorInfoBase* aSensorInfo = nullptr);
253
254
263 static double getUWedged(const std::pair<double, double>& hitLocalUnwedged, VxdID vxdID,
264 const VXD::SensorInfoBase* aSensorInfo = nullptr)
265 {
266 if (aSensorInfo == nullptr) { aSensorInfo = &VXD::GeoCache::getInstance().getSensorInfo(vxdID); }
267 return (aSensorInfo->getWidth(hitLocalUnwedged.second) / aSensorInfo->getWidth()) * hitLocalUnwedged.first;
268 }
269
270
271
278 static double getUUnwedged(const std::pair<double, double>& hitLocalWedged, VxdID::baseType vxdID,
279 const VXD::SensorInfoBase* aSensorInfo = nullptr)
280 {
281 if (aSensorInfo == nullptr) { aSensorInfo = &VXD::GeoCache::getInstance().getSensorInfo(vxdID); }
282 return (aSensorInfo->getWidth() / aSensorInfo->getWidth(hitLocalWedged.second)) * hitLocalWedged.first;
283 }
284
285
286
296 static void boundaryEnforce(double& value, const double& otherValue, double lower = 0, double higher = 1, unsigned int side = 0,
297 VxdID vxdID = VxdID())
298 {
299 // Times to times there are normalized coordinates that are out of the boundaries.
300 // We do apply a small sloppiness here
301
302 double sloppyTerm = 1e-3;
303 if (value < lower - sloppyTerm) {
304 B2WARNING("SpacePoint::boundaryEnforce: value had to be moved (lowerCheck)! old: " << value << ", new: " << lower);
305 B2WARNING("On sensor: " << vxdID << " side: " << (side == 0 ? " U " : " V") <<
306 " when the other coordinate is: " << otherValue);
307
308 value = lower;
309 }
310 if (value > higher + sloppyTerm) {
311 B2WARNING("SpacePoint::boundaryEnforce: value had to be moved (higherCheck)! old: " << value << ", new: " << higher);
312 B2WARNING("On sensor: " << vxdID << " side: " << (side == 0 ? " U " : " V") <<
313 " when the other coordinate is: " << otherValue);
314 value = higher;
315 }
316
317 }
318//---------------------------------------------------------------------------------------------------------------------
319
320 protected:
322 void setPositionError(double uSigma, double vSigma, const VXD::SensorInfoBase* aSensorInfo)
323 {
324 //As only variances, but not the sigmas transform linearly, we need to use some acrobatics.
325 m_positionError = aSensorInfo->vectorToGlobal(ROOT::Math::XYZVector(uSigma * uSigma, vSigma * vSigma, 0),
326 true // use alignment in transformation
327 );
329 }
330
331 //--- Member variables --------------------------------------------------------------------------------------------
337
343
344
349 std::pair<double, double> m_normalizedLocal;
350
354
358
359
365 std::pair<bool, bool> m_clustersAssigned {false, false};
366
369
376
382
383
389
396 mutable bool m_isAssigned {false};
397
398 ClassDefOverride(SpacePoint, 13)
399 };
401}
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433
void Sqrt()
calculates the square root of the absolute values of the coordinates element-wise
Definition: B2Vector3.h:414
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
Defines interface for accessing relations of objects in StoreArray.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
bool isUOnly() const
Returns true if the SP is single clustered and the cluster is a u cluster.
Definition: SpacePoint.h:178
friend std::ostream & operator<<(std::ostream &out, const SpacePoint &aSP)
overloaded '<<' stream operator.
Definition: SpacePoint.h:95
virtual ~SpacePoint()
Currently SpacePoint is used as base class for test beam related TBSpacePoint.
Definition: SpacePoint.h:91
float getQualityEstimationError() const
Getter for the spacePoint quality index error.
Definition: SpacePoint.h:197
double m_VClusterTime
Time of the cluster on the V side in ns.
Definition: SpacePoint.h:357
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'].
Definition: SpacePoint.h:296
std::pair< bool, bool > m_clustersAssigned
The bool value is true, when correct information of the coordinate exists.
Definition: SpacePoint.h:365
VXD::SensorInfoBase::SensorType m_sensorType
Stores the SensorType using the scheme of SensorInfoBase.
Definition: SpacePoint.h:375
unsigned short getNClustersAssigned() const
Returns the number of Clusters assigned to this SpacePoint.
Definition: SpacePoint.h:165
std::string getName() const override
Print out some info for this SpacePoint.
Definition: SpacePoint.h:115
double m_UClusterTime
Time of the cluster on the U side in ns.
Definition: SpacePoint.h:353
double TimeV() const
return the time in ns of the cluster on the V side
Definition: SpacePoint.h:135
bool operator!=(const SpacePoint &b) const
Comparison for inequality with another SpacePoint.
Definition: SpacePoint.h:109
SpacePoint()
Default constructor for the ROOT IO.
Definition: SpacePoint.h:63
float getQualityEstimation() const
Getter for the quality of this SpacePoint.
Definition: SpacePoint.h:191
void setAssignmentState(bool isAssigned) const
Setter for association with a track.
Definition: SpacePoint.h:175
double getNormalizedLocalV() const
Return normalized local coordinates of the cluster in v (0 <= posV <= 1).
Definition: SpacePoint.h:154
std::pair< bool, bool > getIfClustersAssigned() const
Returns, if u(v)-coordinate is based on cluster information.
Definition: SpacePoint.h:162
void setQualityEstimation(float qualityIndicator)
Setter for the quality of this SpacePoint.
Definition: SpacePoint.h:188
bool isUAndV() const
Returns true if the SP is not single clustered.
Definition: SpacePoint.h:182
VxdID getVxdID() const
Return the VxdID of the sensor on which the the cluster of the SpacePoint lives.
Definition: SpacePoint.h:148
SpacePoint(const B2Vector3D &pos, const B2Vector3D &posError, std::pair< double, double > normalizedLocal, std::pair< bool, bool > clustersAssigned, VxdID sensorID, Belle2::VXD::SensorInfoBase::SensorType detID, double UClusterTime=0., double VClusterTime=0.)
Constructor for debugging or other special purposes.
Definition: SpacePoint.h:80
virtual std::vector< genfit::PlanarMeasurement > getGenfitCompatible() const
returns a vector of genfit::PlanarMeasurement, which is needed for genfit::track.
Definition: SpacePoint.cc:117
void setPositionError(double uSigma, double vSigma, const VXD::SensorInfoBase *aSensorInfo)
Setter for global position error from on-sensor sigmas.
Definition: SpacePoint.h:322
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.
Definition: SpacePoint.cc:149
B2Vector3D m_positionError
Global position error vector in sigma.
Definition: SpacePoint.h:342
const B2Vector3D & getPositionError() const
return the hitErrors in sigma of the global position
Definition: SpacePoint.h:141
VxdID::baseType m_vxdID
Stores the VxdID.
Definition: SpacePoint.h:368
bool getAssignmentState() const
Getter for status of assignment to a track.
Definition: SpacePoint.h:185
double TimeU() const
return the time in ns of the cluster on the U side
Definition: SpacePoint.h:132
Belle2::VXD::SensorInfoBase::SensorType getType() const
Return SensorType (PXD, SVD, ...) on which the SpacePoint lives.
Definition: SpacePoint.h:145
float m_qualityIndicator
Stores a quality indicator.
Definition: SpacePoint.h:381
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.
Definition: SpacePoint.cc:178
void setQualityEstimationError(double qualityIndicatorError)
Setter for the spacePoint quality index error.
Definition: SpacePoint.h:194
bool operator==(const SpacePoint &b) const
Compare, if two SpacePoints are the same one.
Definition: SpacePoint.h:103
const B2Vector3D & getPosition() const
return the position vector in global coordinates
Definition: SpacePoint.h:138
bool m_isAssigned
Stores whether this SpacePoint is connected to a track.
Definition: SpacePoint.h:396
bool isVOnly() const
Returns true if the SP is single clustered and the cluster is a v cluster.
Definition: SpacePoint.h:180
static double getUUnwedged(const std::pair< double, double > &hitLocalWedged, VxdID::baseType vxdID, const VXD::SensorInfoBase *aSensorInfo=nullptr)
takes a wedged uCoordinate, and transforms it to general uCoordinate.
Definition: SpacePoint.h:278
double Z() const
return the z-value of the global position of the SpacePoint
Definition: SpacePoint.h:129
std::pair< double, double > m_normalizedLocal
Local position vector normalized to sensor size (0 <= x <= 1).
Definition: SpacePoint.h:349
double X() const
return the x-value of the global position of the SpacePoint
Definition: SpacePoint.h:123
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.
Definition: SpacePoint.cc:204
double getNormalizedLocalU() const
Return normalized local coordinates of the cluster in u (0 <= posU <= 1).
Definition: SpacePoint.h:151
static double getUWedged(const std::pair< double, double > &hitLocalUnwedged, VxdID vxdID, const VXD::SensorInfoBase *aSensorInfo=nullptr)
takes a general uCoordinate, and transforms it to corrected uCoordinate for wedged sensors.
Definition: SpacePoint.h:263
float m_qualityIndicatorError
Stores the error on the quality indicator.
Definition: SpacePoint.h:388
double Y() const
return the y-value of the global position of the SpacePoint
Definition: SpacePoint.h:126
B2Vector3D m_position
Global position vector.
Definition: SpacePoint.h:336
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
Base class to provide Sensor Information for PXD and SVD.
SensorType
Enum specifing the type of sensor the SensorInfo represents.
ROOT::Math::XYZVector vectorToGlobal(const ROOT::Math::XYZVector &local, bool reco=false) const
Convert a vector from local to global coordinates.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
unsigned short baseType
The base integer type for VxdID.
Definition: VxdID.h:36
Abstract base class for different kinds of events.