ATLAS Offline Software
PixelTDAQCondAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "PixelTDAQCondAlg.h"
6 #include "GaudiKernel/EventIDRange.h"
7 #include <memory>
8 #include <sstream>
9 
10 PixelTDAQCondAlg::PixelTDAQCondAlg(const std::string& name, ISvcLocator* pSvcLocator):
11  ::AthReentrantAlgorithm(name, pSvcLocator)
12 {
13 }
14 
16  ATH_MSG_INFO("PixelTDAQCondAlg::initialize()");
17 
18  ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID"));
21 
22  return StatusCode::SUCCESS;
23 }
24 
25 StatusCode PixelTDAQCondAlg::execute(const EventContext& ctx) const {
26 
28  if (writeHandle.isValid()) {
29  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order.");
30  return StatusCode::SUCCESS;
31  }
32 
33  // Construct the output Cond Object and fill it in
34  std::unique_ptr<PixelTDAQData> writeCdo(std::make_unique<PixelTDAQData>());
35 
36  const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0,
37  0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
38  const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1,
39  EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
40 
41  EventIDRange rangeW{start, stop};
42  if (!m_readKey.empty()) {
44  const CondAttrListCollection* readCdo = *readHandle;
45  if (readCdo==nullptr) {
46  ATH_MSG_FATAL("Null pointer to the read conditions object");
47  return StatusCode::FAILURE;
48  }
49  // Get the validitiy range
50  if (not readHandle.range(rangeW)) {
51  ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key());
52  return StatusCode::FAILURE;
53  }
54  ATH_MSG_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
55  ATH_MSG_INFO("Range of input is " << rangeW);
56 
57  // Read dead map info
58  std::vector<int> checkActive;
59  for (const auto & attrList : *readCdo) {
60  CondAttrListCollection::ChanNum channelNumber = attrList.first;
61  checkActive.push_back((int)channelNumber-1);
62  }
63 
64  for (int i=0; i<(int)m_pixelID->wafer_hash_max(); i++) {
65  auto itr = std::find(checkActive.begin(),checkActive.end(),i);
66  if ((size_t)std::distance(checkActive.begin(),itr)==checkActive.size()) { writeCdo->setModuleStatus(i,1); }
67  }
68  }
69 
70  if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) {
71  ATH_MSG_FATAL("Could not record PixelTDAQData " << writeHandle.key() << " with EventRange " << rangeW << " into Conditions Store");
72  return StatusCode::FAILURE;
73  }
74  ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into Conditions Store");
75 
76  return StatusCode::SUCCESS;
77 }
78 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PixelTDAQCondAlg::m_pixelID
const PixelID * m_pixelID
Definition: PixelTDAQCondAlg.h:36
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle::fullKey
const DataObjID & fullKey() const
Definition: ReadCondHandle.h:60
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
PixelTDAQCondAlg.h
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
SG::ReadCondHandle::range
bool range(EventIDRange &r)
Definition: ReadCondHandle.h:224
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition: WriteCondHandle.h:157
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
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::WriteCondHandle::fullKey
const DataObjID & fullKey() const
Definition: WriteCondHandle.h:41
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
PixelTDAQCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: PixelTDAQCondAlg.cxx:25
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
PixelTDAQCondAlg::m_writeKey
SG::WriteCondHandleKey< PixelTDAQData > m_writeKey
Definition: PixelTDAQCondAlg.h:42
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::WriteCondHandle::key
const std::string & key() const
Definition: WriteCondHandle.h:40
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:831
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition: CondAttrListCollection.h:322
PixelTDAQCondAlg::PixelTDAQCondAlg
PixelTDAQCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PixelTDAQCondAlg.cxx:10
PixelTDAQData::setModuleStatus
void setModuleStatus(const int chanNum, const int value)
Definition: PixelTDAQData.cxx:7
SG::WriteCondHandle::isValid
bool isValid() const
Definition: WriteCondHandle.h:248
SG::ReadCondHandle::key
const std::string & key() const
Definition: ReadCondHandle.h:59
PixelTDAQCondAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition: PixelTDAQCondAlg.h:39
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
PixelTDAQCondAlg::initialize
virtual StatusCode initialize() override final
Definition: PixelTDAQCondAlg.cxx:15