ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
PixelConditionsData
src
ITkPixelClusterErrorData.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
PixelConditionsData/ITkPixelClusterErrorData.h
"
6
7
#include "GaudiKernel/ISvcLocator.h"
8
9
#include "
StoreGate/StoreGateSvc.h
"
10
11
#include <fstream>
12
#include <stdexcept>
13
14
15
namespace
ITk
16
{
17
18
void
PixelClusterErrorData::initialize
()
19
{
20
SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore"
)};
21
if
(!detStore){
22
throw
std::runtime_error(
"Could not retrieve DetectorStore"
);
23
}
24
StatusCode
sc
= detStore->retrieve(
m_pixelID
,
"PixelID"
);
25
if
(
sc
.isFailure() or (
m_pixelID
==
nullptr
)){
26
throw
std::runtime_error(
"Could not retrieve PixelID"
);
27
}
28
m_constmap
.resize(
m_pixelID
->wafer_hash_max(),std::array<float,kNParam>{});
29
}
30
31
32
std::pair<double,double>
PixelClusterErrorData::getDelta
(
IdentifierHash
idHash,
33
int
sizePhi,
double
angle
,
34
int
sizeZ,
double
eta
)
const
35
{
36
37
const
std::array<float,kNParam> &value =
m_constmap
.at(idHash);
38
double
period_phi = value[
kPeriod_phi
];
39
double
period_sinheta = value[
kPeriod_sinheta
];
40
double
delta_x_slope = value[
kDelta_x_slope
];
41
double
delta_x_offset = value[
kDelta_x_offset
];
42
double
delta_y_slope = value[
kDelta_y_slope
];
43
double
delta_y_offset = value[
kDelta_y_offset
];
44
45
double
delta_x = delta_x_slope * std::fabs(
angle
- period_phi*(sizePhi-2)) + delta_x_offset;
46
double
delta_y = delta_y_slope * std::fabs(std::sinh(std::fabs(
eta
)) - period_sinheta*(sizeZ-2)) + delta_y_offset;
47
return
std::make_pair(delta_x,delta_y);
48
49
}
50
51
52
53
54
// SET METHODS
55
56
void
PixelClusterErrorData::setDeltaError
(
IdentifierHash
idHash,
57
float
period_phi,
float
period_sinheta,
58
float
delta_x_slope,
float
delta_x_offset,
float
error_x,
59
float
delta_y_slope,
float
delta_y_offset,
float
error_y)
60
{
61
setDeltaError
(idHash, std::array<float, kNParam>{period_phi, period_sinheta,
62
delta_x_slope, delta_x_offset, error_x,
63
delta_y_slope, delta_y_offset, error_y});
64
}
65
66
67
// save all constants to file
68
void
PixelClusterErrorData::print
(
const
std::string&
file
)
const
69
{
70
std::ofstream outfile(
file
.c_str());
71
for
(
unsigned
int
id_hash=0;
const
std::array<float, kNParam> &values :
m_constmap
){
72
outfile << id_hash++;
73
for
(
double
a_val : values ) {
74
outfile <<
" "
<< a_val;
75
}
76
}
77
outfile.close();
78
}
79
80
81
82
// Load ITk constants from file
83
unsigned
int
PixelClusterErrorData::load
(
const
std::string&
file
){
84
85
std::ifstream infile(
file
.c_str() );
86
unsigned
int
n_entries=0;
87
if
(infile.is_open()){
88
89
//
90
// Data in the file is stored in the following columns:
91
// waferID_hash : period_phi : period_sinheta : delta_x_slope : delta_x_offset : delta_error_x : delta_y_slope : delta_y_offset : delta_error_y
92
//
93
94
int
waferID_hash_int;
95
double
period_phi;
96
double
period_sinheta;
97
double
delta_x_slope;
98
double
delta_x_offset;
99
double
delta_error_x;
100
double
delta_y_slope;
101
double
delta_y_offset;
102
double
delta_error_y;
103
104
while
(!infile.eof()){
105
106
infile >> waferID_hash_int >> period_phi >> period_sinheta >> delta_x_slope >> delta_x_offset >> delta_error_x >> delta_y_slope >> delta_y_offset >> delta_error_y;
107
108
IdentifierHash
waferID_hash(waferID_hash_int);
109
setDeltaError
(waferID_hash,
110
period_phi, period_sinheta,
111
delta_x_slope, delta_x_offset, delta_error_x,
112
delta_y_slope, delta_y_offset, delta_error_y);
113
++n_entries;
114
115
}
116
117
infile.close();
118
119
}
else
{
120
throw
std::runtime_error(
"ITkAnalogueClusteringConstantsFile \""
+
file
+
"\" can not be read. Unable to proceed."
);
121
}
122
return
n_entries;
123
}
124
125
}
// namespace ITk
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
ITkPixelClusterErrorData.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
StoreGateSvc.h
angle
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
Definition
TRTDetectorFactory_Full.cxx:71
ITk::PixelClusterErrorData::print
void print(const std::string &file) const
Definition
ITkPixelClusterErrorData.cxx:68
ITk::PixelClusterErrorData::kPeriod_phi
@ kPeriod_phi
Definition
ITkPixelClusterErrorData.h:29
ITk::PixelClusterErrorData::kDelta_x_slope
@ kDelta_x_slope
Definition
ITkPixelClusterErrorData.h:31
ITk::PixelClusterErrorData::kPeriod_sinheta
@ kPeriod_sinheta
Definition
ITkPixelClusterErrorData.h:30
ITk::PixelClusterErrorData::kDelta_y_slope
@ kDelta_y_slope
Definition
ITkPixelClusterErrorData.h:34
ITk::PixelClusterErrorData::kDelta_x_offset
@ kDelta_x_offset
Definition
ITkPixelClusterErrorData.h:32
ITk::PixelClusterErrorData::kDelta_y_offset
@ kDelta_y_offset
Definition
ITkPixelClusterErrorData.h:35
ITk::PixelClusterErrorData::setDeltaError
void setDeltaError(IdentifierHash idHash, float period_phi, float period_sinheta, float delta_x_slope, float delta_x_offset, float error_x, float delta_y_slope, float delta_y_offset, float error_y)
Definition
ITkPixelClusterErrorData.cxx:56
ITk::PixelClusterErrorData::m_pixelID
const PixelID * m_pixelID
Definition
ITkPixelClusterErrorData.h:85
ITk::PixelClusterErrorData::initialize
void initialize()
Definition
ITkPixelClusterErrorData.cxx:18
ITk::PixelClusterErrorData::load
unsigned int load(const std::string &file)
load cluster error data from ascii file
Definition
ITkPixelClusterErrorData.cxx:83
ITk::PixelClusterErrorData::getDelta
std::pair< double, double > getDelta(IdentifierHash idHash, int sizePhi, double angle, int sizeZ, double eta) const
Methods to access the calibration data.
Definition
ITkPixelClusterErrorData.cxx:32
ITk::PixelClusterErrorData::m_constmap
std::vector< std::array< float, kNParam > > m_constmap
Definition
ITkPixelClusterErrorData.h:83
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
ITk
Definition
ITkPixelOfflineCalibCondAlg.cxx:13
file
TFile * file
Definition
tile_monitor.h:29
Generated on
for ATLAS Offline Software by
1.17.0