Belle II Software  release-06-01-15
ROIFinder Class Referenceabstract

Findlet for performing the DATCON ROI calculation. More...

#include <ROIFinder.h>

Inheritance diagram for ROIFinder:
Collaboration diagram for ROIFinder:

Public Types

using IOTypes = std::tuple< AIOTypes... >
 Types that should be served to apply on invokation.
 
using IOVectors = std::tuple< std::vector< AIOTypes >... >
 Vector types that should be served to apply on invokation.
 

Public Member Functions

 ROIFinder ()
 Constructor for adding the subfindlets.
 
 ~ROIFinder ()
 Default desctructor.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) override
 Expose the parameters of the sub findlets.
 
void apply (const std::vector< SpacePointTrackCand > &finalTracks) override
 Function to call all the sub-findlets. More...
 
void initialize () override
 Initialize the StoreArrays. More...
 
void beginRun () override
 Initialize the BField.
 
void beginEvent () override
 Clear the object pools.
 
virtual std::string getDescription ()
 Brief description of the purpose of the concret findlet.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
void endRun () override
 Receive and dispatch signal for the end of the run.
 
void terminate () override
 Receive and dispatch Signal for termination of the event processing.
 

Protected Types

using ToVector = typename ToVectorImpl< T >::Type
 Short hand for ToRangeImpl.
 

Protected Member Functions

void addProcessingSignalListener (ProcessingSignalListener *psl)
 Register a processing signal listener to be notified.
 
int getNProcessingSignalListener ()
 Get the number of currently registered listeners.
 

Private Types

using Super = TrackFindingCDC::Findlet< const SpacePointTrackCand >
 Parent class.
 

Private Attributes

bool m_param_calculateROI = false
 Calculate ROI in this findlet?
 
std::string m_param_storePXDInterceptsName = "DATCONPXDIntercepts"
 Name of the PXDIntercepts StoreArray.
 
std::string m_param_storeROIsName = "DATCONROIs"
 Name of the ROIs StoreArray.
 
StoreArray< PXDInterceptm_storePXDIntercepts
 PXDIntercepts StoreArray.
 
StoreArray< ROIidm_storeROIs
 ROIs StoreArray.
 
double m_param_tolerancePhi = 0.15
 Allowed tolerance (in radians) phi to create intercepts per sensor.
 
double m_param_toleranceZ = 0.5
 Allowed tolerance (in cm) in z to create intercepts per sensor.
 
double m_param_radiusCorrectionFactor = 4.0
 Correction factor for radial bias: factor * charge / radius.
 
double m_param_sinPhiCorrectionFactor = 0.0
 Correction factor for the sin(phi) modulation.
 
double m_param_cosPhiCorrectionFactor = 0.0
 Correction factor for the cos(phi) modulation.
 
double m_param_minimumROISizeUL1 = 40
 Minimum size of ROI in u-direction on L1 in pixel.
 
double m_param_minimumROISizeVL1 = 40
 Minimum size of ROI in v-direction on L1 in pixel.
 
double m_param_minimumROISizeUL2 = 40
 Minimum size of ROI in u-direction on L2 in pixel.
 
double m_param_minimumROISizeVL2 = 40
 Minimum size of ROI in v-direction on L2 in pixel.
 
double m_param_multiplierUL1 = 600
 Multiplier term in ROI size estimation For u: size = multiplier * 1/R + minimumROISize For v: size = (1 + abs(tan(lambda)) * multiplier) + minimumROISize Multiplier term for u-direction on L1.
 
double m_param_multiplierUL2 = 800
 Multiplier term for u-direction on L2.
 
double m_param_multiplierVL1 = 0.8
 Multiplier term for v-direction on L1.
 
double m_param_multiplierVL2 = 1.2
 Multiplier term for v-direction on L2.
 
unsigned short m_param_maximumROISizeU = 120
 maximum ROI size in u in pixel
 
unsigned short m_param_maximumROISizeV = 192
 maximum ROI size in v in pixel
 
const double m_const_centerZShiftLayer1 [2] = {3.68255, -0.88255}
 Shift of the center of the active area of each sensor in a ladder of layer 1 For use of mhp_z > (lengh/-2)+shiftZ && mhp_z < (lengh/2)+shiftZ.
 
const double m_const_centerZShiftLayer2 [2] = {5.01455, -1.21455}
 Shift of the center of the active area of each sensor in a ladder of layer 2 For use of mhp_z > (lengh/-2)+shiftZ && mhp_z < (lengh/2)+shiftZ.
 
