ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
TRT_ConditionsAlgs
src
TRTCondRead.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 <fstream>
6
#include <iostream>
7
#include <string>
8
#include "
TRTCondRead.h
"
9
#include "
TRT_ConditionsData/BasicRtRelation.h
"
10
#include "
TRT_ConditionsData/DinesRtRelation.h
"
11
#include "
TRT_ConditionsData/BinnedRtRelation.h
"
12
#include "
TRT_ConditionsData/RtRelationFactory.h
"
13
20
TRTCondRead::TRTCondRead
(
const
std::string &name, ISvcLocator *pSvcLocator)
21
:
AthAlgorithm
(name, pSvcLocator) {}
22
23
StatusCode
TRTCondRead::initialize
()
24
{
25
26
ATH_MSG_DEBUG
(
"TRTCondRead::initialize() called"
);
27
28
ATH_CHECK
(
m_TRTCalDbTool
.retrieve());
29
30
// Get TRT ID helper
31
ATH_CHECK
(
detStore
()->retrieve(
m_trtid
,
"TRT_ID"
));
32
33
return
StatusCode::SUCCESS;
34
}
35
36
StatusCode
TRTCondRead::execute
(
const
EventContext&
/*ctx*/
)
37
{
38
39
// Write text file.
40
if
(!
m_par_caloutputfile
.empty())
41
{
42
ATH_MSG_INFO
(
" Writing calibration constants to text file "
<<
m_par_caloutputfile
);
43
std::ofstream outfile(
m_par_caloutputfile
);
44
// if ((m_par_caloutputfile.value()).contains("caliboutput")) TO BE CORRECTED when C++23
45
if
(
m_par_caloutputfile
.value().find(
"caliboutput"
) != std::string::npos)
46
{
47
ATH_MSG_INFO
(
"File name: "
<<
m_par_caloutputfile
);
48
ATH_CHECK
(
writeCalibTextFile
(outfile));
49
}
50
// else if ((m_par_caloutputfile.value()).contains("erroroutput")) TO BE CORRECTED when C++23
51
else
if
(
m_par_caloutputfile
.value().find(
"erroroutput"
) != std::string::npos)
52
{
53
ATH_MSG_INFO
(
"File name: "
<<
m_par_caloutputfile
);
54
ATH_CHECK
(
writeErrorTextFile
(outfile));
55
}
56
else
57
{
58
ATH_MSG_WARNING
(
"The file name must contain either 'caliboutput' or 'erroroutput' "
);
59
}
60
outfile.close();
61
}
62
63
// Quick spot check of the T0s
64
ATH_MSG_INFO
(
" Spot check of T0 in every 10'th straw_layer in phi_modules 0, 10, 20 and 30"
);
65
for
(std::vector<Identifier>::const_iterator it =
m_trtid
->straw_layer_begin(); it !=
m_trtid
->straw_layer_end(); ++it)
66
{
67
Identifier
id
=
m_trtid
->straw_id(*it, 0);
68
if
(
m_trtid
->phi_module(
id
) % 10 == 0 &&
m_trtid
->straw_layer(
id
) % 10 == 0)
69
{
70
float
t0
=
m_TRTCalDbTool
->getT0(
id
);
71
ATH_MSG_INFO
(
" bec: "
<<
m_trtid
->barrel_ec(
id
) <<
" lay: "
<<
m_trtid
->layer_or_wheel(
id
) <<
" phi: "
<<
m_trtid
->phi_module(
id
) <<
" slay: "
<<
m_trtid
->straw_layer(
id
) <<
" t0: "
<<
t0
);
72
}
73
}
74
75
ATH_MSG_INFO
(
""
);
76
ATH_MSG_INFO
(
"List of straws with T0=0 :"
);
77
78
int
nzeros = 0;
79
for
(std::vector<Identifier>::const_iterator it =
m_trtid
->straw_layer_begin(); it !=
m_trtid
->straw_layer_end(); ++it)
80
{
81
int
nStrawsInLayer =
m_trtid
->straw_max(*it);
82
for
(
int
i = 0; i <= nStrawsInLayer; i++)
83
{
84
Identifier
strid =
m_trtid
->straw_id(*it, i);
85
if
(
m_TRTCalDbTool
->getT0(strid) == 0)
86
{
87
ATH_MSG_INFO
(
" bec: "
<<
m_trtid
->barrel_ec(strid) <<
" lay: "
<<
m_trtid
->layer_or_wheel(strid)
88
<<
" phi: "
<<
m_trtid
->phi_module(strid) <<
" slay: "
<<
m_trtid
->straw_layer(strid) <<
" straw: "
<<
m_trtid
->straw(strid));
89
nzeros++;
90
}
91
}
92
}
93
94
if
(nzeros > 10)
95
{
96
ATH_MSG_INFO
(
" Several cases of T0=0. Check the input text file and assign default T0 values instead of zero "
);
97
}
98
ATH_MSG_INFO
(
""
);
99
100
return
StatusCode::SUCCESS;
101
}
102
103
StatusCode
TRTCondRead::finalize
()
104
{
105
return
StatusCode::SUCCESS;
106
}
107
108
StatusCode
TRTCondRead::writeCalibTextFile
(std::ostream &outfile)
const
109
{
110
const
RtRelationContainer
*rtContainer =
m_TRTCalDbTool
->getRtContainer();
111
const
StrawT0Container
*t0Container =
m_TRTCalDbTool
->getT0Container();
112
113
// first store rtrelations
114
outfile <<
"# Rtrelation"
<< std::endl;
115
RtRelationContainer::FlatContainer
rtrelations;
116
rtContainer->
getall
(rtrelations);
117
for
(
RtRelationContainer::FlatContainer::iterator
it = rtrelations.begin(); it != rtrelations.end(); ++it)
118
{
119
// write the identifier
120
outfile << it->first <<
" : "
;
121
// write the rt-relation via the factory
122
TRTCond::RtRelationFactory::writeToFile
(outfile, **(it->second));
123
outfile << std::endl;
124
}
125
126
// now store the t0s
127
outfile <<
"# StrawT0"
<< std::endl;
128
StrawT0Container::FlatContainer
packedstrawdata;
129
t0Container->
getall
(packedstrawdata);
130
float
t0
(0), t0err(0);
131
for
(TRTCond::StrawT0Container::FlatContainer::iterator it = packedstrawdata.begin(); it != packedstrawdata.end(); ++it)
132
{
133
const
TRTCond::ExpandedIdentifier
&calid = it->first;
134
t0Container->
unpack
(calid, *it->second,
t0
, t0err);
135
outfile << calid <<
" : "
<<
t0
<<
" "
<< t0err << std::endl;
136
}
137
138
return
StatusCode::SUCCESS;
139
}
140
141
StatusCode
TRTCondRead::writeErrorTextFile
(std::ostream &outfile)
const
142
{
143
const
RtRelationContainer
*errContainer =
m_TRTCalDbTool
->getErrContainer();
144
const
RtRelationContainer
*slopeContainer =
m_TRTCalDbTool
->getSlopeContainer();
145
146
// then store errors2d
147
outfile <<
"# RtErrors"
<< std::endl;
148
RtRelationContainer::FlatContainer
errors;
149
errContainer->
getall
(errors);
150
for
(
RtRelationContainer::FlatContainer::iterator
it = errors.begin();
151
it != errors.end(); ++it)
152
{
153
// write the identifier
154
outfile << it->first <<
" : "
;
155
// write the errors via the factory
156
TRTCond::RtRelationFactory::writeToFile
(outfile, **(it->second));
157
outfile << std::endl;
158
}
159
160
// then store slopes
161
outfile <<
"# RtSlopes"
<< std::endl;
162
RtRelationContainer::FlatContainer
slopes;
163
slopeContainer->
getall
(slopes);
164
for
(
RtRelationContainer::FlatContainer::iterator
it = slopes.begin();
165
it != slopes.end(); ++it)
166
{
167
// write the identifier
168
outfile << it->first <<
" : "
;
169
// write the slopes via the factory
170
TRTCond::RtRelationFactory::writeToFile
(outfile, **(it->second));
171
outfile << std::endl;
172
}
173
174
return
StatusCode::SUCCESS;
175
}
176
177
TRTCond::ExpandedIdentifier
TRTCondRead::trtcondid
(
const
Identifier
&
id
,
int
level)
const
178
{
179
return
TRTCond::ExpandedIdentifier
(
m_trtid
->barrel_ec(
id
),
m_trtid
->layer_or_wheel(
id
),
180
m_trtid
->phi_module(
id
),
m_trtid
->straw_layer(
id
),
181
m_trtid
->straw(
id
), level);
182
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
BasicRtRelation.h
BinnedRtRelation.h
DinesRtRelation.h
t0
static Double_t t0
Definition
LArPhysWaveHECTool.cxx:38
RtRelationFactory.h
TRTCondRead.h
Algorithm to read TRT calibration constants from db and dump them to a text file.
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
DataVector< RtRelationLayerContainer >::iterator
DataModel_detail::iterator< DataVector > iterator
Definition
DataVector.h:842
TRTCondRead::m_TRTCalDbTool
ToolHandle< ITRT_CalDbTool > m_TRTCalDbTool
Definition
TRTCondRead.h:55
TRTCondRead::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
TRTCondRead.cxx:36
TRTCondRead::RtRelationContainer
TRTCond::RtRelationMultChanContainer RtRelationContainer
Definition
TRTCondRead.h:33
TRTCondRead::initialize
virtual StatusCode initialize(void) override
Definition
TRTCondRead.cxx:23
TRTCondRead::finalize
virtual StatusCode finalize(void) override
Definition
TRTCondRead.cxx:103
TRTCondRead::StrawT0Container
TRTCond::StrawT0MultChanContainer StrawT0Container
Definition
TRTCondRead.h:34
TRTCondRead::TRTCondRead
TRTCondRead(const std::string &name, ISvcLocator *pSvcLocator)
constructor
Definition
TRTCondRead.cxx:20
TRTCondRead::m_trtid
const TRT_ID * m_trtid
trt id helper
Definition
TRTCondRead.h:57
TRTCondRead::writeCalibTextFile
virtual StatusCode writeCalibTextFile(std::ostream &) const
write calibration constants or errors to flat text file
Definition
TRTCondRead.cxx:108
TRTCondRead::m_par_caloutputfile
Gaudi::Property< std::string > m_par_caloutputfile
Definition
TRTCondRead.h:56
TRTCondRead::trtcondid
virtual TRTCond::ExpandedIdentifier trtcondid(const Identifier &id, int level=TRTCond::ExpandedIdentifier::STRAW) const
create an TRTCond::ExpandedIdentifier from a TRTID identifier
Definition
TRTCondRead.cxx:177
TRTCondRead::writeErrorTextFile
virtual StatusCode writeErrorTextFile(std::ostream &) const
Definition
TRTCondRead.cxx:141
TRTCond::ExpandedIdentifier
Identifier for TRT detector elements in the conditions code.
Definition
InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:30
TRTCond::MultChanContainer::getall
void getall(typename DaughterContainer::FlatContainer &entries) const
get a flat vector with all values.
Definition
MultChanContainer.h:340
TRTCond::RtRelationFactory::writeToFile
static void writeToFile(std::ostream &os, const RtRelation &rt)
write method
Definition
RtRelationFactory.h:54
TRTCond::RtRelationMultChanContainer::FlatContainer
RtRelationLayerContainer::FlatContainer FlatContainer
typedef
Definition
RtRelationMultChanContainer.h:32
TRTCond::StrawT0MultChanContainer::unpack
void unpack(const ExpandedIdentifier &id, const StrawT0 &sd, float &t0, float &t0err) const
public method to unpack a StrawT0 object
Definition
StrawT0MultChanContainer.h:66
TRTCond::StrawT0MultChanContainer::FlatContainer
StrawT0ContainerTemplate< ExpandedIdentifier::LAYERWHEEL >::FlatContainer FlatContainer
typedefs
Definition
StrawT0MultChanContainer.h:34
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0