ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_MajorityCondAlg.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
8
9#include <memory>
10
11SCT_MajorityCondAlg::SCT_MajorityCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
12 : ::AthCondAlgorithm(name, pSvcLocator)
13{
14}
15
17{
18 ATH_MSG_DEBUG("initialize " << name());
19
20 // Read Cond Handle
21 ATH_CHECK(m_readKey.initialize());
22
23 // Write Cond Handle
24 ATH_CHECK(m_writeKey.initialize());
25
26 return StatusCode::SUCCESS;
27}
28
29StatusCode SCT_MajorityCondAlg::execute(const EventContext& ctx) const
30{
31 ATH_MSG_DEBUG("execute " << name());
32
33 // Write Cond Handle
35
36 // Do we have a valid Write Cond Handle for current time?
37 if (writeHandle.isValid()) {
38 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
39 << ". In theory this should not be called, but may happen"
40 << " if multiple concurrent events are being processed out of order.");
41 return StatusCode::SUCCESS;
42 }
43
44 // Read Cond Handle
46 const CondAttrListCollection* readCdo{*readHandle};
47 if (readCdo==nullptr) {
48 ATH_MSG_FATAL("Null pointer to the read conditions object");
49 return StatusCode::FAILURE;
50 }
51 ATH_MSG_INFO("Size of CondAttrListCollection readCdo->size()= " << readCdo->size());
52
53 // Add dependency
54 writeHandle.addDependency(readHandle);
55
56 int numFilled{0};
57
58 // Construct the output Cond Object and fill it in
59 std::unique_ptr<SCT_MajorityCondData> writeCdo{std::make_unique<SCT_MajorityCondData>()};
60
63 for (;majItr != majEnd; ++majItr) {
64 // A CondAttrListCollection is a map of ChanNum and AttributeList
65 CondAttrListCollection::ChanNum channelNumber{(*majItr).first};
66 const CondAttrListCollection::AttributeList &payload{(*majItr).second};
67 // Possible components
68 if ((channelNumber == SCT_ConditionsData::OVERALL) or
69 (channelNumber == SCT_ConditionsData::BARREL) or
70 (channelNumber == SCT_ConditionsData::ECA) or
71 (channelNumber == SCT_ConditionsData::ECC)) {
72 // Reset default to true at callback
73 bool majorityState{true};
74
75 // Majority state
76 if (not payload[SCT_ConditionsData::INDEX_MajorityState].isNull()) {
77 ATH_MSG_DEBUG("Majority state for " << channelNumber << " = " <<
79 majorityState = (payload[SCT_ConditionsData::INDEX_MajorityState].data<int>()
81 }
82 writeCdo->setMajorityState(channelNumber, majorityState);
83
84 // HV fraction in majority state (>50% by definition) IF majority state is HV and LV on
85 float hvFraction{1.};
86 if (majorityState and (not payload[SCT_ConditionsData::INDEX_HVfraction].isNull())) {
87 ATH_MSG_DEBUG("Majority HV fraction for " << channelNumber << " = " <<
89 hvFraction = payload[SCT_ConditionsData::INDEX_HVfraction].data<float>();
90 numFilled++;
91 }
92 writeCdo->setHVFraction(channelNumber, hvFraction);
93
94 } else {
95 ATH_MSG_WARNING("Unexpected channel number " << channelNumber);
96 }
97 }
98
99 // Has data been filled?
100 // Four regions (OVERALL, BARREL, ECA, ECC) are needed.
101 writeCdo->setFilled(numFilled==SCT_ConditionsData::N_REGIONS);
102
103 // Record the out output Cond Object
104 if (writeHandle.record(std::move(writeCdo)).isFailure()) {
105 ATH_MSG_FATAL("Could not record SCT_MajorityCondData " << writeHandle.key()
106 << " with EventRange " << writeHandle.getRange()
107 << " into Conditions Store");
108 return StatusCode::FAILURE;
109 }
110 ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
111
112 return StatusCode::SUCCESS;
113}
114
116{
117 ATH_MSG_DEBUG("finalize " << name());
118 return StatusCode::SUCCESS;
119}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
header file containing the number of elements and enumerated type of parameters which may be retrieve...
Base class for conditions algorithms.
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
size_type size() const
number of Chan/AttributeList pairs
ChanAttrListMap::const_iterator const_iterator
coral::AttributeList AttributeList
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
SG::WriteCondHandleKey< SCT_MajorityCondData > m_writeKey
SCT_MajorityCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode finalize() override final
virtual StatusCode initialize() override final
virtual StatusCode execute(const EventContext &ctx) const override final
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const