ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibUtils
src
LArOFPhaseFill.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LArCalibUtils/LArOFPhaseFill.h
"
6
#include "
CaloIdentifier/CaloGain.h
"
7
#include "
LArIdentifier/LArOnline_SuperCellID.h
"
8
#include "
LArIdentifier/LArOnlineID.h
"
9
#include "
LArIdentifier/LArOnlineID_Base.h
"
10
#include "
LArRawConditions/LArOFCBinComplete.h
"
11
12
#include "GaudiKernel/ISvcLocator.h"
13
#include "GaudiKernel/IToolSvc.h"
14
15
#include <fstream>
16
#include <map>
17
#include <sstream>
18
19
using
uint
=
unsigned
int;
20
21
LArOFPhaseFill::LArOFPhaseFill
(
const
std::string& name, ISvcLocator* pSvcLocator) :
22
AthAlgorithm
(name, pSvcLocator),
23
m_lar_on_id
(nullptr),
24
m_groupingType
(0)
25
{ }
26
27
StatusCode
LArOFPhaseFill::initialize
()
28
{
29
if
(
m_isSC
) {
30
ATH_MSG_INFO
(
"Processing LAr SuperCells"
);
31
const
LArOnline_SuperCellID
* onlID;
32
ATH_CHECK
(
detStore
()->retrieve(onlID,
"LArOnline_SuperCellID"
));
33
m_lar_on_id
=onlID;
// cast to base-class
34
}
else
{
35
ATH_MSG_INFO
(
"Processing regular LArCells"
);
36
const
LArOnlineID
* onlID;
37
ATH_CHECK
(
detStore
()->retrieve(onlID,
"LArOnlineID"
));
38
m_lar_on_id
=onlID;
// cast to base-class
39
}
40
41
if
(
m_groupingName
==
"Unknown"
) {
42
m_groupingType
=
LArConditionsContainerBase::Unknown
;
43
}
else
if
(
m_groupingName
==
"SingleGroup"
) {
44
m_groupingType
=
LArConditionsContainerBase::SingleGroup
;
45
}
else
if
(
m_groupingName
==
"SubDetector"
) {
46
m_groupingType
=
LArConditionsContainerBase::SubDetectorGrouping
;
47
}
else
if
(
m_groupingName
==
"FeedThrough"
) {
48
m_groupingType
=
LArConditionsContainerBase::FeedThroughGrouping
;
49
}
else
if
(
m_groupingName
==
"ExtendedFeedThrough"
) {
50
m_groupingType
=
LArConditionsContainerBase::ExtendedFTGrouping
;
51
}
else
if
(
m_groupingName
==
"ExtendedSubDet"
) {
52
m_groupingType
=
LArConditionsContainerBase::ExtendedSubDetGrouping
;
53
}
else
if
(
m_groupingName
==
"SuperCells"
) {
54
m_groupingType
=
LArConditionsContainerBase::SuperCells
;
55
}
else
{
56
ATH_MSG_ERROR
(
"Grouping type "
<<
m_groupingName
<<
" is not foreseen!"
);
57
ATH_MSG_ERROR
(
"Only \"Unknown\", \"SingleGroup\", \"SubDetector\", \"FeedThrough\", \"ExtendedFeedThrough\", \"ExtendedSubDetector\" and \"SuperCells\" are allowed"
) ;
58
return
StatusCode::FAILURE ;
59
}
60
61
if
(
m_isSC
)
m_groupingType
=
LArConditionsContainerBase::SuperCells
;
62
63
return
StatusCode::SUCCESS;
64
}
65
66
67
StatusCode
LArOFPhaseFill::stop
()
68
{
69
ATH_MSG_DEBUG
(
" In stop() "
);
70
71
typedef
std::pair<HWIdentifier, int> idi;
72
std::map<idi, uint > inmap;
73
uint
b_ec=0, p_n=0, ft=0, sl=0, ch=0, g=0, onlid=0;
74
uint
count
, gmax;
75
if
(
m_isSC
) gmax=
CaloGain::LARHIGHGAIN
;
else
gmax=
CaloGain::LARLOWGAIN
;
76
77
// Open a file and read it - if exists
78
if
(
m_InputFile
.size() > 0) {
79
std::ifstream in (
m_InputFile
.toString());
80
if
(!in.good()) {
81
ATH_MSG_ERROR
(
"Could not open map file "
<<
m_InputFile
);
82
ATH_MSG_ERROR
(
"Using default phase "
<<
m_defaultPhase
<<
" for all channels"
);
83
}
else
{
84
uint
phase;
85
count
= 0;
86
char
line[100];
87
do
{
88
in.getline(line,99);
89
if
((!in.good()) || in.eof())
break
;
90
if
(line[0]==
'#'
)
continue
;
91
std::istringstream iss(line);
92
if
(
m_isID
)
93
if
(
m_isSC
)
94
iss>>std::dec>>onlid>>phase;
95
else
96
iss>>std::dec>>onlid>>g>>phase;
97
else
{
98
if
(
m_isSC
)
99
iss>>std::dec>>b_ec>>p_n>>ft>>sl>>ch>>g>>phase;
100
if
(!iss.good()) {
101
ATH_MSG_WARNING
(
"Wrong line: "
<<line);
102
continue
;
103
}
104
if
(b_ec > 1) {
105
ATH_MSG_ERROR
(
"Wrong barrel_ec: "
<<b_ec<<
", not taken"
);
106
continue
;
107
}
108
if
(p_n > 1) {
109
ATH_MSG_ERROR
(
"Wrong pos_neg: "
<<p_n<<
", not taken"
);
110
continue
;
111
}
112
if
(ft > 31) {
113
ATH_MSG_ERROR
(
"Wrong FTH: "
<<ft<<
", not taken"
);
114
continue
;
115
}
116
if
(sl == 0 || sl > 15) {
117
ATH_MSG_ERROR
(
"Wrong slot: "
<<sl<<
", not taken"
);
118
continue
;
119
}
120
if
(ch > 127) {
121
ATH_MSG_ERROR
(
"Wrong channel: "
<<ch<<
", not taken"
);
122
continue
;
123
}
124
if
((
int
)g < (
int
)
CaloGain::LARHIGHGAIN
|| g >
CaloGain::LARLOWGAIN
) {
125
ATH_MSG_ERROR
(
"Wrong gain: "
<<g<<
", not taken"
);
126
continue
;
127
}
128
if
(phase > 50) {
129
ATH_MSG_ERROR
(
"Wrong phase: "
<<phase<<
", not taken"
);
130
continue
;
131
}
132
}
133
HWIdentifier
oc;
134
if
(
m_isID
) oc=
HWIdentifier
(onlid);
else
oc =
m_lar_on_id
->channel_Id(b_ec, p_n, ft, sl, ch);
135
ATH_MSG_DEBUG
(
"Read "
<< onlid <<
" gain "
<< g <<
" phase: "
<<phase);
136
inmap[std::make_pair(oc,g)] = phase;
137
++
count
;
138
}
while
(!in.eof());
139
ATH_MSG_INFO
(
count
<<
" lines read out"
);
140
}
141
}
142
143
std::vector<HWIdentifier>::const_iterator it =
m_lar_on_id
->channel_begin();
144
std::vector<HWIdentifier>::const_iterator it_e =
m_lar_on_id
->channel_end();
145
146
StatusCode
sc
;
147
LArOFCBinComplete
* OFCbin =
new
LArOFCBinComplete
();
148
OFCbin->
setGroupingType
(
static_cast<
LArConditionsContainerBase::GroupingType
>
(
m_groupingType
) );
149
ATH_CHECK
( OFCbin->
initialize
() );
150
151
int
fphase;
152
count
= 0;
153
for
(; it!=it_e;++it){
154
const
HWIdentifier
id
= *it;
155
sl =
m_lar_on_id
->slot(
id
);
156
ch =
m_lar_on_id
->channel(
id
);
157
ft =
m_lar_on_id
->feedthrough(
id
);
158
p_n =
m_lar_on_id
->pos_neg(
id
);
159
b_ec =
m_lar_on_id
->barrel_ec(
id
);
160
HWIdentifier
oc =
m_lar_on_id
->channel_Id(b_ec, p_n, ft, sl, ch);
161
if
(
id
!= oc) {
162
std::cout <<
"Something wrong: "
<<
id
<<
" "
<<oc<<std::endl;
163
}
164
++
count
;
165
for
(g =
CaloGain::LARHIGHGAIN
; g <= gmax; ++g) {
166
if
(inmap.find(std::make_pair(oc,g)) != inmap.end()) {
167
fphase = inmap[std::make_pair(oc,g)];
168
}
else
{
169
fphase =
m_defaultPhase
;
170
}
171
ATH_MSG_DEBUG
(
"B_EC: "
<<b_ec<<
" Pos_Neg: "
<<p_n<<
" FT: "
<<ft<<
" Slot: "
<<sl<<
" Chan: "
<<ch<<
" Phase: "
<<fphase);
172
OFCbin->
set
(
id
,g,fphase);
173
}
174
}
175
176
ATH_MSG_DEBUG
(
" Loop over "
<<
count
<<
" cells"
);
177
ATH_CHECK
(
detStore
()->record(OFCbin,
m_keyOFCbin
) );
178
return
StatusCode::SUCCESS;
179
}
180
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
CaloGain.h
LArOFCBinComplete.h
uint
unsigned int uint
Definition
LArOFPhaseFill.cxx:19
LArOFPhaseFill.h
LArOnlineID.h
LArOnlineID_Base.h
LArOnline_SuperCellID.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
HWIdentifier
Definition
HWIdentifier.h:13
LArConditionsContainerBase::setGroupingType
void setGroupingType(GroupingType type)
allow group type to be set externally - need to (re)initialize after setting grouping type
Definition
LArConditionsContainerBase.cxx:88
LArConditionsContainerBase::GroupingType
GroupingType
Grouping type.
Definition
LArConditionsContainerBase.h:44
LArConditionsContainerBase::FeedThroughGrouping
@ FeedThroughGrouping
Definition
LArConditionsContainerBase.h:48
LArConditionsContainerBase::ExtendedSubDetGrouping
@ ExtendedSubDetGrouping
Definition
LArConditionsContainerBase.h:50
LArConditionsContainerBase::ExtendedFTGrouping
@ ExtendedFTGrouping
Definition
LArConditionsContainerBase.h:49
LArConditionsContainerBase::SuperCells
@ SuperCells
Definition
LArConditionsContainerBase.h:51
LArConditionsContainerBase::Unknown
@ Unknown
Definition
LArConditionsContainerBase.h:45
LArConditionsContainerBase::SubDetectorGrouping
@ SubDetectorGrouping
Definition
LArConditionsContainerBase.h:47
LArConditionsContainerBase::SingleGroup
@ SingleGroup
Definition
LArConditionsContainerBase.h:46
LArConditionsContainer::initialize
virtual StatusCode initialize()
Initialization done after creation or read back - derived classes may augment the functionality.
LArOFCBinComplete
Definition
LArOFCBinComplete.h:13
LArOFCBinComplete::set
void set(const HWIdentifier &chid, const int &gain, const int &bin)
Definition
LArOFCBinComplete.cxx:11
LArOFPhaseFill::m_isID
BooleanProperty m_isID
Definition
LArOFPhaseFill.h:43
LArOFPhaseFill::m_defaultPhase
Gaudi::Property< unsigned int > m_defaultPhase
Definition
LArOFPhaseFill.h:42
LArOFPhaseFill::m_groupingType
int m_groupingType
Definition
LArOFPhaseFill.h:45
LArOFPhaseFill::LArOFPhaseFill
LArOFPhaseFill(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArOFPhaseFill.cxx:21
LArOFPhaseFill::initialize
StatusCode initialize()
Definition
LArOFPhaseFill.cxx:27
LArOFPhaseFill::m_keyOFCbin
StringProperty m_keyOFCbin
Definition
LArOFPhaseFill.h:40
LArOFPhaseFill::m_lar_on_id
const LArOnlineID_Base * m_lar_on_id
Definition
LArOFPhaseFill.h:37
LArOFPhaseFill::stop
StatusCode stop()
Definition
LArOFPhaseFill.cxx:67
LArOFPhaseFill::m_groupingName
StringProperty m_groupingName
Definition
LArOFPhaseFill.h:41
LArOFPhaseFill::m_InputFile
StringProperty m_InputFile
Definition
LArOFPhaseFill.h:39
LArOFPhaseFill::m_isSC
BooleanProperty m_isSC
Definition
LArOFPhaseFill.h:44
LArOnlineID
Definition
LArOnlineID.h:21
LArOnline_SuperCellID
Definition
LArOnline_SuperCellID.h:21
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:148
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition
CaloGain.h:18
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition
CaloGain.h:18
Generated on
for ATLAS Offline Software by
1.17.0