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 }
14 inline std::optional<unsigned int> MdtCalibDataContainer::containerIndex(const Identifier& measId, MsgStream& msg) const {
16 
19  m_idHelper.detectorElement_hash_max() < static_cast<unsigned int>(hash))) {
20  msg<<MSG::ERROR <<__FILE__<<":"<<__LINE__<<" Failed to look up a proper detector element hash for "
21  <<m_idHelperSvc->toString(measId)<<endmsg;
22  return std::nullopt;
24  (m_idHelper.get_module_hash(measId, hash) ||
25  m_idHelper.module_hash_max() < static_cast<unsigned int>(hash))) {
26  msg<<MSG::ERROR <<__FILE__<<":"<<__LINE__<<" Failed to look up a proper detector element hash for "
27  <<m_idHelperSvc->toString(measId)<<endmsg;
28  return std::nullopt;
29  }
30  return std::make_optional<unsigned int>(static_cast<unsigned int>(hash));
31 }
32 
33 bool MdtCalibDataContainer::hasDataForChannel(const Identifier& measId, MsgStream& msg) const {
34  std::optional<unsigned int > index = containerIndex(measId, msg);
35  return !(!index || (*index) >= m_dataCache.size() || !m_dataCache[*index]);
36 }
37 
38 const MdtFullCalibData* MdtCalibDataContainer::getCalibData(const Identifier& measId, MsgStream& msg) const {
39  std::optional<unsigned int> index = containerIndex(measId, msg);
40  if (!index) return nullptr;
41  if ((*index ) < m_dataCache.size()) {
43  if (data) {return &data;}
44  }
45  msg<<MSG::WARNING<<__FILE__<<":"<<__LINE__<<" No Mdt calibration data is stored for "
46  <<m_idHelperSvc->toString(measId)<<endmsg;
47  return nullptr;
48 }
49 bool MdtCalibDataContainer::storeData(const Identifier& mlID, CorrectionPtr corrFuncSet, MsgStream& msg) {
51  std::optional<unsigned int> index = containerIndex(mlID, msg);
52  if (!index) return false;
54  if (m_dataCache.size() <= (*index)) m_dataCache.resize(*index + 1);
56  if (cache.corrections) {
57  msg << MSG::ERROR<<__FILE__<<":"<<__LINE__<<" There already exist a rt relation object for multilayer "
58  <<m_idHelperSvc->toString(mlID) << endmsg;
59  return false;
60  }
61  cache.corrections = corrFuncSet;
62 
63  if (msg.level() <= MSG::DEBUG) {
64  msg << MSG::DEBUG<<__FILE__<<":"<<__LINE__<<" Added successfully the rt corrections for "
65  << m_idHelperSvc->toString(mlID)<<endmsg;
66  }
67  return true;
68 }
69 bool MdtCalibDataContainer::storeData(const Identifier& mlID, RtRelationPtr rtRelation, MsgStream& msg) {
71  std::optional<unsigned int> index = containerIndex(mlID, msg);
72  if (!index) return false;
74  if (m_dataCache.size() <= (*index)) m_dataCache.resize(*index + 1);
76  if (cache.rtRelation) {
77  msg << MSG::ERROR<<__FILE__<<":"<<__LINE__<<" There already exist a rt relation object for multilayer "
78  <<m_idHelperSvc->toString(mlID) << endmsg;
79  return false;
80  }
81  cache.rtRelation = rtRelation;
82 
83  if (msg.level() <= MSG::DEBUG) {
84  msg << MSG::DEBUG<<__FILE__<<":"<<__LINE__<<" Added successfully the rt relations for "
85  << m_idHelperSvc->toString(mlID)<<endmsg;
86  }
87  return true;
88 }
89 bool MdtCalibDataContainer::storeData(const Identifier& mlID, TubeContainerPtr tubeContainer, MsgStream& msg){
91  std::optional<unsigned int> index = containerIndex(mlID, msg);
92  if (!index) return false;
94  if (m_dataCache.size() <= (*index)) m_dataCache.resize(*index + 1);
96  if (cache.tubeCalib) {
97  msg << MSG::ERROR<<__FILE__<<":"<<__LINE__<<" There already exist a tube calibration container for multilayer "
98  <<m_idHelperSvc->toString(mlID) << endmsg;
99  return false;
100  }
101  if (msg.level() <= MSG::DEBUG) {
102  msg << MSG::DEBUG<<__FILE__<<":"<<__LINE__<<" Added successfully the tube calibrations for "
103  << m_idHelperSvc->toString(mlID)<<endmsg;
104  }
105  cache.tubeCalib = tubeContainer;
107  m_idHelper.multilayer(mlID) == 2 ||
108  m_idHelper.numberOfMultilayers(mlID) == 1) return true;
109  return storeData(m_idHelper.multilayerID(mlID, 2), tubeContainer, msg);
110 }
111 
112 
113 
114 }
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:48
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
GeoModel::TransientConstSharedPtr< MdtCorFuncSet >
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:49
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:50
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:47
MuonCalib::MdtFullCalibData::tubeCalib
TubeContainerPtr tubeCalib
Definition: MdtFullCalibData.h:22
MuonCalib::MdtCalibDataContainer::granularity
RegionGranularity granularity() const
Definition: MdtCalibDataContainer.cxx:13
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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::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:38
MuonIdHelper::module_hash_max
size_type module_hash_max() const
the maximum hash value
Definition: MuonIdHelper.cxx:752
DeMoScan.index
string index
Definition: DeMoScan.py:362
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
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:325
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:14
Muon::IMuonIdHelperSvc
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
Definition: IMuonIdHelperSvc.h:26
MdtIdHelper::multilayerID
Identifier multilayerID(const Identifier &channeldID) const
Definition: MdtIdHelper.cxx:332
MuonCalib::MdtCalibDataContainer::hasDataForChannel
bool hasDataForChannel(const Identifier &measId, MsgStream &msg) const
Checks whether a calibration data object is already present.
Definition: MdtCalibDataContainer.cxx:33
MdtIdHelper::get_module_hash
virtual int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const override
Definition: MdtIdHelper.cxx:318
MuonCalib::MdtCalibDataContainer::m_idHelper
const MdtIdHelper & m_idHelper
Definition: MdtCalibDataContainer.h:49
IdentifierHash
Definition: IdentifierHash.h:38
MuonCalib::MdtCalibDataContainer::MdtCalibDataContainer
MdtCalibDataContainer(const Muon::IMuonIdHelperSvc *idHelprSvc, const RegionGranularity granularity)
Definition: MdtCalibDataContainer.cxx:8
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7