ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCalib
MdtCalib
MdtCalibSvc
src
MdtCalibrationTMaxShiftTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MdtCalibrationTMaxShiftTool.h
"
6
7
// TRandom2 for random smearing
8
// should later be replaced with std
9
#include "TRandom2.h"
10
11
MdtCalibrationTMaxShiftTool::MdtCalibrationTMaxShiftTool
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent) :
12
MdtCalibrationShiftMapBase
(
type
, name, parent) {}
13
14
StatusCode
MdtCalibrationTMaxShiftTool::initializeMap
() {
15
if
(
m_mapIsInitialized
) {
16
ATH_MSG_WARNING
(
17
"Map already initalized. Multiple calls of initalizeMap "
18
"should not happen."
);
19
return
StatusCode::SUCCESS;
20
}
21
22
/* First try loading the map from its default location */
23
if
(!
m_forceMapRecreate
) {
24
ATH_CHECK
(
loadMapFromFile
());
25
return
StatusCode::SUCCESS;
26
}
27
28
/* map was not found as a file */
29
// TODO: What if multiple jobs started in parallel?
30
// (DataRace on MapFile because of parallel jobs)
31
32
/* initialize random number generator that creates the shift values */
33
TRandom2 rng(
/*seed*/
20160211);
34
35
SG::ReadCondHandle<MuonMDT_CablingMap>
readHandle{
m_mdtCab
, Gaudi::Hive::currentContext()};
36
const
MuonMDT_CablingMap
* mdtCabling{*readHandle};
37
if
(!mdtCabling){
38
ATH_MSG_ERROR
(
"Null pointer to the MDT cabling conditions object"
);
39
return
StatusCode::FAILURE;
40
}
41
42
for
(
const
auto
& onl_cab : mdtCabling->
getOnlineConvMap
()) {
43
MuonMDT_CablingMap::CablingData
cabling_data{};
44
cabling_data.MdtCablingOnData::operator=(onl_cab.first);
46
for
(
const
auto
& tdc : onl_cab.second) {
47
if
(!tdc)
continue
;
48
cabling_data.tdcId = tdc->moduleId();
49
for
(cabling_data.channelId = 0; cabling_data.channelId < 24; ++cabling_data.channelId) {
50
/* Get the offline ID, given the current detector element */
51
if
(!mdtCabling->
getOfflineId
(cabling_data, msgStream())) {
52
ATH_MSG_WARNING
(cabling_data);
53
continue
;
54
}
55
Identifier
channelIdentifier;
56
bool
isValid
= mdtCabling->
convert
(cabling_data,channelIdentifier);
57
// this debug msg can be removed eventually
58
ATH_MSG_DEBUG
(
"Trying to set from online IDs "
<<
59
std::endl<<
60
cabling_data<<
61
" .. with channelID"
<<
62
std::endl <<
63
" Identifier "
<<
64
channelIdentifier <<std::endl<<
" Identifier32 "
<< channelIdentifier.
get_identifier32
());
65
66
if
(!
isValid
) {
67
ATH_MSG_FATAL
(cabling_data<<
" --- Conversion to Identifier is NOT valid."
);
68
return
StatusCode::FAILURE;
69
}
70
if
(
m_shiftValues
.find(channelIdentifier) !=
m_shiftValues
.end()) {
71
ATH_MSG_FATAL
(
"Double counting in initilization of map"
);
72
return
StatusCode::FAILURE;
73
}
74
float
rn = rng.Gaus(
m_centralValue
,
m_sigma
);
75
float
shift =
76
rn /
m_tUpper
;
// store relative variation: Delta_t / t
77
m_shiftValues
[channelIdentifier] = shift;
78
}
79
}
80
}
81
82
83
/* initalization was successful */
84
m_mapIsInitialized
=
true
;
85
86
/* write map to the default location */
87
ATH_CHECK
(
dumpMapAsFile
());
88
89
return
StatusCode::SUCCESS;
90
}
91
92
StatusCode
MdtCalibrationTMaxShiftTool::setTUpper
(
const
float
tUpper) {
93
if
(
m_mapIsInitialized
) {
94
ATH_MSG_FATAL
(
"You cannot change m_tUpper once the map is initialized."
);
95
return
StatusCode::FAILURE;
96
}
97
98
m_tUpper
= tUpper;
99
return
StatusCode::SUCCESS;
100
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
isValid
bool isValid() const
Test to see if the link can be dereferenced.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
MdtCalibrationTMaxShiftTool.h
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
MdtCalibrationShiftMapBase::m_centralValue
Gaudi::Property< float > m_centralValue
Definition
MdtCalibrationShiftMapBase.h:53
MdtCalibrationShiftMapBase::m_shiftValues
std::map< Identifier, float > m_shiftValues
Definition
MdtCalibrationShiftMapBase.h:57
MdtCalibrationShiftMapBase::m_sigma
Gaudi::Property< float > m_sigma
Definition
MdtCalibrationShiftMapBase.h:54
MdtCalibrationShiftMapBase::m_forceMapRecreate
Gaudi::Property< bool > m_forceMapRecreate
Definition
MdtCalibrationShiftMapBase.h:55
MdtCalibrationShiftMapBase::m_mapIsInitialized
bool m_mapIsInitialized
Definition
MdtCalibrationShiftMapBase.h:58
MdtCalibrationShiftMapBase::loadMapFromFile
StatusCode loadMapFromFile()
Definition
MdtCalibrationShiftMapBase.cxx:60
MdtCalibrationShiftMapBase::m_mdtCab
SG::ReadCondHandleKey< MuonMDT_CablingMap > m_mdtCab
Definition
MdtCalibrationShiftMapBase.h:61
MdtCalibrationShiftMapBase::dumpMapAsFile
StatusCode dumpMapAsFile()
Definition
MdtCalibrationShiftMapBase.cxx:22
MdtCalibrationShiftMapBase::MdtCalibrationShiftMapBase
MdtCalibrationShiftMapBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition
MdtCalibrationShiftMapBase.cxx:12
MdtCalibrationTMaxShiftTool::setTUpper
StatusCode setTUpper(const float tUpper)
Definition
MdtCalibrationTMaxShiftTool.cxx:92
MdtCalibrationTMaxShiftTool::m_tUpper
float m_tUpper
Definition
MdtCalibrationTMaxShiftTool.h:33
MdtCalibrationTMaxShiftTool::MdtCalibrationTMaxShiftTool
MdtCalibrationTMaxShiftTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition
MdtCalibrationTMaxShiftTool.cxx:11
MdtCalibrationTMaxShiftTool::initializeMap
StatusCode initializeMap() override final
Definition
MdtCalibrationTMaxShiftTool.cxx:14
MuonMDT_CablingMap
Definition
MuonMDT_CablingMap.h:28
MuonMDT_CablingMap::getOnlineConvMap
const OnlToOffMap & getOnlineConvMap() const
Returns the map to convert the online -> offline identifiers.
Definition
MuonMDT_CablingMap.cxx:348
MuonMDT_CablingMap::CablingData
MdtCablingData CablingData
Definition
MuonMDT_CablingMap.h:79
MuonMDT_CablingMap::getOfflineId
bool getOfflineId(CablingData &cabling_data, MsgStream &log) const
return the offline id given the online id
Definition
MuonMDT_CablingMap.cxx:252
MuonMDT_CablingMap::convert
bool convert(const CablingData &cabling_data, Identifier &id, bool check_valid=true) const
converts the cabling data into an identifier.
Definition
MuonMDT_CablingMap.cxx:44
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
Identifier
Definition
IdentifierFieldParser.cxx:14
type
Generated on
for ATLAS Offline Software by
1.17.0