ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibTools
src
LArAutoCorr2Ntuple.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 "
LArCalibTools/LArAutoCorr2Ntuple.h
"
6
#include "
LArRawConditions/LArAutoCorrComplete.h
"
7
#include "
CaloIdentifier/CaloGain.h
"
8
#include "
LArIdentifier/LArOnlineID.h
"
9
#include "
StoreGate/StoreGateSvc.h
"
10
11
LArAutoCorr2Ntuple::LArAutoCorr2Ntuple
(
const
std::string& name, ISvcLocator* pSvcLocator)
12
:
LArCond2NtupleBase
(name, pSvcLocator)
13
{
14
declareProperty
(
"Nsamples"
,
m_nsamples
=32);
15
16
m_ntTitle
=
"AutoCorrelation"
;
17
m_ntpath
=
"/NTUPLES/FILE1/AUTOCORR"
;
18
19
}
20
21
StatusCode
LArAutoCorr2Ntuple::initialize
() {
22
ATH_CHECK
(
m_objKey
.initialize());
23
return
LArCond2NtupleBase::initialize
();
24
}
25
26
27
28
StatusCode
LArAutoCorr2Ntuple::stop
() {
29
ATH_MSG_INFO
(
"LArAutoCorr2Ntuple in stop "
<<
m_nt
);
30
StatusCode
sc
;
31
NTuple::Array<float> cov;
32
NTuple::Item<long> gain, cellIndex;
33
NTuple::Item<long> corrUndo;
34
sc
=
m_nt
->addItem(
"gain"
,gain,0,3);
35
if
(
sc
!=StatusCode::SUCCESS) {
36
ATH_MSG_ERROR
(
"addItem 'gain' failed"
);
37
return
StatusCode::FAILURE;
38
}
39
40
sc
=
m_nt
->addItem(
"cellIndex"
,cellIndex,0,200000);
41
if
(
sc
!=StatusCode::SUCCESS) {
42
ATH_MSG_ERROR
(
"addItem 'cellIndex' failed"
);
43
return
StatusCode::FAILURE;
44
}
45
46
sc
=
m_nt
->addItem(
"covr"
,
m_nsamples
-1,cov);
47
if
(
sc
!=StatusCode::SUCCESS) {
48
ATH_MSG_ERROR
(
"addItem 'covr' failed"
);
49
return
StatusCode::FAILURE;
50
}
51
52
sc
=
m_nt
->addItem(
"corrUndo"
,corrUndo,0,2);
53
if
(
sc
!=StatusCode::SUCCESS) {
54
ATH_MSG_ERROR
(
"addItem 'corrUndo' failed"
);
55
return
StatusCode::FAILURE;
56
}
57
58
ATH_MSG_DEBUG
(
"LArAutoCorr2Ntuple reading container "
<<
m_objKey
.key());
59
// For compatibility with existing configurations, look in the detector
60
// store first, then in conditions.
61
const
ILArAutoCorr
* larAutoCorr=
nullptr
;
62
larAutoCorr =
detStore
()->tryConstRetrieve<
ILArAutoCorr
>(
m_objKey
.key());
63
if
(!larAutoCorr) {
64
ATH_MSG_DEBUG
(
"No ILArAutoCorr found, trying LArAutoCorrComplete "
<<
m_objKey
.key());
65
const
LArAutoCorrComplete
*larComplete =
66
detStore
()->tryConstRetrieve<
LArAutoCorrComplete
>(
m_objKey
.key());
67
if
(larComplete) {
68
larAutoCorr = larComplete;
69
}
else
{
70
ATH_MSG_DEBUG
(
"LArAutoCorr2Ntuple reading conditions"
);
71
SG::ReadCondHandle<ILArAutoCorr>
acHdl{
m_objKey
};
72
larAutoCorr = *acHdl;
73
}
74
}
75
76
if
(larAutoCorr==
nullptr
){
77
ATH_MSG_ERROR
(
"Unable to retrieve ILArAutoCorr with key "
<<
m_objKey
.key() <<
" neither from DetectorStore neither from conditions"
);
78
return
StatusCode::FAILURE;
79
}
80
auto
* larAutoCorr_c =
dynamic_cast<
const
LArAutoCorrComplete
*
>
(larAutoCorr);
81
if
(not larAutoCorr_c) {
82
ATH_MSG_ERROR
(
"Dynamic cast failed in LArAutoCorr2Ntuple::stop"
);
83
return
StatusCode::FAILURE;
84
}
85
if
(
m_applyCorr
) {
86
if
(not larAutoCorr_c->correctionsApplied()) {
87
//ouch; but we are only in 'stop'
88
auto
larAutoCorr_nc
ATLAS_THREAD_SAFE
=
const_cast<
LArAutoCorrComplete
*
>
(larAutoCorr_c);
89
sc
=larAutoCorr_nc->applyCorrections();
90
if
(
sc
.isFailure()) {
91
ATH_MSG_ERROR
(
"Failed to apply corrections to LArCaliWaveContainer!"
);
92
}
else
{
93
ATH_MSG_INFO
(
"Applied corrections to LArCaliWaveContainer"
);
94
}
95
}
else
{
96
ATH_MSG_WARNING
(
"Corrections already applied. Can't apply twice!"
);
97
}
98
}
// end if applyCorr
99
100
unsigned
cellCounter=0;
101
unsigned
cellZeroCounter=0;
102
for
(
int
igain=
CaloGain::LARHIGHGAIN
; igain<
m_NGains
; ++igain ) {
103
for
(
HWIdentifier
hwid :
m_onlineId
->channel_range()) {
104
ILArAutoCorr::AutoCorrRef_t
corr=larAutoCorr->
autoCorr
(hwid,igain);
105
if
(corr.size()>0) {
106
fillFromIdentifier
(hwid);
107
gain = igain;
108
cellIndex = cellCounter;
109
for
(
unsigned
i=0;i<
m_nsamples
-1 && i<corr.size();i++){
110
cov[i] = corr[i];
111
}
112
corrUndo=0;
113
sc
=
ntupleSvc
()->writeRecord(
m_nt
);
114
if
(
sc
!=StatusCode::SUCCESS) {
115
ATH_MSG_ERROR
(
"writeRecord failed"
);
116
return
StatusCode::FAILURE;
117
}
118
cellCounter++;
119
}
else
{ ++cellZeroCounter;}
//end if size>0
120
}
//end if loop over cells
121
}
//end if loop over gains
122
123
if
(
m_addCorrUndo
) {
124
for
(
int
igain=
CaloGain::LARHIGHGAIN
; igain<
m_NGains
.value(); ++igain ) {
125
LArAutoCorrComplete::ConstCorrectionIt
itUndo=larAutoCorr_c->undoCorrBegin(igain);
126
LArAutoCorrComplete::ConstCorrectionIt
itUndo_e=larAutoCorr_c->undoCorrEnd(igain);
127
for
(;itUndo!=itUndo_e;++itUndo) {
128
const
HWIdentifier
hwid(itUndo->first);
129
const
LArAutoCorrP1
& ac = itUndo->second;
130
fillFromIdentifier
(hwid);
131
for
(
unsigned
i=0;i<
m_nsamples
-1 && i<ac.
m_vAutoCorr
.size();i++) cov[i] = ac.
m_vAutoCorr
[i];
132
gain=igain;
133
corrUndo=1;
134
sc
=
ntupleSvc
()->writeRecord(
m_nt
);
135
if
(
sc
!=StatusCode::SUCCESS) {
136
ATH_MSG_ERROR
(
"writeRecord failed"
);
137
return
StatusCode::FAILURE;
138
}
139
}
140
}
//gain
141
}
//if m_corrUndo
142
143
144
ATH_MSG_INFO
(
"LArAutoCorr2Ntuple has finished, "
<< cellCounter <<
"records written, "
<< cellZeroCounter <<
" zero length vectors"
);
145
return
StatusCode::SUCCESS;
146
}
// end finalize-method.
147
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
LArAutoCorr2Ntuple.h
LArAutoCorrComplete.h
LArOnlineID.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
ntupleSvc
INTupleSvc * ntupleSvc()
Definition
ServiceAccessor.h:14
StoreGateSvc.h
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition
checker_macros.h:211
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
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
LArAutoCorr2Ntuple::m_applyCorr
BooleanProperty m_applyCorr
Definition
LArAutoCorr2Ntuple.h:36
LArAutoCorr2Ntuple::m_addCorrUndo
BooleanProperty m_addCorrUndo
Definition
LArAutoCorr2Ntuple.h:37
LArAutoCorr2Ntuple::LArAutoCorr2Ntuple
LArAutoCorr2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArAutoCorr2Ntuple.cxx:11
LArAutoCorr2Ntuple::stop
virtual StatusCode stop()
Definition
LArAutoCorr2Ntuple.cxx:28
LArAutoCorr2Ntuple::initialize
virtual StatusCode initialize()
Definition
LArAutoCorr2Ntuple.cxx:21
LArAutoCorr2Ntuple::m_objKey
SG::ReadCondHandleKey< ILArAutoCorr > m_objKey
Definition
LArAutoCorr2Ntuple.h:34
LArAutoCorr2Ntuple::m_nsamples
unsigned m_nsamples
Definition
LArAutoCorr2Ntuple.h:40
LArAutoCorrComplete
This class implements the ILArAutoCorr interface.
Definition
LArAutoCorrComplete.h:26
LArAutoCorrP1
c-struct reproducing the structure of the persistent data
Definition
LArAutoCorrP1.h:25
LArAutoCorrP1::m_vAutoCorr
std::vector< float > m_vAutoCorr
Definition
LArAutoCorrP1.h:31
LArCond2NtupleBase::initialize
StatusCode initialize()
Definition
LArCond2NtupleBase.cxx:33
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition
LArCond2NtupleBase.h:68
LArCond2NtupleBase::m_NGains
Gaudi::Property< int > m_NGains
Definition
LArCond2NtupleBase.h:64
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition
LArCond2NtupleBase.h:71
LArCond2NtupleBase::m_onlineId
const LArOnlineID_Base * m_onlineId
Definition
LArCond2NtupleBase.h:88
LArCond2NtupleBase::m_ntpath
std::string m_ntpath
Definition
LArCond2NtupleBase.h:68
LArCond2NtupleBase::fillFromIdentifier
bool fillFromIdentifier(const HWIdentifier &id)
Definition
LArCond2NtupleBase.cxx:290
LArCond2NtupleBase::LArCond2NtupleBase
LArCond2NtupleBase(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArCond2NtupleBase.cxx:15
LArConditionsContainer< LArAutoCorrP1 >::ConstCorrectionIt
Subset::ConstCorrectionVecIt ConstCorrectionIt
Definition
LArConditionsContainer.h:78
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition
CaloGain.h:18
Generated on
for ATLAS Offline Software by
1.17.0