ATLAS Offline Software
ITkPixelCablingAlg.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 "ITkPixelCablingAlg.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
35 ITkPixelCablingAlg::ITkPixelCablingAlg(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 ITkPixel 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  // ITkPixelID
50  ATH_CHECK(detStore()->retrieve(m_idHelper, "PixelID"));
51  // Write Cond Handle
53 
54  return StatusCode::SUCCESS;
55 }
56 
57 
58 //
60 ITkPixelCablingAlg::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<ITkPixelCablingData> pCabling = std::make_unique<ITkPixelCablingData>();
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 ITkPixelCablingData " << 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
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
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
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
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
ITkPixelCablingAlg::initialize
virtual StatusCode initialize() override
Definition: ITkPixelCablingAlg.cxx:42
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
ITkPixelCablingAlg.h
Fills an ITkPixelCablingData object and records it in Storegate.
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ITkPixelCablingData::size
std::size_t size() const
Definition: ITkPixelCablingData.cxx:21
PathResolver.h
ITkPixelCablingAlg::m_idHelper
const PixelID * m_idHelper
Definition: ITkPixelCablingAlg.h:48
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::WriteCondHandle::key
const std::string & key() const
Definition: WriteCondHandle.h:40
IdentifierHash.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
ITkPixelCablingAlg::m_source
StringProperty m_source
Definition: ITkPixelCablingAlg.h:46
ITkPixelCablingAlg::ITkPixelCablingAlg
ITkPixelCablingAlg(const std::string &name, ISvcLocator *svc)
Definition: ITkPixelCablingAlg.cxx:35
SG::WriteCondHandle::isValid
bool isValid() const
Definition: WriteCondHandle.h:248
ITkPixelCablingAlg::m_writeKey
SG::WriteCondHandleKey< ITkPixelCablingData > m_writeKey
Definition: ITkPixelCablingAlg.h:47
ITkPixelCablingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: ITkPixelCablingAlg.cxx:60
SG::WriteCondHandle
Definition: WriteCondHandle.h:26