ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibUtils
src
LArCaliWaveSelector.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LArCalibUtils/LArCaliWaveSelector.h
"
6
7
#include "GaudiKernel/MsgStream.h"
8
9
#include "
AthenaKernel/errorcheck.h
"
10
11
#include "
CaloIdentifier/CaloCell_ID.h
"
12
#include "
LArIdentifier/LArOnlineID.h
"
13
#include "
CaloIdentifier/CaloGain.h
"
14
15
#include "
LArRawConditions/LArCaliWaveContainer.h
"
16
17
#include "
LArRawConditions/LArWaveHelper.h
"
18
19
20
using
CaliMapIt
=
LArCaliWaveContainer::ConstConditionsMapIterator
;
21
using
CaliWaveIt
= LArCaliWaveContainer::LArCaliWaves::const_iterator;
22
23
LArCaliWaveSelector::LArCaliWaveSelector
(
const
std::string& name, ISvcLocator* pSvcLocator)
24
:
AthAlgorithm
(name, pSvcLocator),
25
m_cellID
(nullptr),
26
m_gmask
(0),
27
m_groupingType
(
"ExtendedFeedThrough"
)
28
{
29
declareProperty
(
"SelectionList"
,
m_selectionList
);
// Vector of strings of det/lay/gain/DAC -> "EMB/0/0/200"
30
// Known detectors EMB, EMEC, HEC, FCAL
31
// Available layers 0-3, gains 0-2, DAC 0-65000
32
declareProperty
(
"KeyList"
,
m_keyList
);
33
declareProperty
(
"KeyOutput"
,
m_outputKey
);
34
declareProperty
(
"GroupingType"
,
m_groupingType
);
35
}
36
37
LArCaliWaveSelector::~LArCaliWaveSelector
()
38
=
default
;
39
40
StatusCode
LArCaliWaveSelector::initialize
()
41
{
42
ATH_MSG_INFO
(
" in initialize.."
);
43
44
// Default list
45
if
(
m_keyList
.empty()) {
m_keyList
.emplace_back(
"LArCaliWave"
); }
46
parseSelection
();
47
48
ATH_CHECK
(
detStore
()->retrieve (
m_cellID
,
"CaloCell_ID"
) );
49
if
(!
m_cellID
) {
50
ATH_MSG_ERROR
(
"Could not access CaloCell_ID helper"
);
51
return
StatusCode::FAILURE;
52
}
53
54
ATH_CHECK
(
m_cablingKey
.initialize() );
55
56
return
StatusCode::SUCCESS;
57
}
58
59
60
StatusCode
LArCaliWaveSelector::stop
()
61
{
62
ATH_MSG_INFO
(
" in stop.."
);
63
64
SG::ReadCondHandle<LArOnOffIdMapping>
cablingHdl{
m_cablingKey
};
65
const
LArOnOffIdMapping
* cabling{*cablingHdl};
66
if
(!cabling){
67
ATH_MSG_ERROR
(
"Do not have mapping object "
<<
m_cablingKey
.key() );
68
return
StatusCode::FAILURE;
69
}
70
71
// create empty LArCaliWaveContainer to store DAC selected LArCaliWave
72
// make it view container
73
// LArCaliWaveContainer* selectedCaliWaveContainer = new LArCaliWaveContainer(SG::VIEW_ELEMENTS);
74
auto
selectedCaliWaveContainer = std::make_unique<LArCaliWaveContainer>();
75
CHECK
( selectedCaliWaveContainer->setGroupingType(
m_groupingType
,
msg
()));
76
CHECK
( selectedCaliWaveContainer->initialize());
77
78
std::vector<std::string>::const_iterator key_it =
m_keyList
.begin();
79
std::vector<std::string>::const_iterator key_it_e =
m_keyList
.end();
80
81
for
(;key_it!=key_it_e; ++key_it) {
82
const
LArCaliWaveContainer
* larCaliWaveContainer;
83
StatusCode
sc
=
detStore
()->retrieve(larCaliWaveContainer,*key_it);
84
if
(
sc
.isFailure()) {
85
ATH_MSG_WARNING
(
"No LArCaliWaveContainer in StoreGate with key = "
<< *key_it );
86
continue
;
87
}
else
{
88
ATH_MSG_INFO
(
"Reading LArCaliWaveContainer with key = "
<< *key_it );
89
}
90
91
int
det, lay;
92
for
(
unsigned
gain =
CaloGain::LARHIGHGAIN
; gain <
CaloGain::LARNGAIN
; ++gain ) {
93
if
(!( (0x1<<gain) &
m_gmask
) )
continue
;
94
95
CaliMapIt
cali_it = larCaliWaveContainer->
begin
(gain) ;
96
CaliMapIt
cali_it_e = larCaliWaveContainer->
end
(gain) ;
97
98
if
( cali_it == cali_it_e ) {
99
ATH_MSG_DEBUG
(
"No wave with gain = "
<< gain <<
" in container with key = "
<< *key_it );
100
continue
;
101
}
else
{
102
ATH_MSG_DEBUG
(
"processing gain = "
<< gain );
103
}
104
for
( ; cali_it != cali_it_e; ++cali_it) {
105
106
CaliWaveIt
wave_it = cali_it->begin();
107
CaliWaveIt
wave_it_e = cali_it->end();
108
if
( wave_it == wave_it_e ) {
109
ATH_MSG_DEBUG
(
"Empty channel found..."
);
110
continue
;
111
}
112
113
HWIdentifier
chid = cali_it.
channelId
();
114
Identifier
cell_id = cabling->cnvToIdentifier(chid);
115
if
(
m_cellID
->is_em_barrel(cell_id)){ det = 0;
116
}
else
if
(
m_cellID
->is_em_endcap(cell_id)) { det = 1;
117
}
else
if
(
m_cellID
->is_hec(cell_id)) { det = 2;
118
}
else
if
(
m_cellID
->is_fcal(cell_id)) { det = 3;
119
}
else
{
120
ATH_MSG_ERROR
(
"Wrong ID in LArCaliWaveContainer: "
<<
m_cellID
->print_to_string(cell_id));
121
continue
;
122
}
123
lay =
m_cellID
->sampling(cell_id);
124
DetGain
dg = std::make_pair( std::make_pair(det,lay), gain);
125
if
(
m_mapDAC
.find(dg) ==
m_mapDAC
.end() )
continue
;
126
127
for
( ; wave_it != wave_it_e; ++wave_it) {
128
if
(wave_it->getDAC() ==
m_mapDAC
[dg]) {
129
(selectedCaliWaveContainer->get(chid,gain)).push_back(*wave_it);
130
break
;
131
}
132
}
133
}
134
}
135
}
136
137
ATH_CHECK
(
detStore
()->record(std::move(selectedCaliWaveContainer),
m_outputKey
) );
138
return
StatusCode::SUCCESS;
139
}
140
141
void
LArCaliWaveSelector::parseSelection
()
142
{
143
int
det,lay,gain,DAC;
144
std::string selstr;
145
for
(
unsigned
i=0; i<
m_selectionList
.size(); ++i) {
146
std::string::size_type det_delimiter(
m_selectionList
[i].
find
(
'/'
) );
147
if
( std::string::npos == det_delimiter ){
148
ATH_MSG_WARNING
(
"Bad selection string: "
<<
m_selectionList
[i] <<
" skipped...."
);
149
continue
;
150
}
151
std::string det_string =
m_selectionList
[i].substr(0, det_delimiter);
152
if
(det_string==
"EMB"
) {
153
det = 0;
154
}
else
if
(det_string ==
"EMEC"
) {
155
det = 1;
156
}
else
if
(det_string ==
"HEC"
) {
157
det = 2;
158
}
else
if
(det_string ==
"FCAL"
) {
159
det = 3;
160
}
else
{
161
ATH_MSG_WARNING
(
"Bad detector substring: "
<< det_string <<
" skipped ... "
);
162
continue
;
163
}
164
std::string::size_type lay_delimiter(
m_selectionList
[i].
find
(
'/'
,det_delimiter+1) );
165
lay = atoi(
m_selectionList
[i].substr(det_delimiter+1, lay_delimiter).c_str());
166
if
(lay < 0 || lay > 3) {
167
ATH_MSG_WARNING
(
"Bad layer: "
<< lay <<
" skipped..."
);
168
continue
;
169
}
170
std::string::size_type gain_delimiter(
m_selectionList
[i].
find
(
'/'
,lay_delimiter+1) );
171
gain = atoi(
m_selectionList
[i].substr(lay_delimiter+1, gain_delimiter).c_str());
172
if
(gain < 0 || gain > 2) {
173
ATH_MSG_WARNING
(
"Bad gain: "
<< gain <<
" skipped..."
);
174
continue
;
175
}
176
DAC = atoi(
m_selectionList
[i].substr(gain_delimiter+1).c_str());
177
if
(DAC < 0 || DAC > 65000) {
178
ATH_MSG_WARNING
(
"Bad DAC: "
<< DAC <<
" skipped..."
);
179
continue
;
180
}
181
182
// Now we have all numbers
183
m_mapDAC
[std::make_pair( std::make_pair(det,lay), gain)] = DAC;
184
m_gmask
|= (0x1<<gain);
185
}
186
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloCell_ID.h
CaloGain.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
LArCaliWaveContainer.h
CaliWaveIt
LArCaliWaveContainer::LArCaliWaves::const_iterator CaliWaveIt
Definition
LArCaliWaveSelector.cxx:21
CaliMapIt
LArCaliWaveContainer::ConstConditionsMapIterator CaliMapIt
Definition
LArCaliWaveSelector.cxx:20
LArCaliWaveSelector.h
DetGain
std::pair< std::pair< int, int >, int > DetGain
Definition
LArCaliWaveSelector.h:23
LArOnlineID.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
LArWaveHelper.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
HWIdentifier
Definition
HWIdentifier.h:13
LArCaliWaveContainer
Liquid Argon Cumulative Wave Container.
Definition
LArCaliWaveContainer.h:33
LArCaliWaveSelector::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition
LArCaliWaveSelector.h:41
LArCaliWaveSelector::stop
StatusCode stop()
Definition
LArCaliWaveSelector.cxx:60
LArCaliWaveSelector::m_groupingType
std::string m_groupingType
Definition
LArCaliWaveSelector.h:53
LArCaliWaveSelector::~LArCaliWaveSelector
~LArCaliWaveSelector()
LArCaliWaveSelector::m_mapDAC
std::map< DetGain, int > m_mapDAC
Definition
LArCaliWaveSelector.h:47
LArCaliWaveSelector::m_keyList
std::vector< std::string > m_keyList
Definition
LArCaliWaveSelector.h:50
LArCaliWaveSelector::m_selectionList
std::vector< std::string > m_selectionList
Definition
LArCaliWaveSelector.h:51
LArCaliWaveSelector::m_cellID
const CaloCell_ID * m_cellID
Definition
LArCaliWaveSelector.h:45
LArCaliWaveSelector::LArCaliWaveSelector
LArCaliWaveSelector(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArCaliWaveSelector.cxx:23
LArCaliWaveSelector::parseSelection
void parseSelection()
Definition
LArCaliWaveSelector.cxx:141
LArCaliWaveSelector::m_gmask
unsigned short m_gmask
Definition
LArCaliWaveSelector.h:48
LArCaliWaveSelector::m_outputKey
std::string m_outputKey
Definition
LArCaliWaveSelector.h:52
LArCaliWaveSelector::initialize
StatusCode initialize()
Definition
LArCaliWaveSelector.cxx:40
LArConditionsContainerDB::iteratorT::channelId
HWIdentifier channelId() const
LArConditionsContainer< LArCaliWaveVec >::ConstConditionsMapIterator
ConditionsMap::const_iterator ConstConditionsMapIterator
Definition
LArConditionsContainer.h:86
LArConditionsContainer::begin
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
LArConditionsContainer::end
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
LArOnOffIdMapping
Definition
LArOnOffIdMapping.h:20
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
CaloGain::LARNGAIN
@ LARNGAIN
Definition
CaloGain.h:19
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition
CaloGain.h:18
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0