ATLAS Offline Software
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 
14 //package includes
15 #include "ITkStripCablingAlg.h"
16 
17 //indet includes
18 #include "InDetIdentifier/SCT_ID.h"
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
35 ITkStripCablingAlg::ITkStripCablingAlg(const std::string& name, ISvcLocator* pSvcLocator):
36  AthReentrantAlgorithm(name, pSvcLocator)
37 {}
38 
39 //
42  ATH_MSG_INFO("Reading ITk Strip cabling file from " << m_source.value());
43  // ITkStripID
44  ATH_CHECK(detStore()->retrieve(m_idHelper, "SCT_ID"));
45  // Write Cond Handle
47 
48  return StatusCode::SUCCESS;
49 }
50 
51 
52 //
54 ITkStripCablingAlg::execute(const EventContext& ctx) const {
55  // Write Cond Handle
57  if (writeHandle.isValid()) {
58  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
59  << ". In theory this should not be called, but may happen"
60  << " if multiple concurrent events are being processed out of order.");
61  return StatusCode::SUCCESS;
62  }
63 
64  // Construct the output Cond Object and fill it in
65  std::unique_ptr<ITkStripCablingData> pCabling = std::make_unique<ITkStripCablingData>();
66  auto inputFile = std::ifstream(m_source.value());
67  if (not inputFile.good()){
68  ATH_MSG_ERROR("The itk cabling file "<<m_source.value()<<" could not be opened.");
69  return StatusCode::FAILURE;
70  }
71  inputFile>>*pCabling;
72  ATH_MSG_DEBUG("Cabling file size: " << pCabling->size());
73  const int numEntries = pCabling->size();
74  ATH_MSG_DEBUG(numEntries << " entries were made to the identifier map.");
75 
76  // Define validity of the output cond object and record it
77  const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
78  const EventIDBase stop{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
79  const EventIDRange rangeW{start, stop};
80  if (writeHandle.record(rangeW, std::move(pCabling)).isFailure()) {
81  ATH_MSG_FATAL("Could not record ITkStripCablingData " << writeHandle.key()
82  << " with EventRange " << rangeW
83  << " into Conditions Store");
84  return StatusCode::FAILURE;
85  }
86  ATH_MSG_VERBOSE("recorded new conditions data object " << writeHandle.key() << " with range " << rangeW << " into Conditions Store");
87  return (numEntries==0) ? (StatusCode::FAILURE) : (StatusCode::SUCCESS);
88 }
89 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ITkStripCablingAlg::m_source
StringProperty m_source
Definition: ITkStripCablingAlg.h:46
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:13
ITkStripCablingAlg::ITkStripCablingAlg
ITkStripCablingAlg(const std::string &name, ISvcLocator *svc)
Definition: ITkStripCablingAlg.cxx:35
ITkStripCablingAlg::initialize
virtual StatusCode initialize() override
Definition: ITkStripCablingAlg.cxx:41
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition: WriteCondHandle.h:161
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
SG::WriteCondHandle::fullKey
const DataObjID & fullKey() const
Definition: WriteCondHandle.h:45
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CaloCondBlobAlgs_fillNoiseFromASCII.inputFile
string inputFile
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:16
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
ITkStripCablingAlg::m_writeKey
SG::WriteCondHandleKey< ITkStripCablingData > m_writeKey
Definition: ITkStripCablingAlg.h:47
ITkStripCablingAlg::m_idHelper
const SCT_ID * m_idHelper
Definition: ITkStripCablingAlg.h:48
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ITkStripCablingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: ITkStripCablingAlg.cxx:54
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
SG::WriteCondHandle::key
const std::string & key() const
Definition: WriteCondHandle.h:44
IdentifierHash.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
ITkStripCablingAlg.h
Fills an ITkStripCablingData object and records it in Storegate (based on ITkPixelCabling package)
SG::WriteCondHandle::isValid
bool isValid() const
Definition: WriteCondHandle.h:252
SG::WriteCondHandle
Definition: WriteCondHandle.h:26