ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCalib
MdtCalib
MdtCalibData
src
MdtCalibDataContainer.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 <
MdtCalibData/MdtCalibDataContainer.h
>
6
#include <
MuonIdHelpers/IMuonIdHelperSvc.h
>
7
#include "
Identifier/IdentifierHash.h
"
8
#include "Identifier/Identifier.h"
9
10
11
namespace
MuonCalib
{
12
13
MdtCalibDataContainer::MdtCalibDataContainer
(
const
Muon::IMuonIdHelperSvc
* idHelperSvc,
14
const
RegionGranularity
granularity
):
15
m_idHelperSvc
{idHelperSvc},
16
m_granularity
{
granularity
} {
17
}
18
void
MdtCalibDataContainer::setInversePropSpeed
(
const
float
speed) {
m_invPropSpeed
= speed; }
19
float
MdtCalibDataContainer::inversePropSpeed
()
const
{
return
m_invPropSpeed
; }
20
21
MdtCalibDataContainer::RegionGranularity
MdtCalibDataContainer::granularity
()
const
{
return
m_granularity
; }
22
inline
std::optional<unsigned int>
MdtCalibDataContainer::containerIndex
(
const
Identifier
& measId, MsgStream&
msg
)
const
{
23
IdentifierHash
hash{0};
24
25
if
(
m_granularity
== RegionGranularity::OnePerMultiLayer &&
26
(
m_idHelper
.get_detectorElement_hash(measId, hash) ||
27
m_idHelper
.detectorElement_hash_max() <
static_cast<
unsigned
int
>
(hash))) {
28
msg
<<MSG::ERROR <<__FILE__<<
":"
<<__LINE__<<
" Failed to look up a proper detector element hash for "
29
<<
m_idHelperSvc
->toString(measId)<<
endmsg
;
30
return
std::nullopt;
31
}
else
if
(
m_granularity
== RegionGranularity::OnePerChamber &&
32
(
m_idHelper
.get_module_hash(measId, hash) ||
33
m_idHelper
.module_hash_max() <
static_cast<
unsigned
int
>
(hash))) {
34
msg
<<MSG::ERROR <<__FILE__<<
":"
<<__LINE__<<
" Failed to look up a proper detector element hash for "
35
<<
m_idHelperSvc
->toString(measId)<<
endmsg
;
36
return
std::nullopt;
37
}
38
return
std::make_optional<unsigned int>(
static_cast<
unsigned
int
>
(hash));
39
}
40
41
bool
MdtCalibDataContainer::hasDataForChannel
(
const
Identifier
& measId, MsgStream&
msg
)
const
{
42
std::optional<unsigned int >
index
=
containerIndex
(measId,
msg
);
43
return
!(!
index
|| (*index) >=
m_dataCache
.size() || !
m_dataCache
[*
index
]);
44
}
45
46
const
MdtFullCalibData
*
MdtCalibDataContainer::getCalibData
(
const
Identifier
& measId, MsgStream&
msg
)
const
{
47
std::optional<unsigned int>
index
=
containerIndex
(measId,
msg
);
48
if
(!
index
)
return
nullptr
;
49
if
((*
index
) <
m_dataCache
.size()) {
50
const
MdtFullCalibData
& data =
m_dataCache
[*
index
];
51
if
(data) {
return
&data;}
52
}
53
msg
<<MSG::WARNING<<__FILE__<<
":"
<<__LINE__<<
" No Mdt calibration data is stored for "
54
<<
m_idHelperSvc
->toString(measId)<<
endmsg
;
55
return
nullptr
;
56
}
57
bool
MdtCalibDataContainer::storeData
(
const
Identifier
& mlID,
CorrectionPtr
corrFuncSet, MsgStream&
msg
) {
59
std::optional<unsigned int>
index
=
containerIndex
(mlID,
msg
);
60
if
(!
index
)
return
false
;
61
if
(!corrFuncSet) {
62
msg
<< MSG::ERROR<<__FILE__<<
":"
<<__LINE__<<
" No correction functional set parsed for multilayer "
63
<<
m_idHelperSvc
->toString(mlID) <<
endmsg
;
64
return
false
;
65
}
67
if
(
m_dataCache
.size() <= (*
index
))
m_dataCache
.resize(*
index
+ 1);
68
MdtFullCalibData
& cache =
m_dataCache
[*
index
];
69
if
(cache.corrections && cache.corrections != corrFuncSet) {
70
msg
<< MSG::ERROR<<__FILE__<<
":"
<<__LINE__<<
" There already exist a rt relation object for multilayer "
71
<<
m_idHelperSvc
->toString(mlID) <<
endmsg
;
72
return
false
;
73
}
74
cache.corrections = std::move(corrFuncSet);
75
76
if
(
msg
.level() <= MSG::DEBUG) {
77
msg
<< MSG::DEBUG<<__FILE__<<
":"
<<__LINE__<<
" Added successfully the rt corrections for "
78
<<
m_idHelperSvc
->toString(mlID)<<
endmsg
;
79
}
80
return
true
;
81
}
82
bool
MdtCalibDataContainer::storeData
(
const
Identifier
& mlID,
RtRelationPtr
rtRelation, MsgStream&
msg
) {
84
std::optional<unsigned int>
index
=
containerIndex
(mlID,
msg
);
85
if
(!
index
)
return
false
;
86
if
(!rtRelation) {
87
msg
<< MSG::ERROR<<__FILE__<<
":"
<<__LINE__<<
" No rt relation parsed for multilayer "
88
<<
m_idHelperSvc
->toString(mlID) <<
endmsg
;
89
return
false
;
90
}
92
if
(
m_dataCache
.size() <= (*
index
))
m_dataCache
.resize(*
index
+ 1);
93
MdtFullCalibData
& cache =
m_dataCache
[*
index
];
94
if
(cache.rtRelation && cache.rtRelation != rtRelation) {
95
msg
<< MSG::ERROR<<__FILE__<<
":"
<<__LINE__<<
" There already exist a rt relation object for multilayer "
96
<<
m_idHelperSvc
->toString(mlID) <<
endmsg
;
97
return
false
;
98
}
99
cache.rtRelation = std::move(rtRelation);
100
101
if
(
msg
.level() <= MSG::DEBUG) {
102
msg
<< MSG::DEBUG<<__FILE__<<
":"
<<__LINE__<<
" Added successfully the rt relations for "
103
<<
m_idHelperSvc
->toString(mlID)<<
endmsg
;
104
}
105
return
true
;
106
}
107
bool
MdtCalibDataContainer::storeData
(
const
Identifier
& mlID,
TubeContainerPtr
tubeContainer, MsgStream&
msg
){
109
std::optional<unsigned int>
index
=
containerIndex
(mlID,
msg
);
110
if
(!
index
)
return
false
;
111
if
(!tubeContainer) {
112
msg
<< MSG::ERROR<<__FILE__<<
":"
<<__LINE__<<
" No tube ontainer parsed for multilayer "
113
<<
m_idHelperSvc
->toString(mlID) <<
endmsg
;
114
return
false
;
115
}
116
118
if
(
m_dataCache
.size() <= (*
index
))
m_dataCache
.resize(*
index
+ 1);
119
MdtFullCalibData
& cache =
m_dataCache
[*
index
];
120
if
(cache.tubeCalib && cache.tubeCalib != tubeContainer) {
121
msg
<< MSG::ERROR<<__FILE__<<
":"
<<__LINE__<<
" There already exist a tube calibration container for multilayer "
122
<<
m_idHelperSvc
->toString(mlID) <<
endmsg
;
123
return
false
;
124
}
125
if
(
msg
.level() <= MSG::DEBUG) {
126
msg
<< MSG::DEBUG<<__FILE__<<
":"
<<__LINE__<<
" Added successfully the tube calibrations for "
127
<<
m_idHelperSvc
->toString(mlID)<<
endmsg
;
128
}
129
cache.tubeCalib = tubeContainer;
130
if
(
m_granularity
== RegionGranularity::OneRt ||
131
m_idHelper
.multilayer(mlID) == 2 ||
132
m_idHelper
.numberOfMultilayers(mlID) == 1)
return
true
;
133
return
storeData
(
m_idHelper
.multilayerID(mlID, 2), std::move(tubeContainer),
msg
);
134
}
135
136
137
138
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
IMuonIdHelperSvc.h
IdentifierHash.h
MdtCalibDataContainer.h
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
MuonCalib::MdtCalibDataContainer::containerIndex
std::optional< unsigned int > containerIndex(const Identifier &measId, MsgStream &msg) const
Definition
MdtCalibDataContainer.cxx:22
MuonCalib::MdtCalibDataContainer::storeData
bool storeData(const Identifier &mlID, CorrectionPtr corrFuncSet, MsgStream &msg)
Definition
MdtCalibDataContainer.cxx:57
MuonCalib::MdtCalibDataContainer::m_dataCache
std::vector< MdtFullCalibData > m_dataCache
Definition
MdtCalibDataContainer.h:60
MuonCalib::MdtCalibDataContainer::m_idHelper
const MdtIdHelper & m_idHelper
Definition
MdtCalibDataContainer.h:59
MuonCalib::MdtCalibDataContainer::TubeContainerPtr
MdtFullCalibData::TubeContainerPtr TubeContainerPtr
Definition
MdtCalibDataContainer.h:31
MuonCalib::MdtCalibDataContainer::MdtCalibDataContainer
MdtCalibDataContainer(const Muon::IMuonIdHelperSvc *idHelprSvc, const RegionGranularity granularity)
Definition
MdtCalibDataContainer.cxx:13
MuonCalib::MdtCalibDataContainer::inversePropSpeed
float inversePropSpeed() const
Definition
MdtCalibDataContainer.cxx:19
MuonCalib::MdtCalibDataContainer::CorrectionPtr
MdtFullCalibData::CorrectionPtr CorrectionPtr
Definition
MdtCalibDataContainer.h:29
MuonCalib::MdtCalibDataContainer::m_granularity
const RegionGranularity m_granularity
Definition
MdtCalibDataContainer.h:58
MuonCalib::MdtCalibDataContainer::m_idHelperSvc
const Muon::IMuonIdHelperSvc * m_idHelperSvc
Definition
MdtCalibDataContainer.h:57
MuonCalib::MdtCalibDataContainer::m_invPropSpeed
float m_invPropSpeed
Definition
MdtCalibDataContainer.h:61
MuonCalib::MdtCalibDataContainer::RtRelationPtr
MdtFullCalibData::RtRelationPtr RtRelationPtr
Definition
MdtCalibDataContainer.h:30
MuonCalib::MdtCalibDataContainer::RegionGranularity
RegionGranularity
Definition
MdtCalibDataContainer.h:33
MuonCalib::MdtCalibDataContainer::hasDataForChannel
bool hasDataForChannel(const Identifier &measId, MsgStream &msg) const
Checks whether a calibration data object is already present.
Definition
MdtCalibDataContainer.cxx:41
MuonCalib::MdtCalibDataContainer::setInversePropSpeed
void setInversePropSpeed(const float speed)
Definition
MdtCalibDataContainer.cxx:18
MuonCalib::MdtCalibDataContainer::granularity
RegionGranularity granularity() const
Definition
MdtCalibDataContainer.cxx:21
MuonCalib::MdtCalibDataContainer::getCalibData
const MdtFullCalibData * getCalibData(const Identifier &measId, MsgStream &msg) const
Returns the calibration data associated with this station.
Definition
MdtCalibDataContainer.cxx:46
Muon::IMuonIdHelperSvc
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
Definition
IMuonIdHelperSvc.h:27
Identifier
Definition
IdentifierFieldParser.cxx:14
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition
CscCalcPed.cxx:21
index
Definition
index.py:1
MuonCalib::MdtFullCalibData
class which holds the full set of calibration constants for a given tube
Definition
MdtFullCalibData.h:15
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0