ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCalib
MdtCalib
MdtCalibSvc
src
MdtCalibrationT0ShiftTool.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 "
MdtCalibrationT0ShiftTool.h
"
6
7
// TRandom3 for random smearing
8
// should later be replaced with std
9
#include "TRandom3.h"
10
11
MdtCalibrationT0ShiftTool::MdtCalibrationT0ShiftTool
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent) :
12
MdtCalibrationShiftMapBase
(
type
, name, parent) {
13
}
14
15
StatusCode
MdtCalibrationT0ShiftTool::initializeMap
()
16
{
17
if
(
m_mapIsInitialized
) {
18
ATH_MSG_WARNING
(
"Map already initalized. Multiple calls of initalizeMap 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 or needs to be recreated */
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
TRandom3 rng(
/*seed*/
20120704);
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
71
double
rn = rng.Gaus(
m_centralValue
,
m_sigma
);
72
// Fatal if entry exists
73
if
(
m_shiftValues
.find(channelIdentifier) !=
m_shiftValues
.end()) {
74
ATH_MSG_FATAL
(
"Double counting in initialization of map"
);
75
return
StatusCode::FAILURE;
76
}
77
m_shiftValues
[channelIdentifier] = rn;
78
79
}
80
}
81
}
82
/* initalization was successful */
83
m_mapIsInitialized
=
true
;
84
85
/* write map to the default location */
86
ATH_CHECK
(
dumpMapAsFile
() );
87
88
return
StatusCode::SUCCESS;
89
}
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
MdtCalibrationT0ShiftTool.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
MdtCalibrationT0ShiftTool::initializeMap
StatusCode initializeMap() override final
Definition
MdtCalibrationT0ShiftTool.cxx:15
MdtCalibrationT0ShiftTool::MdtCalibrationT0ShiftTool
MdtCalibrationT0ShiftTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
Definition
MdtCalibrationT0ShiftTool.cxx:11
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