ATLAS Offline Software
TRT_ConditionsSummarySvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 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  AthService(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
57  sc = service("DetectorStore", detStore);
58  if (sc.isFailure()){
59  msg(MSG::FATAL) << "DetectorStore service not found!" << endmsg;
60  return sc;
61  }
62 
63  // Retrieve TRT_DetectorManager
64  std::string managerName;
65  sc=detStore->retrieve(m_manager, managerName);
66  if (sc.isFailure() || !m_manager)
67  {
68  msg(MSG::FATAL) << "Could not find the Manager: "
69  << managerName << " !" << endmsg;
70  return sc;
71  }
72 
73  // Retrieve TRT ID Helper
74  sc = detStore->retrieve(m_trtid,"TRT_ID");
75  if ( sc.isFailure() ) {
76  ATH_MSG_FATAL("Could not retrieve TRT ID Helper.");
77  return sc;
78  }
79 
80  return sc;
81 }
82 
83 //Finalize
86  return StatusCode::SUCCESS;
87 }
88 
89 bool
91  bool result(false);
92 
95 
98  //need to loop over all straws at this hierarchy level
99  result=true;
100  const InDetDD::TRT_BaseElement *element=m_manager->getElement(elementId);
101 
102  //loop over all straws
103  int nelements=element->nStraws();
104  for(int i=0;i<nelements;i++){
107  result=false;
108  break;
109  }
110  }
111  }else{
112  msg(MSG::FATAL)<<"Hierarchy Level "<<h<<" not yet implemented!!!"<<endmsg;
113  result=false;
114  }
115 
116  return result;
117 }
118 
119 bool
121  bool result(true);
122 
123  const InDetDD::TRT_BaseElement *element=m_manager->getElement(elementHash);
124 
125  Identifier elementId=m_trtid->layer_id(elementHash);
126 
127  //loop over all straws
128  int nelements=element->nStraws();
129  for(int i=0;i<nelements;i++){
132  result=false;
133  break;
134  }
135  }
136 
137  return result;
138 }
139 
140 bool
142  bool result(false);
143 
145 
146  return result;
147 }
148 
149 double
150 TRT_ConditionsSummarySvc::activeFraction(const IdentifierHash & elementHash, const Identifier & idStart, const Identifier & idEnd){
151  double result(0.0);
152 
153  Identifier layerId=m_trtid->layer_id(elementHash);
154 
155  int start=m_trtid->straw(idStart);
156  int end=m_trtid->straw(idEnd);
157 
158  double count=1.0;
159  for(int i=start;i<=end;i++){
160  Identifier elementId=m_trtid->straw_id(layerId,i);
161  if(isActive(elementId,InDetConditions::TRT_STRAW))
162  result+=1.0;
163  }
164  if(count>0){
165  result/=count;
166  }
167 
168  return result;
169 }
170 
171 bool
173  bool result(false);
174 
177 
180  //need to loop over all straws at this hierarchy level
181  result=true;
182  const InDetDD::TRT_BaseElement *element=m_manager->getElement(elementId);
183 
184  //loop over all straws
185  int nelements=element->nStraws();
186  for(int i=0;i<nelements;i++){
188  if(!(flag==InDet::TRT_COND_GOOD)){
189  result=false;
190  break;
191  }
192  }
193  }else{
194  msg(MSG::FATAL)<<"Hierarchy Level "<<h<<" not yet implemented!!!"<<endmsg;
195  result=false;
196  }
197 
198  return result;
199 }
200 
201 bool
203  bool result(false);
204 
205  const InDetDD::TRT_BaseElement *element=m_manager->getElement(elementHash);
206 
207  Identifier elementId=m_trtid->layer_id(elementHash);
208 
209  //loop over all straws
210  int nelements=element->nStraws();
211  for(int i=0;i<nelements;i++){
213  if(!(flag==InDet::TRT_COND_GOOD)){
214  result=false;
215  break;
216  }
217  }
218 
219  return result;
220 }
221 
222 bool
224  bool result(false);
225 
227 
228  return result;
229 }
230 
231 double
232 TRT_ConditionsSummarySvc::goodFraction(const IdentifierHash & elementHash, const Identifier & idStart, const Identifier & idEnd){
233  double result(0.0);
234 
235  Identifier layerId=m_trtid->layer_id(elementHash);
236 
237  int start=m_trtid->straw(idStart);
238  int end=m_trtid->straw(idEnd);
239 
240  double count=1.0;
241  for(int i=start;i<=end;i++){
242  Identifier elementId=m_trtid->straw_id(layerId,i);
243  if(isGood(elementId,InDetConditions::TRT_STRAW))
244  result+=1.0;
245  }
246  if(count>0){
247  result/=count;
248  }
249 
250  return result;
251 }
252 
254  const Identifier &ident ) {
255 
256  // Identifier id=ident;
258 
259  // Call condSummaryStatus for each service in m_svcCollection.
260  ServiceHandleArray<ITRT_ConditionsSvc>::const_iterator svcItr;
261  for ( svcItr = m_svcCollection.begin();
262  svcItr != m_svcCollection.end(); ++svcItr ) {
263  InDet::TRT_CondFlag thisSvcFlag;
264  thisSvcFlag = (*svcItr)->condSummaryStatus( ident );
265  if ( thisSvcFlag == InDet::TRT_COND_SKIPME ) continue;
266  if ( thisSvcFlag == InDet::TRT_COND_NOINFO ) continue;
267  // If any tool reports CAUTION, return CAUTION.
268  // If any tool reports BAD, return BAD.
269  if ( thisSvcFlag != InDet::TRT_COND_GOOD ) {
271  if ( thisSvcFlag == InDet::TRT_COND_BAD ) status = InDet::TRT_COND_BAD;
272  }
273  }
274 
275  return status;
276 }
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:253
TRT_ConditionsSummarySvc::m_svcCollection
ServiceHandleArray< ITRT_ConditionsSvc > m_svcCollection
Definition: TRT_ConditionsSummarySvc.h:66
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...
AthCommonMsg< Service >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
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)
goodFraction method gives the fraction of good elements in the range of identifiers
Definition: TRT_ConditionsSummarySvc.cxx:232
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
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
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)
activeFraction method gives the fraction of active elements in the range of identifiers
Definition: TRT_ConditionsSummarySvc.cxx:150
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
AthService
Definition: AthService.h:32
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:172
InDetHierarchy.h
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:85
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:69
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:195
InDetDD::TRT_DetectorManager::getElement
const TRT_BaseElement * getElement(Identifier id) const
Access Elements Generically---------------------------------------------—.
Definition: TRT_DetectorManager.cxx:158
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:90
TRT_ConditionsSummarySvc::m_trtid
const TRT_ID * m_trtid
Definition: TRT_ConditionsSummarySvc.h:70
InDet::TRT_COND_BAD
@ TRT_COND_BAD
Definition: ITRT_ConditionsSvc.h:25
h
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Service >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
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
Definition: IdentifierHash.h:38
InDetConditions::DEFAULT
@ DEFAULT
Definition: InDetHierarchy.h:14
StoreGateSvc.h
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