ATLAS Offline Software
TRT_StrawStatusSummaryTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 #include "Identifier/Identifier.h"
13 #include "InDetIdentifier/TRT_ID.h"
14 
15 TRT_StrawStatusSummaryTool::TRT_StrawStatusSummaryTool( const std::string& type, const std::string& name, const IInterface* parent)
16  : base_class(type, name, parent),
17  m_condSvc("CondSvc",name) {}
18 
19 
21 {
22  ATH_MSG_DEBUG("TRT_StrawStatusSummaryTool initialize method called");
23 
24  // Get the TRT ID helper
25  if (StatusCode::SUCCESS!=detStore()->retrieve(m_trtId,"TRT_ID")) {
26  ATH_MSG_FATAL("Problem retrieving TRTID helper");
27  return StatusCode::FAILURE;
28  }
29 
30  // Read keys in case of normal reconstruction/digitization
31  ATH_CHECK( m_statReadKey.initialize() );
32  ATH_CHECK( m_permReadKey.initialize() );
33 
34  // Only require this input if not using G4 sim
35  ATH_CHECK( m_statHTReadKey.initialize( !m_isGEANT4 ) );
36 
37  ATH_MSG_DEBUG("TRT_StrawStatusSummaryTool initialized successfully ");
38  return StatusCode::SUCCESS;
39 }
40 
42 
43 
45 {
46  return StatusCode::SUCCESS;
47 }
48 
49 
50 int TRT_StrawStatusSummaryTool::getStatus(Identifier offlineID, const EventContext& ctx) const{
53  m_trtId->phi_module(offlineID),m_trtId->straw_layer(offlineID),
54  m_trtId->straw(offlineID),level );
55 
57  const StrawStatusContainer* strawstatuscontainer(*rst);
58 
59  return int((*strawstatuscontainer).get(id).getstatus());
60 }
61 
62 
63 
64 int TRT_StrawStatusSummaryTool::getStatusPermanent(Identifier offlineID, const EventContext& ctx) const{
67  m_trtId->phi_module(offlineID),m_trtId->straw_layer(offlineID),
68  m_trtId->straw(offlineID),level );
69 
71  const StrawStatusContainer* strawstatuspermanentcontainer=(*rp);
72 
73  return int((*strawstatuspermanentcontainer).get(id).getstatus());
74 }
75 
76 
77 
78 int TRT_StrawStatusSummaryTool::getStatusHT(Identifier offlineID, const EventContext& ctx) const{
79 
82  m_trtId->phi_module(offlineID),m_trtId->straw_layer(offlineID),
83  m_trtId->straw(offlineID),level );
84 
85  const StrawStatusContainer* strawstatusHTcontainer = nullptr;
86  if(m_isGEANT4) {
87  if ( StatusCode::SUCCESS!=detStore()->retrieve( strawstatusHTcontainer, m_par_strawstatusHTcontainerkey ) ) {
88  ATH_MSG_FATAL( "Could not retrieve folder " << m_par_strawstatusHTcontainerkey );
89  return 0;
90  }
91  }
92  else {
94  strawstatusHTcontainer=(*rht);
95  }
96 
97  return int((*strawstatusHTcontainer).get(id).getstatus());
98 }
99 
101 
102  const StrawStatusContainer* strawstatusHTcontainer = nullptr;
103  if(m_isGEANT4) {
104  // processing GEANT4 simulation - revert to old non-MT style cond access
105  if ( StatusCode::SUCCESS!=detStore()->retrieve( strawstatusHTcontainer, m_par_strawstatusHTcontainerkey ) ) {
106  ATH_MSG_WARNING( "Could not retrieve folder " << m_par_strawstatusHTcontainerkey );
107  }
108  }
109  else {
110  SG::ReadCondHandle<StrawStatusContainer> rht(m_statHTReadKey,Gaudi::Hive::currentContext());
111  strawstatusHTcontainer=(*rht);
112  }
113 
114  return strawstatusHTcontainer;
115 }
116 
117 
119 
120 
121 bool TRT_StrawStatusSummaryTool::get_status(Identifier offlineID, const EventContext& ctx) const{
122  constexpr unsigned int statusbitmask = 1 << 8;// 0000001 00000000
123  const int status=getStatus(offlineID,ctx);
124  const int statusperm=getStatusPermanent(offlineID,ctx);
125  ATH_MSG_VERBOSE("offlineID "<<offlineID<<" "<<status <<" "<< statusperm);
126 
127  bool st = false, stperm=false;
128 
129  if (status==1) st = true;
130  else if (status==0) st = false;
131  else {st = bool( (status & statusbitmask) >> 8);};
132 
133  if (statusperm==1) stperm = true;
134  else if (statusperm==0) stperm = false;
135  else {stperm = bool( (statusperm & statusbitmask) >> 8);};
136 
137  return (st||stperm);
138 
139 }
140 
141 
142 
143 bool TRT_StrawStatusSummaryTool::get_statusHT(Identifier offlineID, const EventContext& ctx) const{
144  constexpr unsigned int statusbitmask = 1 << 8;// 0000001 00000000
145  bool stHT=false;
146  const int statusHT=getStatusHT(offlineID,ctx);
147 
148  if (statusHT==1) stHT = true;
149  else if (statusHT==0) stHT = false;
150  else {stHT = bool( (statusHT & statusbitmask) >> 8);};
151 
152  return ( stHT );
153 
154 }
155 
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
Definition: ReadCondHandle.h:44
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TRTCond::StrawStatusMultChanContainer
Definition: StrawStatusMultChanContainer.h:19
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
ExpandedIdentifier.h
TRT_StrawStatusSummaryTool.h
interface to TRT straw status constants used in normal reconstruction
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TRT_StrawStatusSummaryTool::get_status
virtual bool get_status(Identifier offlineId, const EventContext &) const override
Definition: TRT_StrawStatusSummaryTool.cxx:121
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
TRT_StrawStatusSummaryTool::getStatus
virtual int getStatus(Identifier offlineId, const EventContext &) const override
Definition: TRT_StrawStatusSummaryTool.cxx:50
TRT_ID::straw
int straw(const Identifier &id) const
Definition: TRT_ID.h:902
TRT_StrawStatusSummaryTool::getStatusPermanent
virtual int getStatusPermanent(Identifier offlineId, const EventContext &) const override
Definition: TRT_StrawStatusSummaryTool.cxx:64
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
TRT_StrawStatusSummaryTool::getStrawStatusHTContainer
virtual const StrawStatusContainer * getStrawStatusHTContainer() const override
Definition: TRT_StrawStatusSummaryTool.cxx:100
TRT_StrawStatusSummaryTool::m_permReadKey
SG::ReadCondHandleKey< StrawStatusContainer > m_permReadKey
Definition: TRT_StrawStatusSummaryTool.h:63
TRT_StrawStatusSummaryTool::m_statHTReadKey
SG::ReadCondHandleKey< StrawStatusContainer > m_statHTReadKey
Definition: TRT_StrawStatusSummaryTool.h:64
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TRT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: TRT_ID.h:866
TRT_ID::straw_layer
int straw_layer(const Identifier &id) const
Definition: TRT_ID.h:893
TRT_ID::layer_or_wheel
int layer_or_wheel(const Identifier &id) const
Definition: TRT_ID.h:884
TRT_StrawStatusSummaryTool::m_statReadKey
SG::ReadCondHandleKey< StrawStatusContainer > m_statReadKey
Definition: TRT_StrawStatusSummaryTool.h:62
TRT_StrawStatusSummaryTool::get_statusHT
virtual bool get_statusHT(Identifier offlineId, const EventContext &) const override
Definition: TRT_StrawStatusSummaryTool.cxx:143
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
TRT_StrawStatusSummaryTool::finalize
virtual StatusCode finalize() override
tool finalize
Definition: TRT_StrawStatusSummaryTool.cxx:44
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TRT_StrawStatusSummaryTool::m_isGEANT4
Gaudi::Property< bool > m_isGEANT4
Definition: TRT_StrawStatusSummaryTool.h:67
TRTCond::ExpandedIdentifier::STRAW
@ STRAW
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:37
TRT_StrawStatusSummaryTool::TRT_StrawStatusSummaryTool
TRT_StrawStatusSummaryTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
Definition: TRT_StrawStatusSummaryTool.cxx:15
TRT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: TRT_ID.h:875
TRT_StrawStatusSummaryTool::m_par_strawstatusHTcontainerkey
Gaudi::Property< std::string > m_par_strawstatusHTcontainerkey
Definition: TRT_StrawStatusSummaryTool.h:68
TRT_StrawStatusSummaryTool::initialize
virtual StatusCode initialize() override
tool initialize
Definition: TRT_StrawStatusSummaryTool.cxx:20
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TRT_StrawStatusSummaryTool::getStatusHT
virtual int getStatusHT(Identifier offlineId, const EventContext &) const override
Definition: TRT_StrawStatusSummaryTool.cxx:78
merge.status
status
Definition: merge.py:17
TRT_StrawStatusSummaryTool::m_trtId
const TRT_ID * m_trtId
Definition: TRT_StrawStatusSummaryTool.h:58
rp
ReadCards * rp
Definition: IReadCards.cxx:26
TRTCond::ExpandedIdentifier
Identifier for TRT detector elements in the conditions code.
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:30
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
Identifier
Definition: IdentifierFieldParser.cxx:14