Belle II Software  release-05-02-19
DATCONSVDSpacePoint.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Christian Wessel *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/geometry/B2Vector3.h>
14 #include <framework/datastore/RelationsObject.h>
15 #include <framework/logging/Logger.h>
16 
17 #include <vxd/geometry/GeoCache.h>
18 #include <vxd/geometry/SensorInfoBase.h>
19 
20 #include <svd/dataobjects/SVDCluster.h>
21 
22 #include <vxd/dataobjects/VxdID.h>
23 
24 #include <vector>
25 #include <string>
26 #include <utility> // std::pair
27 
28 namespace Belle2 {
43  class DATCONSVDSpacePoint: public RelationsObject {
44 
45  public:
46  //--- C'tors and D'tors -------------------------------------------------------------------------------------------
52  explicit DATCONSVDSpacePoint(std::vector<SVDCluster const*>& clusters,
53  VXD::SensorInfoBase const* aSensorInfo = nullptr);
54 
57  m_vxdID(0), m_sensorType(VXD::SensorInfoBase::SensorType::VXD) // type is set to generic VXD
58  {}
59 
68  DATCONSVDSpacePoint(B2Vector3<double>& pos, const std::pair<double, double>& normalizedLocal,
69  std::pair<bool, bool> clustersAssigned, VxdID sensorID, Belle2::VXD::SensorInfoBase::SensorType detID) :
70  m_position(pos),
71  m_normalizedLocal(normalizedLocal),
72  m_clustersAssigned(clustersAssigned),
73  m_vxdID(sensorID), m_sensorType(detID)
74  {}
75 
76  //-----------------------------------------------------------------------------------------------------------------
77 
79  friend std::ostream& operator<< (std::ostream& out, const DATCONSVDSpacePoint& aSP) { return out << aSP.getName();}
80 
87  bool operator == (const DATCONSVDSpacePoint& b) const
88  {
89  return getArrayIndex() == b.getArrayIndex();
90  }
91 
93  bool operator != (const DATCONSVDSpacePoint& b) const
94  {
95  return !(*this == b);
96  }
97 
98  //--- Global Coordinate Getters -----------------------------------------------------------------------------------
100  double X() const { return m_position.X(); }
101 
103  double Y() const { return m_position.Y(); }
104 
106  double Z() const { return m_position.Z(); }
107 
109  const B2Vector3<double>& getPosition() const { return m_position; }
110 
111  //---- Sensor Level Information Getters ---------------------------------------------------------------------------
114 
116  VxdID getVxdID() const { return m_vxdID; }
117 
119  double getNormalizedLocalU() const { return m_normalizedLocal.first; }
120 
122  double getNormalizedLocalV() const { return m_normalizedLocal.second; }
123  //-----------------------------------------------------------------------------------------------------------------
124 
130  std::pair<bool, bool> getIfClustersAssigned() const { return m_clustersAssigned; }
131 
133  unsigned short getNClustersAssigned() const
134  {
135  if (m_sensorType == VXD::SensorInfoBase::SensorType::SVD &&
136  m_clustersAssigned.first && m_clustersAssigned.second) {
137  return 2;
138  }
139  return 1;
140  }
141 
143  void setAssignmentState(bool isAssigned) const { m_isAssigned = isAssigned; }
144 
146  bool isUOnly() const { return m_clustersAssigned.first and not m_clustersAssigned.second; }
148  bool isVOnly() const { return not m_clustersAssigned.first and m_clustersAssigned.second; }
150  bool isUAndV() const { return m_clustersAssigned.first and m_clustersAssigned.second; }
151 
153  bool getAssignmentState() const { return m_isAssigned; }
154 
155 
156  // static converter functions:
157 
168  static B2Vector3<double> getGlobalCoordinates(const std::pair<double, double>& hitLocal, VxdID vxdID,
169  const VXD::SensorInfoBase* aSensorInfo = nullptr);
170 
181  static std::pair<double, double> convertLocalToNormalizedCoordinates(const std::pair<double, double>& hitLocal,
182  VxdID vxdID, const VXD::SensorInfoBase* aSensorInfo = nullptr);
183 
184 
192  static std::pair<double, double> convertNormalizedToLocalCoordinates(const std::pair<double, double>& hitNormalized,
193  Belle2::VxdID vxdID, const Belle2::VXD::SensorInfoBase* aSensorInfo = nullptr);
194 
195 
204  static double getUWedged(const std::pair<double, double>& hitLocalUnwedged, VxdID vxdID,
205  const VXD::SensorInfoBase* aSensorInfo = nullptr)
206  {
207  if (aSensorInfo == nullptr) { aSensorInfo = &VXD::GeoCache::getInstance().getSensorInfo(vxdID); }
208  return (aSensorInfo->getWidth(hitLocalUnwedged.second) / aSensorInfo->getWidth()) * hitLocalUnwedged.first;
209  }
210 
217  static double getUUnwedged(const std::pair<double, double>& hitLocalWedged, VxdID::baseType vxdID,
218  const VXD::SensorInfoBase* aSensorInfo = nullptr)
219  {
220  if (aSensorInfo == nullptr) { aSensorInfo = &VXD::GeoCache::getInstance().getSensorInfo(vxdID); }
221  return (aSensorInfo->getWidth() / aSensorInfo->getWidth(hitLocalWedged.second)) * hitLocalWedged.first;
222  }
223 
225  std::vector<SVDCluster> getAssignedDATCONSVDClusters() { return m_assignedDATCONSVDClusters; }
226 
236  static void boundaryEnforce(double& value, const double& otherValue, double lower = 0, double higher = 1, unsigned int side = 0,
237  VxdID vxdID = VxdID())
238  {
239  // Times to times there are normalized coordinates that are out of the boundaries.
240  // We do apply a smal sloppyness here
241 
242  double sloppyTerm = 1e-3;
243  if (value < lower - sloppyTerm) {
244  B2WARNING("DATCONSVDSpacePoint::boundaryEnforce: value had to be moved (lowerCheck)! old: " << value << ", new: " << lower);
245  B2WARNING("On sensor: " << vxdID << " side: " << (side == 0 ? " U " : " V") <<
246  " when the other coordinate is: " << otherValue);
247 
248  value = lower;
249  }
250  if (value > higher + sloppyTerm) {
251  B2WARNING("DATCONSVDSpacePoint::boundaryEnforce: value had to be moved (higherCheck)! old: " << value << ", new: " << higher);
252  B2WARNING("On sensor: " << vxdID << " side: " << (side == 0 ? " U " : " V") <<
253  " when the other coordinate is: " << otherValue);
254  value = higher;
255  }
256 
257  }
258  //---------------------------------------------------------------------------------------------------------------------
259 
260  protected:
261  //--- Member variables --------------------------------------------------------------------------------------------
266  B2Vector3<double> m_position;
267 
272  std::pair<double, double> m_normalizedLocal;
273 
279  std::pair<bool, bool> m_clustersAssigned {false, false};
280 
282  std::vector<SVDCluster> m_assignedDATCONSVDClusters;
283 
286 
293 
300  mutable bool m_isAssigned {false};
301 
302 
304  }; // end class
306 } // end namespace Belle2
Belle2::DATCONSVDSpacePoint::getPosition
const B2Vector3< double > & getPosition() const
return the position vector in global coordinates
Definition: DATCONSVDSpacePoint.h:117
Belle2::DATCONSVDSpacePoint
DATCONSVDSpacePoint typically is build from 1-2 DATCONSimpleSVDClusters.
Definition: DATCONSVDSpacePoint.h:51
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::VXD::SensorInfoBase::SensorType
SensorType
Enum specifing the type of sensor the SensorInfo represents.
Definition: SensorInfoBase.h:43
Belle2::DATCONSVDSpacePoint::getUUnwedged
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: DATCONSVDSpacePoint.h:225
Belle2::DATCONSVDSpacePoint::DATCONSVDSpacePoint
DATCONSVDSpacePoint()
Default constructor for the ROOT IO.
Definition: DATCONSVDSpacePoint.h:64
Belle2::DATCONSVDSpacePoint::getNClustersAssigned
unsigned short getNClustersAssigned() const
Returns the number of Clusters assigned to this DATCONSVDSpacePoint.
Definition: DATCONSVDSpacePoint.h:141
Belle2::DATCONSVDSpacePoint::getUWedged
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: DATCONSVDSpacePoint.h:212
Belle2::DATCONSVDSpacePoint::m_assignedDATCONSVDClusters
std::vector< SVDCluster > m_assignedDATCONSVDClusters
Vector containing the DATCONSVDClusters assigned to this DATCONSVDSpacePoint.
Definition: DATCONSVDSpacePoint.h:290
Belle2::RelationsInterface::ClassDef
ClassDef(RelationsInterface, 0)
defines interface for accessing relations of objects in StoreArray.
Belle2::DATCONSVDSpacePoint::boundaryEnforce
static void boundaryEnforce(double &value, const double &otherValue, double lower=0, double higher=1, unsigned int side=0, VxdID vxdID=VxdID())
Enforce.
Definition: DATCONSVDSpacePoint.h:244
Belle2::DATCONSVDSpacePoint::getGlobalCoordinates
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.
Definition: DATCONSVDSpacePoint.cc:130
Belle2::VXD::SensorInfoBase
Base class to provide Sensor Information for PXD and SVD.
Definition: SensorInfoBase.h:40
Belle2::B2Vector3::Z
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:434
Belle2::DATCONSVDSpacePoint::convertNormalizedToLocalCoordinates
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: DATCONSVDSpacePoint.cc:104
Belle2::B2Vector3< double >
Belle2::DATCONSVDSpacePoint::getVxdID
VxdID getVxdID() const
Return the VxdID of the sensor on which the the cluster of the DATCONSVDSpacePoint lives.
Definition: DATCONSVDSpacePoint.h:124
Belle2::DATCONSVDSpacePoint::Z
double Z() const
return the z-value of the global position of the DATCONSVDSpacePoint
Definition: DATCONSVDSpacePoint.h:114
Belle2::DATCONSVDSpacePoint::getNormalizedLocalV
double getNormalizedLocalV() const
Return normalized local coordinates of the cluster in v (0 <= posV <= 1).
Definition: DATCONSVDSpacePoint.h:130
Belle2::VxdID::baseType
unsigned short baseType
The base integer type for VxdID.
Definition: VxdID.h:46
Belle2::DATCONSVDSpacePoint::m_isAssigned
bool m_isAssigned
Stores whether this DATCONSVDSpacePoint is connected to a track.
Definition: DATCONSVDSpacePoint.h:308
Belle2::DATCONSVDSpacePoint::getNormalizedLocalU
double getNormalizedLocalU() const
Return normalized local coordinates of the cluster in u (0 <= posU <= 1).
Definition: DATCONSVDSpacePoint.h:127
Belle2::DATCONSVDSpacePoint::operator==
bool operator==(const DATCONSVDSpacePoint &b) const
Compare, if two DATCONSVDSpacePoints are the same one.
Definition: DATCONSVDSpacePoint.h:95
Belle2::DATCONSVDSpacePoint::operator<<
friend std::ostream & operator<<(std::ostream &out, const DATCONSVDSpacePoint &aSP)
overloaded '<<' stream operator.
Definition: DATCONSVDSpacePoint.h:87
Belle2::VXD::GeoCache::getInstance
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:215
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DATCONSVDSpacePoint::Y
double Y() const
return the y-value of the global position of the DATCONSVDSpacePoint
Definition: DATCONSVDSpacePoint.h:111
Belle2::DATCONSVDSpacePoint::isUOnly
bool isUOnly() const
Returns true if the SP is single clustered and the cluster is a u cluster.
Definition: DATCONSVDSpacePoint.h:154
Belle2::DATCONSVDSpacePoint::m_sensorType
VXD::SensorInfoBase::SensorType m_sensorType
Stores the SensorType using the scheme of SensorInfoBase.
Definition: DATCONSVDSpacePoint.h:300
Belle2::DATCONSVDSpacePoint::m_vxdID
VxdID::baseType m_vxdID
Stores the VxdID.
Definition: DATCONSVDSpacePoint.h:293
Belle2::DATCONSVDSpacePoint::m_normalizedLocal
std::pair< double, double > m_normalizedLocal
Local position vector normalized to sensor size (0 <= x <= 1).
Definition: DATCONSVDSpacePoint.h:280
Belle2::RelationsInterface::getArrayIndex
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
Definition: RelationsObject.h:387
Belle2::DATCONSVDSpacePoint::operator!=
bool operator!=(const DATCONSVDSpacePoint &b) const
Comparison for inequality with another DATCONSVDSpacePoint.
Definition: DATCONSVDSpacePoint.h:101
Belle2::DATCONSVDSpacePoint::convertLocalToNormalizedCoordinates
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: DATCONSVDSpacePoint.cc:75
Belle2::DATCONSVDSpacePoint::isVOnly
bool isVOnly() const
Returns true if the SP is single clustered and the cluster is a v cluster.
Definition: DATCONSVDSpacePoint.h:156
Belle2::RelationsObject
RelationsInterface< TObject > RelationsObject
Provides interface for getting/adding relations to objects in StoreArrays.
Definition: RelationsObject.h:443
Belle2::DATCONSVDSpacePoint::getIfClustersAssigned
std::pair< bool, bool > getIfClustersAssigned() const
Returns, if u(v)-coordinate is based on cluster information.
Definition: DATCONSVDSpacePoint.h:138
Belle2::VXD::GeoCache::getSensorInfo
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:68
Belle2::DATCONSVDSpacePoint::m_position
B2Vector3< double > m_position
Global position vector.
Definition: DATCONSVDSpacePoint.h:274
Belle2::DATCONSVDSpacePoint::X
double X() const
return the x-value of the global position of the DATCONSVDSpacePoint
Definition: DATCONSVDSpacePoint.h:108
Belle2::DATCONSVDSpacePoint::setAssignmentState
void setAssignmentState(bool isAssigned) const
Setter for association with a track.
Definition: DATCONSVDSpacePoint.h:151
Belle2::B2Vector3::X
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:430
Belle2::DATCONSVDSpacePoint::m_clustersAssigned
std::pair< bool, bool > m_clustersAssigned
The bool value is true, when correct information of the coordinate exists.
Definition: DATCONSVDSpacePoint.h:287
Belle2::DATCONSVDSpacePoint::getAssignmentState
bool getAssignmentState() const
Getter for status of assignment to a track.
Definition: DATCONSVDSpacePoint.h:161
Belle2::DATCONSVDSpacePoint::getType
Belle2::VXD::SensorInfoBase::SensorType getType() const
Return SensorType (PXD, SVD, ...) on which the DATCONSVDSpacePoint lives.
Definition: DATCONSVDSpacePoint.h:121
Belle2::B2Vector3::Y
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:432
Belle2::DATCONSVDSpacePoint::isUAndV
bool isUAndV() const
Returns true if the SP is not single clustered.
Definition: DATCONSVDSpacePoint.h:158
Belle2::DATCONSVDSpacePoint::getAssignedDATCONSVDClusters
std::vector< SVDCluster > getAssignedDATCONSVDClusters()
Getter function for the DATCONSVDClusters assigned to this DATCONSVDSpacePoint.
Definition: DATCONSVDSpacePoint.h:233