ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrk::NNinput Class Reference

#include <NNPixelClusterCalibratorHelpers.h>

Collaboration diagram for ActsTrk::NNinput:

Public Types

enum class  Index : index_t {
  chargeOffset = 0 , windowSize = 7 , center = (windowSize - 1) / 2 , halfSize = center ,
  chargeEnd = windowSize * windowSize , pitchYOffset = chargeEnd , pitchXOffset = pitchYOffset + windowSize , layer = pitchXOffset + windowSize ,
  bec = layer + 1 , phi = bec + 1 , theta = phi + 1 , totalSize = theta + 1
}
using payload_t = float
using index_t = int

Public Member Functions

 NNinput ()
std::vector< payload_t > & payload ()
float totCharge () const
void setPixelCharge (index_t x, index_t y, payload_t charge)
void setPixelXPitch (index_t i, payload_t pitch)
payload_t getPixelXPitch (index_t i) const
void setPixelYPitch (index_t i, payload_t pitch)
void set (Index i, payload_t v)
float indexCoordToRealCoord (float coord, Index pitchOffset)
 translates position returned from the network to mm The position returned from the network is given in the "index" space while it needs to be be in mm.
float precisionToRealCoord (float prec, Index pitchOffset)
 translate RMS that is output from NN to detector units (mm) Conversion is done by integrating the actual pitches, so non-uniform pitch (ITk long/end pixels, 25 um modules) is handled.

Static Public Member Functions

static int toNNinputIndex (index_t pixelIndex, index_t centerIndex)
 Translate from module indices to NNinput indices e.g.
static int toModuleIndex (index_t nnIndex, index_t centerIndex)
 Reverse operation to toNNInputIndex.
static bool inWindow (index_t x, index_t y)

Public Attributes

InDetDD::SiCellId centerCell
 !
InDetDD::SiLocalPosition centerPosition

Private Member Functions

void checkRange (index_t i, const std::string &context) const
 ! storage for NN input

Private Attributes

std::vector< payload_tm_payload

Detailed Description

Definition at line 20 of file NNPixelClusterCalibratorHelpers.h.

Member Typedef Documentation

◆ index_t

Definition at line 23 of file NNPixelClusterCalibratorHelpers.h.

◆ payload_t

Definition at line 22 of file NNPixelClusterCalibratorHelpers.h.

Member Enumeration Documentation

◆ Index

enum class ActsTrk::NNinput::Index : index_t
strong
Enumerator
chargeOffset 
windowSize 
center 
halfSize 
chargeEnd 
pitchYOffset 
pitchXOffset 
layer 
bec 
phi 
theta 
totalSize 

Definition at line 24 of file NNPixelClusterCalibratorHelpers.h.

24 : index_t {
25 chargeOffset = 0,
26 windowSize = 7,
27 center = (windowSize - 1) / 2, // this should be index of center point
28 halfSize = center,
29 chargeEnd = windowSize * windowSize,
30 pitchYOffset = chargeEnd,
31 pitchXOffset = pitchYOffset + windowSize,
32 layer = pitchXOffset + windowSize,
33 bec = layer + 1,
34 phi = bec + 1,
35 theta = phi + 1,
36 totalSize = theta + 1
37 };
Scalar phi() const
phi method
Scalar theta() const
theta method
static unsigned int totalSize(const MultiDimArray< T, N > &ht)
int32_t index_t
The index type of the node in the vector.

Constructor & Destructor Documentation

◆ NNinput()

ActsTrk::NNinput::NNinput ( )
inline

Definition at line 38 of file NNPixelClusterCalibratorHelpers.h.

38: m_payload(static_cast<index_t>(Index::totalSize), {}) {}
std::vector< payload_t > m_payload

Member Function Documentation

◆ checkRange()

void ActsTrk::NNinput::checkRange ( index_t i,
const std::string & context ) const
inlineprivate

! storage for NN input

validates index arguments passed to setters

Definition at line 176 of file NNPixelClusterCalibratorHelpers.h.

176 {
177 if (i >= static_cast<index_t>(Index::windowSize))
178 throw std::domain_error(
179 "Filling the NNinput for pixel calibration, the value should be "
180 "within 0-6, while it "
181 "is " +
182 std::to_string(i) + " " + context);
183 }

◆ getPixelXPitch()

