ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonRDO
src
MdtCsmIdHash.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
MuonRDO/MdtCsmIdHash.h
"
7
8
#include "
MuonIdHelpers/MdtIdHelper.h
"
9
10
#include "GaudiKernel/Bootstrap.h"
11
#include "GaudiKernel/GaudiException.h"
12
#include "GaudiKernel/StatusCode.h"
13
#include "
AthenaKernel/errorcheck.h
"
14
#include "
StoreGate/StoreGateSvc.h
"
15
16
#include "
Identifier/IdentifierHash.h
"
17
18
#include <cassert>
19
#include <iostream>
20
21
// This class converts a Mdt Identifier into a integer, according to its
22
// fields
23
24
25
// default contructor
26
MdtCsmIdHash::MdtCsmIdHash
( )
27
{
28
const
MdtIdHelper
* mdtHelper=
nullptr
;
29
SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore"
)};
30
31
StatusCode
sc
= detStore->retrieve( mdtHelper,
"MDTIDHELPER"
);
32
if
(
sc
.isFailure()) {
33
throw
GaudiException(
"can not get MdtIdHelper"
,
34
"MdtCsmIdHash::MdtCsmIdHash()"
,
sc
);
35
}
36
37
unsigned
int
used
= mdtHelper->
module_hash_max
();
38
IdContext
context = mdtHelper->
module_context
();
39
40
if
( mdtHelper->
stationNameIndex
(
"BME"
) != -1 ) {
41
used
= mdtHelper->
detectorElement_hash_max
();
42
context = mdtHelper->
detectorElement_context
();
43
}
44
45
for
(
unsigned
int
hash=0; hash <
used
; ++hash){
46
Identifier
id;
47
if
(!mdtHelper->
get_id
(hash,
id
,&context)) {
48
m_lookup
[id]=(int) hash;
49
m_int2id
.push_back(
id
);
50
}
else
{
51
REPORT_MESSAGE_WITH_CONTEXT
(MSG::ERROR,
"MdtCscIdHash"
) <<
52
"MDT hash constructor failed!"
<<
endmsg
;
53
}
54
}
55
56
m_size
= (int)
used
;
57
}
58
59
MdtCsmIdHash::ID
MdtCsmIdHash::identifier
(
int
index
)
const
{
60
61
if
(
index
>=0 &&
index
<
m_size
) {
62
return
m_int2id
[
index
] ;
63
}
64
// return blank id for invalid index
65
std::cout <<
" MdtCsmIdHash::ERROR : identifier invalid ID "
<<std::endl;
66
Identifier
id;
67
return
id;
68
69
}
70
71
int
MdtCsmIdHash::operator()
(
const
ID
&
id
)
const
{
72
73
std::map<ID,int>::const_iterator it =
m_lookup
.find(
id
);
74
if
(it!=
m_lookup
.end()){
75
return
(*it).second;
76
}
77
78
// FIXME -1 for invalid ID?
79
return
-1;
80
81
}
82
83
int
MdtCsmIdHash::max
()
const
{
84
85
return
m_size
;
86
87
}
88
89
int
MdtCsmIdHash::offset
() {
90
91
return
0;
92
93
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:61
errorcheck.h
Helpers for checking error return status codes and reporting errors.
REPORT_MESSAGE_WITH_CONTEXT
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:345
IdentifierHash.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
MdtCsmIdHash.h
MdtIdHelper.h
StoreGateSvc.h
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition
IdContext.h:26
MdtCsmIdHash::ID
Identifier ID
Definition
MdtCsmIdHash.h:22
MdtCsmIdHash::m_lookup
std::map< Identifier, int > m_lookup
lookup table
Definition
MdtCsmIdHash.h:46
MdtCsmIdHash::MdtCsmIdHash
MdtCsmIdHash()
Definition
MdtCsmIdHash.cxx:26
MdtCsmIdHash::m_size
int m_size
total number of IDs
Definition
MdtCsmIdHash.h:42
MdtCsmIdHash::offset
static int offset()
return offset
Definition
MdtCsmIdHash.cxx:89
MdtCsmIdHash::m_int2id
std::vector< ID > m_int2id
reverse lookup
Definition
MdtCsmIdHash.h:50
MdtCsmIdHash::operator()
int operator()(const ID &id) const
Convert ID to int.
Definition
MdtCsmIdHash.cxx:71
MdtCsmIdHash::max
int max() const
return maximum number of IDs
Definition
MdtCsmIdHash.cxx:83
MdtCsmIdHash::identifier
ID identifier(int i) const
reverse conversion
Definition
MdtCsmIdHash.cxx:59
MdtIdHelper
Definition
MdtIdHelper.h:61
MuonIdHelper::stationNameIndex
int stationNameIndex(const std::string &name) const
Definition
MuonIdHelper.cxx:827
MuonIdHelper::get_id
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const override
Create compact id from hash id (return == 0 for OK).
Definition
MuonIdHelper.cxx:74
MuonIdHelper::module_hash_max
size_type module_hash_max() const
the maximum hash value
Definition
MuonIdHelper.cxx:755
MuonIdHelper::module_context
IdContext module_context() const
id for module
Definition
MuonIdHelper.cxx:738
MuonIdHelper::detectorElement_context
IdContext detectorElement_context() const
id for detector element
Definition
MuonIdHelper.cxx:743
MuonIdHelper::detectorElement_hash_max
size_type detectorElement_hash_max() const
Definition
MuonIdHelper.h:173
used
holding In fact this class is here in order to allow STL container for all features This class is sho...
Identifier
Definition
IdentifierFieldParser.cxx:14
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0