ATLAS Offline Software
Loading...
Searching...
No Matches
MuonStationIntersectCondAlg.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
7MuonStationIntersectCondAlg::MuonStationIntersectCondAlg(const std::string& name, ISvcLocator* pSvcLocator) :
8 AthCondAlgorithm(name, pSvcLocator) {}
10 ATH_CHECK(m_idHelperSvc.retrieve());
11 ATH_CHECK(m_writeKey.initialize());
12 ATH_CHECK(m_condKey.initialize(!m_condKey.empty()));
13 ATH_CHECK(m_DetectorManagerKey.initialize());
14 return StatusCode::SUCCESS;
15}
16StatusCode MuonStationIntersectCondAlg::execute(const EventContext& ctx) const {
18 if (!det_mgr.isValid()) {
19 ATH_MSG_FATAL("Failed to retrieve Muon detector manager " << m_DetectorManagerKey.fullKey());
20 return StatusCode::FAILURE;
21 }
22
23 EventIDRange rangeGeo;
24 if (!det_mgr.range(rangeGeo)) {
25 ATH_MSG_ERROR("Failed to retrieve validity range for " << m_DetectorManagerKey.key());
26 return StatusCode::FAILURE;
27 }
28 EventIDRange rangeIntersection = rangeGeo;
29
30 const MdtCondDbData* condData{nullptr};
31 if (!m_condKey.empty()) {
33 if (!condDbHandle.isValid()) {
34 ATH_MSG_FATAL("Failed to retrieve conditions data " << m_condKey.fullKey());
35 return StatusCode::FAILURE;
36 }
37
38 EventIDRange rangeCondDb;
39 if (!condDbHandle.range(rangeCondDb)) {
40 ATH_MSG_ERROR("Failed to retrieve validity range for " << m_DetectorManagerKey.key());
41 return StatusCode::FAILURE;
42 }
43 // Create an intersection of input IOVs
44 rangeIntersection = EventIDRange::intersect(rangeGeo, rangeCondDb);
45 }
46
48 if (writeHandle.isValid()) {
49 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
50 << ". In theory this should not be called, but may happen"
51 << " if multiple concurrent events are being processed out of order.");
52 return StatusCode::SUCCESS;
53 }
54
55 std::unique_ptr<Muon::MuonIntersectGeoData> geo_data =
56 std::make_unique<Muon::MuonIntersectGeoData>(msgStream(), det_mgr.cptr(), m_idHelperSvc.get(), condData);
57
58 if (writeHandle.record(rangeIntersection, std::move(geo_data)).isFailure()) {
59 ATH_MSG_FATAL("Could not record MuonMDT_CablingMap " << writeHandle.key() << " with EventRange " << rangeIntersection
60 << " into Conditions Store");
61 return StatusCode::FAILURE;
62 }
63 ATH_MSG_DEBUG("Recorded successfully the MuonIntersectionGeoData "<<writeHandle.key()<<" with EventRange "<<rangeIntersection);
64
65 return StatusCode::SUCCESS;
66}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
Base class for conditions algorithms.
MuonStationIntersectCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadCondHandleKey< MdtCondDbData > m_condKey
virtual StatusCode initialize() override
SG::WriteCondHandleKey< Muon::MuonIntersectGeoData > m_writeKey
bool range(EventIDRange &r)
const_pointer_type cptr()
const std::string & key() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const