ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonDetDescr
MuonAGDDDescription
src
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
5
#include "
MuonAGDDDescription/MMDetectorHelper.h
"
6
#include "
MuonAGDDDescription/MMDetectorDescription.h
"
7
#include "
AGDDKernel/AGDDDetectorStore.h
"
8
#include "
AGDDKernel/AGDDPositionerStore.h
"
9
#include "
AGDDKernel/AGDDDetectorPositioner.h
"
10
#include "
AGDDControl/AGDDController.h
"
11
#include <vector>
12
#include <charconv>
13
14
15
MMDetectorHelper::MMDetectorHelper
()
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
41
MMDetectorDescription
*
MMDetectorHelper::Get_MMDetector
(
char
type
,
int
ieta,
int
iphi,
int
layer,
char
side)
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
{
49
AGDDDetectorPositioner
* dp=
dynamic_cast<
AGDDDetectorPositioner
*
>
(ps[i]);
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
76
AGDDPositionedDetector
MMDetectorHelper::Get_MMPositionedDetector
(
char
type
,
int
ieta,
int
iphi,
int
layer,
char
side)
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;
109
AGDDPositionedDetector
p_mm(mm,dp);
110
return
p_mm;
111
}
112
113
MMDetectorDescription
*
MMDetectorHelper::Get_MMDetectorType
(
const
std::string&
type
)
114
{
115
if
(
auto
itr =
m_MicromegasList
.find(
type
); itr !=
m_MicromegasList
.end())
return
itr->second;
116
return
nullptr
;
117
}
118
119
MMDetectorDescription
*
MMDetectorHelper::Get_MMDetectorSubType
(
const
std::string&
type
)
120
{
121
if
(
auto
itr =
m_MicromegasListSubType
.find(
type
); itr !=
m_MicromegasListSubType
.end())
return
itr->second;
122
return
nullptr
;
123
}
124
125
126
IAGDDtoGeoSvc::LockedController
MMDetectorHelper::Get_Controller
()
127
{
128
return
m_svc
->getController();
129
}
AGDDController.h
AGDDDetectorPositioner.h
AGDDDetectorStore.h
detectorList
std::map< std::string, AGDDDetector * > detectorList
Definition
AGDDDetectorStore.h:15
AGDDPositionerStore.h
myatoi
int myatoi(std::string_view str)
Definition
MMDetectorHelper.cxx:34
MMDetectorDescription.h
myatoi
int myatoi(std::string_view str)
Definition
MMDetectorHelper.cxx:34
MMDetectorHelper.h
AGDDPositionedDetector
std::pair< MMDetectorDescription *, AGDDDetectorPositioner * > AGDDPositionedDetector
Definition
MMDetectorHelper.h:22
AGDDDetectorPositioner
Definition
AGDDDetectorPositioner.h:39
AGDDPositionerStore
Definition
AGDDPositionerStore.h:14
IAGDDtoGeoSvc::LockedController
CxxUtils::LockedPointer< AGDDController > LockedController
Definition
IAGDD2GeoSvc.h:26
MMDetectorDescription
Definition
MMDetectorDescription.h:45
MMDetectorHelper::Get_MMDetectorType
MMDetectorDescription * Get_MMDetectorType(const std::string &type)
Definition
MMDetectorHelper.cxx:113
MMDetectorHelper::Get_MMPositionedDetector
AGDDPositionedDetector Get_MMPositionedDetector(char type, int ieta, int iphi, int layer=1, char side='A')
Definition
MMDetectorHelper.cxx:76
MMDetectorHelper::m_svc
ServiceHandle< IAGDDtoGeoSvc > m_svc
Definition
MMDetectorHelper.h:40
MMDetectorHelper::Get_MMDetectorSubType
MMDetectorDescription * Get_MMDetectorSubType(const std::string &type)
Definition
MMDetectorHelper.cxx:119
MMDetectorHelper::Get_Controller
IAGDDtoGeoSvc::LockedController Get_Controller()
Definition
MMDetectorHelper.cxx:126
MMDetectorHelper::m_MicromegasList
MicromegasMap m_MicromegasList
Definition
MMDetectorHelper.h:38
MMDetectorHelper::Get_MMDetector
MMDetectorDescription * Get_MMDetector(char type, int ieta, int iphi, int layer=1, char side='A')
Definition
MMDetectorHelper.cxx:41
MMDetectorHelper::m_MicromegasListSubType
MicromegasMapSubType m_MicromegasListSubType
Definition
MMDetectorHelper.h:39
MMDetectorHelper::MMDetectorHelper
MMDetectorHelper()
Definition
MMDetectorHelper.cxx:15
str
Definition
BTagTrackIpAccessor.cxx:11
type
Generated on
for ATLAS Offline Software by
1.17.0