ATLAS Offline Software
PixelDCSCondHVAlg.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 "PixelDCSCondHVAlg.h"
7 #include <memory>
8 
9 PixelDCSCondHVAlg::PixelDCSCondHVAlg(const std::string& name, ISvcLocator* pSvcLocator):
10  ::AthReentrantAlgorithm(name, pSvcLocator)
11 {
12 }
13 
15  ATH_MSG_DEBUG("PixelDCSCondHVAlg::initialize()");
16 
17  ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID"));
18 
22 
23  return StatusCode::SUCCESS;
24 }
25 
26 StatusCode PixelDCSCondHVAlg::execute(const EventContext& ctx) const {
27  ATH_MSG_DEBUG("PixelDCSCondHVAlg::execute()");
28 
30  if (writeHandle.isValid()) {
31  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.");
32  return StatusCode::SUCCESS;
33  }
34 
36  const PixelModuleData* modData=(*modDataHdl);
37  ATH_MSG_INFO("Range of input PixelModule data is " << modDataHdl.getRange());
38 
39  // Construct the output Cond Object and fill it in
40  std::unique_ptr<PixelDCSHVData> writeCdo(std::make_unique<PixelDCSHVData>());
41 
42  const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
43  const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
44 
45  EventIDRange rangeW{start, stop};
46 
47  if (!m_readKey.empty()) {
49  const CondAttrListCollection* readCdo = *readHandle;
50  if (readCdo==nullptr) {
51  ATH_MSG_FATAL("Null pointer to the read conditions object");
52  return StatusCode::FAILURE;
53  }
54  // Get the validitiy range
55  if (not readHandle.range(rangeW)) {
56  ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key());
57  return StatusCode::FAILURE;
58  }
59  ATH_MSG_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
60  ATH_MSG_INFO("Range of DCS input is " << rangeW);
61 
62  // Read HV info
63  std::string param("HV");
64  for (const auto & attrList : *readCdo) {
65  const CondAttrListCollection::ChanNum &channelNumber = attrList.first;
66  const CondAttrListCollection::AttributeList &payload = attrList.second;
67  if (payload.exists(param) and not payload[param].isNull()) {
68  float val = payload[param].data<float>();
69  if (val>1000.0 || val<-1000.0) {
70  writeCdo -> setBiasVoltage((int)channelNumber, modData->getDefaultBiasVoltage());
71  }
72  else {
73  writeCdo -> setBiasVoltage((int)channelNumber, val);
74  }
75  }
76  else {
77  ATH_MSG_WARNING(param << " does not exist for ChanNum " << channelNumber);
78  writeCdo -> setBiasVoltage((int)channelNumber, modData->getDefaultBiasVoltage());
79  }
80  }
81  }
82  else {
83  for (int i=0; i<(int)m_pixelID->wafer_hash_max(); i++) {
84  writeCdo -> setBiasVoltage(i, modData->getDefaultBiasVoltage());
85  }
86  }
87 
88  if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) {
89  ATH_MSG_FATAL("Could not record PixelDCSHVData " << writeHandle.key() << " with EventRange "
90  << writeHandle.getRange() << " into Conditions Store");
91  return StatusCode::FAILURE;
92  }
93  ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange()
94  << " into Conditions Store");
95 
96  return StatusCode::SUCCESS;
97 }
98 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle::getRange
const EventIDRange & getRange()
Definition: ReadCondHandle.h:242
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
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
PixelModuleData
Definition: PixelModuleData.h:22
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
SG::WriteCondHandle::getRange
const EventIDRange & getRange() const
Definition: WriteCondHandle.h:89
PixelModuleData::getDefaultBiasVoltage
float getDefaultBiasVoltage() const
Definition: PixelModuleData.cxx:336
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
PixelDCSCondHVAlg::m_pixelID
const PixelID * m_pixelID
Definition: PixelDCSCondHVAlg.h:37
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
PixelDCSCondHVAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition: PixelDCSCondHVAlg.h:43
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
PixelDCSCondHVAlg.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
PixelDCSCondHVAlg::m_moduleDataKey
SG::ReadCondHandleKey< PixelModuleData > m_moduleDataKey
Definition: PixelDCSCondHVAlg.h:40
PixelDCSCondHVAlg::PixelDCSCondHVAlg
PixelDCSCondHVAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PixelDCSCondHVAlg.cxx:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SG::WriteCondHandle::key
const std::string & key() const
Definition: WriteCondHandle.h:40
IdentifierHash.h
PixelDCSCondHVAlg::initialize
virtual StatusCode initialize() override final
Definition: PixelDCSCondHVAlg.cxx:14
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:907
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition: CondAttrListCollection.h:322
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
PixelDCSCondHVAlg::m_writeKey
SG::WriteCondHandleKey< PixelDCSHVData > m_writeKey
Definition: PixelDCSCondHVAlg.h:46
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
SG::WriteCondHandle::isValid
bool isValid() const
Definition: WriteCondHandle.h:248
CondAttrListCollection::AttributeList
coral::AttributeList AttributeList
Definition: CondAttrListCollection.h:56
SG::ReadCondHandle::key
const std::string & key() const
Definition: ReadCondHandle.h:59
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
PixelDCSCondHVAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: PixelDCSCondHVAlg.cxx:26
SG::WriteCondHandle
Definition: WriteCondHandle.h:26