ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
HighGranularityTimingDetector
HGTDMapping
src
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
11
#include "
PathResolver/PathResolver.h
"
12
// for std::ifstream
13
#include <fstream>
14
15
16
HGTDMappingAlg::HGTDMappingAlg
(
const
std::string& name, ISvcLocator* pSvcLocator):
17
AthReentrantAlgorithm
(name, pSvcLocator)
18
{
19
}
20
21
22
StatusCode
HGTDMappingAlg::initialize
() {
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
36
StatusCode
HGTDMappingAlg::execute
(
const
EventContext& ctx)
const
{
37
38
SG::WriteCondHandle<HGTDMappingData>
writeHandle =
SG::makeHandle
(
m_writeKey
, ctx);
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
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
HGTDMappingAlg.h
Online Identifier for HGTD.
PathResolver.h
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
HGTDMappingAlg::initialize
virtual StatusCode initialize() override
Definition
HGTDMappingAlg.cxx:22
HGTDMappingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
HGTDMappingAlg.cxx:36
HGTDMappingAlg::m_idHelper
const HGTD_ID * m_idHelper
Definition
HGTDMappingAlg.h:32
HGTDMappingAlg::m_writeKey
SG::WriteCondHandleKey< HGTDMappingData > m_writeKey
Definition
HGTDMappingAlg.h:31
HGTDMappingAlg::m_source
StringProperty m_source
Definition
HGTDMappingAlg.h:29
HGTDMappingAlg::HGTDMappingAlg
HGTDMappingAlg(const std::string &name, ISvcLocator *svc)
Definition
HGTDMappingAlg.cxx:16
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Definition
PathResolver.cxx:220
SG::WriteCondHandle
Definition
WriteCondHandle.h:26
SG::WriteCondHandle::key
const std::string & key() const
Definition
WriteCondHandle.h:44
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition
WriteCondHandle.h:161
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
Generated on
for ATLAS Offline Software by
1.17.0