ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibUtils
src
LArAutoCorrAlgToDB.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
7
NAME: LArAutoCorrAlgToDB.cxx
8
PACKAGE: LArCalorimeter/LArCalibUtils
9
10
AUTHORS: P. Strizenec, based on Tool by G. Unal
11
12
PURPOSE: write LArAutoCorr in Database from LArAutoCorrTotal conditions object
13
14
********************************************************************/
15
16
// Include files
17
#include "
LArCalibUtils/LArAutoCorrAlgToDB.h
"
18
#include "
LArRawConditions/LArAutoCorrComplete.h
"
19
#include "
CaloIdentifier/CaloGain.h
"
20
21
22
LArAutoCorrAlgToDB::LArAutoCorrAlgToDB
(
const
std::string& name, ISvcLocator* pSvcLocator)
23
:
AthAlgorithm
(name, pSvcLocator),
24
m_onlineHelper
(nullptr)
25
{
26
declareProperty
(
"GroupingType"
,
m_groupingType
=
"ExtendedFeedThrough"
);
27
declareProperty
(
"OutAutoCorrKey"
,
m_acContName
=
"LArPhysAutoCorr"
);
28
declareProperty
(
"isSC"
,
m_isSC
=
false
);
29
declareProperty
(
"NMinbias"
,
m_nMinbias
);
30
}
31
32
33
LArAutoCorrAlgToDB::~LArAutoCorrAlgToDB
()
34
=
default
;
35
36
//----------------------------------------------------------------------------
37
StatusCode
LArAutoCorrAlgToDB::initialize
()
38
{
39
StatusCode
sc
;
40
if
(
m_isSC
) {
41
const
LArOnline_SuperCellID
* ll;
42
sc
=
detStore
()->retrieve(ll,
"LArOnline_SuperCellID"
);
43
if
(
sc
.isFailure()) {
44
ATH_MSG_ERROR
(
"Could not get LArOnlineID helper !"
);
45
return
StatusCode::FAILURE;
46
}
47
else
{
48
m_onlineHelper
=
static_cast<
const
LArOnlineID_Base
*
>
(ll);
49
ATH_MSG_DEBUG
(
"Found the LArOnlineID helper"
);
50
}
51
m_nGains
=1;
52
}
else
{
// m_isSC
53
const
LArOnlineID
* ll;
54
sc
=
detStore
()->retrieve(ll,
"LArOnlineID"
);
55
if
(
sc
.isFailure()) {
56
ATH_MSG_ERROR
(
"Could not get LArOnlineID helper !"
);
57
return
StatusCode::FAILURE;
58
}
59
else
{
60
m_onlineHelper
=
static_cast<
const
LArOnlineID_Base
*
>
(ll);
61
ATH_MSG_DEBUG
(
" Found the LArOnlineID helper. "
);
62
}
63
m_nGains
=(unsigned)
CaloGain::LARNGAIN
;
64
}
65
66
ATH_CHECK
(
m_autocorrKey
.initialize() );
67
return
StatusCode::SUCCESS;
68
}
69
70
//---------------------------------------------------------------------------
71
StatusCode
LArAutoCorrAlgToDB::stop
() {
72
73
ATH_MSG_INFO
(
">>> stop()"
);
74
75
// ReadHandle setup
76
SG::ReadCondHandle<LArAutoCorrTotal>
acHdl(
m_autocorrKey
);
77
const
LArAutoCorrTotal
*acTotal = *acHdl;
78
if
(!acTotal) {
79
ATH_MSG_ERROR
(
"Could not read LArAutoCorrTotal with key "
<<
m_autocorrKey
.key()<<
" from ConditionsStore"
);
80
return
StatusCode::FAILURE;
81
}
82
83
auto
larAutoCorrComplete = std::make_unique<LArAutoCorrComplete>();
84
// Initialize LArAutoCorrComplete
85
ATH_CHECK
( larAutoCorrComplete->setGroupingType(
m_groupingType
,
msg
()) );
86
ATH_CHECK
( larAutoCorrComplete->initialize() );
87
88
//Loop over gains
89
for
(
unsigned
igain=0;igain<
m_nGains
;igain++) {
90
CaloGain::CaloGain
gain=(
CaloGain::CaloGain
)igain;
91
//Loop over cells
92
std::vector<HWIdentifier>::const_iterator it =
m_onlineHelper
->channel_begin();
93
std::vector<HWIdentifier>::const_iterator it_e =
m_onlineHelper
->channel_end();
94
unsigned
nSkipped=0;
95
unsigned
nDone=0;
96
for
(;it!=it_e;++it) {
97
98
HWIdentifier
chid = (*it);
99
100
const
std::vector<double>
AutoCorr
= acTotal->
autoCorrTotal
(chid,igain,
m_nMinbias
);
101
// Not to process channels not existing in input elec. autocorr. DB
102
if
(
AutoCorr
.size() < 2 || (
AutoCorr
[0]==0. &&
AutoCorr
[1]==0.)) {
103
++nSkipped;
104
continue
;
105
}
106
const
std::vector<double> rmsSampl = acTotal->
samplRMS
(chid,igain,
m_nMinbias
);
107
unsigned
int
nsamples_AC = (1+((int)(sqrt(1+8*
AutoCorr
.size()))))/2;
108
109
std::vector<float> cov;
110
unsigned
int
ntot = nsamples_AC*(nsamples_AC+1) / 2;
111
cov.resize(ntot,0.);
112
113
unsigned
int
k=0;
114
for
(
unsigned
i=0;i<nsamples_AC;i++) {
115
for
(
unsigned
j=i;j<nsamples_AC;j++,k++) {
116
double
AC;
117
if
(i==j) {
118
AC=1.;
119
}
120
else
{
121
int
i1=std::min(i,j);
122
int
i2=std::max(i,j);
123
int
index
= i1*nsamples_AC - i1*(i1+1)/2 -(i1+1) + i2;
124
AC=
AutoCorr
[
index
];
125
}
126
AC = AC*rmsSampl[i]*rmsSampl[j];
127
cov[k] = AC;
128
}
129
}
130
131
larAutoCorrComplete->set(chid,gain,cov);
132
++nDone;
133
}
//end loop over all cells
134
ATH_MSG_INFO
(
"Gain "
<< gain <<
": "
<< nDone <<
" channels done, "
<< nSkipped <<
" channels skipped (no Elec Noise AC in input)"
);
135
}
//end loop over gains
136
137
// Record LArAutoCorrComplete
138
ATH_CHECK
(
detStore
()->record(std::move(larAutoCorrComplete),
m_acContName
) );
139
ATH_MSG_INFO
(
"Recorded LArAutCorrComplete object with key "
<<
m_acContName
);
140
ATH_CHECK
(
detStore
()->symLink(
ClassID_traits<LArAutoCorrComplete>::ID
(),
m_acContName
,
ClassID_traits<ILArAutoCorr>::ID
()));
141
ATH_MSG_INFO
(
detStore
()->
dump
());
142
143
return
StatusCode::SUCCESS;
144
}
145
146
147
148
149
150
151
152
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_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloGain.h
LArAutoCorrAlgToDB.h
LArAutoCorrComplete.h
MonDataType::AutoCorr
@ AutoCorr
Definition
LArLATOMEDecoder.h:54
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 >::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
LArAutoCorrAlgToDB::m_nMinbias
float m_nMinbias
Definition
LArAutoCorrAlgToDB.h:58
LArAutoCorrAlgToDB::~LArAutoCorrAlgToDB
~LArAutoCorrAlgToDB()
LArAutoCorrAlgToDB::m_acContName
std::string m_acContName
Definition
LArAutoCorrAlgToDB.h:53
LArAutoCorrAlgToDB::LArAutoCorrAlgToDB
LArAutoCorrAlgToDB(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArAutoCorrAlgToDB.cxx:22
LArAutoCorrAlgToDB::m_autocorrKey
SG::ReadCondHandleKey< LArAutoCorrTotal > m_autocorrKey
Definition
LArAutoCorrAlgToDB.h:47
LArAutoCorrAlgToDB::m_nGains
unsigned int m_nGains
Definition
LArAutoCorrAlgToDB.h:56
LArAutoCorrAlgToDB::m_groupingType
std::string m_groupingType
Definition
LArAutoCorrAlgToDB.h:50
LArAutoCorrAlgToDB::stop
StatusCode stop()
Definition
LArAutoCorrAlgToDB.cxx:71
LArAutoCorrAlgToDB::m_onlineHelper
const LArOnlineID_Base * m_onlineHelper
Definition
LArAutoCorrAlgToDB.h:43
LArAutoCorrAlgToDB::m_isSC
bool m_isSC
Definition
LArAutoCorrAlgToDB.h:45
LArAutoCorrAlgToDB::initialize
StatusCode initialize()
Definition
LArAutoCorrAlgToDB.cxx:37
LArAutoCorrTotal
Definition
LArAutoCorrTotal.h:19
LArAutoCorrTotal::autoCorrTotal
const std::vector< double > autoCorrTotal(const IdentifierHash &hid, int gain, float Nminbias) const
Definition
LArAutoCorrTotal.cxx:58
LArAutoCorrTotal::samplRMS
const std::vector< double > samplRMS(const IdentifierHash &hid, int gain, float Nminbias) const
Definition
LArAutoCorrTotal.cxx:90
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
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
CaloGain::CaloGain
CaloGain
Definition
CaloGain.h:11
CaloGain::LARNGAIN
@ LARNGAIN
Definition
CaloGain.h:19
dump
-event-from-file
index
Definition
index.py:1
ClassID_traits::ID
static constexpr CLID ID()
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
Generated on
for ATLAS Offline Software by
1.17.0