ATLAS Offline Software
Loading...
Searching...
No Matches
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
10PixelTDAQCondAlg::PixelTDAQCondAlg(const std::string& name, ISvcLocator* pSvcLocator):
11 ::AthCondAlgorithm(name, pSvcLocator)
12{
13}
14
16 ATH_MSG_INFO("PixelTDAQCondAlg::initialize()");
17
18 ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID"));
19 ATH_CHECK(m_readKey.initialize(!m_readKey.empty()));
20 ATH_CHECK(m_writeKey.initialize());
21
22 return StatusCode::SUCCESS;
23}
24
25StatusCode 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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
Base class for conditions algorithms.
This class is a collection of AttributeLists where each one is associated with a channel number.
size_type size() const
number of Chan/AttributeList pairs
PixelTDAQCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
const PixelID * m_pixelID
virtual StatusCode execute(const EventContext &ctx) const override final
SG::WriteCondHandleKey< PixelTDAQData > m_writeKey
virtual StatusCode initialize() override final
bool range(EventIDRange &r)
const std::string & key() const
const DataObjID & fullKey() const
const std::string & key() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const