ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibTools
src
LArMphysOverMcal2Ntuple.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 "
LArCalibTools/LArMphysOverMcal2Ntuple.h
"
6
#include "
CaloIdentifier/CaloGain.h
"
7
8
#include "
LArIdentifier/LArOnlineID.h
"
9
#include "
LArIdentifier/LArOnline_SuperCellID.h
"
10
11
12
LArMphysOverMcal2Ntuple::LArMphysOverMcal2Ntuple
(
const
std::string& name, ISvcLocator* pSvcLocator):
13
LArCond2NtupleBase
(name, pSvcLocator) {
14
m_ntTitle
=
"MphysOverMcal"
;
15
m_ntpath
=
"/NTUPLES/FILE1/MPMC"
;
16
17
}
18
19
LArMphysOverMcal2Ntuple::~LArMphysOverMcal2Ntuple
()
20
=
default
;
21
22
StatusCode
LArMphysOverMcal2Ntuple::initialize
() {
23
ATH_CHECK
(
m_contKey
.initialize());
24
return
LArCond2NtupleBase::initialize
();
25
}
26
27
28
StatusCode
LArMphysOverMcal2Ntuple::stop
() {
29
30
// For compatibility with existing configurations, look in the detector
31
// store first, then in conditions.
32
const
ILArMphysOverMcal
* larMphysOverMcal=
detStore
()->tryConstRetrieve<
ILArMphysOverMcal
>(
m_contKey
.key());
33
if
(!larMphysOverMcal) {
34
SG::ReadCondHandle<ILArMphysOverMcal>
mpmcHandle{
m_contKey
};
35
larMphysOverMcal=*mpmcHandle;
36
}
37
38
if
(!larMphysOverMcal) {
39
ATH_MSG_ERROR
(
"Unable to retrieve ILArMphysOverMcal with key "
40
<<
m_contKey
.key() <<
" from DetectorStore nor from ConditionsStore"
);
41
return
StatusCode::FAILURE;
42
}
43
44
45
46
StatusCode
sc
;
47
NTuple::Item<long> cellIndex,gain;
48
NTuple::Item<float> mpmc;
49
50
sc
=
m_nt
->addItem(
"icell"
,cellIndex,0,2000);
51
if
(
sc
!=StatusCode::SUCCESS)
52
{
ATH_MSG_ERROR
(
"addItem 'Cell Index' failed"
);
53
return
StatusCode::FAILURE;
54
}
55
56
sc
=
m_nt
->addItem(
"gain"
,gain,0,3);
57
if
(
sc
!=StatusCode::SUCCESS) {
58
ATH_MSG_ERROR
(
"addItem 'gain' failed"
);
59
return
StatusCode::FAILURE;
60
}
61
62
63
sc
=
m_nt
->addItem(
"mphysovermcal"
,mpmc,-1000.,2.);
64
if
(
sc
!=StatusCode::SUCCESS) {
65
ATH_MSG_ERROR
(
"addItem 'mphysovermcal' failed"
);
66
return
StatusCode::FAILURE;
67
}
68
69
70
const
LArOnOffIdMapping
*cabling=
nullptr
;
71
if
(
m_isSC
) {
72
ATH_MSG_DEBUG
(
"LArMphysOverMcal2Ntuple: using SC cabling"
);
73
SG::ReadCondHandle<LArOnOffIdMapping>
cablingHdl{
m_cablingSCKey
};
74
cabling=*cablingHdl;
75
}
else
{
76
ATH_MSG_DEBUG
(
"LArMphysOverMcal2Ntuple: using LAr cell cabling"
);
77
SG::ReadCondHandle<LArOnOffIdMapping>
cablingHdl{
m_cablingKey
};
78
cabling=*cablingHdl;
79
}
80
if
(!cabling) {
81
ATH_MSG_WARNING
(
"Do not have cabling object LArOnOffIdMapping"
);
82
return
StatusCode::FAILURE;
83
}
84
85
//=================
86
87
if
(
m_isSC
){
88
const
LArOnline_SuperCellID
* ll;
89
sc
=
detStore
()->retrieve(ll,
"LArOnline_SuperCellID"
);
90
if
(
sc
.isFailure()) {
91
msg
(MSG::ERROR) <<
"Could not get LArOnlineID helper !"
<<
endmsg
;
92
return
StatusCode::FAILURE;
93
}
94
else
{
95
m_onlineId
=
static_cast<
const
LArOnlineID_Base
*
>
(ll);
96
ATH_MSG_DEBUG
(
"Found the SC LArOnlineID helper"
);
97
}
98
}
else
{
99
const
LArOnlineID
* ll;
100
sc
=
detStore
()->retrieve(ll,
"LArOnlineID"
);
101
if
(
sc
.isFailure()) {
102
msg
(MSG::ERROR) <<
"Could not get LArOnlineID helper !"
<<
endmsg
;
103
return
StatusCode::FAILURE;
104
}
105
else
{
106
m_onlineId
=
static_cast<
const
LArOnlineID_Base
*
>
(ll);
107
ATH_MSG_DEBUG
(
" Found the LAr cell LArOnlineID helper. "
);
108
}
109
110
}
111
112
// ==============
113
114
unsigned
cellCounter=0;
115
unsigned
filledCell=0;
116
unsigned
nGain =
m_isSC
? 1 :
m_NGains
.value();
117
for
(
unsigned
igain=
CaloGain::LARHIGHGAIN
; igain<nGain; igain++) {
118
for
(
const
HWIdentifier
hwid:
m_onlineId
->channel_range()) {
119
if
( cabling->isOnlineConnected(hwid) && !
m_onlineId
->isFCALchannel(hwid)) {
120
fillFromIdentifier
(hwid);
121
cellIndex = cellCounter;
122
gain=igain;
123
mpmc = larMphysOverMcal->
MphysOverMcal
(hwid,igain);
124
sc
=
ntupleSvc
()->writeRecord(
m_nt
);
125
if
(
sc
!=StatusCode::SUCCESS) {
126
ATH_MSG_ERROR
(
"writeRecord failed"
);
127
return
StatusCode::FAILURE;
128
}
129
filledCell++;
130
}
//end if isConnected
131
cellCounter++;
132
}
//end loop over online ID
133
}
// ovr gains
134
ATH_MSG_INFO
(
"LArMphysOverMcal2Ntuple: filled "
<<filledCell<<
" out of "
<<cellCounter);
135
ATH_MSG_INFO
(
"LArMphysOverMcal2Ntuple has finished."
);
136
return
StatusCode::SUCCESS;
137
}
// end finalize-method.
138
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
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
LArMphysOverMcal2Ntuple.h
LArOnlineID.h
LArOnline_SuperCellID.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
ntupleSvc
INTupleSvc * ntupleSvc()
Definition
ServiceAccessor.h:14
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
ILArMphysOverMcal
Definition
ILArMphysOverMcal.h:13
ILArMphysOverMcal::MphysOverMcal
virtual const float & MphysOverMcal(const HWIdentifier &id, int gain) 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_NGains
Gaudi::Property< int > m_NGains
Definition
LArCond2NtupleBase.h:64
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
LArMphysOverMcal2Ntuple::LArMphysOverMcal2Ntuple
LArMphysOverMcal2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArMphysOverMcal2Ntuple.cxx:12
LArMphysOverMcal2Ntuple::stop
virtual StatusCode stop()
Definition
LArMphysOverMcal2Ntuple.cxx:28
LArMphysOverMcal2Ntuple::m_contKey
SG::ReadCondHandleKey< ILArMphysOverMcal > m_contKey
Definition
LArMphysOverMcal2Ntuple.h:37
LArMphysOverMcal2Ntuple::initialize
StatusCode initialize()
Definition
LArMphysOverMcal2Ntuple.cxx:22
LArMphysOverMcal2Ntuple::~LArMphysOverMcal2Ntuple
~LArMphysOverMcal2Ntuple()
LArOnOffIdMapping
Definition
LArOnOffIdMapping.h:20
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::LARHIGHGAIN
@ LARHIGHGAIN
Definition
CaloGain.h:18
Generated on
for ATLAS Offline Software by
1.17.0