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