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 ()
const std::vector< payload_t > & payload () const
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 181 of file NNPixelClusterCalibratorHelpers.h.

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

◆ getPixelXPitch()

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

Definition at line 63 of file NNPixelClusterCalibratorHelpers.h.

63 {
64 return m_payload[static_cast<index_t>(Index::pitchXOffset) + i];
65 }

◆ 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 108 of file NNPixelClusterCalibratorHelpers.h.

108 {
109 std::span<payload_t, static_cast<index_t>(Index::windowSize)> pitches(
110 m_payload.begin() + static_cast<index_t>(pitchOffset),
111 m_payload.begin() + static_cast<index_t>(pitchOffset) +
112 static_cast<index_t>(Index::windowSize));
113 const std::size_t windowSize = static_cast<std::size_t>(Index::windowSize);
114
115 std::array<double, static_cast<std::size_t>(Index::windowSize)>
116 cumulative{};
117 double acc = 0.0;
118 for (std::size_t j = 0; j < windowSize; ++j) {
119 acc += pitches[j];
120 cumulative[j] = acc;
121 }
122
123 const std::size_t centerIdx = static_cast<std::size_t>(Index::center);
124 const double centerValue = cumulative[centerIdx];
125 for (double& value : cumulative) {
126 value -= centerValue;
127 }
128
129 const double coordsIdx = coord + static_cast<double>(Index::center);
130 const double floorValue = std::floor(coordsIdx);
131 const double frac = floorValue - coordsIdx;
132 const long intIdx = static_cast<long>(floorValue);
133 const long clippedIdx = std::clamp(intIdx, static_cast<long>(0),
134 static_cast<long>(windowSize) - 1);
135 const double base = cumulative[clippedIdx];
136 const double pitchAtIdx = pitches[clippedIdx];
137 const double centerOfCluster = pitchOffset == Index::pitchXOffset
138 ? this->centerPosition.xPhi()
139 : this->centerPosition.xEta();
140 return base + std::abs(frac) * pitchAtIdx + centerOfCluster;
141 }
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 92 of file NNPixelClusterCalibratorHelpers.h.

92 {
93 return x >= 0 && x < static_cast<index_t>(Index::windowSize) && y >= 0 &&
94 y < static_cast<index_t>(Index::windowSize);
95 }
#define y
#define x

◆ payload() [1/2]

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

Definition at line 40 of file NNPixelClusterCalibratorHelpers.h.

40{ return m_payload; }

◆ payload() [2/2]

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

Definition at line 42 of file NNPixelClusterCalibratorHelpers.h.

42{ 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 151 of file NNPixelClusterCalibratorHelpers.h.

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

◆ set()

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

Definition at line 72 of file NNPixelClusterCalibratorHelpers.h.

72{ 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 50 of file NNPixelClusterCalibratorHelpers.h.

50 {
51 checkRange(x, "x of coordinate of the charge");
52 checkRange(y, "x of coordinate of the charge");
53
54 m_payload[static_cast<index_t>(Index::chargeOffset) +
55 x * static_cast<index_t>(Index::windowSize) + y] = charge;
56 }
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 58 of file NNPixelClusterCalibratorHelpers.h.

58 {
59 checkRange(i, "x pitch");
60 m_payload[static_cast<index_t>(Index::pitchXOffset) + i] = pitch;
61 }

◆ setPixelYPitch()

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

Definition at line 67 of file NNPixelClusterCalibratorHelpers.h.

67 {
68 checkRange(i, "y pitch");
69 m_payload[static_cast<index_t>(Index::pitchYOffset) + i] = pitch;
70 }

◆ 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 88 of file NNPixelClusterCalibratorHelpers.h.

88 {
89 return nnIndex + centerIndex - static_cast<NNinput::index_t>(Index::center);
90 }

◆ 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 80 of file NNPixelClusterCalibratorHelpers.h.

80 {
81 return pixelIndex - centerIndex +
82 static_cast<NNinput::index_t>(Index::center);
83 }

◆ totCharge()

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

Definition at line 44 of file NNPixelClusterCalibratorHelpers.h.

44 {
45 return std::accumulate(
46 std::begin(m_payload) + static_cast<index_t>(Index::chargeOffset),
47 std::begin(m_payload) + static_cast<index_t>(Index::chargeEnd), 0.0f);
48 }

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 174 of file NNPixelClusterCalibratorHelpers.h.

◆ centerPosition

InDetDD::SiLocalPosition ActsTrk::NNinput::centerPosition

Definition at line 175 of file NNPixelClusterCalibratorHelpers.h.

◆ m_payload

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

Definition at line 178 of file NNPixelClusterCalibratorHelpers.h.


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