ATLAS Offline Software
SCT_DCSConditionsStatCondAlg.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 
11 SCT_DCSConditionsStatCondAlg::SCT_DCSConditionsStatCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
12  : ::AthReentrantAlgorithm(name, pSvcLocator)
13 {
14 }
15 
17  ATH_MSG_DEBUG("initialize " << name());
18 
20 
21  // Read Cond Handle (HV)
23 
24  // Read Cond Handle (state)
26  // Write Cond Handle
28 
29  if (m_useDefaultHV) {
33  ATH_MSG_INFO("Using HV and Chanstat"<< m_chanstatCut << " for marking modules bad. >=Hvlow: "
34  << m_hvLowLimit<< " and <=Hv Up: " << m_hvUpLimit <<
35  ". Note: UseHV Overrides hv limit and chanstat values in joboptions!!");
36  }
37 
38  return StatusCode::SUCCESS;
39 }
40 
41 StatusCode SCT_DCSConditionsStatCondAlg::execute(const EventContext& ctx) const {
42  ATH_MSG_DEBUG("execute " << name());
43 
44  if (not m_doState) {
45  return StatusCode::SUCCESS;
46  }
47 
48  // Write Cond Handle (state)
50  // Do we have a valid Write Cond Handle for current time?
51  if (writeHandle.isValid()) {
52  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
53  << ". In theory this should not be called, but may happen"
54  << " if multiple concurrent events are being processed out of order.");
55  return StatusCode::SUCCESS;
56  }
57 
58  // Read Cond Handle (state)
60  const CondAttrListCollection* readCdoState{*readHandleState};
61  if (readCdoState==nullptr) {
62  ATH_MSG_FATAL("Null pointer to the read conditions object (state)");
63  return StatusCode::FAILURE;
64  }
65  // Add dependency
66  writeHandle.addDependency(readHandleState);
67  ATH_MSG_INFO("Size of CondAttrListCollection " << readHandleState.fullKey() << " readCdo->size()= " << readCdoState->size());
68  ATH_MSG_INFO("Range of state input is " << readHandleState.getRange());
69 
70  // Construct the output Cond Object and fill it in
71  std::unique_ptr<SCT_DCSStatCondData> writeCdoState{std::make_unique<SCT_DCSStatCondData>()};
72 
73  // Read state info
74  // Meaning of state word is found at
75  // https://twiki.cern.ch/twiki/bin/view/Atlas/SctDCSSoftware#Decoding_Status_words
76  std::string paramState{"STATE"};
77  CondAttrListCollection::const_iterator attrListState{readCdoState->begin()};
78  CondAttrListCollection::const_iterator endState{readCdoState->end()};
79  // CondAttrListCollection doesn't support C++11 type loops, no generic 'begin'
80  for (; attrListState!=endState; ++attrListState) {
81  // A CondAttrListCollection is a map of ChanNum and AttributeList
82  CondAttrListCollection::ChanNum channelNumber{attrListState->first};
83  const CondAttrListCollection::AttributeList &payload{attrListState->second};
84  if (payload.exists(paramState) and not payload[paramState].isNull()) {
85  unsigned int val{payload[paramState].data<unsigned int>()};
86  unsigned int hvstate{(val >> 4) & 0xF};
87  unsigned int lvstate{ val & 0xF};
88  if ( ((m_chanstatCut=="NORM")
89  and not ((hvstate==ON or hvstate==MANUAL)
90  and (lvstate==ON or lvstate==MANUAL)))
91  or ((m_chanstatCut=="NSTBY")
92  and not ((hvstate==ON or hvstate==MANUAL or hvstate==STANDBY)
93  and (lvstate==ON or lvstate==MANUAL or lvstate==STANDBY)))
94  or ((m_chanstatCut=="LOOSE")
95  and not ((hvstate==ON or hvstate==MANUAL or hvstate==STANDBY or hvstate==RAMPING)
96  and (lvstate==ON or lvstate==MANUAL or lvstate==STANDBY or lvstate==RAMPING)))) {
97  writeCdoState->fill(channelNumber, paramState);
98  } else {
99  writeCdoState->remove(channelNumber, paramState);
100  }
101  } else {
102  ATH_MSG_WARNING(paramState << " does not exist for ChanNum " << channelNumber);
103  }
104  }
105 
106  if (m_returnHVTemp) {
107  // Read Cond Handle
109  const CondAttrListCollection* readCdoHV{*readHandleHV};
110  if (readCdoHV==nullptr) {
111  ATH_MSG_FATAL("Null pointer to the read conditions object (HV)");
112  return StatusCode::FAILURE;
113  }
114  // Add dependency
115  writeHandle.addDependency(readHandleHV);
116  ATH_MSG_INFO("Size of CondAttrListCollection " << readHandleHV.fullKey() << " readCdo->size()= " << readCdoHV->size());
117  ATH_MSG_INFO("Range of HV input is " << readHandleHV.getRange());
118 
119  std::string paramHV{"HVCHVOLT_RECV"};
120  CondAttrListCollection::const_iterator attrListHV{readCdoHV->begin()};
121  CondAttrListCollection::const_iterator endHV{readCdoHV->end()};
122  // CondAttrListCollection doesn't support C++11 type loops, no generic 'begin'
123  for (; attrListHV!=endHV; ++attrListHV) {
124  // A CondAttrListCollection is a map of ChanNum and AttributeList
125  CondAttrListCollection::ChanNum channelNumber{attrListHV->first};
126  const CondAttrListCollection::AttributeList &payload{attrListHV->second};
127  if (payload.exists(paramHV) and not payload[paramHV].isNull()) {
128  float hvval{payload[paramHV].data<float>()};
129  if ((hvval<m_hvLowLimit) or (hvval>m_hvUpLimit)) {
130  writeCdoState->fill(channelNumber, paramHV);
131  } else {
132  writeCdoState->remove(channelNumber, paramHV);
133  }
134  } else {
135  ATH_MSG_WARNING(paramHV << " does not exist for ChanNum " << channelNumber);
136  }
137  }
138  }
139 
140  // Record the output cond object
141  if (writeHandle.record(std::move(writeCdoState)).isFailure()) {
142  ATH_MSG_FATAL("Could not record SCT_DCSStatCondData " << writeHandle.key()
143  << " with EventRange " << writeHandle.getRange()
144  << " into Conditions Store");
145  return StatusCode::FAILURE;
146  }
147  ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
148 
149  return StatusCode::SUCCESS;
150 }
151 
153 {
154  ATH_MSG_DEBUG("finalize " << name());
155  return StatusCode::SUCCESS;
156 }
SCT_DCSConditionsStatCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: SCT_DCSConditionsStatCondAlg.cxx:41
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_DCSConditionsStatCondAlg::m_useHVChanCut
StringProperty m_useHVChanCut
Definition: SCT_DCSConditionsStatCondAlg.h:63
SCT_DCSConditionsStatCondAlg::m_readAllDBFolders
BooleanProperty m_readAllDBFolders
Definition: SCT_DCSConditionsStatCondAlg.h:55
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SCT_DCSConditionsStatCondAlg::SCT_DCSConditionsStatCondAlg
SCT_DCSConditionsStatCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCT_DCSConditionsStatCondAlg.cxx:11
SCT_DCSConditionsStatCondAlg::m_hvUpLimit
FloatProperty m_hvUpLimit
Definition: SCT_DCSConditionsStatCondAlg.h:59
SCT_DCSConditionsStatCondAlg::m_useHVUpLimit
FloatProperty m_useHVUpLimit
Definition: SCT_DCSConditionsStatCondAlg.h:62
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SCT_DCSConditionsStatCondAlg::m_useHVLowLimit
FloatProperty m_useHVLowLimit
Definition: SCT_DCSConditionsStatCondAlg.h:61
SCT_DCSConditionsStatCondAlg::m_chanstatCut
StringProperty m_chanstatCut
Definition: SCT_DCSConditionsStatCondAlg.h:57
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
SCT_DCSConditionsStatCondAlg::m_hvLowLimit
FloatProperty m_hvLowLimit
Definition: SCT_DCSConditionsStatCondAlg.h:58
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_DCSConditionsStatCondAlg::MANUAL
@ MANUAL
Definition: SCT_DCSConditionsStatCondAlg.h:36
SCT_DCSConditionsStatCondAlg::m_readKeyHV
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyHV
Definition: SCT_DCSConditionsStatCondAlg.h:50
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SCT_DCSConditionsStatCondAlg.h
IdentifierHash.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SCT_DCSConditionsStatCondAlg::initialize
virtual StatusCode initialize() override final
Definition: SCT_DCSConditionsStatCondAlg.cxx:16
SCT_DCSConditionsStatCondAlg::ON
@ ON
Definition: SCT_DCSConditionsStatCondAlg.h:34
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
SCT_DCSConditionsStatCondAlg::m_readKeyState
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyState
Definition: SCT_DCSConditionsStatCondAlg.h:51
SCT_DCSConditionsStatCondAlg::m_doState
bool m_doState
Definition: SCT_DCSConditionsStatCondAlg.h:54
SCT_DCSConditionsStatCondAlg::m_returnHVTemp
BooleanProperty m_returnHVTemp
Definition: SCT_DCSConditionsStatCondAlg.h:56
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
SCT_DCSConditionsStatCondAlg::STANDBY
@ STANDBY
Definition: SCT_DCSConditionsStatCondAlg.h:35
CondAttrListCollection::AttributeList
coral::AttributeList AttributeList
Definition: CondAttrListCollection.h:56
SCT_DCSConditionsStatCondAlg::m_useDefaultHV
BooleanProperty m_useDefaultHV
Definition: SCT_DCSConditionsStatCondAlg.h:60
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
SCT_DCSConditionsStatCondAlg::m_writeKeyState
SG::WriteCondHandleKey< SCT_DCSStatCondData > m_writeKeyState
Definition: SCT_DCSConditionsStatCondAlg.h:52
SCT_DCSConditionsStatCondAlg::RAMPING
@ RAMPING
Definition: SCT_DCSConditionsStatCondAlg.h:41
SCT_DCSConditionsStatCondAlg::finalize
virtual StatusCode finalize() override final
Definition: SCT_DCSConditionsStatCondAlg.cxx:152