ATLAS Offline Software
DQBadLBFilterAlg.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 "DQBadLBFilterAlg.h"
9 #include "CoralBase/AttributeListException.h"
10 
11 DQBadLBFilterAlg::DQBadLBFilterAlg(const std::string& name, ISvcLocator* pSvcLocator)
12 : AthAlgorithm( name, pSvcLocator )
13 , m_ignoreRecoverable(true)
14 , m_readKey("/GLOBAL/DETSTATUS/DEFECTS")
15 , m_writeKey("")
16 , m_attribListSpec(0)
17 {
18  declareProperty("ignoreRecoverable", m_ignoreRecoverable);
19  declareProperty("defectListStr", m_listofdefects_str);
20  declareProperty("defectList", m_listofdefects);
21  declareProperty("ReadKey", m_readKey);
22  declareProperty("WriteKey", m_writeKey);
23 }
24 
26  if ( m_attribListSpec ) {
27  m_attribListSpec->release();
28  }
29 }
30 
32 {
33 
34  ATH_MSG_DEBUG("size of defects list in Bad DB " << m_listofdefects_str.size()<< " : " << m_listofdefects.size());
35 
36  ATH_MSG_VERBOSE("ATLAS Ready initialize");
37  // define attributes to upload
38  m_attribListSpec = new coral::AttributeListSpecification;
39  m_attribListSpec->extend("Accept", "bool");
40 
41  // Handles
44 
45  return StatusCode::SUCCESS;
46 }
47 
49  // from pixel example code ...
50  // Write Cond Handle
52  // Do we have a valid Write Cond Handle for current time?
53  if(writeHandle.isValid()) {
54  // in theory this should never be called in MT
55  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid.");
56  return StatusCode::SUCCESS;
57  }
58 
59  ATH_MSG_DEBUG( "Creating AthenaAttributeList object." );
60  std::unique_ptr<AthenaAttributeList> attribListW = std::make_unique<AthenaAttributeList>(*m_attribListSpec);
61  (*attribListW)["Accept"].setValue(true);
62 
64  const CondAttrListCollection* attrListCol{*readHandle};
65  if (attrListCol == nullptr) {
66  ATH_MSG_ERROR("Unable to retrieve defect information");
67  return StatusCode::FAILURE;
68  }
69 
70  ATH_MSG_DEBUG("Col range " << " iov min " << attrListCol->minRange().start().event() << " iov max " << attrListCol->minRange().stop().event());
71 
72  std::vector<int>::const_iterator defect_iter = m_listofdefects.begin();
73 
74  for ( ; defect_iter != m_listofdefects.end();++defect_iter){
75  if (attrListCol->chanAttrListPair(*defect_iter) != attrListCol->end()){
76  const CondAttrListCollection::AttributeList* attrList =
77  &(attrListCol->attributeList( (*defect_iter) ));
78  ATH_MSG_DEBUG("FOUND CHANNEL " << (*defect_iter) << " is: " << (*attrList)["present"].data<bool>());
79  ATH_MSG_DEBUG("current channel : " << (*defect_iter) << " Name : " << attrListCol->chanName(*defect_iter) << " : iovrange " << attrListCol->iovRange(*defect_iter).start().event() << " : " << attrListCol->iovRange(*defect_iter).stop().event());
80  ATH_MSG_DEBUG( "Check address " << attrList << " : " << *attrList);
81  if ((*attrList)["present"].data<bool>() != 0){
82  if ((*attrList)["recoverable"].data<bool>() == 1 && m_ignoreRecoverable){
83  continue;
84  }
85  (*attribListW)["Accept"].setValue(false);
86  }
87  }
88  }
89 
90  // Define validity of the output cond object and record it
91  writeHandle.addDependency(readHandle);
92 
93  if(writeHandle.record(attribListW.release()).isFailure()) {
94  ATH_MSG_ERROR("Could not record DQ AthenaAttributeList object with "
95  << writeHandle.key()
96  << " with EventRange " << writeHandle.getRange()
97  << " into Conditions Store");
98  return StatusCode::FAILURE;
99  }
100  ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
101 
102  return StatusCode::SUCCESS;
103 }
DQBadLBFilterAlg::m_listofdefects_str
std::vector< std::string > m_listofdefects_str
Definition: DQBadLBFilterAlg.h:34
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
DQBadLBFilterAlg::m_writeKey
SG::WriteCondHandleKey< AthenaAttributeList > m_writeKey
Definition: DQBadLBFilterAlg.h:36
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthenaAttributeListSpecification.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
AthenaAttributeList.h
DQBadLBFilterAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition: DQBadLBFilterAlg.h:35
DQBadLBFilterAlg.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DQBadLBFilterAlg::initialize
virtual StatusCode initialize() override
Definition: DQBadLBFilterAlg.cxx:31
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DQBadLBFilterAlg::m_listofdefects
std::vector< int > m_listofdefects
Definition: DQBadLBFilterAlg.h:33
AthAlgorithm
Definition: AthAlgorithm.h:47
DQBadLBFilterAlg::m_attribListSpec
coral::AttributeListSpecification * m_attribListSpec
Definition: DQBadLBFilterAlg.h:37
DQBadLBFilterAlg::~DQBadLBFilterAlg
virtual ~DQBadLBFilterAlg() override
Definition: DQBadLBFilterAlg.cxx:25
DQBadLBFilterAlg::DQBadLBFilterAlg
DQBadLBFilterAlg(const std::string &, ISvcLocator *)
Definition: DQBadLBFilterAlg.cxx:11
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CondAttrListCollection::AttributeList
coral::AttributeList AttributeList
Definition: CondAttrListCollection.h:56
DQBadLBFilterAlg::m_ignoreRecoverable
bool m_ignoreRecoverable
Definition: DQBadLBFilterAlg.h:32
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
DQBadLBFilterAlg::execute
virtual StatusCode execute() override
Definition: DQBadLBFilterAlg.cxx:48