const double m_const_sensorMinY = -0.36
 PXD is shifted to create the windmill structure. More...
 
const double m_const_sensorMaxY = 0.89
 Maximum y coordinate if x-axis is perpendicular to the sensor:
 
const double m_const_activeSensorWidth = (m_const_sensorMaxY - m_const_sensorMinY)
 PXD sensors in L1 and L2 have the same size in u direction (=width):
 
const double m_const_shiftY = (m_const_sensorMaxY + m_const_sensorMinY) / 2.0
 Shift of the center position in y if the x-axis is perpendicular to the sensor:
 
const double m_const_layerRadius [2] = {1.42854, 2.21218}
 Radius of the two layers.
 
const double m_const_activeSensorLength [2] = {4.48, 6.144}
 Length of the active region for L1 and L2.
 
const double m_const_ladderPhiL1 [8] = {0., 0.25 * M_PI, M_PI_2, 0.75 * M_PI, M_PI, -0.75 * M_PI, -M_PI_2, -0.25 * M_PI}
 Phi values of the ladders of L1.
 
const double m_const_ladderPhiL2 [12] = {0., 1. / 6. * M_PI, 1. / 3. * M_PI, M_PI_2, 2. / 3. * M_PI, 5. / 6. * M_PI, M_PI, -5. / 6. * M_PI, -2. / 3. * M_PI, -M_PI_2, -1. / 3. * M_PI, -1. / 6. * M_PI}
 Phi values of the ladders of L2.
 
double m_bFieldZ = 1.5
 BField in Tesla.
 
B2Vector3D m_BeamSpotPosition
 B2Vector3D actually contining the BeamSpot position. This will be used as the starting point of the extrapolation.
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized = false
 Flag to keep track whether initialization happend before.
 
bool m_terminated = false
 Flag to keep track whether termination happend before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

Findlet for performing the DATCON ROI calculation.

Definition at line 32 of file ROIFinder.h.

Member Function Documentation

◆ apply()

void apply ( const std::vector< SpacePointTrackCand > &  finalTracks)
override

Function to call all the sub-findlets.

Loop over both PXD layer

Loop over all ladders of layer

Loop over both modules of a ladder

Lower left corner

Upper right corner

Definition at line 146 of file ROIFinder.cc.

