ATLAS Offline Software
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 
7 MuonStationIntersectCondAlg::MuonStationIntersectCondAlg(const std::string& name, ISvcLocator* pSvcLocator) :
8  AthReentrantAlgorithm(name, pSvcLocator) {}
10  ATH_CHECK(m_idHelperSvc.retrieve());
14  return StatusCode::SUCCESS;
15 }
16 StatusCode 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 }
MuonStationIntersectCondAlg::m_writeKey
SG::WriteCondHandleKey< Muon::MuonIntersectGeoData > m_writeKey
Definition: MuonStationIntersectCondAlg.h:26
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
MuonStationIntersectCondAlg::m_condKey
SG::ReadCondHandleKey< MdtCondDbData > m_condKey
Definition: MuonStationIntersectCondAlg.h:29
MuonStationIntersectCondAlg::m_DetectorManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
Definition: MuonStationIntersectCondAlg.h:31
MdtCondDbData
Definition: MdtCondDbData.h:21
MuonStationIntersectCondAlg.h
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonStationIntersectCondAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonStationIntersectCondAlg.h:24
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonStationIntersectCondAlg::MuonStationIntersectCondAlg
MuonStationIntersectCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonStationIntersectCondAlg.cxx:7
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MuonStationIntersectCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: MuonStationIntersectCondAlg.cxx:16
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::intersect
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
Definition: GeoPrimitivesHelpers.h:347
MuonStationIntersectCondAlg::initialize
virtual StatusCode initialize() override
Definition: MuonStationIntersectCondAlg.cxx:9
SG::WriteCondHandle
Definition: WriteCondHandle.h:26