ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibTools
src
LAruA2MeV2Ntuple.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/LAruA2MeV2Ntuple.h
"
6
#include "
LArElecCalib/ILAruA2MeV.h
"
7
#include "
LArElecCalib/ILArDAC2uA.h
"
8
#include "
CaloIdentifier/CaloGain.h
"
9
#include "
LArIdentifier/LArOnlineID.h
"
10
#include "
StoreGate/StoreGateSvc.h
"
11
12
LAruA2MeV2Ntuple::LAruA2MeV2Ntuple
(
const
std::string& name, ISvcLocator* pSvcLocator):
LArCond2NtupleBase
(name, pSvcLocator) {
13
m_ntTitle
=
"ADC to Mev Conversion"
;
14
m_ntpath
=
"/NTUPLES/FILE1/ADCMEV"
;
15
16
}
17
18
StatusCode
LAruA2MeV2Ntuple::initialize
() {
19
ATH_CHECK
(
m_uA2MeVKey
.initialize(
SG::AllowEmpty
));
20
ATH_CHECK
(
m_DAC2uAKey
.initialize(
SG::AllowEmpty
));
21
22
if
(
m_uA2MeVKey
.empty() and
m_DAC2uAKey
.empty()) {
23
ATH_MSG_ERROR
(
"Configuration problem: Both uA2MeVKey and DACuAKey are emtpy"
);
24
return
StatusCode::FAILURE;
25
}
26
return
LArCond2NtupleBase::initialize
();
27
}
28
29
LAruA2MeV2Ntuple::~LAruA2MeV2Ntuple
()
30
=
default
;
31
32
StatusCode
LAruA2MeV2Ntuple::stop
() {
33
StatusCode
sc
;
34
NTuple::Item<long> cellIndex;
35
NTuple::Item<float> uA2MeV;
36
NTuple::Item<float> DAC2uA;
37
38
sc
=
m_nt
->addItem(
"icell"
,cellIndex,0,2000);
39
if
(
sc
!=StatusCode::SUCCESS) {
40
ATH_MSG_ERROR
(
"addItem 'Cell Index' failed"
);
41
return
StatusCode::FAILURE;
42
}
43
44
if
(!
m_uA2MeVKey
.empty()) {
45
sc
=
m_nt
->addItem(
"uAMeV"
,uA2MeV,-1000.,5000.);
46
if
(
sc
!=StatusCode::SUCCESS) {
47
ATH_MSG_ERROR
(
"addItem 'uAMeV' failed"
);
48
return
StatusCode::FAILURE;
49
}
50
}
51
52
if
(!
m_DAC2uAKey
.empty()) {
53
sc
=
m_nt
->addItem(
"DAC2uA"
,DAC2uA,-1000.,5000.);
54
if
(
sc
!=StatusCode::SUCCESS) {
55
ATH_MSG_ERROR
(
"addItem 'DAC2uA' failed"
);
56
return
StatusCode::FAILURE;
57
}
58
}
59
60
// For compatibility with existing configurations, look in the detector
61
// store first, then in conditions store.
62
const
ILAruA2MeV
* laruA2MeVComplete=
nullptr
;
63
if
(!
m_uA2MeVKey
.empty()) {
64
laruA2MeVComplete=
detStore
()->tryRetrieve<
ILAruA2MeV
>(
m_uA2MeVKey
.key());
65
if
(!laruA2MeVComplete) {
66
SG::ReadCondHandle<ILAruA2MeV>
ua2MeVHdl{
m_uA2MeVKey
};
67
laruA2MeVComplete=*ua2MeVHdl;
68
}
69
if
(!laruA2MeVComplete) {
70
ATH_MSG_ERROR
(
"Failed to retrieve ILAruA2MeV with key "
71
<<
m_uA2MeVKey
.key() <<
"from DetectorStore nor from ConditonsStore"
);
72
return
StatusCode::FAILURE;
73
}
74
}
75
76
const
ILArDAC2uA
* larDAC2uAComplete=
nullptr
;
77
if
(!
m_DAC2uAKey
.empty()) {
78
larDAC2uAComplete=
detStore
()->tryRetrieve<
ILArDAC2uA
>(
m_DAC2uAKey
.key());
79
if
(!larDAC2uAComplete) {
80
SG::ReadCondHandle<ILArDAC2uA>
DAC2uAHdl{
m_DAC2uAKey
};
81
larDAC2uAComplete=*DAC2uAHdl;
82
}
83
if
(!larDAC2uAComplete) {
84
ATH_MSG_ERROR
(
"Failed to retrieve ILArDAC2uA with key "
85
<<
m_DAC2uAKey
.key() <<
"from DetectorStore nor from ConditonsStore"
);
86
return
StatusCode::FAILURE;
87
}
88
}
89
90
const
LArOnOffIdMapping
* cabling=
nullptr
;
91
if
(
m_isSC
) {
92
SG::ReadCondHandle<LArOnOffIdMapping>
cablingHdl{
m_cablingSCKey
};
93
cabling=*cablingHdl;
94
}
else
{
95
SG::ReadCondHandle<LArOnOffIdMapping>
cablingHdl{
m_cablingKey
};
96
cabling=*cablingHdl;
97
}
98
if
(!cabling) {
99
ATH_MSG_WARNING
(
"Do not have cabling object LArOnOffIdMapping"
);
100
return
StatusCode::FAILURE;
101
}
102
103
unsigned
cellCounter=0;
104
for
(
const
HWIdentifier
hwid:
m_onlineId
->channel_range()) {
105
if
(cabling->isOnlineConnected(hwid)) {
106
if
(laruA2MeVComplete) uA2MeV=laruA2MeVComplete->
UA2MEV
(hwid);
107
if
(larDAC2uAComplete) DAC2uA=larDAC2uAComplete->
DAC2UA
(hwid);
108
fillFromIdentifier
(hwid);
109
cellIndex=cellCounter;
110
sc
=
ntupleSvc
()->writeRecord(
m_nt
);
111
112
if
(
sc
!=StatusCode::SUCCESS) {
113
ATH_MSG_ERROR
(
"writeRecord failed"
);
114
return
StatusCode::FAILURE;
115
}
116
cellCounter++;
117
}
//end if connected
118
}
//end loop over online ID
119
120
ATH_MSG_INFO
(
"LAruA2MeV2Ntuple has finished."
);
121
return
StatusCode::SUCCESS;
122
}
// end finalize-method.
123
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:47
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
CaloGain.h
ILArDAC2uA.h
ILAruA2MeV.h
LArOnlineID.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
LAruA2MeV2Ntuple.h
ntupleSvc
INTupleSvc * ntupleSvc()
Definition
ServiceAccessor.h:14
StoreGateSvc.h
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
HWIdentifier
Definition
HWIdentifier.h:13
ILArDAC2uA
Definition
ILArDAC2uA.h:13
ILArDAC2uA::DAC2UA
virtual const float & DAC2UA(const HWIdentifier &id) const =0
access to DAC2UA conversion factor index by Identifier, and gain setting
ILAruA2MeV
Definition
ILAruA2MeV.h:13
ILAruA2MeV::UA2MEV
virtual const float & UA2MEV(const HWIdentifier &id) const =0
LArCond2NtupleBase::initialize
StatusCode initialize()
Definition
LArCond2NtupleBase.cxx:33
LArCond2NtupleBase::m_isSC
Gaudi::Property< bool > m_isSC
Definition
LArCond2NtupleBase.h:57
LArCond2NtupleBase::m_cablingSCKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingSCKey
Definition
LArCond2NtupleBase.h:93
LArCond2NtupleBase::m_ntTitle
std::string m_ntTitle
Definition
LArCond2NtupleBase.h:68
LArCond2NtupleBase::m_nt
NTuple::Tuple * m_nt
Definition
LArCond2NtupleBase.h:71
LArCond2NtupleBase::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition
LArCond2NtupleBase.h:92
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
LArOnOffIdMapping
Definition
LArOnOffIdMapping.h:20
LAruA2MeV2Ntuple::stop
virtual StatusCode stop()
Definition
LAruA2MeV2Ntuple.cxx:32
LAruA2MeV2Ntuple::~LAruA2MeV2Ntuple
~LAruA2MeV2Ntuple()
LAruA2MeV2Ntuple::LAruA2MeV2Ntuple
LAruA2MeV2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LAruA2MeV2Ntuple.cxx:12
LAruA2MeV2Ntuple::initialize
StatusCode initialize()
Definition
LAruA2MeV2Ntuple.cxx:18
LAruA2MeV2Ntuple::m_uA2MeVKey
SG::ReadCondHandleKey< ILAruA2MeV > m_uA2MeVKey
Definition
LAruA2MeV2Ntuple.h:36
LAruA2MeV2Ntuple::m_DAC2uAKey
SG::ReadCondHandleKey< ILArDAC2uA > m_DAC2uAKey
Definition
LAruA2MeV2Ntuple.h:37
SG::ReadCondHandle
Definition
ReadCondHandle.h:39
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
Generated on
for ATLAS Offline Software by
1.17.0