ATLAS Offline Software
MdtCalibDataContainer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 namespace MuonCalib{
7 
9  const RegionGranularity granularity):
10  m_idHelperSvc{idHelperSvc},
11  m_granularity{granularity} {
12 }
15 
17 inline std::optional<unsigned int> MdtCalibDataContainer::containerIndex(const Identifier& measId, MsgStream& msg) const {
19 
22  m_idHelper.detectorElement_hash_max() < static_cast<unsigned int>(hash))) {
23  msg<<MSG::ERROR <<__FILE__<<":"<<__LINE__<<" Failed to look up a proper detector element hash for "
24  <<m_idHelperSvc->toString(measId)<<endmsg;
25  return std::nullopt;
27  (m_idHelper.get_module_hash(measId, hash) ||
28  m_idHelper.module_hash_max() < static_cast<unsigned int>(hash))) {
29  msg<<MSG::ERROR <<__FILE__<<":"<<__LINE__<<" Failed to look up a proper detector element hash for "
30  <<m_idHelperSvc->toString(measId)<<endmsg;
31  return std::nullopt;
32  }
33  return std::make_optional<unsigned int>(static_cast<unsigned int>(hash));
34 }
35 
36 bool MdtCalibDataContainer::hasDataForChannel(const Identifier& measId, MsgStream& msg) const {
37  std::optional<unsigned int > index = containerIndex(measId, msg);
38  return !(!index || (*index) >= m_dataCache.size() || !m_dataCache[*index]);
39 }
40 
41 const MdtFullCalibData* MdtCalibDataContainer::getCalibData(const Identifier& measId, MsgStream& msg) const {
42  std::optional<unsigned int> index = containerIndex(measId, msg);
43  if (!index) return nullptr;
44  if ((*index ) < m_dataCache.size()) {
46  if (data) {return &data;}
47  }
48  msg<<MSG::WARNING<<__FILE__<<":"<<__LINE__<<" No Mdt calibration data is stored for "
49  <<m_idHelperSvc->toString(measId)<<endmsg;
50  return nullptr;
51 }
52 bool MdtCalibDataContainer::storeData(const Identifier& mlID, CorrectionPtr corrFuncSet, MsgStream& msg) {
54  std::optional<unsigned int> index = containerIndex(mlID, msg);
55  if (!index) return false;
56  if (!corrFuncSet) {
57  msg << MSG::ERROR<<__FILE__<<":"<<__LINE__<<" No correction functional set parsed for multilayer "
58  <<m_idHelperSvc->toString(mlID) << endmsg;
59  return false;
60  }
62  if (m_dataCache.size() <= (*index)) m_dataCache.resize(*index + 1);
64  if (cache.corrections && cache.corrections != corrFuncSet) {
65  msg << MSG::ERROR<<__FILE__<<":"<<__LINE__<<" There already exist a rt relation object for multilayer "
66  <<m_idHelperSvc->toString(mlID) << endmsg;
67  return false;
68  }
69  cache.corrections = std::move(corrFuncSet);
70 
71  if (msg.level() <= MSG::DEBUG) {
72  msg << MSG::DEBUG<<__FILE__<<":"<<__LINE__<<" Added successfully the rt corrections for "
73  << m_idHelperSvc->toString(mlID)<<endmsg;
74  }
75  return true;
76 }
77 bool MdtCalibDataContainer::storeData(const Identifier& mlID, RtRelationPtr rtRelation, MsgStream& msg) {
79  std::optional<unsigned int> index = containerIndex(mlID, msg);
80  if (!index) return false;
81  if (!rtRelation) {
82  msg << MSG::ERROR<<__FILE__<<":"<<__LINE__<<" No rt relation parsed for multilayer "
83  <<m_idHelperSvc->toString(mlID) << endmsg;
84  return false;
85  }
87  if (m_dataCache.size() <= (*index)) m_dataCache.resize(*index + 1);
89  if (cache.rtRelation && cache.rtRelation != rtRelation) {
90  msg << MSG::ERROR<<__FILE__<<":"<<__LINE__<<" There already exist a rt relation object for multilayer "
91  <<m_idHelperSvc->toString(mlID) << endmsg;
92  return false;
93  }
94  cache.rtRelation = std::move(rtRelation);
95 
96  if (msg.level() <= MSG::DEBUG) {
97  msg << MSG::DEBUG<<__FILE__<<":"<<__LINE__<<" Added successfully the rt relations for "
98  << m_idHelperSvc->toString(mlID)<<endmsg;
99  }
100  return true;
101 }
102 bool MdtCalibDataContainer::storeData(const Identifier& mlID, TubeContainerPtr tubeContainer, MsgStream& msg){
104  std::optional<unsigned int> index = containerIndex(mlID, msg);
105  if (!index) return false;
106  if (!tubeContainer) {
107  msg << MSG::ERROR<<__FILE__<<":"<<__LINE__<<" No tube ontainer parsed for multilayer "
108  <<m_idHelperSvc->toString(mlID) << endmsg;
109  return false;
110  }
111 
113  if (m_dataCache.size() <= (*index)) m_dataCache.resize(*index + 1);
115  if (cache.tubeCalib && cache.tubeCalib != tubeContainer) {
116  msg << MSG::ERROR<<__FILE__<<":"<<__LINE__<<" There already exist a tube calibration container for multilayer "
117  <<m_idHelperSvc->toString(mlID) << endmsg;
118  return false;
119  }
120  if (msg.level() <= MSG::DEBUG) {
121  msg << MSG::DEBUG<<__FILE__<<":"<<__LINE__<<" Added successfully the tube calibrations for "
122  << m_idHelperSvc->toString(mlID)<<endmsg;
123  }
124  cache.tubeCalib = tubeContainer;
126  m_idHelper.multilayer(mlID) == 2 ||
127  m_idHelper.numberOfMultilayers(mlID) == 1) return true;
128  return storeData(m_idHelper.multilayerID(mlID, 2), tubeContainer, msg);
129 }
130 
131 
132 
133 }
MdtIdHelper::multilayer
int multilayer(const Identifier &id) const
Access to components of the ID.
Definition: MdtIdHelper.cxx:722
MuonCalib::MdtCalibDataContainer::m_granularity
const RegionGranularity m_granularity
Definition: MdtCalibDataContainer.h:51
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
GeoModel::TransientConstSharedPtr< MdtCorFuncSet >
MuonCalib::MdtCalibDataContainer::setInversePropSpeed
void setInversePropSpeed(const float speed)
Definition: MdtCalibDataContainer.cxx:13
MdtIdHelper::numberOfMultilayers
int numberOfMultilayers(const Identifier &id) const
Definition: MdtIdHelper.cxx:496
MuonCalib::MdtCalibDataContainer::RegionGranularity
RegionGranularity
Definition: MdtCalibDataContainer.h:26
index
Definition: index.py:1
MuonCalib::MdtCalibDataContainer::storeData
bool storeData(const Identifier &mlID, CorrectionPtr corrFuncSet, MsgStream &msg)
Definition: MdtCalibDataContainer.cxx:52
MuonIdHelper::detectorElement_hash_max
size_type detectorElement_hash_max() const
Definition: MuonIdHelper.h:186
MdtCalibDataContainer.h
MuonCalib::MdtFullCalibData::rtRelation
RtRelationPtr rtRelation
Definition: MdtFullCalibData.h:21
MuonCalib::MdtCalibDataContainer::m_dataCache
std::vector< MdtFullCalibData > m_dataCache
Definition: MdtCalibDataContainer.h:53
MuonCalib::MdtFullCalibData
class which holds the full set of calibration constants for a given tube
Definition: MdtFullCalibData.h:15
MuonCalib::MdtFullCalibData::corrections
CorrectionPtr corrections
Definition: MdtFullCalibData.h:20
MuonCalib::MdtCalibDataContainer::m_idHelperSvc
const Muon::IMuonIdHelperSvc * m_idHelperSvc
Definition: MdtCalibDataContainer.h:50
MuonCalib::MdtFullCalibData::tubeCalib
TubeContainerPtr tubeCalib
Definition: MdtFullCalibData.h:22
MuonCalib::MdtCalibDataContainer::granularity
RegionGranularity granularity() const
Definition: MdtCalibDataContainer.cxx:16
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MuonCalib::MdtCalibDataContainer::RegionGranularity::OnePerChamber
@ OnePerChamber
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
MuonCalib::MdtCalibDataContainer::m_invPropSpeed
float m_invPropSpeed
Definition: MdtCalibDataContainer.h:54
MuonCalib::MdtCalibDataContainer::RegionGranularity::OnePerMultiLayer
@ OnePerMultiLayer
MuonCalib::MdtCalibDataContainer::getCalibData
const MdtFullCalibData * getCalibData(const Identifier &measId, MsgStream &msg) const
Returns the calibration data associated with this station
Definition: MdtCalibDataContainer.cxx:41
MuonIdHelper::module_hash_max
size_type module_hash_max() const
the maximum hash value
Definition: MuonIdHelper.cxx:754
DeMoScan.index
string index
Definition: DeMoScan.py:362
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
Muon::IMuonIdHelperSvc::toString
virtual std::string toString(const Identifier &id) const =0
print all fields to string
MdtIdHelper::get_detectorElement_hash
virtual int get_detectorElement_hash(const Identifier &id, IdentifierHash &hash_id) const override
Definition: MdtIdHelper.cxx:326
MuonCalib::MdtCalibDataContainer::RegionGranularity::OneRt
@ OneRt
DEBUG
#define DEBUG
Definition: page_access.h:11
MuonCalib::MdtCalibDataContainer::containerIndex
std::optional< unsigned int > containerIndex(const Identifier &measId, MsgStream &msg) const
Definition: MdtCalibDataContainer.cxx:17
Muon::IMuonIdHelperSvc
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
Definition: IMuonIdHelperSvc.h:27
MdtIdHelper::multilayerID
Identifier multilayerID(const Identifier &channeldID) const
Definition: MdtIdHelper.cxx:333
MuonCalib::MdtCalibDataContainer::hasDataForChannel
bool hasDataForChannel(const Identifier &measId, MsgStream &msg) const
Checks whether a calibration data object is already present.
Definition: MdtCalibDataContainer.cxx:36
MdtIdHelper::get_module_hash
virtual int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const override
Definition: MdtIdHelper.cxx:319
MuonCalib::MdtCalibDataContainer::m_idHelper
const MdtIdHelper & m_idHelper
Definition: MdtCalibDataContainer.h:52
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
MuonCalib::MdtCalibDataContainer::inversePropSpeed
float inversePropSpeed() const
Definition: MdtCalibDataContainer.cxx:14
MuonCalib::MdtCalibDataContainer::MdtCalibDataContainer
MdtCalibDataContainer(const Muon::IMuonIdHelperSvc *idHelprSvc, const RegionGranularity granularity)
Definition: MdtCalibDataContainer.cxx:8
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
Identifier
Definition: IdentifierFieldParser.cxx:14