Belle II Software  release-06-00-14
ROIDetPlane.cc
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 
9 #include <tracking/pxdDataReductionClasses/ROIDetPlane.h>
10 
11 #include <vxd/geometry/GeoCache.h>
12 #include <vxd/geometry/SensorInfoBase.h>
13 #include <framework/logging/Logger.h>
14 
15 using namespace Belle2;
16 using namespace std;
17 
18 
19 ROIDetPlane::ROIDetPlane(const VxdID& vxdID) : ROIDetPlane(vxdID, 10.0, 0.4999999 * M_PI)
20 {
21 }
22 
23 
24 ROIDetPlane::ROIDetPlane(const VxdID& vxdID, double toleranceZ, double tolerancePhi)
25  : m_vxdID(vxdID), m_orthoVec_upper(0, 0, 0), m_orthoVec_lower(0, 0, 0)
26 {
27 
29  m_vxdID);
31  TVector3 local(0, 0, 0);
32  TVector3 uVector(1, 0, 0);
33  TVector3 vVector(0, 1, 0);
34 
35  TVector3 globalSensorPos = aSensorInfo.pointToGlobal(local, true);
36  TVector3 globaluVector = aSensorInfo.vectorToGlobal(uVector, true);
37  TVector3 globalvVector = aSensorInfo.vectorToGlobal(vVector, true);
38 
39  setO(globalSensorPos);
40 
41  setUV(globaluVector, globalvVector);
42 
43 
44  // the maximum distance in u-direction for hit to be considered to lie on the sensor (for wedge take the maximum width)
45  double maxDistU = std::max(aSensorInfo.getForwardWidth(), aSensorInfo.getBackwardWidth()) / 2.0;
46 
47  // translate the phi-tolerance into a tolerance in u, NOTE: this is only approximate as it uses the center and not the edge of the sensor.
48  if (tolerancePhi >= 0 && tolerancePhi < M_PI / 2.0) {
49  maxDistU += fabs(std::tan(tolerancePhi) * globalSensorPos.Perp());
50  } else {
51  B2WARNING("No valid value for the phi tolerance given! Will use 0 tolerance!" << LogVar("tolerance phi", tolerancePhi));
52  }
53 
54 
55  // get points at upper and lower edge of the sensor
56  TVector3 edgepoint_upper = globalSensorPos + maxDistU * globaluVector;
57  TVector3 edgepoint_lower = globalSensorPos - maxDistU * globaluVector;
58  /* Get the orthogonal vectors, no need to normalize as we only test for the sign.
59  These two vectors are defined so that they are orthogonal to the plane spanned by the z-axis and the vector going from
60  the origin to the upper/lower edge of the sensor (global coordinates).*/
61  m_orthoVec_upper = TVector3(0, 0, 1).Cross(edgepoint_upper);
62  m_orthoVec_lower = TVector3(0, 0, 1).Cross(edgepoint_lower);
63 
64  //setting acceptance in z for the sensor
65  TVector3 minVecV(0, -aSensorInfo.getVSize() / 2.0, 0);
66  TVector3 maxVecV(0, aSensorInfo.getVSize() / 2.0, 0);
67  m_sensorZMin = aSensorInfo.pointToGlobal(minVecV, true).Z() - toleranceZ;
68  m_sensorZMax = aSensorInfo.pointToGlobal(maxVecV, true).Z() + toleranceZ;
69 
70  m_layer = (aSensorInfo.getID()).getLayerNumber();
71 }
72 
73 
74 bool ROIDetPlane::isSensorInRange(const TVector3& trackPosition, int layer)
75 {
76  // check for correct layer
77  if (layer != m_layer)
78  return false;
79 
80  double trackZ = trackPosition.Z();
81  // check whether genfit track is in z range
82  if (m_sensorZMin > trackZ || m_sensorZMax < trackZ) {
83  return false;
84  }
85 
86  /* Positions on the sensor have to lie between the planes that go through the upper edge of the sensor
87  and the lower edge of the senor (all w.r.t. the origin 0,0,0, and in r-phi-direction). That means for vectors pointing to the sensor
88  it has to be "below" (w.r.t. the plane) the plane going through the upper edge defined by its
89  orthogonal vector m_orthoVec_upper and
90  the origin (which means the dot product of m_orthoVec_upper and the position is smaller 0) and "above" the lower plane
91  defined by its orthogonal vector m_orthoVec_lower vector and the origin (which means the dot product with m_orthoVec_lower
92  is greater 0) */
93  if (trackPosition.Dot(m_orthoVec_upper) > 0 || trackPosition.Dot(m_orthoVec_lower) < 0) {
94  return false;
95  }
96 
97  // fullfilled all conditions
98  return true;
99 }
ROIDetPlane describes the plane containing a sensor.
Definition: ROIDetPlane.h:26
double m_sensorZMax
max of allowed global z range
Definition: ROIDetPlane.h:58
TVector3 m_orthoVec_lower
vector normal to the vector from 0,0,0 to a point on the lower edge of the sensor in x-y-plane
Definition: ROIDetPlane.h:55
bool isSensorInRange(const TVector3 &trackPosition, int layer)
determine if the sensor is in range
Definition: ROIDetPlane.cc:74
double m_sensorZMin
min of allowed global z range
Definition: ROIDetPlane.h:57
TVector3 m_orthoVec_upper
these two vectors define the planes going through the upper and lower edge of the sensor
Definition: ROIDetPlane.h:54
VxdID m_vxdID
the sensor ID
Definition: ROIDetPlane.h:48
int m_layer
layer number
Definition: ROIDetPlane.h:60
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:66
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:213
Base class to provide Sensor Information for PXD and SVD.
double getVSize() const
Return the length of the sensor.
double getForwardWidth() const
Convinience Wrapper to return width at forward side.
VxdID getID() const
Return the ID of the Sensor.
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.
TVector3 vectorToGlobal(const TVector3 &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
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.