ATLAS Offline Software
Loading...
Searching...
No Matches
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
9
10#include "Identifier/Identifier.h"
14
15TRT_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
50int TRT_StrawStatusSummaryTool::getStatus(Identifier offlineID, const EventContext& ctx) const{
51 constexpr int level = TRTCond::ExpandedIdentifier::STRAW ;
52 TRTCond::ExpandedIdentifier id= TRTCond::ExpandedIdentifier( m_trtId->barrel_ec(offlineID),m_trtId->layer_or_wheel(offlineID),
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
64int TRT_StrawStatusSummaryTool::getStatusPermanent(Identifier offlineID, const EventContext& ctx) const{
65 constexpr int level = TRTCond::ExpandedIdentifier::STRAW ;
66 TRTCond::ExpandedIdentifier id= TRTCond::ExpandedIdentifier( m_trtId->barrel_ec(offlineID),m_trtId->layer_or_wheel(offlineID),
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
78int TRT_StrawStatusSummaryTool::getStatusHT(Identifier offlineID, const EventContext& ctx) const{
79
80 constexpr int level = TRTCond::ExpandedIdentifier::STRAW ;
81 TRTCond::ExpandedIdentifier id= TRTCond::ExpandedIdentifier( m_trtId->barrel_ec(offlineID),m_trtId->layer_or_wheel(offlineID),
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
121bool 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
143bool 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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
ReadCards * rp
This is an Identifier helper class for the TRT subdetector.
interface to TRT straw status constants used in normal reconstruction
A COOL multichannel container for StrawStatus.
virtual int getStatus(Identifier offlineId, const EventContext &) const override
virtual int getStatusPermanent(Identifier offlineId, const EventContext &) const override
virtual int getStatusHT(Identifier offlineId, const EventContext &) const override
virtual bool get_statusHT(Identifier offlineId, const EventContext &) const override
SG::ReadCondHandleKey< StrawStatusContainer > m_statHTReadKey
virtual StatusCode finalize() override
tool finalize
virtual StatusCode initialize() override
tool initialize
SG::ReadCondHandleKey< StrawStatusContainer > m_permReadKey
Gaudi::Property< std::string > m_par_strawstatusHTcontainerkey
SG::ReadCondHandleKey< StrawStatusContainer > m_statReadKey
TRTCond::StrawStatusMultChanContainer StrawStatusContainer
TRT_StrawStatusSummaryTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
virtual const StrawStatusContainer * getStrawStatusHTContainer() const override
ServiceHandle< ICondSvc > m_condSvc
virtual bool get_status(Identifier offlineId, const EventContext &) const override