ATLAS Offline Software
Loading...
Searching...
No Matches
ITkStripCablingAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
13
14//package includes
15#include "ITkStripCablingAlg.h"
16
17//indet includes
19
20//Athena includes
21#include "Identifier/Identifier.h"
24
25// Gaudi include
26#include "GaudiKernel/EventIDRange.h"
27
28//STL
29#include <iostream>
30#include <fstream>
31
32
33
34// Constructor
35ITkStripCablingAlg::ITkStripCablingAlg(const std::string& name, ISvcLocator* pSvcLocator):
36 AthReentrantAlgorithm(name, pSvcLocator)
37{}
38
39//
40StatusCode
43 if(m_configFilePath.empty()){
44 ATH_MSG_ERROR("Failed to find Calibration file: " << m_source);
45 return StatusCode::FAILURE;
46 }
47 ATH_MSG_INFO("Reading ITk Strip cabling file from " << m_configFilePath);
48 // ITkStripID
49 ATH_CHECK(detStore()->retrieve(m_idHelper, "SCT_ID"));
50 // Write Cond Handle
51 ATH_CHECK(m_writeKey.initialize());
52
53 return StatusCode::SUCCESS;
54}
55
56
57//
58StatusCode
59ITkStripCablingAlg::execute(const EventContext& ctx) const {
60 // Write Cond Handle
62 if (writeHandle.isValid()) {
63 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
64 << ". In theory this should not be called, but may happen"
65 << " if multiple concurrent events are being processed out of order.");
66 return StatusCode::SUCCESS;
67 }
68
69 // Construct the output Cond Object and fill it in
70 std::unique_ptr<ITkStripCablingData> pCabling = std::make_unique<ITkStripCablingData>();
71 auto inputFile = std::ifstream(m_configFilePath);
72 if (not inputFile.good()){
73 ATH_MSG_ERROR("The itk cabling file "<<m_configFilePath<<" could not be opened.");
74 return StatusCode::FAILURE;
75 }
76 inputFile>>*pCabling;
77 ATH_MSG_DEBUG("Cabling file size: " << pCabling->size());
78 const int numEntries = pCabling->size();
79 ATH_MSG_DEBUG(numEntries << " entries were made to the identifier map.");
80
81 // Define validity of the output cond object and record it
82 const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
83 const EventIDBase stop{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
84 const EventIDRange rangeW{start, stop};
85 if (writeHandle.record(rangeW, std::move(pCabling)).isFailure()) {
86 ATH_MSG_FATAL("Could not record ITkStripCablingData " << writeHandle.key()
87 << " with EventRange " << rangeW
88 << " into Conditions Store");
89 return StatusCode::FAILURE;
90 }
91 ATH_MSG_VERBOSE("recorded new conditions data object " << writeHandle.key() << " with range " << rangeW << " into Conditions Store");
92 return (numEntries==0) ? (StatusCode::FAILURE) : (StatusCode::SUCCESS);
93}
94
#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)
Fills an ITkStripCablingData object and records it in Storegate (based on ITkPixelCabling package)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
This is an Identifier helper class for the SCT subdetector.
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
StringProperty m_source
const SCT_ID * m_idHelper
ITkStripCablingAlg(const std::string &name, ISvcLocator *svc)
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteCondHandleKey< ITkStripCablingData > m_writeKey
virtual StatusCode initialize() override
const std::string & key() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())