payload_t ActsTrk::NNinput::getPixelXPitch ( index_t i) const
inline

Definition at line 58 of file NNPixelClusterCalibratorHelpers.h.

58 {
59 return m_payload[static_cast<index_t>(Index::pitchXOffset) + i];
60 }

◆ indexCoordToRealCoord()

float ActsTrk::NNinput::indexCoordToRealCoord ( float coord,
Index pitchOffset )
inline

translates position returned from the network to mm The position returned from the network is given in the "index" space while it needs to be be in mm.

Simplifying, the returned position need to be multiplied by pitch however, due to uneven pitch size the translation is slightly trickier. The code is reverse engineered from: https://pixsplit.docs.cern.ch/export/ and associated python implementation

Parameters
coord- position in nn coordinates
pitchOffset- either pitchXOffset or pitchYOffset - place where pitches vectors are stored
Returns
position shift in mm

Definition at line 103 of file NNPixelClusterCalibratorHelpers.h.

103 {
104 std::span<payload_t, static_cast<index_t>(Index::windowSize)> pitches(
105 m_payload.begin() + static_cast<index_t>(pitchOffset),
106 m_payload.begin() + static_cast<index_t>(pitchOffset) +
107 static_cast<index_t>(Index::windowSize));
108 const std::size_t windowSize = static_cast<std::size_t>(Index::windowSize);
109
110 std::array<double, static_cast<std::size_t>(Index::windowSize)>
111 cumulative{};
112 double acc = 0.0;
113 for (std::size_t j = 0; j < windowSize; ++j) {
114 acc += pitches[j];
115 cumulative[j] = acc;
116 }
117
118 const std::size_t centerIdx = static_cast<std::size_t>(Index::center);
119 const double centerValue = cumulative[centerIdx];
120 for (double& value : cumulative) {
121 value -= centerValue;
122 }
123
124 const double coordsIdx = coord + static_cast<double>(Index::center) ;
125 const double floorValue = std::floor(coordsIdx);
126 const double frac = floorValue - coordsIdx;
127 const long intIdx = static_cast<long>(floorValue);
128 const long clippedIdx = std::clamp(intIdx, static_cast<long>(0),
129 static_cast<long>(windowSize) - 1);
130 const double base = cumulative[clippedIdx];
131 const double pitchAtIdx = pitches[clippedIdx];
132 const double centerOfCluster = pitchOffset == Index::pitchXOffset
133 ? this->centerPosition.xPhi()
134 : this->centerPosition.xEta();
135 return base + std::abs(frac) * pitchAtIdx + centerOfCluster;
136 }
double coord
Type of coordination system.
InDetDD::SiLocalPosition centerPosition
std::string base
Definition hcg.cxx:83
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)

◆ inWindow()

bool ActsTrk::NNinput::inWindow ( index_t x,
index_t y )
inlinestatic

Definition at line 87 of file NNPixelClusterCalibratorHelpers.h.

87 {
88 return x >= 0 && x < static_cast<index_t>(Index::windowSize) && y >= 0 &&
89 y < static_cast<index_t>(Index::windowSize);
90 }
#define y
#define x

◆ payload()

std::vector< payload_t > & ActsTrk::NNinput::payload ( )
inline

Definition at line 39 of file NNPixelClusterCalibratorHelpers.h.

39{ return m_payload; }

◆ precisionToRealCoord()

float ActsTrk::NNinput::precisionToRealCoord ( float prec,
Index pitchOffset )
inline

translate RMS that is output from NN to detector units (mm) Conversion is done by integrating the actual pitches, so non-uniform pitch (ITk long/end pixels, 25 um modules) is handled.

size is m_sizeX in phi (x), m_sizeY in eta (y). this code is adopted from NNClusterizationFactory

Parameters
precprecision returned by NN
pitchOffseteither pitchXOffset or pitchYOffset
Returns

Definition at line 146 of file NNPixelClusterCalibratorHelpers.h.

