ATLAS Offline Software
LArFEBConfigCondAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "LArFEBConfigCondAlg.h"
7 
8 
9 LArFEBConfigCondAlg::LArFEBConfigCondAlg(const std::string& name, ISvcLocator* pSvcLocator) :
10  AthReentrantAlgorithm(name,pSvcLocator),m_onlineID(nullptr) {}
11 
12 
14 
16 
17  ATH_MSG_DEBUG(" trying initialize");
18 
19  ATH_CHECK(detStore()->retrieve(m_onlineID,"LArOnlineID"));
20 
21  if (m_listOfFolders.empty()) {
22  ATH_MSG_WARNING( "List of folders is emtpy, do nothing");
23  return StatusCode::SUCCESS;
24  }
25 
26  ATH_CHECK(m_listOfFolders.initialize());
28 
29  ATH_MSG_DEBUG("Successfully initialized LArFEBConfigCondAlg");
30  return StatusCode::SUCCESS;
31 }
32 
33 
34 
35 StatusCode LArFEBConfigCondAlg::execute(const EventContext& ctx) const {
36  ATH_MSG_DEBUG("executing");
37 
39  if (writeHandle.isValid()) {
40  ATH_MSG_DEBUG("Found valid write LArFebConfig handle");
41  return StatusCode::SUCCESS;
42  }
43 
44 
45  std::vector<const CondAttrListCollection*> attrvec;
46 
47  for (const auto& fldkey: m_listOfFolders) {
49  const CondAttrListCollection* cattr = *cHdl;
50  if(cattr) {
51  ATH_MSG_DEBUG("Folder: "<<cHdl.key()<<" has size: "<<std::distance(cattr->begin(),cattr->end()));
52  attrvec.push_back(cattr);
53  writeHandle.addDependency(cHdl);
54  } else {
55  ATH_MSG_WARNING("Why do not have FEB config folder " << fldkey.fullKey());
56  }
57  }
58 
59  // Fill LArFebConfig
60  std::unique_ptr<LArFebConfig> febConfig=std::make_unique<LArFebConfig>(m_onlineID);
61  LArFebConfig* p_febConfig = febConfig.get();
62 
63  unsigned nFebs=0;
64  for(const auto *dh: attrvec){
67  for (;chanit!=chanit_e;++chanit) {
68  if (chanit->first==0) {
69  ATH_MSG_DEBUG("Invalid channel number 0, ignoring...");
70  continue;
71  }
72  const HWIdentifier fid(chanit->first); //COOL channel number == FEB identifier
73  //const coral::AttributeList& attr = chanit->second;
74  ATH_MSG_VERBOSE("Working on FEB 0x" << std::hex << fid.get_compact() << std::dec << " " << m_onlineID->channel_name(fid));
75  p_febConfig->add (fid, &chanit->second);
76  ++nFebs;
77  }//End loop over COOL channels
78  }
79  ATH_MSG_INFO("Read gain thresholds for " << nFebs << " Febs from " << m_listOfFolders.size() << " database folders.");
80 
81  // Record output
82  if(writeHandle.record(std::move(febConfig)).isFailure()) {
83  ATH_MSG_ERROR("Could not record LArFebConfig object with " << writeHandle.key()
84  << " with EventRange " << writeHandle.getRange() << " into Conditions Store");
85  return StatusCode::FAILURE;
86  }
87 
88  ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
89 
90  return StatusCode::SUCCESS;
91 }
92 
93 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
LArFEBConfigCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: LArFEBConfigCondAlg.cxx:35
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArFEBConfigCondAlg::LArFEBConfigCondAlg
LArFEBConfigCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArFEBConfigCondAlg.cxx:9
LArFEBConfigCondAlg::m_listOfFolders
SG::ReadCondHandleKeyArray< CondAttrListCollection > m_listOfFolders
Definition: LArFEBConfigCondAlg.h:31
Identifier::get_compact
value_type get_compact() const
Get the compact id.
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition: CondAttrListCollection.h:309
LArFEBConfigCondAlg.h
PyPoolBrowser.dh
dh
Definition: PyPoolBrowser.py:102
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
HWIdentifier
Definition: HWIdentifier.h:13
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
LArFebConfig
Definition: LArFebConfig.h:16
LArFebConfig::add
void add(HWIdentifier febid, const coral::AttributeList *attrList)
Definition: LArFebConfig.cxx:21
LArFEBConfigCondAlg::initialize
virtual StatusCode initialize() override
Definition: LArFEBConfigCondAlg.cxx:15
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
LArFEBConfigCondAlg::m_configKey
SG::WriteCondHandleKey< LArFebConfig > m_configKey
Definition: LArFEBConfigCondAlg.h:32
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArFEBConfigCondAlg::m_onlineID
const LArOnlineID * m_onlineID
Definition: LArFEBConfigCondAlg.h:30
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
LArFEBConfigCondAlg::~LArFEBConfigCondAlg
virtual ~LArFEBConfigCondAlg()
Definition: LArFEBConfigCondAlg.cxx:13
SG::ReadCondHandle::key
const std::string & key() const
Definition: ReadCondHandle.h:59
LArOnlineID_Base::channel_name
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
Definition: LArOnlineID_Base.cxx:219
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
LArOnlineID.h