ATLAS Offline Software
TRT_ConditionsSummarySvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
14 #include "InDetIdentifier/TRT_ID.h"
16 
17 //Gaudi includes
18 #include "StoreGate/StoreGateSvc.h"
19 
20 // Constructor
21 TRT_ConditionsSummarySvc::TRT_ConditionsSummarySvc( const std::string& name, ISvcLocator* pSvcLocator ) :
22  base_class(name, pSvcLocator),
23  m_svcCollection(name),
24  m_manager(nullptr),
25  m_trtid(nullptr)
26 {
27  // Get properties from job options
28  declareProperty( "ServiceList", m_svcCollection );
29 }
30 
31 // Destructor
33 
34 //Initialize
37  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "TRT_ConditionsSummarySvc::initialize." << endmsg;
38  StatusCode sc(StatusCode::SUCCESS);
39 
40  // Retrieve the services to be called.
41  if ( m_svcCollection.empty() ) {
42  msg(MSG::WARNING) << "No services to be called!" << endmsg;
43  } else {
44  sc = m_svcCollection.retrieve();
45  if ( sc.isFailure() ) {
46  msg(MSG::ERROR) << "Couldn't retrieve services: "
47  << m_svcCollection << endmsg;
48  return sc;
49  } else {
50  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Successfully retrieved services: "
51  << m_svcCollection << endmsg;
52  }
53  }
54 
55  // Get DetectorStore service
56  SmartIF<StoreGateSvc> detStore{service("DetectorStore")};
57  ATH_CHECK( detStore.isValid() );
58 
59  // Retrieve TRT_DetectorManager
60  std::string managerName;
61  sc=detStore->retrieve(m_manager, managerName);
62  if (sc.isFailure() || !m_manager)
63  {
64  msg(MSG::FATAL) << "Could not find the Manager: "
65  << managerName << " !" << endmsg;
66  return sc;
67  }
68 
69  // Retrieve TRT ID Helper
70  sc = detStore->retrieve(m_trtid,"TRT_ID");
71  if ( sc.isFailure() ) {
72  ATH_MSG_FATAL("Could not retrieve TRT ID Helper.");
73  return sc;
74  }
75 
76  return sc;
77 }
78 
79 //Finalize
82  return StatusCode::SUCCESS;
83 }
84 
85 bool
87  bool result(false);
88 
91 
94  //need to loop over all straws at this hierarchy level
95  result=true;
96  const InDetDD::TRT_BaseElement *element=m_manager->getElement(elementId);
97 
98  //loop over all straws
99  int nelements=element->nStraws();
100  for(int i=0;i<nelements;i++){
103  result=false;
104  break;
105  }
106  }
107  }else{
108  msg(MSG::FATAL)<<"Hierarchy Level "<<h<<" not yet implemented!!!"<<endmsg;
109  result=false;
110  }
111 
112  return result;
113 }
114 
115 bool
117  bool result(true);
118 
119  const InDetDD::TRT_BaseElement *element=m_manager->getElement(elementHash);
120 
121  Identifier elementId=m_trtid->layer_id(elementHash);
122 
123  //loop over all straws
124  int nelements=element->nStraws();
125  for(int i=0;i<nelements;i++){
128  result=false;
129  break;
130  }
131  }
132 
133  return result;
134 }
135 
136 bool
138  bool result(false);
139 
141 
142  return result;
143 }
144 
145 double
146 TRT_ConditionsSummarySvc::activeFraction(const IdentifierHash & elementHash, const Identifier & idStart, const Identifier & idEnd){
147  double result(0.0);
148 
149  Identifier layerId=m_trtid->layer_id(elementHash);
150 
151  int start=m_trtid->straw(idStart);
152  int end=m_trtid->straw(idEnd);
153 
154  double count=1.0;
155  for(int i=start;i<=end;i++){
156  Identifier elementId=m_trtid->straw_id(layerId,i);
157  if(isActive(elementId,InDetConditions::TRT_STRAW))
158  result+=1.0;
159  }
160  if(count>0){
161  result/=count;
162  }
163 
164  return result;
165 }
166 
167 bool
169  bool result(false);
170 
173 
176  //need to loop over all straws at this hierarchy level
177  result=true;
178  const InDetDD::TRT_BaseElement *element=m_manager->getElement(elementId);
179 
180  //loop over all straws
181  int nelements=element->nStraws();
182  for(int i=0;i<nelements;i++){
184  if(!(flag==InDet::TRT_COND_GOOD)){
185  result=false;
186  break;
187  }
188  }
189  }else{
190  msg(MSG::FATAL)<<"Hierarchy Level "<<h<<" not yet implemented!!!"<<endmsg;
191  result=false;
192  }
193 
194  return result;
195 }
196 
197 bool
199  bool result(false);
200 
201  const InDetDD::TRT_BaseElement *element=m_manager->getElement(elementHash);
202 
203  Identifier elementId=m_trtid->layer_id(elementHash);
204 
205  //loop over all straws
206  int nelements=element->nStraws();
207  for(int i=0;i<nelements;i++){
209  if(!(flag==InDet::TRT_COND_GOOD)){
210  result=false;
211  break;
212  }
213  }
214 
215  return result;
216 }
217 
218 bool
220  bool result(false);
221 
223 
224  return result;
225 }
226 
227 double
228 TRT_ConditionsSummarySvc::goodFraction(const IdentifierHash & elementHash, const Identifier & idStart, const Identifier & idEnd){
229  double result(0.0);
230 
231  Identifier layerId=m_trtid->layer_id(elementHash);
232 
233  int start=m_trtid->straw(idStart);
234  int end=m_trtid->straw(idEnd);
235 
236  double count=1.0;
237  for(int i=start;i<=end;i++){
238  Identifier elementId=m_trtid->straw_id(layerId,i);
239  if(isGood(elementId,InDetConditions::TRT_STRAW))
240  result+=1.0;
241  }
242  if(count>0){
243  result/=count;
244  }
245 
246  return result;
247 }
248 
250  const Identifier &ident ) {
251 
252  // Identifier id=ident;
254 
255  // Call condSummaryStatus for each service in m_svcCollection.
256  ServiceHandleArray<ITRT_ConditionsSvc>::const_iterator svcItr;
257  for ( svcItr = m_svcCollection.begin();
258  svcItr != m_svcCollection.end(); ++svcItr ) {
259  InDet::TRT_CondFlag thisSvcFlag;
260  thisSvcFlag = (*svcItr)->condSummaryStatus( ident );
261  if ( thisSvcFlag == InDet::TRT_COND_SKIPME ) continue;
262  if ( thisSvcFlag == InDet::TRT_COND_NOINFO ) continue;
263  // If any tool reports CAUTION, return CAUTION.
264  // If any tool reports BAD, return BAD.
265  if ( thisSvcFlag != InDet::TRT_COND_GOOD ) {
267  if ( thisSvcFlag == InDet::TRT_COND_BAD ) status = InDet::TRT_COND_BAD;
268  }
269  }
270 
271  return status;
272 }
TRT_ID::layer_id
Identifier layer_id(int barrel_ec, int phi_module, int layer_or_wheel, int straw_layer) const
For an individual straw layer.
Definition: TRT_ID.h:500
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
get_generator_info.result
result
Definition: get_generator_info.py:21
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
TRT_DetectorManager.h
TRT_ConditionsSummarySvc::condSummaryStatus
InDet::TRT_CondFlag condSummaryStatus(const Identifier &ident)
Definition: TRT_ConditionsSummarySvc.cxx:249
TRT_ConditionsSummarySvc::m_svcCollection
ServiceHandleArray< ITRT_ConditionsSvc > m_svcCollection
Definition: TRT_ConditionsSummarySvc.h:63
InDetDD::TRT_BaseElement::nStraws
unsigned int nStraws() const
Number of straws in the element.
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
TRT_ConditionsSummarySvc::~TRT_ConditionsSummarySvc
virtual ~TRT_ConditionsSummarySvc()
InDetConditions::Hierarchy
Hierarchy
Definition: InDetHierarchy.h:14
TRT_ConditionsSummarySvc::goodFraction
virtual double goodFraction(const IdentifierHash &elementHash, const Identifier &idStart, const Identifier &idEnd)
Definition: TRT_ConditionsSummarySvc.cxx:228
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
InDet::TRT_COND_NOINFO
@ TRT_COND_NOINFO
Definition: ITRT_ConditionsSvc.h:20
TRT_ConditionsSummarySvc.h
TRT_ID::straw
int straw(const Identifier &id) const
Definition: TRT_ID.h:902
TRT_ConditionsSummarySvc::activeFraction
virtual double activeFraction(const IdentifierHash &elementHash, const Identifier &idStart, const Identifier &idEnd)
Definition: TRT_ConditionsSummarySvc.cxx:146
lumiFormat.i
int i
Definition: lumiFormat.py:85
InDet::TRT_COND_CAUTION
@ TRT_COND_CAUTION
Definition: ITRT_ConditionsSvc.h:22
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
InDet::TRT_COND_SKIPME
@ TRT_COND_SKIPME
Definition: ITRT_ConditionsSvc.h:26
master.flag
bool flag
Definition: master.py:29
TRT_ConditionsSummarySvc::isGood
virtual bool isGood(const Identifier &elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT)
Definition: TRT_ConditionsSummarySvc.cxx:168
InDetHierarchy.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TRT_ConditionsSummarySvc::TRT_ConditionsSummarySvc
TRT_ConditionsSummarySvc(const std::string &name, ISvcLocator *svc)
Service constructor.
Definition: TRT_ConditionsSummarySvc.cxx:21
TRT_ConditionsSummarySvc::finalize
virtual StatusCode finalize()
Service finalize.
Definition: TRT_ConditionsSummarySvc.cxx:81
InDetConditions::TRT_STRAW_LAYER
@ TRT_STRAW_LAYER
Definition: InDetHierarchy.h:16
TRT_ConditionsSummarySvc::m_manager
const InDetDD::TRT_DetectorManager * m_manager
Definition: TRT_ConditionsSummarySvc.h:66
TRT_BaseElement.h
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
TRT_ConditionsSummarySvc::initialize
virtual StatusCode initialize()
Service init.
Definition: TRT_ConditionsSummarySvc.cxx:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
InDetDD::TRT_DetectorManager::getElement
const TRT_BaseElement * getElement(Identifier id) const
Access Elements Generically---------------------------------------------—.
Definition: TRT_DetectorManager.cxx:148
TRT::Hit::ident
@ ident
Definition: HitInfo.h:77
TRT_ConditionsSummarySvc::isActive
virtual bool isActive(const Identifier &elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT)
Definition: TRT_ConditionsSummarySvc.cxx:86
TRT_ConditionsSummarySvc::m_trtid
const TRT_ID * m_trtid
Definition: TRT_ConditionsSummarySvc.h:67
InDet::TRT_COND_BAD
@ TRT_COND_BAD
Definition: ITRT_ConditionsSvc.h:25
h
DEBUG
#define DEBUG
Definition: page_access.h:11
InDetConditions::TRT_STRAW
@ TRT_STRAW
Definition: InDetHierarchy.h:16
InDet::TRT_CondFlag
TRT_CondFlag
status flag to be derived from the inheriting tool's conditions info
Definition: ITRT_ConditionsSvc.h:19
merge.status
status
Definition: merge.py:17
InDet::TRT_COND_GOOD
@ TRT_COND_GOOD
Definition: ITRT_ConditionsSvc.h:21
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
InDetConditions::DEFAULT
@ DEFAULT
Definition: InDetHierarchy.h:14
StoreGateSvc.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
InDetDD::TRT_BaseElement
Definition: TRT_BaseElement.h:57
TRT_ID::straw_id
Identifier straw_id(int barrel_ec, int phi_module, int layer_or_wheel, int straw_layer, int straw) const
Three ways of getting id for a single straw:
Definition: TRT_ID.h:581
Identifier
Definition: IdentifierFieldParser.cxx:14