Belle II Software  release-08-01-10
ToPXDExtrapolator.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 #include <tracking/datcon/findlets/ToPXDExtrapolator.h>
9 #include <tracking/datcon/utilities/DATCONHelpers.h>
10 #include <tracking/dataobjects/PXDIntercept.h>
11 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
12 #include <pxd/geometry/SensorInfo.h>
13 #include <vxd/dataobjects/VxdID.h>
14 #include <vxd/geometry/GeoCache.h>
15 #include <framework/gearbox/Unit.h>
16 #include <framework/core/ModuleParamList.h>
17 #include <framework/core/ModuleParamList.templateDetails.h>
18 
19 using namespace Belle2;
20 using namespace TrackFindingCDC;
21 
23 {
24 }
25 
26 void ToPXDExtrapolator::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
27 {
28  Super::exposeParameters(moduleParamList, prefix);
29 
30  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "extrapolationPhiCutL1"), m_param_phiCutL1,
31  "Only extrapolate to PXD sensors within this value away from the track phi value, L1.",
33 
34  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "extrapolationPhiCutL2"), m_param_phiCutL2,
35  "Only extrapolate to PXD sensors within this value away from the track phi value, L2.",
37 
38  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "createPXDIntercepts"), m_param_createPXDIntercepts,
39  "Store PXDIntercepts to StoreArray?", m_param_createPXDIntercepts);
40 
41  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "storePXDInterceptsName"), m_param_PXDInterceptStoreArrayName,
42  "Name of the PXDIntercepts StoreArray?", m_param_PXDInterceptStoreArrayName);
43 
44 }
45 
47 {
49 
52  }
53 
54 }
55 
56 void ToPXDExtrapolator::apply(const std::vector<std::pair<double, double>>& uTracks,
57  const std::vector<std::pair<double, double>>& vTracks,
58  std::vector<std::pair<VxdID, long>>& uExtrapolations, std::vector<std::pair<VxdID, long>>& vExtrapolations)
59 {
60  VxdID sensorID;
61 
62  for (auto& uTrack : uTracks) {
63  const double trackPhi = uTrack.first;
64  const double trackRadius = uTrack.second;
65 
66  extrapolateUTrack(trackPhi, trackRadius, 1, uExtrapolations);
67  extrapolateUTrack(trackPhi, trackRadius, 2, uExtrapolations);
68  }
69 
70  for (auto& vTrack : vTracks) {
71  const double& trackLambda = -vTrack.first;
72  const long tanLambda = convertFloatToInt(tan(trackLambda), 3);
73 
74  extrapolateVTrack(tanLambda, 1, vExtrapolations);
75  extrapolateVTrack(tanLambda, 2, vExtrapolations);
76  }
77 
79  for (auto& uExtrapolatedHit : uExtrapolations) {
80  const VxdID& uHitSensorID = uExtrapolatedHit.first;
81 
82  for (auto& vExtrapolatedHit : vExtrapolations) {
83  const VxdID& vHitSensorID = vExtrapolatedHit.first;
84 
85  if (uHitSensorID != vHitSensorID) {
86  continue;
87  }
88 
89  // convert back from nm to cm
90  double uCoordinateInCM = uExtrapolatedHit.second * Unit::nm;
91  double vCoordinateInCM = vExtrapolatedHit.second * Unit::nm;
92 
93  PXDIntercept intercept;
94  intercept.setCoorU(uCoordinateInCM);
95  intercept.setCoorV(vCoordinateInCM);
96  intercept.setVxdID(uHitSensorID);
97  m_pxdIntercepts.appendNew(intercept);
98  }
99  }
100  }
101 
102  B2DEBUG(29, "uExtrapolations.size: " << uExtrapolations.size() << " vExtrapolations.size: " << vExtrapolations.size());
103 }
104 
105 void ToPXDExtrapolator::extrapolateUTrack(const double trackPhi, const double trackRadius, const uint layer,
106  std::vector<std::pair<VxdID, long>>& uExtrapolations)
107 {
108  long sensorPerpRadius = layerRadius[layer - 1];
109  for (uint ladder = 1; ladder <= laddersPerLayer[layer - 1]; ladder++) {
110  double sensorPhi = M_PI / (laddersPerLayer[layer - 1] / 2) * (ladder - 1);
111  if (sensorPhi > M_PI) {
112  sensorPhi -= 2. * M_PI;
113  }
114 
115  double angleDiff = trackPhi - sensorPhi;
116  if (angleDiff > M_PI) {
117  angleDiff -= 2. * M_PI;
118  }
119  if (angleDiff < -M_PI) {
120  angleDiff += 2. * M_PI;
121  }
122  if (fabs(angleDiff) >= (layer == 1 ? m_param_phiCutL1 : m_param_phiCutL2)) continue;
123 
124  // additional factor of 10^3, as the sine and cosine values are also multiplied by 1000
125  long trackRadiusSquared = convertFloatToInt(trackRadius, 3) * convertFloatToInt(trackRadius, 3);
126  // additional factor of 10^3, as the sine and cosine values are also multiplied by 1000
127  long b = convertFloatToInt(sensorPerpRadius, 3) - trackRadius * convertFloatToInt(sin(angleDiff), 3);
128  double y = -trackRadius * convertFloatToInt(cos(angleDiff), 3) + sqrt(trackRadiusSquared - b * b);
129 
130  if (y >= sensorMinY && y <= sensorMaxY) {
131  long localUPosition = y - shiftY;
132 
133  // store extrapolated hit for first sensor in ladder
134  VxdID sensorID = VxdID(layer, ladder, 1);
135  uExtrapolations.emplace_back(sensorID, localUPosition);
136 
137  // store extrapolated hit for second sensor in ladder
138  sensorID = VxdID(layer, ladder, 2);
139  uExtrapolations.emplace_back(sensorID, localUPosition);
140  }
141  }
142 }
143 
144 void ToPXDExtrapolator::extrapolateVTrack(const long tanLambda, const uint layer,
145  std::vector<std::pair<VxdID, long>>& vExtrapolations)
146 {
147  for (uint sensor = 1; sensor <= 2; sensor++) {
148  const long& sensorPerpRadius = layerRadius[layer - 1];
149  const long& lengthOfSensor = sensorLength[layer - 1];
150  const long& shiftZ = (layer == 1 ? centerZShiftLayer1[sensor - 1] : centerZShiftLayer2[sensor - 1]);
151  // sensorPerpRadius is in µm, inverseTanTheta is multiplied by 1000, so this is basically nm
152  const long globalz = sensorPerpRadius * tanLambda;
153  // shift globalz into local coordinate system by subtracting the z-shift of this sensor
154  const long localVPosition = globalz - shiftZ;
155  if (localVPosition >= -lengthOfSensor / 2. && localVPosition <= lengthOfSensor / 2.) {
156 
157  for (uint ladder = 1; ladder <= laddersPerLayer[layer - 1]; ladder++) {
158  VxdID sensorID = VxdID(layer, ladder, sensor);
159  vExtrapolations.emplace_back(sensorID, localVPosition);
160  }
161  }
162  }
163 }
The Module parameter list class.
PXDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an PXD ...
Definition: PXDIntercept.h:22
const long layerRadius[2]
radius of L1 and L2, in µm
const long sensorMinY
minimum y coordinate for a ladder in the position of ladder 1 (perpendicular to the x-axis),...
ToPXDExtrapolator()
Find intercepts in the 2D Hough space.
const long sensorLength[2]
length of the modules flr L1 and L2, in µm
void initialize() override
Create the store arrays.
StoreArray< PXDIntercept > m_pxdIntercepts
PXDIntercept StoreArray.
double m_param_phiCutL1
Create ROIs in phi only if the absolute difference in phi between sensor and track is smaller than th...
void extrapolateUTrack(const double trackPhi, const double trackRadius, const uint layer, std::vector< std::pair< VxdID, long >> &uExtrapolations)
extrapolate the u-track to the two PXD layers
void extrapolateVTrack(const long tanLambda, const uint layer, std::vector< std::pair< VxdID, long >> &vExtrapolations)
extrapolate the v-track to the two PXD layers
double m_param_phiCutL2
Create ROIs in phi only if the absolute difference in phi between sensor and track is smaller than th...
const long sensorMaxY
maximum y coordinate for a ladder in the position of ladder 1 (perpendicular to the x-axis),...
const long centerZShiftLayer1[2]
shift of the sensor center along z for L1, in µm for use of mhp_z > (lengh/-2)+shiftZ && mhp_z < (len...
const long centerZShiftLayer2[2]
shift of the sensor center along z for L2, in µm for use of mhp_z > (lengh/-2)+shiftZ && mhp_z < (len...
bool m_param_createPXDIntercepts
Create PXDIntercepts?
const long shiftY
shift of the sensor center in r-phi
std::string m_param_PXDInterceptStoreArrayName
name of the PXDIntercept StoreArray
const uint laddersPerLayer[2]
number of ladders per layer
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
void apply(const std::vector< std::pair< double, double >> &uTracks, const std::vector< std::pair< double, double >> &vTracks, std::vector< std::pair< VxdID, long >> &uExtrapolations, std::vector< std::pair< VxdID, long >> &vExtrapolations) override
Load in the prepared hits and create tracks for extrapolation to PXD.
void initialize() override
Receive and dispatch signal before the start of the event processing.
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Forward prefixed parameters of this findlet to the module parameter list.
Definition: Findlet.h:69
static const double nm
[nanometers]
Definition: Unit.h:72
void setVxdID(VxdID::baseType user_vxdID)
set the sensor ID
Definition: VXDIntercept.h:75
void setCoorU(double user_coorU)
set the U coordinate of the intercept
Definition: VXDIntercept.h:68
void setCoorV(double user_coorV)
set the V coordinate of the intercept
Definition: VXDIntercept.h:69
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
double tan(double a)
tan for double
Definition: beamHelpers.h:31
long convertFloatToInt(double value, int power)
Convert float or double to long int for more similarity to the FPGA implementation.
Definition: DATCONHelpers.h:21
Abstract base class for different kinds of events.