ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibTools
src
LArPhysWaves2Ntuple.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LArCalibTools/LArPhysWaves2Ntuple.h
"
6
#include "
CaloIdentifier/CaloGain.h
"
7
8
9
LArPhysWaves2Ntuple::LArPhysWaves2Ntuple
(
const
std::string& name, ISvcLocator* pSvcLocator):
LArWaves2Ntuple
(name, pSvcLocator)
10
{
11
m_keylist
.clear() ;
12
declareProperty
(
"KeyList"
,
m_keylist
);
13
declareProperty
(
"NtupleName"
,
m_ntName
);
14
declareProperty
(
"AddCorrUndo"
,
m_addCorrUndo
=
true
);
15
declareProperty
(
"ApplyCorrection"
,
m_applyCorr
=
false
);
16
}
17
18
LArPhysWaves2Ntuple::~LArPhysWaves2Ntuple
()
19
=
default
;
20
21
22
StatusCode
LArPhysWaves2Ntuple::initialize
() {
23
m_ntTitle
=
"Physics Wave"
;
24
m_ntpath
=std::string(
"/NTUPLES/FILE1/"
)+
m_ntName
;
25
return
LArWaves2Ntuple::initialize
();
26
}
27
28
29
StatusCode
LArPhysWaves2Ntuple::stop
()
30
{
31
32
StatusCode
sc
;
33
34
sc
=
m_nt
->addItem(
"gain"
,
m_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(
"timeOffset"
,
m_timeOffset
,0.,100.);
41
if
(
sc
!=StatusCode::SUCCESS) {
42
ATH_MSG_ERROR
(
"addItem 'timeOffset' failed"
);
43
return
StatusCode::FAILURE;
44
}
45
46
47
if
(
m_addCorrUndo
) {
48
sc
=
m_nt
->addItem(
"corrUndo"
,
m_corrUndo
,0,1);
49
if
(
sc
!=StatusCode::SUCCESS) {
50
ATH_MSG_ERROR
(
"addItem 'corrUndo' failed"
);
51
return
StatusCode::FAILURE;
52
}
53
}
54
55
for
(
unsigned
k=0 ; k<
m_keylist
.size() ; k++ ) {
56
const
std::string& key =
m_keylist
[k] ;
57
58
59
ATH_MSG_INFO
(
"Processing WaveContainer from StoreGate! key="
<<
m_keylist
[k] );
60
const
LArPhysWaveContainer
* physWaveContainer =
nullptr
;
61
LArPhysWaveContainer
* physWaveContainer_nc =
nullptr
;
62
StatusCode
sc
;
63
if
(
m_applyCorr
) {
64
sc
=
m_detStore
->retrieve(physWaveContainer_nc,key);
65
if
(
sc
.isFailure()) {
66
ATH_MSG_ERROR
(
"Cannot read non-const LArPhysWaveContainer from StoreGate! key="
<< key );
67
ATH_MSG_ERROR
(
"The ApplyCorrection option works only for non-const containers!"
);
68
return
sc
;
69
}
70
else
71
ATH_MSG_INFO
(
"Read non-const LArPhysWaveContainer from StoreGate! key= "
<< key );
72
73
if
(!physWaveContainer_nc->
correctionsApplied
()) {
74
sc
=physWaveContainer_nc->
applyCorrections
();
75
if
(
sc
.isFailure()) {
76
ATH_MSG_ERROR
(
"Failed to apply corrections to LArPhysWaveContainer!"
);
77
}
78
}
79
physWaveContainer=physWaveContainer_nc;
80
}
81
else
{
82
sc
=
m_detStore
->retrieve(physWaveContainer,key);
83
if
(
sc
.isFailure()) {
84
ATH_MSG_ERROR
(
"Cannot read LArPhysWaveContainer from StoreGate! key="
<< key );
85
return
StatusCode::FAILURE;
86
}
else
87
ATH_MSG_INFO
(
"Read const LArPhysWaveContainer from StoreGate! key= "
<< key );
88
}
89
90
for
(
int
igain=
CaloGain::LARHIGHGAIN
;igain<
m_NGains
.value() ;++igain){
91
for
(
const
HWIdentifier
chid:
m_onlineId
->channel_range()) {
92
m_gain
=(long)igain;
93
const
LArPhysWave
& wave=physWaveContainer->
get
(chid,igain);
94
if
(wave.
isEmpty
())
continue
;
95
if
(
m_addCorrUndo
)
m_corrUndo
=0;
96
fillWave
(chid,wave);
//Fill method from base-class
97
m_timeOffset
= wave.
getTimeOffset
();
98
sc
=
ntupleSvc
()->writeRecord(
m_nt
);
99
if
(
sc
!=StatusCode::SUCCESS) {
100
ATH_MSG_ERROR
(
"writeRecord failed"
);
101
return
sc
;
102
}
103
}
//end loop over identifiers
104
}
//end loop over gains
105
106
if
(
m_addCorrUndo
) {
107
for
(
int
igain=
CaloGain::LARHIGHGAIN
;igain<
m_NGains
;++igain) {
108
LArPhysWaveContainer::ConstCorrectionIt
itUndo=physWaveContainer->
undoCorrBegin
(igain);
109
LArPhysWaveContainer::ConstCorrectionIt
itUndo_e=physWaveContainer->
undoCorrEnd
(igain);
110
for
(;itUndo!=itUndo_e;itUndo++) {
111
const
HWIdentifier
chid(itUndo->first);
112
const
LArPhysWave
& wave = itUndo->second;
113
m_gain
= (long)igain;
114
m_corrUndo
= 1;
115
fillWave
(chid,wave);
//Fill method from base-class
116
sc
=
ntupleSvc
()->writeRecord(
m_nt
);
117
if
(
sc
!=StatusCode::SUCCESS) {
118
ATH_MSG_ERROR
(
"writeRecord failed"
);
119
return
sc
;
120
}
121
}
//end loop over corrections
122
}
//end loop over gain
123
}
//end if addCorrUndo
124
}
//end loop over container keys
125
ATH_MSG_INFO
(
"LArWave2Ntuple has finished."
);
126
return
StatusCode::SUCCESS;
127
}
// end finalize-method.
128
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
CaloGain.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
LArPhysWaves2Ntuple.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition
ServiceAccessor.h:14
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
HWIdentifier
Definition
HWIdentifier.h:13
LArCond2NtupleBase::m_detStore
StoreGateSvc * m_detStore
Definition
LArCond2NtupleBase.h:84
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
LArConditionsContainer::correctionsApplied
bool correctionsApplied() const
Have corrections been applied?
LArConditionsContainer::applyCorrections
StatusCode applyCorrections()
apply correction set
LArConditionsContainer::undoCorrBegin
ConstCorrectionIt undoCorrBegin(unsigned int gain) const
get iterator over the Undo-Vector for a certain gain
LArConditionsContainer::undoCorrEnd
ConstCorrectionIt undoCorrEnd(unsigned int gain) const
LArConditionsContainer::get
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
get data with online identifier
LArConditionsContainer< LArPhysWave >::ConstCorrectionIt
Subset::ConstCorrectionVecIt ConstCorrectionIt
Definition
LArConditionsContainer.h:78
LArPhysWaveContainer
Liquid Argon Physics Wave Container.
Definition
LArPhysWaveContainer.h:23
LArPhysWave
Definition
LArPhysWave.h:14
LArPhysWave::getTimeOffset
int getTimeOffset() const
Definition
LArPhysWave.h:97
LArPhysWaves2Ntuple::initialize
StatusCode initialize()
Definition
LArPhysWaves2Ntuple.cxx:22
LArPhysWaves2Ntuple::m_keylist
std::vector< std::string > m_keylist
Definition
LArPhysWaves2Ntuple.h:42
LArPhysWaves2Ntuple::m_timeOffset
NTuple::Item< float > m_timeOffset
Definition
LArPhysWaves2Ntuple.h:49
LArPhysWaves2Ntuple::~LArPhysWaves2Ntuple
~LArPhysWaves2Ntuple()
LArPhysWaves2Ntuple::stop
virtual StatusCode stop()
Definition
LArPhysWaves2Ntuple.cxx:29
LArPhysWaves2Ntuple::m_addCorrUndo
bool m_addCorrUndo
Definition
LArPhysWaves2Ntuple.h:44
LArPhysWaves2Ntuple::m_corrUndo
NTuple::Item< long > m_corrUndo
Definition
LArPhysWaves2Ntuple.h:48
LArPhysWaves2Ntuple::LArPhysWaves2Ntuple
LArPhysWaves2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArPhysWaves2Ntuple.cxx:9
LArPhysWaves2Ntuple::m_ntName
std::string m_ntName
Definition
LArPhysWaves2Ntuple.h:43
LArPhysWaves2Ntuple::m_gain
NTuple::Item< long > m_gain
Definition
LArPhysWaves2Ntuple.h:47
LArPhysWaves2Ntuple::m_applyCorr
bool m_applyCorr
Definition
LArPhysWaves2Ntuple.h:44
LArWave::isEmpty
bool isEmpty() const
is LArWave uninitialized?
Definition
LArWave.h:183
LArWaves2Ntuple::initialize
StatusCode initialize()
Definition
LArWaves2Ntuple.cxx:18
LArWaves2Ntuple::LArWaves2Ntuple
LArWaves2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArWaves2Ntuple.cxx:9
LArWaves2Ntuple::fillWave
bool fillWave(const HWIdentifier chid, const LArWaveCumul &wave)
Definition
LArWaves2Ntuple.cxx:107
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition
CaloGain.h:18
Generated on
for ATLAS Offline Software by
1.17.0