ATLAS Offline Software
SCT_ModuleVetoCondAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <memory>
8 
9 namespace {
10  template <class T>
11  std::vector<T>
12  string2Vector(const std::string& s) {
13  std::vector<T> v;
14  std::istringstream inputStream{s};
15  std::istream_iterator<T> vecRead{inputStream};
16  std::istream_iterator<T> endOfString; //relies on default constructor to produce eof
17  std::copy(vecRead,endOfString, std::back_inserter(v)); // DOESN'T ALLOW NON-WHITESPACE DELIMITER !
18  return v;
19  }
20 }
21 
22 SCT_ModuleVetoCondAlg::SCT_ModuleVetoCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
23  : ::AthReentrantAlgorithm(name, pSvcLocator)
24 {
25 }
26 
28  ATH_MSG_DEBUG("initialize " << name());
29 
30  // Read Cond Handle
32  // Write Cond Handles
34 
35  return StatusCode::SUCCESS;
36 }
37 
38 StatusCode SCT_ModuleVetoCondAlg::execute(const EventContext& ctx) const {
39  ATH_MSG_DEBUG("execute " << name());
40 
41  // Write Cond Handle
43  // Do we have a valid Write Cond Handle for current time?
44  if (writeHandle.isValid()) {
45  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
46  << ". In theory this should not be called, but may happen"
47  << " if multiple concurrent events are being processed out of order.");
48  return StatusCode::SUCCESS;
49  }
50 
51  // Read Cond Handle
53  const AthenaAttributeList* readCdo{*readHandle};
54  if (readCdo==nullptr) {
55  ATH_MSG_FATAL("Null pointer to the read conditions object");
56  return StatusCode::FAILURE;
57  }
58  // Add dependency
59  writeHandle.addDependency(readHandle);
60  ATH_MSG_INFO("Size of AthenaAttributeList " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
61  ATH_MSG_INFO("Range of input is " << readHandle.getRange());
62 
63  // Construct the output Cond Object and fill it in
64  std::unique_ptr<SCT_ModuleVetoCondData> writeCdo{std::make_unique<SCT_ModuleVetoCondData>()};
65 
66  // Read bad wafer info
67  const std::string &badModuleString{(*readCdo)["ModuleList"].data<std::string>()};
68  std::vector<unsigned long long> v{string2Vector<unsigned long long>(badModuleString)};
69  unsigned long long numberInDb{static_cast<unsigned long long>(v.size())};
70  ATH_MSG_INFO(numberInDb << " elements were declared bad in the database.");
71  for (const unsigned long long badWaferId: v) {
72  writeCdo->setBadWaferId(Identifier{badWaferId});
73  }
74 
75  // Record the output cond object
76  if (writeHandle.record(std::move(writeCdo)).isFailure()) {
77  ATH_MSG_FATAL("Could not record SCT_ModuleVetoCondData " << writeHandle.key()
78  << " with EventRange " << writeHandle.getRange()
79  << " into Conditions Store");
80  return StatusCode::FAILURE;
81  }
82  ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
83 
84  return StatusCode::SUCCESS;
85 }
86 
88  ATH_MSG_DEBUG("finalize " << name());
89  return StatusCode::SUCCESS;
90 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SCT_ModuleVetoCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: SCT_ModuleVetoCondAlg.cxx:38
SCT_ModuleVetoCondAlg::initialize
virtual StatusCode initialize() override final
Definition: SCT_ModuleVetoCondAlg.cxx:27
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SCT_ModuleVetoCondAlg::m_readKey
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
Definition: SCT_ModuleVetoCondAlg.h:30
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
SCT_ModuleVetoCondAlg::m_writeKey
SG::WriteCondHandleKey< SCT_ModuleVetoCondData > m_writeKey
Definition: SCT_ModuleVetoCondAlg.h:31
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
python.PyAthena.v
v
Definition: PyAthena.py:157
SCT_ModuleVetoCondAlg.h
SCT_ModuleVetoCondAlg::SCT_ModuleVetoCondAlg
SCT_ModuleVetoCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCT_ModuleVetoCondAlg.cxx:22
calibdata.copy
bool copy
Definition: calibdata.py:27
SCT_ModuleVetoCondAlg::finalize
virtual StatusCode finalize() override final
Definition: SCT_ModuleVetoCondAlg.cxx:87
SG::WriteCondHandle
Definition: WriteCondHandle.h:26