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