ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7#include "GaudiKernel/ISvcLocator.h"
8
10
11#include <fstream>
12#include <stdexcept>
13
14
15namespace ITk
16{
17
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
32std::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
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
68void 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
83unsigned 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
Scalar eta() const
pseudorapidity method
static Double_t sc
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
void print(const std::string &file) const
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)
unsigned int load(const std::string &file)
load cluster error data from ascii file
std::pair< double, double > getDelta(IdentifierHash idHash, int sizePhi, double angle, int sizeZ, double eta) const
Methods to access the calibration data.
std::vector< std::array< float, kNParam > > m_constmap
This is a "hash" representation of an Identifier.
TFile * file