146 {
147 std::span<payload_t, static_cast<index_t>(Index::windowSize)> pitches(
148 m_payload.begin() + static_cast<index_t>(pitchOffset),
149 m_payload.begin() + static_cast<index_t>(pitchOffset) +
150 static_cast<index_t>(Index::windowSize));
151
152 const float p = ((prec > 0) ? std::sqrt(1.0f / prec) : 0.01f) +
153 static_cast<float>(Index::center);
154 float pitchPos = -100; // unset position
155 float pitchCenter = -100; // unset position
156 float pitchActual = 0; // integral of pitch sizes
157 for (index_t i = 0; i < static_cast<index_t>(Index::windowSize); i++) {
158 if (p >= i and p <= (i + 1))
159 pitchPos = pitchActual + (p - i + 0.5) * pitches[i];
160 if (i == static_cast<index_t>(Index::center))
161 pitchCenter = pitchActual + 0.5 * pitches[i];
162 pitchActual += pitches[i];
163 }
164 return std::abs(pitchPos - pitchCenter);
165 }

◆ set()

void ActsTrk::NNinput::set ( Index i,
payload_t v )
inline

Definition at line 67 of file NNPixelClusterCalibratorHelpers.h.

67{ m_payload[static_cast<index_t>(i)] = v; }

◆ setPixelCharge()

void ActsTrk::NNinput::setPixelCharge ( index_t x,
index_t y,
payload_t charge )
inline

Definition at line 45 of file NNPixelClusterCalibratorHelpers.h.

45 {
46 checkRange(x, "x of coordinate of the charge");
47 checkRange(y, "x of coordinate of the charge");
48
49 m_payload[static_cast<index_t>(Index::chargeOffset) +
50 x * static_cast<index_t>(Index::windowSize) + y] = charge;
51 }
double charge(const T &p)
Definition AtlasPID.h:997
void checkRange(index_t i, const std::string &context) const
! storage for NN input

◆ setPixelXPitch()

void ActsTrk::NNinput::setPixelXPitch ( index_t i,
payload_t pitch )
inline

Definition at line 53 of file NNPixelClusterCalibratorHelpers.h.

53 {
54 checkRange(i, "x pitch");
55 m_payload[static_cast<index_t>(Index::pitchXOffset) + i] = pitch;
56 }

◆ setPixelYPitch()

void ActsTrk::NNinput::setPixelYPitch ( index_t i,
payload_t pitch )
inline

Definition at line 62 of file NNPixelClusterCalibratorHelpers.h.

62 {
63 checkRange(i, "y pitch");
64 m_payload[static_cast<index_t>(Index::pitchYOffset) + i] = pitch;
65 }

◆ toModuleIndex()

int ActsTrk::NNinput::toModuleIndex ( index_t nnIndex,
index_t centerIndex )
inlinestatic

Reverse operation to toNNInputIndex.

Parameters
nnIndexpixel index in NN repsentation
centerIndexcluster center
Returns
pixel index in module

Definition at line 83 of file NNPixelClusterCalibratorHelpers.h.

83 {
84 return nnIndex + centerIndex - static_cast<NNinput::index_t>(Index::center);
85 }

◆ toNNinputIndex()

int ActsTrk::NNinput::toNNinputIndex ( index_t pixelIndex,
index_t centerIndex )
inlinestatic

Translate from module indices to NNinput indices e.g.

if the cluster is of size 3 and indices of pixels are 23,24,25

Parameters
pixelIndex
centerIndex
Returns

Definition at line 75 of file NNPixelClusterCalibratorHelpers.h.

75 {
76 return pixelIndex - centerIndex +
77 static_cast<NNinput::index_t>(Index::center);
78 }

◆ totCharge()

float ActsTrk::NNinput::totCharge ( ) const
inline

Definition at line 40 of file NNPixelClusterCalibratorHelpers.h.

40 {
41 return std::accumulate(
42 std::begin(m_payload) + static_cast<index_t>(Index::chargeOffset),
43 std::begin(m_payload) + static_cast<index_t>(Index::chargeEnd), 0.0f);
44 }

Member Data Documentation

◆ centerCell

InDetDD::SiCellId ActsTrk::NNinput::centerCell

!

to avoid need to calculate them once more time when translating from index biases to local module coordinates

Definition at line 169 of file NNPixelClusterCalibratorHelpers.h.

◆ centerPosition

InDetDD::SiLocalPosition ActsTrk::NNinput::centerPosition

Definition at line 170 of file NNPixelClusterCalibratorHelpers.h.

◆ m_payload

std::vector<payload_t> ActsTrk::NNinput::m_payload
private

Definition at line 173 of file NNPixelClusterCalibratorHelpers.h.


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