ATLAS Offline Software
SCT_MajorityConditionsTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 
9 // Gaudi includes
10 #include "GaudiKernel/StatusCode.h"
11 #include "GaudiKernel/ThreadLocalContext.h"
12 
13 using namespace SCT_ConditionsData;
14 
15 // Constructor
16 SCT_MajorityConditionsTool::SCT_MajorityConditionsTool(const std::string& type, const std::string& name, const IInterface* parent) :
17  base_class(type, name, parent)
18 {
19 }
20 
21 // Initialize
23  ATH_MSG_INFO("Initializing SCT_MajorityConditionsTool");
24 
25  // Read Cond Handle Key
27 
28  return StatusCode::SUCCESS;
29 }
30 
31 // Finalize
33  ATH_MSG_INFO("Finalizing SCT_MajorityConditionsTool");
34 
35  return StatusCode::SUCCESS;
36 }
37 
38 // Is the detector good?
39 bool SCT_MajorityConditionsTool::isGood(const EventContext& ctx) const {
40  const SCT_MajorityCondData* condData{getCondData(ctx)};
41  if (condData==nullptr) return false;
42 
43  if (m_overall) {
44  return (condData->getMajorityState(OVERALL) and (condData->getHVFraction(OVERALL) > m_majorityFraction));
45  } else {
46  return ((condData->getMajorityState(BARREL) and condData->getMajorityState(ECA) and condData->getMajorityState(ECC)) and
47  (condData->getHVFraction(BARREL) > m_majorityFraction) and
48  (condData->getHVFraction(ECA) > m_majorityFraction) and
49  (condData->getHVFraction(ECC) > m_majorityFraction));
50  }
51 }
52 
54  const EventContext& ctx{Gaudi::Hive::currentContext()};
55  return isGood(ctx);
56 }
57 
58 // Is a barrel/endcap good?
59 bool SCT_MajorityConditionsTool::isGood(int bec, const EventContext& ctx) const {
60  const SCT_MajorityCondData* condData{getCondData(ctx)};
61  if (condData==nullptr) return false;
62 
63  bool result{true};
64 
65  // Check numbering
66 
67  if (bec == bec_BARREL) {
68  result = (condData->getMajorityState(BARREL) and (condData->getHVFraction(BARREL) > m_majorityFraction));
69  } else if (bec == bec_ECC) {
70  result = (condData->getMajorityState(ECC) and (condData->getHVFraction(ECC) > m_majorityFraction));
71  } else if (bec == bec_ECA) {
72  result = (condData->getMajorityState(ECA) and (condData->getHVFraction(ECA) > m_majorityFraction));
73  } else {
74  ATH_MSG_WARNING("Unrecognised BEC " << bec);
75  }
76 
77  return result;
78 }
79 
81  const EventContext& ctx{Gaudi::Hive::currentContext()};
82  return isGood(bec, ctx);
83 }
84 
85 const SCT_MajorityCondData* SCT_MajorityConditionsTool::getCondData(const EventContext& ctx) const {
87  return condData.retrieve();
88 }
SCT_ConditionsData::ECC
@ ECC
Definition: SCT_ConditionsParameters.h:27
SCT_MajorityConditionsTool::m_majorityFraction
FloatProperty m_majorityFraction
Definition: SCT_MajorityConditionsTool.h:59
get_generator_info.result
result
Definition: get_generator_info.py:21
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ParticleGun_SamplingFraction.bec
int bec
Definition: ParticleGun_SamplingFraction.py:89
SCT_MajorityCondData
Class for data object used in SCT_MajorityCondAlg and SCT_MajorityConditionsTool.
Definition: SCT_MajorityCondData.h:23
SCT_MajorityConditionsTool::isGood
virtual bool isGood() const override
Is the detector good?
Definition: SCT_MajorityConditionsTool.cxx:53
SCT_ConditionsData::bec_ECA
@ bec_ECA
Definition: SCT_ConditionsParameters.h:31
SCT_ConditionsData::bec_BARREL
@ bec_BARREL
Definition: SCT_ConditionsParameters.h:31
SCT_ConditionsParameters.h
header file containing the number of elements and enumerated type of parameters which may be retrieve...
SCT_MajorityConditionsTool.h
SCT_MajorityConditionsTool::m_overall
BooleanProperty m_overall
Definition: SCT_MajorityConditionsTool.h:58
SCT_ConditionsData::bec_ECC
@ bec_ECC
Definition: SCT_ConditionsParameters.h:31
SCT_ConditionsData::ECA
@ ECA
Definition: SCT_ConditionsParameters.h:26
SCT_ConditionsData
Definition: SCT_ConditionsParameters.h:17
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ConditionsData::OVERALL
@ OVERALL
Definition: SCT_ConditionsParameters.h:24
SCT_MajorityConditionsTool::initialize
virtual StatusCode initialize() override
Definition: SCT_MajorityConditionsTool.cxx:22
SCT_MajorityConditionsTool::getCondData
const SCT_MajorityCondData * getCondData(const EventContext &ctx) const
Definition: SCT_MajorityConditionsTool.cxx:85
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
BARREL
@ BARREL
Definition: TRTRadiatorParameters.h:10
SCT_MajorityConditionsTool::m_condKey
SG::ReadCondHandleKey< SCT_MajorityCondData > m_condKey
Definition: SCT_MajorityConditionsTool.h:61
SCT_MajorityConditionsTool::finalize
virtual StatusCode finalize() override
Definition: SCT_MajorityConditionsTool.cxx:32
SCT_MajorityConditionsTool::SCT_MajorityConditionsTool
SCT_MajorityConditionsTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SCT_MajorityConditionsTool.cxx:16