ATLAS Offline Software
MMDetectorHelper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include <vector>
12 #include <charconv>
13 
14 
16 {
17  if (m_svc.retrieve().isFailure()) {
18  std::abort();
19  }
20  IAGDDtoGeoSvc::LockedController c = m_svc->getController();
21  detectorList vl= c->GetDetectorStore().GetDetectorList();
22 
23  for ( const auto& vl_iter: vl)
24  {
25  MMDetectorDescription* st=dynamic_cast<MMDetectorDescription*>(vl_iter.second);
26  if (st) {
27  m_MicromegasList[vl_iter.first]=st;
28  m_MicromegasListSubType[vl_iter.second->subType()]=st;
29  }
30  }
31 
32 }
33 
34 int myatoi(std::string_view str){
35  int result=-9999;
36  std::from_chars(str.data(), str.data() + str.size(), result);
37  return result;
38 }
39 
40 
42 {
43  MMDetectorDescription* mm=nullptr;
44 
45  IAGDDtoGeoSvc::LockedController c = m_svc->getController();
46  AGDDPositionerStore& ps = c->GetPositionerStore();
47  for (unsigned int i=0;i<ps.size();i++)
48  {
50  if (dp)
51  {
52  if (dp->ID.detectorType != "Micromegas") continue;
53  std::string_view dad=dp->ID.detectorAddress;
54 
55  char dtype=dad[3];
56  char dctype='L';
57  if (dtype=='3') dctype='S';
58  if (dctype!=type) continue;
59  int deta=myatoi(dad.substr(5,1));
60  if (deta!=ieta) continue;
61  int dphi=myatoi(dad.substr(12,1));
62  if (dphi!=iphi) continue;
63  int dlayer=myatoi(dad.substr(7,1));
64  if (dlayer!=layer) continue;
65  char dside=dad[13];
66  if (dside!=side) continue;
67 
68  mm=dynamic_cast<MMDetectorDescription*>(dp->theDetector);
69  }
70  if(mm) break;
71  }
72  if (!mm) std::cout<<" could not find a positioned Micromegas!!!! "<<std::endl;
73  return mm;
74 }
75 
77 {
78  MMDetectorDescription* mm=nullptr;
79  AGDDDetectorPositioner* dp=nullptr;
80 
81  IAGDDtoGeoSvc::LockedController c = m_svc->getController();
82  AGDDPositionerStore& ps = c->GetPositionerStore();
83  for (unsigned int i=0;i<ps.size();i++)
84  {
85  dp=dynamic_cast<AGDDDetectorPositioner*>(ps[i]);
86  if (dp)
87  {
88  if (dp->ID.detectorType != "Micromegas") continue;
89  std::string_view dad=dp->ID.detectorAddress;
90 
91  char dtype=dad[3];
92  char dctype='L';
93  if (dtype=='3') dctype='S';
94  if (dctype!=type) continue;
95  int deta=myatoi(dad.substr(5,1));
96  if (deta!=ieta) continue;
97  int dphi=myatoi(dad.substr(12,1));
98  if (dphi!=iphi) continue;
99  int dlayer=myatoi(dad.substr(7,1));
100  if (dlayer!=layer) continue;
101  char dside=dad[13];
102  if (dside!=side) continue;
103 
104  mm=dynamic_cast<MMDetectorDescription*>(dp->theDetector);
105  }
106  if(mm) break;
107  }
108  if (!mm) std::cout<<" could not find a positioned Micromegas!!!! "<<std::endl;
110  return p_mm;
111 }
112 
114 {
115  if (auto itr = m_MicromegasList.find(type); itr != m_MicromegasList.end()) return itr->second;
116  return nullptr;
117 }
118 
120 {
121  if (auto itr = m_MicromegasListSubType.find(type); itr != m_MicromegasListSubType.end()) return itr->second;
122  return nullptr;
123 }
124 
125 
127 {
128  return m_svc->getController();
129 }
AGDDController.h
AGDDDetectorStore.h
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
get_generator_info.result
result
Definition: get_generator_info.py:21
MMDetectorDescription.h
CxxUtils::LockedPointer
A pointer together with a movable lock.
Definition: LockedPointer.h:35
PlotCalibFromCool.dtype
dtype
Definition: PlotCalibFromCool.py:495
MMDetectorHelper::Get_MMDetectorType
MMDetectorDescription * Get_MMDetectorType(const std::string &type)
Definition: MMDetectorHelper.cxx:113
MMDetectorHelper::m_svc
ServiceHandle< IAGDDtoGeoSvc > m_svc
Definition: MMDetectorHelper.h:40
AGDDDetectorPositioner
Definition: AGDDDetectorPositioner.h:39
detectorList
std::map< std::string, AGDDDetector * > detectorList
Definition: AGDDDetectorStore.h:9
TRT::Hit::side
@ side
Definition: HitInfo.h:83
MMDetectorHelper::Get_Controller
IAGDDtoGeoSvc::LockedController Get_Controller()
Definition: MMDetectorHelper.cxx:126
MMDetectorDescription
Definition: MMDetectorDescription.h:45
lumiFormat.i
int i
Definition: lumiFormat.py:85
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
AGDDDetectorPositioner.h
MMDetectorHelper::m_MicromegasList
MicromegasMap m_MicromegasList
Definition: MMDetectorHelper.h:38
myatoi
int myatoi(std::string_view str)
Definition: MMDetectorHelper.cxx:34
MMDetectorHelper::Get_MMDetector
MMDetectorDescription * Get_MMDetector(char type, int ieta, int iphi, int layer=1, char side='A')
Definition: MMDetectorHelper.cxx:41
MMDetectorHelper::MMDetectorHelper
MMDetectorHelper()
Definition: MMDetectorHelper.cxx:15
MMDetectorHelper::Get_MMPositionedDetector
AGDDPositionedDetector Get_MMPositionedDetector(char type, int ieta, int iphi, int layer=1, char side='A')
Definition: MMDetectorHelper.cxx:76
AGDDPositionerStore
Definition: AGDDPositionerStore.h:14
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
str
Definition: BTagTrackIpAccessor.cxx:11
MMDetectorHelper::Get_MMDetectorSubType
MMDetectorDescription * Get_MMDetectorSubType(const std::string &type)
Definition: MMDetectorHelper.cxx:119
AGDDPositionerStore.h
MMDetectorHelper.h
python.compressB64.c
def c
Definition: compressB64.py:93
MMDetectorHelper::m_MicromegasListSubType
MicromegasMapSubType m_MicromegasListSubType
Definition: MMDetectorHelper.h:39
AGDDPositionedDetector
std::pair< MMDetectorDescription *, AGDDDetectorPositioner * > AGDDPositionedDetector
Definition: MMDetectorHelper.h:22