Belle II Software  release-05-02-19
DATCONPXDExtrapolationModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Michael Schnell, Christian Wessel *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <tracking/modules/DATCON/DATCONPXDExtrapolationModule.h>
12 
13 using namespace std;
14 using namespace Belle2;
15 
16 //-----------------------------------------------------------------
17 // Register the Module
18 //-----------------------------------------------------------------
19 REG_MODULE(DATCONPXDExtrapolation)
20 
21 //-----------------------------------------------------------------
22 // Implementation
23 //-----------------------------------------------------------------
24 
26 {
27  //Set module properties
28  setDescription("DATCONPXDExtrapolationModule: Extrapolates the tracks found by "
29  "the DATCONTrackingModule to the PXD and stores the extrapolated "
30  "hits (called Most Probable Hit, MPH) as PXDIntercept.");
31  setPropertyFlags(c_ParallelProcessingCertified);
32 
33  addParam("DATCONTracks", m_storeDATCONTracksName,
34  "Name of the DATCONTrack StoreArray", string(""));
35  addParam("DATCONPXDIntercepts", m_storeDATCONPXDInterceptsName,
36  "Name of the DATCONPXDIntercepts StoreArray", string("DATCONPXDIntercepts"));
37  addParam("DATCONMPHs", m_storeDATCONMPHName,
38  "Name of the DATCONMPH StoreArray", string(""));
39 
40 
41 }
42 
43 
44 void DATCONPXDExtrapolationModule::initialize()
45 {
46 
47  storeDATCONTracks.isRequired(m_storeDATCONTracksName);
48  m_storeDATCONTracksName = storeDATCONTracks.getName();
49 
50  storeDATCONPXDIntercepts.registerInDataStore(m_storeDATCONPXDInterceptsName);
51  m_storeDATCONPXDInterceptsName = storeDATCONPXDIntercepts.getName();
52 
53  storeDATCONMPHs.registerInDataStore(m_storeDATCONMPHName);
54  m_storeDATCONMPHName = storeDATCONMPHs.getName();
55 
56 
57 }
58 
59 
60 void
61 DATCONPXDExtrapolationModule::event()
62 {
63  const double centerZShiftLayer1[2] = {3.68255, -0.88255}; // for use of mhp_z > (lengh/-2)+shiftZ && mhp_z < (lengh/2)+shiftZ // ATTENTION: hard coded values taken and derived from pxd/data/PXD-Components.xml
64  const double centerZShiftLayer2[2] = {5.01455, -1.21455}; // for use of mhp_z > (lengh/-2)+shiftZ && mhp_z < (lengh/2)+shiftZ // ATTENTION: hard coded values taken and derived from pxd/data/PXD-Components.xml
65  const double sensorMinY = -0.36; // ATTENTION: hard coded values taken and derived from pxd/data/PXD-Components.xml
66  const double sensorMaxY = 0.89; // ATTENTION: hard coded values taken and derived from pxd/data/PXD-Components.xml
67  const double shiftY = (sensorMaxY + sensorMinY) / 2.0;
68  const double layerRadius[2] = {1.42854, 2.21218}; // ATTENTION: hard coded values from pxd/data/PXD-Components.xml
69  const double sensorLength[2] = {4.48, 6.144};
70 
71  for (auto& track : storeDATCONTracks) {
72  double trackPhi = track.getTrackPhi();
73  double trackTheta = track.getTrackTheta();
74  double trackCurvsign = track.getTrackCurvature();
75 
76  double trackRadius = trackCurvsign * fabs(track.getTrackRadius());
77 
78  /* Determine qualityOfHit */
79  double qualityOfHit = 1.0 / fabs(trackRadius);
80 
82  for (int layer = 1; layer <= 2; layer++) {
84  for (int ladder = 1; ladder <= (layer == 1 ? 8 : 12); ladder++) {
86  for (int sensor = 1; sensor <= 2; sensor++) {
87 
88  double a, b, cp;
89  double shiftZ;
90  double sensorPhi;
91  TVector2 mostProbableHitLocal(0, 0);
92 
93  VxdID sensorID = VxdID(layer, ladder, sensor);
94 
95  double sensorPerpRadius = layerRadius[layer - 1];
96 
97  double x = std::numeric_limits<double>::max();
98  double y = std::numeric_limits<double>::max();
99 
100  if (layer == 1) {
101  sensorPhi = M_PI / 4. * (ladder - 1);
102  shiftZ = centerZShiftLayer1[sensor - 1];
103  } else {
104  sensorPhi = M_PI / 6. * (ladder - 1);
105  shiftZ = centerZShiftLayer2[sensor - 1];
106  }
107 
108  double angleDiff = trackPhi - sensorPhi;
109  if (angleDiff > M_PI) {
110  angleDiff -= 2 * M_PI;
111  }
112  if (angleDiff < -M_PI) {
113  angleDiff += 2 * M_PI;
114  }
115 
116  if (trackCurvsign == +1 /* =negative charge */ && fabs(trackRadius) < 1) {
117  a = sensorPerpRadius + fabs(trackRadius) * sin(angleDiff);
118  b = fabs(trackRadius * trackRadius - a * a);
119  cp = trackRadius * cos(angleDiff) + sqrt(b);
120  x = sensorPerpRadius;
121  y = cp;
122  } else if (trackCurvsign == -1 /* positive charge */ && fabs(trackRadius) < 1) {
123  a = sensorPerpRadius - fabs(trackRadius) * sin(angleDiff);
124  b = fabs(trackRadius * trackRadius - a * a);
125  cp = trackRadius * cos(angleDiff) + sqrt(b);
126  x = sensorPerpRadius;
127  y = cp;
128  } else if (trackCurvsign == 0 /* assume straight line */ || fabs(trackRadius) >= 1) {
129  x = sensorPerpRadius;
130  y = sensorPerpRadius * tan(angleDiff);
131  }
132 
133  double z;
134  if (trackTheta < (M_PI / 2.0)) {
135  z = sqrt(x * x + y * y) / tan(trackTheta);
136  } else if (trackTheta > (M_PI / 2.0)) {
137  z = sqrt(x * x + y * y) / tan(trackTheta);
138  } else {
139  z = 0.0;
140  }
141 
142  if (z >= ((sensorLength[layer - 1] / -2.0) + shiftZ) && z <= ((sensorLength[layer - 1] / 2.0) + shiftZ)) {
143  if (y >= sensorMinY && y <= sensorMaxY) {
144 
145  double localUPosition = y - shiftY;
146  double localVPosition = z - shiftZ;
147  mostProbableHitLocal.SetX(localUPosition);
148  mostProbableHitLocal.SetY(localVPosition);
149 
150  storeDATCONMPHs.appendNew(DATCONMostProbableHit(sensorID, mostProbableHitLocal, qualityOfHit));
151  PXDIntercept intercept;
152  intercept.setCoorU(mostProbableHitLocal.X());
153  intercept.setCoorV(mostProbableHitLocal.Y());
154  intercept.setVxdID(sensorID);
155  storeDATCONPXDIntercepts.appendNew(intercept);
156 
157  break;
158  }
159  } else {
160  continue;
161  }
162  }
163  }
164  }
165  }
166 }
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::DATCONPXDExtrapolationModule
The DATCONPXDExtrapolationModule does an extrapolation to the PXD and creates "Most Probable Hits" (M...
Definition: DATCONPXDExtrapolationModule.h:47
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DATCONMostProbableHit
The DATCON Most Probable Hit (MPH) class.
Definition: DATCONMostProbableHit.h:36
Belle2::PXDIntercept
PXDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an PXD ...
Definition: PXDIntercept.h:32