ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
16
17//Gaudi includes
19
20// Constructor
21TRT_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
33StatusCode
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
58bool
60 bool result(false);
61
63 InDet::TRT_CondFlag flag=condSummaryStatus(elementId);
64
65 result = flag==InDet::TRT_COND_GOOD || flag==InDet::TRT_COND_CAUTION || flag==InDet::TRT_COND_NOINFO;
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++){
74 InDet::TRT_CondFlag flag=condSummaryStatus(m_trtid->straw_id(elementId,i));
75 if(!(flag==InDet::TRT_COND_GOOD || flag==InDet::TRT_COND_CAUTION || flag==InDet::TRT_COND_NOINFO)){
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
88bool
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++){
99 InDet::TRT_CondFlag flag=condSummaryStatus(m_trtid->straw_id(elementId,i));
100 if(!(flag==InDet::TRT_COND_GOOD || flag==InDet::TRT_COND_CAUTION || flag==InDet::TRT_COND_NOINFO)){
101 result=false;
102 break;
103 }
104 }
105
106 return result;
107}
108
109bool
111 bool result(false);
112
114
115 return result;
116}
117
118double
119TRT_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);
131 result+=1.0;
132 }
133 if(count>0){
134 result/=count;
135 }
136
137 return result;
138}
139
140bool
142 bool result(false);
143
145 InDet::TRT_CondFlag flag=condSummaryStatus(elementId);
146
147 result = flag==InDet::TRT_COND_GOOD;
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++){
156 InDet::TRT_CondFlag flag=condSummaryStatus(m_trtid->straw_id(elementId,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
170bool
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++){
181 InDet::TRT_CondFlag flag=condSummaryStatus(m_trtid->straw_id(elementId,i));
182 if(!(flag==InDet::TRT_COND_GOOD)){
183 result=false;
184 break;
185 }
186 }
187
188 return result;
189}
190
191bool
193 bool result(false);
194
196
197 return result;
198}
199
200double
201TRT_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);
213 result+=1.0;
214 }
215 if(count>0){
216 result/=count;
217 }
218
219 return result;
220}
221
222InDet::TRT_CondFlag
224
225 // Identifier id=ident;
226 InDet::TRT_CondFlag status = InDet::TRT_COND_GOOD;
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 ) {
239 if ( status != InDet::TRT_COND_BAD ) status = InDet::TRT_COND_CAUTION;
240 if ( thisSvcFlag == InDet::TRT_COND_BAD ) status = InDet::TRT_COND_BAD;
241 }
242 }
243
244 return status;
245}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Header containing the InDetHierarchy enum, to avoid pulling in a class every time it is needed and na...
This is an Identifier helper class for the TRT subdetector.
Header file for AthHistogramAlgorithm.
This is a "hash" representation of an Identifier.
Virtual base class of TRT readout elements.
unsigned int nStraws() const
Number of straws in the element.
InDet::TRT_CondFlag condSummaryStatus(const Identifier &ident)
const InDetDD::TRT_DetectorManager * m_manager
virtual StatusCode initialize() override
Service init.
virtual double goodFraction(const IdentifierHash &elementHash, const Identifier &idStart, const Identifier &idEnd) override
TRT_ConditionsSummarySvc(const std::string &name, ISvcLocator *svc)
Service constructor.
virtual bool isActive(const Identifier &elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) override
virtual ~TRT_ConditionsSummarySvc()
virtual bool isGood(const Identifier &elementId, const InDetConditions::Hierarchy h=InDetConditions::DEFAULT) override
ServiceHandleArray< ITRT_ConditionsSvc > m_svcCollection
virtual double activeFraction(const IdentifierHash &elementHash, const Identifier &idStart, const Identifier &idEnd) override
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146