ATLAS Offline Software
Loading...
Searching...
No Matches
HGTDMappingAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6//package includes
7#include "HGTDMappingAlg.h"
8
9
10//Athena
12// for std::ifstream
13#include <fstream>
14
15
16HGTDMappingAlg::HGTDMappingAlg(const std::string& name, ISvcLocator* pSvcLocator):
17 AthReentrantAlgorithm(name, pSvcLocator)
18{
19}
20
21
23 m_source = PathResolver::find_file(m_source.value(), "DATAPATH");
24 if (m_source.empty()) {
25 ATH_MSG_FATAL("The HGTD data file for cabling, " << m_source.value() << ", was not found.");
26 return StatusCode::FAILURE;
27 }
28 ATH_MSG_INFO("Reading cabling from " << m_source.value());
29
30 ATH_CHECK(detStore()->retrieve(m_idHelper, "HGTD_ID"));
31 ATH_CHECK(m_writeKey.initialize());
32
33 return StatusCode::SUCCESS;
34}
35
36StatusCode HGTDMappingAlg::execute(const EventContext& ctx) const {
37
39
40 // Construct the output Cond Object and fill it in
41 std::unique_ptr<HGTDMappingData> pMapping = std::make_unique<HGTDMappingData>();
42 auto inputFile = std::ifstream(m_source.value());
43 if (not inputFile.good()){
44 ATH_MSG_ERROR("The HGTD mapping file "<<m_source.value()<<" could not be opened.");
45 return StatusCode::FAILURE;
46 }
47 else{
48 ATH_MSG_DEBUG("input file is good " << m_source.value());
49 }
50
51 inputFile>>*pMapping;
52 const int numEntries = pMapping->size();
53
54 // Define validity of the output cond object and record it
55 const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
56 const EventIDBase stop{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
57 const EventIDRange rangeW{start, stop};
58 if (writeHandle.record(rangeW, std::move(pMapping)).isFailure()) {
59 ATH_MSG_FATAL("Could not record MappingData " << writeHandle.key()
60 << " with EventRange " << rangeW
61 << " into Conditions Store");
62 return StatusCode::FAILURE;
63 }
64 ATH_MSG_VERBOSE("recorded new conditions data object " << writeHandle.key() << " with range " << rangeW << " into Conditions Store");
65 return (numEntries==0) ? (StatusCode::FAILURE) : (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_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Online Identifier for HGTD.
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &ctx) const override
const HGTD_ID * m_idHelper
SG::WriteCondHandleKey< HGTDMappingData > m_writeKey
StringProperty m_source
HGTDMappingAlg(const std::string &name, ISvcLocator *svc)
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
const std::string & key() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())