ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibUtils
src
LArAutoCorrDecoderTool.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
#include "
LArCalibUtils/LArAutoCorrDecoderTool.h
"
6
#include "
AthenaKernel/errorcheck.h
"
7
8
LArAutoCorrDecoderTool::~LArAutoCorrDecoderTool
() =
default
;;
9
10
StatusCode
LArAutoCorrDecoderTool::initialize
()
11
{
12
ATH_MSG_DEBUG
(
"LArAutoCorrDecoderTool initialize() begin"
);
13
14
if
(
m_isSC
) {
15
const
LArOnline_SuperCellID
* ll;
16
ATH_CHECK
( detStore()->retrieve(ll,
"LArOnline_SuperCellID"
) );
17
m_onlineID
=
static_cast<
const
LArOnlineID_Base
*
>
(ll);
18
ATH_MSG_DEBUG
(
"Found the LArOnlineID helper"
);
19
20
}
else
{
// m_isSC
21
const
LArOnlineID
* ll;
22
ATH_CHECK
( detStore()->retrieve(ll,
"LArOnlineID"
) );
23
m_onlineID
=
static_cast<
const
LArOnlineID_Base
*
>
(ll);
24
ATH_MSG_DEBUG
(
" Found the LArOnlineID helper. "
);
25
}
26
27
28
if
(!
m_isSC
&&
m_alwaysHighGain
)
29
ATH_MSG_INFO
(
"Will always return HIGH gain autocorrelation matrix for EM calo, MEDIUM for HEC and FCAL"
);
30
31
ATH_MSG_DEBUG
(
"LArAutoCorrDecoderTool initialize() end"
);
32
return
StatusCode::SUCCESS;
33
}
34
35
36
const
Eigen::MatrixXd
LArAutoCorrDecoderTool::AutoCorr
(
const
HWIdentifier
& CellID,
int
gain,
unsigned
nSamples=5 )
const
37
{
38
if
(
m_decodemode
==1u)
39
return
ACPhysics
(CellID,gain,nSamples);
40
else
41
return
ACDiagonal
(CellID,gain,nSamples);
42
}
43
44
45
const
Eigen::MatrixXd
LArAutoCorrDecoderTool::ACDiagonal
(
const
HWIdentifier
& CellID,
int
gain,
unsigned
nSamples=5 )
const
{
46
47
if
(!
m_isSC
&&
m_alwaysHighGain
) {
48
if
(
m_onlineID
->isFCALchannel(CellID) ||
m_onlineID
->isHECchannel(CellID))
49
gain=1;
50
else
51
gain=0;
52
}
53
54
Eigen::MatrixXd AutoCorrMatrix=Eigen::MatrixXd::Zero(nSamples,nSamples);
55
56
const
ILArAutoCorr
* autoCorr=
nullptr
;
57
detStore()->retrieve(autoCorr,
m_keyAutoCorr
).ignore();
58
59
60
if
( autoCorr ) {
// LArAutoCorrComplete is loaded in DetStore
61
62
ILArAutoCorr::AutoCorrRef_t
dbcorr = autoCorr->
autoCorr
(CellID,gain);
63
64
if
( dbcorr.size()== 0 ) {
// empty AutoCorr for given channel
65
ATH_MSG_WARNING
(
"Empty AutoCorr vector for channel "
<<
m_onlineID
->channel_name(CellID) <<
" in Gain = "
<< gain);
66
nSamples=0;
67
}
68
else
if
(dbcorr.size() < nSamples-1 ) {
69
ATH_MSG_WARNING
(
"Not enough samples in AutoCorr vector for channel "
<<
m_onlineID
->channel_name(CellID) <<
" in Gain = "
<< gain);
70
nSamples=1+dbcorr.size();
//The remaining values of the eigen matrix are left to 0.0
71
}
72
73
// fill diagonal matrix with vector
74
for
(
unsigned
i=0;i<nSamples;i++) {
75
AutoCorrMatrix(i,i)= 1 ;
76
for
(
unsigned
j=i+1;j<nSamples;j++) {
77
AutoCorrMatrix(i,j) = AutoCorrMatrix(j,i) = dbcorr[j-i-1];
78
}
79
}
80
}
//else if m_autoCorr
81
else
{
// no LArAutoCorrComplete loaded in DetStore (e.g. DB problem) :-(
82
ATH_MSG_WARNING
(
"No valid AutoCorr object loaded from DetStore"
);
83
}
84
85
ATH_MSG_DEBUG
(
"AutoCorr Diagonal matrix for channel "
<<
m_onlineID
->channel_name(CellID)
86
<<
" in Gain = "
<< gain
87
<<
":\n"
<< AutoCorrMatrix);
88
89
return
AutoCorrMatrix;
90
91
}
92
93
const
Eigen::MatrixXd
LArAutoCorrDecoderTool::ACPhysics
(
const
HWIdentifier
& CellID,
int
gain,
unsigned
nSamples=5 )
const
{
94
95
96
if
(!
m_isSC
&&
m_alwaysHighGain
) {
97
if
(
m_onlineID
->isFCALchannel(CellID) ||
m_onlineID
->isHECchannel(CellID))
98
gain=1;
99
else
100
gain=0;
101
}
102
103
Eigen::MatrixXd AutoCorrMatrix=Eigen::MatrixXd::Identity(nSamples,nSamples);
104
105
const
ILArAutoCorr
* autoCorr=
nullptr
;
106
detStore()->retrieve(autoCorr,
m_keyAutoCorr
).ignore();
107
108
if
( autoCorr ) {
// LArAutoCorrComplete is loaded in DetStore
109
110
ILArAutoCorr::AutoCorrRef_t
corrdb = autoCorr->
autoCorr
(CellID,gain);
111
112
if
( corrdb.size()== 0 ) {
// empty AutoCorr for given channel
113
ATH_MSG_WARNING
(
"Empty AutoCorr vector for channel "
<<
m_onlineID
->channel_name(CellID) <<
" in Gain = "
<< gain);
114
nSamples=0;
//return all-zero matrix
115
}
116
else
if
( corrdb.size() < nSamples*(nSamples+1)/2 ) {
117
ATH_MSG_WARNING
(
"Not enough samples in AutoCorr vector for channel "
<<
m_onlineID
->channel_name(CellID)
118
<<
"in Gain = "
<< gain <<
" for AC Physics mode"
);
119
nSamples=0;
//return all-zero matrix
120
}
121
122
// Corr size could be bigger, then it's asked now, need remapping:
123
const
unsigned
int
nsamples_AC = (-1+((int)(sqrt(1+8*corrdb.size()))))/2;
124
unsigned
int
k=0;
125
for
(
unsigned
i=0;i<nSamples;i++) {
126
for
(
unsigned
j=i;j<nSamples;j++,k++) {
127
if
(i<=j) {
128
AutoCorrMatrix(i,j) = AutoCorrMatrix(j,i)= corrdb[k];
129
}
130
}
131
k+=nsamples_AC-nSamples;
132
}
133
}
//end if m_autoCorr
134
else
{
// no LArAutoCorrComplete loaded in DetStore (e.g. DB problem) :-(
135
ATH_MSG_WARNING
(
"No valid AutoCorr object loaded from DetStore"
);
136
}
137
138
ATH_MSG_DEBUG
(
"AutoCorr Physics matrix for channel "
<<
m_onlineID
->channel_name(CellID)
139
<<
" in Gain = "
<< gain
140
<<
":\n"
<< AutoCorrMatrix);
141
return
AutoCorrMatrix;
142
143
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
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
errorcheck.h
Helpers for checking error return status codes and reporting errors.
LArAutoCorrDecoderTool.h
HWIdentifier
Definition
HWIdentifier.h:13
ILArAutoCorr
This class defines the interface for accessing AutoCorrelation parameters for each channel @stereotyp...
Definition
ILArAutoCorr.h:29
ILArAutoCorr::AutoCorrRef_t
LArVectorProxy AutoCorrRef_t
Definition
ILArAutoCorr.h:33
ILArAutoCorr::autoCorr
virtual AutoCorrRef_t autoCorr(const HWIdentifier &CellID, int gain) const =0
LArAutoCorrDecoderTool::ACDiagonal
const Eigen::MatrixXd ACDiagonal(const HWIdentifier &CellID, int gain, unsigned nSamples) const
Definition
LArAutoCorrDecoderTool.cxx:45
LArAutoCorrDecoderTool::m_onlineID
const LArOnlineID_Base * m_onlineID
Definition
LArAutoCorrDecoderTool.h:55
LArAutoCorrDecoderTool::initialize
virtual StatusCode initialize()
Definition
LArAutoCorrDecoderTool.cxx:10
LArAutoCorrDecoderTool::~LArAutoCorrDecoderTool
virtual ~LArAutoCorrDecoderTool()
LArAutoCorrDecoderTool::AutoCorr
const Eigen::MatrixXd AutoCorr(const HWIdentifier &CellID, int gain, unsigned nSamples) const
Definition
LArAutoCorrDecoderTool.cxx:36
LArAutoCorrDecoderTool::m_keyAutoCorr
Gaudi::Property< std::string > m_keyAutoCorr
Definition
LArAutoCorrDecoderTool.h:50
LArAutoCorrDecoderTool::m_decodemode
Gaudi::Property< unsigned > m_decodemode
Definition
LArAutoCorrDecoderTool.h:47
LArAutoCorrDecoderTool::m_alwaysHighGain
Gaudi::Property< bool > m_alwaysHighGain
Definition
LArAutoCorrDecoderTool.h:48
LArAutoCorrDecoderTool::ACPhysics
const Eigen::MatrixXd ACPhysics(const HWIdentifier &CellID, int gain, unsigned nSamples) const
Definition
LArAutoCorrDecoderTool.cxx:93
LArAutoCorrDecoderTool::m_isSC
Gaudi::Property< bool > m_isSC
Definition
LArAutoCorrDecoderTool.h:49
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition
LArOnlineID_Base.h:97
LArOnlineID
Definition
LArOnlineID.h:21
LArOnline_SuperCellID
Definition
LArOnline_SuperCellID.h:21
Generated on
for ATLAS Offline Software by
1.17.0