ATLAS Offline Software
ITkStripCablingAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 
40 //
43  m_source = PathResolver::find_file(m_source.value(), "DATAPATH");
44  if (m_source.empty()) {
45  ATH_MSG_FATAL("The ITkStrip data file for cabling, " << m_source.value() << ", was not found.");
46  return StatusCode::FAILURE;
47  }
48  ATH_MSG_INFO("Reading cabling from " << m_source.value());
49  // ITkStripID
50  ATH_CHECK(detStore()->retrieve(m_idHelper, "SCT_ID"));
51  // Write Cond Handle
53 
54  return StatusCode::SUCCESS;
55 }
56 
57 
58 //
60 ITkStripCablingAlg::execute(const EventContext& ctx) const {
61  // Write Cond Handle
63  if (writeHandle.isValid()) {
64  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
65  << ". In theory this should not be called, but may happen"
66  << " if multiple concurrent events are being processed out of order.");
67  return StatusCode::SUCCESS;
68  }
69 
70  // Construct the output Cond Object and fill it in
71  std::unique_ptr<ITkStripCablingData> pCabling = std::make_unique<ITkStripCablingData>();
72  auto inputFile = std::ifstream(m_source.value());
73  if (not inputFile.good()){
74  ATH_MSG_ERROR("The itk cabling file "<<m_source.value()<<" could not be opened.");
75  return StatusCode::FAILURE;
76  }
77  inputFile>>*pCabling;
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 
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
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
ITkStripCablingAlg::m_source
StringProperty m_source
Definition: ITkStripCablingAlg.h:46
ITkStripCablingData::size
std::size_t size() const
Definition: ITkStripCablingData.cxx:22
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
ITkStripCablingAlg::ITkStripCablingAlg
ITkStripCablingAlg(const std::string &name, ISvcLocator *svc)
Definition: ITkStripCablingAlg.cxx:35
ITkStripCablingAlg::initialize
virtual StatusCode initialize() override
Definition: ITkStripCablingAlg.cxx:42
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:157
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:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
SG::WriteCondHandle::fullKey
const DataObjID & fullKey() const
Definition: WriteCondHandle.h:41
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CaloCondBlobAlgs_fillNoiseFromASCII.inputFile
string inputFile
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:17
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:60
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SG::WriteCondHandle::key
const std::string & key() const
Definition: WriteCondHandle.h:40
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:248
SG::WriteCondHandle
Definition: WriteCondHandle.h:26