Belle II Software development
ROICalculator.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/ROICalculator.h>
9#include <framework/core/ModuleParamList.h>
10#include <framework/core/ModuleParamList.templateDetails.h>
11#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
12#include <framework/gearbox/Unit.h>
13#include <tracking/dataobjects/ROIid.h>
14#include <pxd/geometry/SensorInfo.h>
15#include <vxd/dataobjects/VxdID.h>
16#include <vxd/geometry/GeoCache.h>
17
18using namespace Belle2;
19using namespace TrackFindingCDC;
20
22{
23}
24
25void ROICalculator::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
26{
27 Super::exposeParameters(moduleParamList, prefix);
28
29 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "ROIsStoreArrayName"), m_param_ROIsStoreArrayName,
30 "Name of the ROIs StoreArray?", m_param_ROIsStoreArrayName);
31
32 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "uROIsizeL1"), m_param_uROIsizeL1,
33 "u direction ROI size on L1. Data type: short", m_param_uROIsizeL1);
34
35 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "uROIsizeL2"), m_param_uROIsizeL2,
36 "u direction ROI size on L2. Data type: short", m_param_uROIsizeL2);
37
38 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "vROIsizeL1"), m_param_vROIsizeL1,
39 "v direction ROI size on L1. Data type: short", m_param_vROIsizeL1);
40
41 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "vROIsizeL2"), m_param_vROIsizeL2,
42 "v direction ROI size on L2. Data type: short", m_param_vROIsizeL2);
43
44}
45
47{
49
51}
52
53void ROICalculator::apply(const std::vector<std::pair<VxdID, long>>& uExtrapolations,
54 const std::vector<std::pair<VxdID, long>>& vExtrapolations)
55{
57 const unsigned short uCells = 250, vCells = 768;
58
59 const PXD::SensorInfo* currentSensor;
60
61 for (auto& uExtrapolatedHit : uExtrapolations) {
62 const VxdID& uHitSensorID = uExtrapolatedHit.first;
63
64 for (auto& vExtrapolatedHit : vExtrapolations) {
65 const VxdID& vHitSensorID = vExtrapolatedHit.first;
66
67 if (uHitSensorID != vHitSensorID) {
68 continue;
69 }
70
71 // Convert back from nm to cm.
72 // Before the all values were upscaled with "convertFloatToInt" as the FPGA only works with integers.
73 // This conversion from nm to cm is hardcoded, if the powers of 10 are changed in the other modules, this conversion
74 // would not necessarily be right anymore, so maybe there is a better way of doing this - I didn't find any.
75 double uCoordinateInCM = uExtrapolatedHit.second * Unit::nm;
76 double vCoordinateInCM = vExtrapolatedHit.second * Unit::nm;
77
78 currentSensor = dynamic_cast<const PXD::SensorInfo*>(&VXD::GeoCache::getInstance().getSensorInfo(uHitSensorID));
79 const short uCell = currentSensor->getUCellID(uCoordinateInCM);
80 const short vCell = currentSensor->getVCellID(vCoordinateInCM);
81
82 const unsigned short& uROIsize = (uHitSensorID.getLayerNumber() == 1 ? m_param_uROIsizeL1 : m_param_uROIsizeL2);
83 const unsigned short& vROIsize = (uHitSensorID.getLayerNumber() == 1 ? m_param_vROIsizeL1 : m_param_vROIsizeL2);
84
85 B2DEBUG(29, "sensorID: " << uHitSensorID << ", localUCoordinate: " << uCoordinateInCM << ", localVCoordinate: " << vCoordinateInCM
86 << ", localUCell: " << uCell << ", localVCell: " << vCell << ", uROIsize : " << uROIsize << ", vROIsize: " << vROIsize);
87
89 short uCellDownLeft = uCell - uROIsize / 2;
90 if (uCellDownLeft < 0) uCellDownLeft = 0;
91 short vCellDownLeft = vCell - vROIsize / 2;
92 if (vCellDownLeft < 0) vCellDownLeft = 0;
93
95 short uCellUpRight = uCell + uROIsize / 2;
96 if (uCellUpRight >= uCells) uCellUpRight = uCells - 1;
97 short vCellUpRight = vCell + vROIsize / 2;
98 if (vCellUpRight >= vCells) vCellUpRight = vCells - 1;
99
100 m_storeDATCONROIs.appendNew(ROIid(uCellDownLeft, uCellUpRight, vCellDownLeft, vCellUpRight, uHitSensorID));
101 }
102 }
103}
The Module parameter list class.
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Definition: SensorInfo.h:23
void initialize() override
Create the store arrays.
short m_param_uROIsizeL2
ROI size in u direction on L2.
Definition: ROICalculator.h:56
short m_param_uROIsizeL1
ROI size in u direction on L1.
Definition: ROICalculator.h:54
void apply(const std::vector< std::pair< VxdID, long > > &uExtrapolations, const std::vector< std::pair< VxdID, long > > &vExtrapolations) override
Load in the prepared hits and create tracks for extrapolation to PXD.
short m_param_vROIsizeL2
ROI size in v direction on L2.
Definition: ROICalculator.h:60
ROICalculator()
Find intercepts in the 2D Hough space.
short m_param_vROIsizeL1
ROI size in v direction on L1.
Definition: ROICalculator.h:58
StoreArray< ROIid > m_storeDATCONROIs
PXDIntercept StoreArray.
Definition: ROICalculator.h:51
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
std::string m_param_ROIsStoreArrayName
name of the PXDIntercept StoreArray
Definition: ROICalculator.h:49
ROIid stores the U and V ids and the sensor id of the Region Of Interest.
Definition: ROIid.h:25
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
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
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
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.