147 {
148  // If no ROIs shall be calculated, return rightaway and don't do anything
149  if (not m_param_calculateROI) {
150  return;
151  }
152 
153  for (auto& track : finalTracks) {
154  // do nothing if the SpacePointTrackCand is not active
155  if (!track.hasRefereeStatus(SpacePointTrackCand::c_isActive)) {
156  continue;
157  }
158 
159  std::vector<PXDIntercept> thisTracksIntercepts;
160  thisTracksIntercepts.reserve(8);
161 
162  const B2Vector3D& momentumEstimate = track.getMomSeed();
163 
164  const double trackPhi = momentumEstimate.Phi();
165  const double trackTheta = momentumEstimate.Theta();
166  const double tanTrackLambda = tan(M_PI_2 - trackTheta);
167  const double trackRadius = momentumEstimate.Perp() / (0.00299792458 * m_bFieldZ) ;
168  const double trackCharge = track.getChargeSeed();
169 
171  for (int layer = 1; layer <= 2; layer++) {
172  const double sensorPerpRadius = m_const_layerRadius[layer - 1];
173 
175  for (int ladder = 1; ladder <= (layer == 1 ? 8 : 12); ladder++) {
176  const double sensorPhi = (layer == 1) ? m_const_ladderPhiL1[ladder - 1] : m_const_ladderPhiL2[ladder - 1];
177  const double rotatedBeamSpotX = m_BeamSpotPosition.X() * cos(sensorPhi) + m_BeamSpotPosition.Y() * sin(sensorPhi);
178  const double rotatedBeamSpotY = -m_BeamSpotPosition.X() * sin(sensorPhi) + m_BeamSpotPosition.Y() * cos(sensorPhi);
179 
180  // in the rotated coordinate the sensor is perpendicular to the x axis at position sensorLocalX
181  const double sensorLocalX = sensorPerpRadius - rotatedBeamSpotX;
182 
183  double phiDiff = trackPhi - sensorPhi;
184  if (phiDiff < -M_PI) {
185  phiDiff += 2. * M_PI;
186  }
187  if (phiDiff > M_PI) {
188  phiDiff -= 2. * M_PI;
189  }
190 
191  // Don't try to extrapolate if track direction and sensor are too different (in phi)
192  // this should speed up the calculation as wrong combinations are not checked at all.
193  // Two values to check both the outgoing (0.3) and incoming (0.8) arm.
194  if (fabs(phiDiff) > 0.3 * M_PI /*and fabs(phiDiff) < 0.8 * M_PI*/) {
195  continue;
196  }
197 
198  // relative phi value of the track center compared to the rotated
199  // coordinate system defined by the (rotated) line perpendicular
200  // to the sensor (with length sensorPerpRadius)
201  double relTrackCenterPhi = 0;
202  if (trackCharge < 0) {
203  relTrackCenterPhi = trackPhi - M_PI_2 - sensorPhi;
204  } else if (trackCharge > 0) {
205  relTrackCenterPhi = trackPhi + M_PI_2 - sensorPhi;
206  }
207  const double xCenter = trackRadius * cos(relTrackCenterPhi);
208  const double yCenter = trackRadius * sin(relTrackCenterPhi);
209 
210  // continue if radicant of sqrt is negative
211  if ((trackRadius * trackRadius - (sensorLocalX - xCenter) * (sensorLocalX - xCenter)) < 0) {
212  continue;
213  }
214  const double ytmp = sqrt(trackRadius * trackRadius - (sensorLocalX - xCenter) * (sensorLocalX - xCenter));
215  const double yplus = yCenter + ytmp + rotatedBeamSpotY;
216  const double yminus = yCenter - ytmp + rotatedBeamSpotY;
217 
218  const double correctionterm = (m_param_radiusCorrectionFactor * trackCharge / trackRadius) +
219  m_param_sinPhiCorrectionFactor * sin(trackPhi) +
220  m_param_cosPhiCorrectionFactor * cos(trackPhi);
221 
222  const double localUPositionPlus = yplus - m_const_shiftY + correctionterm;
223  const double localUPositionMinus = yminus - m_const_shiftY + correctionterm;
224  const double toleranceRPhi = m_param_tolerancePhi * sensorLocalX;
225 
226  // if the hit for sure is out of reach of the current ladder, continue
227  if (not(yplus >= m_const_sensorMinY - toleranceRPhi and yplus <= m_const_sensorMaxY + toleranceRPhi) and
228  not(yminus >= m_const_sensorMinY - toleranceRPhi and yminus <= m_const_sensorMaxY + toleranceRPhi)) {
229  continue;
230  }
231 
232  // estimate the z coordinate of the extrapolation on this layer
233  const double z = sensorLocalX * tanTrackLambda - m_BeamSpotPosition.Z();
234 
236  for (int sensor = 1; sensor <= 2; sensor++) {
237 
238  const double shiftZ = (layer == 1) ? m_const_centerZShiftLayer1[sensor - 1] : m_const_centerZShiftLayer2[sensor - 1];
239 
240  double localVPosition = z - shiftZ;
241  // check whether z intersection possibly is on sensor to be checked, only continue with the rest of calculations if that's the case
242  if (localVPosition >= ((-m_const_activeSensorLength[layer - 1] / 2.0) - m_param_toleranceZ) and
243  localVPosition <= ((m_const_activeSensorLength[layer - 1] / 2.0) + m_param_toleranceZ)) {
244 
245  const VxdID sensorID = VxdID(layer, ladder, sensor);
246 
247  // double localVPosition = z - shiftZ;
248  // check for first option of the intersection
249  if (localUPositionPlus >= -m_const_activeSensorWidth / 2.0 - toleranceRPhi and
250  localUPositionPlus <= m_const_activeSensorWidth / 2.0 + toleranceRPhi) {
251  PXDIntercept intercept;
252  intercept.setCoorU(localUPositionPlus);
253  intercept.setCoorV(localVPosition);
254  intercept.setVxdID(sensorID);
255  m_storePXDIntercepts.appendNew(intercept);
256  thisTracksIntercepts.push_back(intercept);
257  }
258  // check for second option of the intersection
259  if (localUPositionMinus >= -m_const_activeSensorWidth / 2.0 - toleranceRPhi and
260  localUPositionMinus <= m_const_activeSensorWidth / 2.0 + toleranceRPhi) {
261  PXDIntercept intercept;
262  intercept.setCoorU(localUPositionMinus);
263  intercept.setCoorV(localVPosition);
264  intercept.setVxdID(sensorID);
265  m_storePXDIntercepts.appendNew(intercept);
266  thisTracksIntercepts.push_back(intercept);
267  }
268  }
269  }
270  }
271  }
272 
273  const double omega = 1. / trackRadius;
274  unsigned short uSizeL1 = (unsigned short)(m_param_multiplierUL1 * omega + m_param_minimumROISizeUL1);
275  unsigned short uSizeL2 = (unsigned short)(m_param_multiplierUL2 * omega + m_param_minimumROISizeUL2);
276  unsigned short vSizeL1 = (unsigned short)((1. + fabs(tanTrackLambda) * m_param_multiplierVL1) * m_param_minimumROISizeVL1);
277  unsigned short vSizeL2 = (unsigned short)((1. + fabs(tanTrackLambda) * m_param_multiplierVL2) * m_param_minimumROISizeVL2);
278  for (auto& intercept : thisTracksIntercepts) {
279  const VxdID& interceptSensorID = intercept.getSensorID();
280 
281  double uCoordinate = intercept.getCoorU();
282  double vCoordinate = intercept.getCoorV();
283 
284  const PXD::SensorInfo* currentSensor = dynamic_cast<const PXD::SensorInfo*>(&VXD::GeoCache::get(interceptSensorID));
285 
286  int interceptUCell = currentSensor->getUCellID(uCoordinate, vCoordinate, false);
287  int interceptVCell = currentSensor->getVCellID(vCoordinate, false);
288  int nUCells = currentSensor->getUCells();
289  int nVCells = currentSensor->getVCells();
290 
291  unsigned short uSize = (interceptSensorID.getLayerNumber() == 1 ? uSizeL1 : uSizeL2);
292  unsigned short vSize = (interceptSensorID.getLayerNumber() == 1 ? vSizeL1 : vSizeL2);
293  if (uSize > m_param_maximumROISizeU) {
294  uSize = m_param_maximumROISizeU;
295  }
296  if (vSize > m_param_maximumROISizeV) {
297  vSize = m_param_maximumROISizeV;
298  }
299 
301  short uCellDownLeft = interceptUCell - uSize / 2;
302  short vCellDownLeft = interceptVCell - vSize / 2;
303 
305  short uCellUpRight = interceptUCell + uSize / 2;
306  short vCellUpRight = interceptVCell + vSize / 2;
307 
308  if (uCellDownLeft >= nUCells or vCellDownLeft >= nVCells or uCellUpRight < 0 or vCellUpRight < 0) {
309  continue;
310  }
311 
312  if (uCellDownLeft < 0) {
313  uCellDownLeft = 0;
314  }
315  if (vCellDownLeft < 0) {
316  vCellDownLeft = 0;
317  }
318 
319  // minimum cell id is 0, maximum is nCells - 1
320  if (uCellUpRight >= nUCells) {
321  uCellUpRight = nUCells - 1;
322  }
323  if (vCellUpRight >= nVCells) {
324  vCellUpRight = nVCells - 1;
325  }
326 
327  m_storeROIs.appendNew(ROIid(uCellDownLeft, uCellUpRight, vCellDownLeft, vCellUpRight, interceptSensorID));
328  }
329 
330  }
331 }
DataType Phi() const
The azimuth angle.
Definition: B2Vector3.h:136
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:420
DataType Theta() const
The polar angle.
Definition: B2Vector3.h:138
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:416
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:418
DataType Perp() const
The transverse component (R in cylindrical coordinate system).
Definition: B2Vector3.h:185
PXDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an PXD ...
Definition: PXDIntercept.h:22
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Definition: SensorInfo.h:23
ROIid stores the U and V ids and the sensor id of the Region Of Interest.
Definition: ROIid.h:25
@ c_isActive
bit 11: SPTC is active (i.e.
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
double getCoorV() const
return the V coordinate of the intercept
Definition: VXDIntercept.h:60
VxdID::baseType getSensorID() const
return the sensor ID
Definition: VXDIntercept.h:66
double getCoorU() const
return the U coordinate of the intercept
Definition: VXDIntercept.h:59
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
Definition: GeoCache.h:139
int getVCells() const
Return number of pixel/strips in v direction.
int getUCells() const
Return number of pixel/strips in u direction.
int getVCellID(double v, bool clamp=false) const
Return the corresponding pixel/strip ID of a given v coordinate.
int getUCellID(double u, double v=0, bool clamp=false) const
Return the corresponding pixel/strip ID of a given u coordinate.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:96
unsigned short m_param_maximumROISizeV
maximum ROI size in v in pixel
Definition: ROIFinder.h:116
double m_param_tolerancePhi
Allowed tolerance (in radians) phi to create intercepts per sensor.
Definition: ROIFinder.h:75
B2Vector3D m_BeamSpotPosition
B2Vector3D actually contining the BeamSpot position. This will be used as the starting point of the e...
Definition: ROIFinder.h:149
const double m_const_activeSensorWidth
PXD sensors in L1 and L2 have the same size in u direction (=width):
Definition: ROIFinder.h:132
const double m_const_ladderPhiL2[12]
Phi values of the ladders of L2.
Definition: ROIFinder.h:142
const double m_const_activeSensorLength[2]
Length of the active region for L1 and L2.
Definition: ROIFinder.h:138
bool m_param_calculateROI
Calculate ROI in this findlet?
Definition: ROIFinder.h:60
StoreArray< ROIid > m_storeROIs
ROIs StoreArray.
Definition: ROIFinder.h:70
double m_param_cosPhiCorrectionFactor
Correction factor for the cos(phi) modulation.
Definition: ROIFinder.h:88
double m_param_minimumROISizeUL2
Minimum size of ROI in u-direction on L2 in pixel.
Definition: ROIFinder.h:97
const double m_const_centerZShiftLayer1[2]
Shift of the center of the active area of each sensor in a ladder of layer 1 For use of mhp_z > (leng...
Definition: ROIFinder.h:122
double m_param_minimumROISizeVL2
Minimum size of ROI in v-direction on L2 in pixel.
Definition: ROIFinder.h:99
double m_param_sinPhiCorrectionFactor
Correction factor for the sin(phi) modulation.
Definition: ROIFinder.h:86
const double m_const_ladderPhiL1[8]
Phi values of the ladders of L1.
Definition: ROIFinder.h:140
double m_param_multiplierVL1
Multiplier term for v-direction on L1.
Definition: ROIFinder.h:109
StoreArray< PXDIntercept > m_storePXDIntercepts
PXDIntercepts StoreArray.
Definition: ROIFinder.h:68
const double m_const_sensorMaxY
Maximum y coordinate if x-axis is perpendicular to the sensor:
Definition: ROIFinder.h:130
double m_param_multiplierUL2
Multiplier term for u-direction on L2.
Definition: ROIFinder.h:107
double m_param_minimumROISizeVL1
Minimum size of ROI in v-direction on L1 in pixel.
Definition: ROIFinder.h:95
double m_param_multiplierUL1
Multiplier term in ROI size estimation For u: size = multiplier * 1/R + minimumROISize For v: size = ...
Definition: ROIFinder.h:105
unsigned short m_param_maximumROISizeU
maximum ROI size in u in pixel
Definition: ROIFinder.h:114
double m_bFieldZ
BField in Tesla.
Definition: ROIFinder.h:145
const double m_const_layerRadius[2]
Radius of the two layers.
Definition: ROIFinder.h:136
double m_param_toleranceZ
Allowed tolerance (in cm) in z to create intercepts per sensor.
Definition: ROIFinder.h:77
double m_param_multiplierVL2
Multiplier term for v-direction on L2.
Definition: ROIFinder.h:111
const double m_const_shiftY
Shift of the center position in y if the x-axis is perpendicular to the sensor:
Definition: ROIFinder.h:134
double m_param_radiusCorrectionFactor
Correction factor for radial bias: factor * charge / radius.
Definition: ROIFinder.h:84
double m_param_minimumROISizeUL1
Minimum size of ROI in u-direction on L1 in pixel.
Definition: ROIFinder.h:93
const double m_const_centerZShiftLayer2[2]
Shift of the center of the active area of each sensor in a ladder of layer 2 For use of mhp_z > (leng...
Definition: ROIFinder.h:125
const double m_const_sensorMinY
PXD is shifted to create the windmill structure.
Definition: ROIFinder.h:128

◆ initialize()

void initialize ( void  )
overridevirtual

Initialize the StoreArrays.

Create the store arrays.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 93 of file ROIFinder.cc.

Member Data Documentation

◆ m_const_sensorMinY

const double m_const_sensorMinY = -0.36
private

PXD is shifted to create the windmill structure.

Minimum y coordinate if x-axis is perpendicular to the sensor:

Definition at line 128 of file ROIFinder.h.


The documentation for this class was generated from the following files: