ATLAS Offline Software
TRT_ConditionsSummarySvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 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 {
25  // Get properties from job options
26  declareProperty( "ServiceList", m_svcCollection );
27 }
28 
29 // Destructor
31 
32 //Initialize
35  ATH_MSG_DEBUG("TRT_ConditionsSummarySvc::initialize.");
36 
37  // Retrieve the services to be called.
38  if ( m_svcCollection.empty() ) {
39  ATH_MSG_WARNING("No services to be called!");
40  } else {
41  ATH_CHECK(m_svcCollection.retrieve());
42  ATH_MSG_DEBUG("Successfully retrieved services: " << m_svcCollection);
43  }
44 
45  // Get DetectorStore service
46  SmartIF<StoreGateSvc> detStore{service("DetectorStore")};
47  ATH_CHECK( detStore.isValid() );
48 
49  // Retrieve TRT_DetectorManager
50  ATH_CHECK(detStore->retrieve(m_manager, "TRT"));
51 
52  // Retrieve TRT ID Helper
53  ATH_CHECK(detStore->retrieve(m_trtid,"TRT_ID"));
54 
55  return StatusCode::SUCCESS;
56 }
57 
58 bool
60  bool result(false);
61 
64 
67  //need to loop over all straws at this hierarchy level
68  result=true;
69  const InDetDD::TRT_BaseElement *element=m_manager->getElement(elementId);
70 
71  //loop over all straws
72  int nelements=element->nStraws();
73  for(int i=0;i<nelements;i++){
76  result=false;
77  break;
78  }
79  }
80  }else{
81  ATH_MSG_FATAL("Hierarchy Level "<<h<<" not yet implemented!!!");
82  result=false;
83  }
84 
85  return result;
86 }
87 
88 bool
90  bool result(true);
91 
92  const InDetDD::TRT_BaseElement *element=m_manager->getElement(elementHash);
93 
94  Identifier elementId=m_trtid->layer_id(elementHash);
95 
96  //loop over all straws
97  int nelements=element->nStraws();
98  for(int i=0;i<nelements;i++){
101  result=false;
102  break;
103  }
104  }
105 
106  return result;
107 }
108 
109 bool
111  bool result(false);
112 
114 
115  return result;
116 }
117 
118 double
119 TRT_ConditionsSummarySvc::activeFraction(const IdentifierHash & elementHash, const Identifier & idStart, const Identifier & idEnd){
120  double result(0.0);
121 
122  Identifier layerId=m_trtid->layer_id(elementHash);
123 
124  int start=m_trtid->straw(idStart);
125  int end=m_trtid->straw(idEnd);
126 
127  double count=1.0;
128  for(int i=start;i<=end;i++){
129  Identifier elementId=m_trtid->straw_id(layerId,i);
130  if(isActive(elementId,InDetConditions::TRT_STRAW))
131  result+=1.0;
132  }
133  if(count>0){
134  result/=count;
135  }
136 
137  return result;
138 }
139 
140 bool
142  bool result(false);
143 
146 
149  //need to loop over all straws at this hierarchy level
150  result=true;
151  const InDetDD::TRT_BaseElement *element=m_manager->getElement(elementId);
152 
153  //loop over all straws
154  int nelements=element->nStraws();
155  for(int i=0;i<nelements;i++){
157  if(!(flag==InDet::TRT_COND_GOOD)){
158  result=false;
159  break;
160  }
161  }
162  }else{
163  ATH_MSG_FATAL("Hierarchy Level "<<h<<" not yet implemented!!!");
164  result=false;
165  }
166 
167  return result;
168 }
169 
170 bool
172  bool result(false);
173 
174  const InDetDD::TRT_BaseElement *element=m_manager->getElement(elementHash);
175 
176  Identifier elementId=m_trtid->layer_id(elementHash);
177 
178  //loop over all straws
179  int nelements=element->nStraws();
180  for(int i=0;i<nelements;i++){
182  if(!(flag==InDet::TRT_COND_GOOD)){
183  result=false;
184  break;
185  }
186  }
187 
188  return result;
189 }
190 
191 bool
193  bool result(false);
194 
196 
197  return result;
198 }
199 
200 double
201 TRT_ConditionsSummarySvc::goodFraction(const IdentifierHash & elementHash, const Identifier & idStart, const Identifier & idEnd){
202  double result(0.0);
203 
204  Identifier layerId=m_trtid->layer_id(elementHash);
205 
206  int start=m_trtid->straw(idStart);
207  int end=m_trtid->straw(idEnd);
208 
209  double count=1.0;
210  for(int i=start;i<=end;i++){
211  Identifier elementId=m_trtid->straw_id(layerId,i);
212  if(isGood(elementId,InDetConditions::TRT_STRAW))
213  result+=1.0;
214  }
215  if(count>0){
216  result/=count;
217  }
218 
219  return result;
220 }
221 
224 
225  // Identifier id=ident;
227 
228  // Call condSummaryStatus for each service in m_svcCollection.
229  ServiceHandleArray<ITRT_ConditionsSvc>::const_iterator svcItr;
230  for ( svcItr = m_svcCollection.begin();
231  svcItr != m_svcCollection.end(); ++svcItr ) {
232  InDet::TRT_CondFlag thisSvcFlag;
233  thisSvcFlag = (*svcItr)->condSummaryStatus( ident );
234  if ( thisSvcFlag == InDet::TRT_COND_SKIPME ) continue;
235  if ( thisSvcFlag == InDet::TRT_COND_NOINFO ) continue;
236  // If any tool reports CAUTION, return CAUTION.
237  // If any tool reports BAD, return BAD.
238  if ( thisSvcFlag != InDet::TRT_COND_GOOD ) {
240  if ( thisSvcFlag == InDet::TRT_COND_BAD ) status = InDet::TRT_COND_BAD;
241  }
242  }
243 
244  return status;
245 }
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:494
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
get_generator_info.result
result
Definition: get_generator_info.py:21
TRT_DetectorManager.h
TRT_ConditionsSummarySvc::condSummaryStatus
InDet::TRT_CondFlag condSummaryStatus(const Identifier &ident)
Definition: TRT_ConditionsSummarySvc.cxx:223
TRT_ConditionsSummarySvc::m_svcCollection
ServiceHandleArray< ITRT_ConditionsSvc > m_svcCollection
Definition: TRT_ConditionsSummarySvc.h:62
InDetDD::TRT_BaseElement::nStraws
unsigned int nStraws() const
Number of straws in the element.
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:13
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::isActive
virtual bool isActive(const Identifier &elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) override
Definition: TRT_ConditionsSummarySvc.cxx:59
XMLtoHeader.count
count
Definition: XMLtoHeader.py:84
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
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:896
lumiFormat.i
int i
Definition: lumiFormat.py:85
InDet::TRT_COND_CAUTION
@ TRT_COND_CAUTION
Definition: ITRT_ConditionsSvc.h:22
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
InDet::TRT_COND_SKIPME
@ TRT_COND_SKIPME
Definition: ITRT_ConditionsSvc.h:26
master.flag
bool flag
Definition: master.py:29
InDetHierarchy.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TRT_ConditionsSummarySvc::activeFraction
virtual double activeFraction(const IdentifierHash &elementHash, const Identifier &idStart, const Identifier &idEnd) override
Definition: TRT_ConditionsSummarySvc.cxx:119
TRT_ConditionsSummarySvc::TRT_ConditionsSummarySvc
TRT_ConditionsSummarySvc(const std::string &name, ISvcLocator *svc)
Service constructor.
Definition: TRT_ConditionsSummarySvc.cxx:21
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:65
TRT_BaseElement.h
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
InDetDD::TRT_DetectorManager::getElement
const TRT_BaseElement * getElement(Identifier id) const
Access Elements Generically---------------------------------------------—.
Definition: TRT_DetectorManager.cxx:145
TRT::Hit::ident
@ ident
Definition: HitInfo.h:77
TRT_ConditionsSummarySvc::m_trtid
const TRT_ID * m_trtid
Definition: TRT_ConditionsSummarySvc.h:66
InDet::TRT_COND_BAD
@ TRT_COND_BAD
Definition: ITRT_ConditionsSvc.h:25
h
TRT_ConditionsSummarySvc::goodFraction
virtual double goodFraction(const IdentifierHash &elementHash, const Identifier &idStart, const Identifier &idEnd) override
Definition: TRT_ConditionsSummarySvc.cxx:201
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
InDetConditions::TRT_STRAW
@ TRT_STRAW
Definition: InDetHierarchy.h:16
TRT_ConditionsSummarySvc::initialize
virtual StatusCode initialize() override
Service init.
Definition: TRT_ConditionsSummarySvc.cxx:34
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:16
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
TRT_ConditionsSummarySvc::isGood
virtual bool isGood(const Identifier &elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) override
Definition: TRT_ConditionsSummarySvc.cxx:141
InDetConditions::DEFAULT
@ DEFAULT
Definition: InDetHierarchy.h:14
StoreGateSvc.h
InDetDD::TRT_BaseElement
Definition: TRT_BaseElement.h:52
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:575
Identifier
Definition: IdentifierFieldParser.cxx:14