ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibTools
src
LArOFC2Ntuple.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LArCalibTools/LArOFC2Ntuple.h
"
6
#include "
CaloIdentifier/CaloGain.h
"
7
#include "
LArIdentifier/LArOnlineID.h
"
8
#include "
StoreGate/ReadCondHandle.h
"
9
#include "GaudiKernel/ThreadLocalContext.h"
10
11
LArOFC2Ntuple::LArOFC2Ntuple
(
const
std::string& name, ISvcLocator* pSvcLocator):
12
LArCond2NtupleBase
(name, pSvcLocator)
13
{
14
declareProperty
(
"Nsamples"
,
m_nSamples
= 5);
15
declareProperty
(
"NtupleName"
,
m_ntName
=
"OFC"
);
16
declareProperty
(
"NtupleFile"
,
m_ntFile
=
"FILE1"
);
17
}
18
19
LArOFC2Ntuple::~LArOFC2Ntuple
()
20
=
default
;
21
22
StatusCode
LArOFC2Ntuple::initialize
() {
23
m_ntTitle
=
"Optimal Filtering Coefficients"
;
24
m_ntpath
=std::string(
"/NTUPLES/"
)+
m_ntFile
+std::string(
"/"
)+
m_ntName
;
25
26
ATH_CHECK
(
m_ofcKey
.initialize() );
27
28
ATH_CHECK
(
LArCond2NtupleBase::initialize
() );
29
return
StatusCode::SUCCESS;
30
}
31
32
StatusCode
LArOFC2Ntuple::stop
() {
33
const
EventContext& ctx = Gaudi::Hive::currentContext();
34
35
// Ntuple booking: Specific
36
NTuple::Item<long> gain, phase, nSamples;
37
NTuple::Item<float> timeOffset, phasetime;
38
NTuple::Array<float> OFCa, OFCb;
39
40
ATH_CHECK
(
m_nt
->addItem(
"Gain"
,gain,-1,2) );
41
ATH_CHECK
(
m_nt
->addItem(
"TimeOffset"
,timeOffset,0,100) );
42
ATH_CHECK
(
m_nt
->addItem(
"Phase"
,phase,0,49) );
43
ATH_CHECK
(
m_nt
->addItem(
"PhaseTime"
,phasetime,0,800) );
44
ATH_CHECK
(
m_nt
->addItem(
"nSamples"
,nSamples,0,100) );
45
ATH_CHECK
(
m_nt
->addItem(
"OFCa"
,
m_nSamples
,OFCa) );
46
ATH_CHECK
(
m_nt
->addItem(
"OFCb"
,
m_nSamples
,OFCb) );
47
48
// retrieve OFC object
49
const
ILArOFC
* larOFC=
nullptr
;
50
51
//Try Det-Store (real data, elec-calib case)
52
if
(
detStore
()->
contains<ILArOFC>
(
m_ofcKey
.key())) {
53
ATH_CHECK
(
detStore
()->retrieve(larOFC,
m_ofcKey
.key()));
54
}
55
else
{
//Via ReadCondHandle from CondStore (MC case)
56
SG::ReadCondHandle<ILArOFC>
larOFCHdl (
m_ofcKey
, ctx);
57
larOFC=larOFCHdl.
cptr
();
58
}
59
60
const
LArOnOffIdMapping
*cabling=
nullptr
;
61
if
(
m_isSC
) {
62
ATH_MSG_DEBUG
(
"LArOFC2Ntuple: using SC cabling"
);
63
SG::ReadCondHandle<LArOnOffIdMapping>
cablingHdl{
m_cablingSCKey
, ctx};
64
cabling=*cablingHdl;
65
}
else
{
66
SG::ReadCondHandle<LArOnOffIdMapping>
cablingHdl{
m_cablingKey
, ctx};
67
cabling=*cablingHdl;
68
}
69
70
71
if
(!cabling) {
72
ATH_MSG_WARNING
(
"Do not have cabling object LArOnOffIdMapping"
);
73
return
StatusCode::FAILURE;
74
}
75
76
unsigned
cellCounter=0;
77
auto
maxgain =
m_NGains
.value();
78
if
(
m_isSC
) maxgain=
CaloGain::LARMEDIUMGAIN
;
79
80
for
(
int
igain=
CaloGain::LARHIGHGAIN
;
81
igain<maxgain ; ++igain )
82
{
83
for
(
HWIdentifier
chid :
m_onlineId
->channel_range()) {
84
if
( !cabling->isOnlineConnected(chid))
continue
;
85
ATH_MSG_VERBOSE
(
"Dumping OFC for channel 0x"
<< MSG::hex
86
<< chid.get_compact() << MSG::dec );
87
for
(
unsigned
iphase=0;iphase<larOFC->
nTimeBins
(chid,igain);iphase++) {
88
ILArOFC::OFCRef_t
ofc_a=larOFC->
OFC_a
(chid,igain,iphase);
89
//Check if we have OFC for this channel and gain
90
if
(!ofc_a.size())
break
;
//No more phases
91
ILArOFC::OFCRef_t
ofc_b=larOFC->
OFC_b
(chid,igain,iphase);
92
fillFromIdentifier
(chid);
93
gain = (long)igain ;
94
phase = (long)iphase ;
95
nSamples=ofc_a.size();
96
for
(
int
k=0;k<nSamples;k++ ) {
97
OFCa[k] = ofc_a[k] ;
98
OFCb[k] = ofc_b[k] ;
99
}
100
101
timeOffset = larOFC->
timeOffset
(chid,igain);
102
phasetime = phase*larOFC->
timeBinWidth
(chid,igain);
103
104
105
ATH_CHECK
(
ntupleSvc
()->writeRecord(
m_nt
) );
106
cellCounter++;
107
}
//loop over phases
108
}
//loop over channels
109
}
//loop over gains
110
ATH_MSG_INFO
(
"Total number of cells = "
<< cellCounter );
111
ATH_MSG_INFO
(
"LArOFC2Ntuple has finished."
);
112
return
StatusCode::SUCCESS;
113
}
// end finalize-method.
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
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
LArOFC2Ntuple.h
LArOnlineID.h
ReadCondHandle.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
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
HWIdentifier
Definition
HWIdentifier.h:13
ILArOFC
Definition
ILArOFC.h:14
ILArOFC::OFC_b
virtual OFCRef_t OFC_b(const HWIdentifier &id, int gain, int tbin=0) const =0
ILArOFC::nTimeBins
virtual unsigned nTimeBins(const HWIdentifier &CellID, int gain) const =0
ILArOFC::OFC_a
virtual OFCRef_t OFC_a(const HWIdentifier &id, int gain, int tbin=0) const =0
access to OFCs by online ID, gain, and tbin (!=0 for testbeam)
ILArOFC::timeBinWidth
virtual float timeBinWidth(const HWIdentifier &CellID, int gain) const =0
ILArOFC::OFCRef_t
LArVectorProxy OFCRef_t
This class defines the interface for accessing Optimal Filtering coefficients for each channel provid...
Definition
ILArOFC.h:26
ILArOFC::timeOffset
virtual float timeOffset(const HWIdentifier &CellID, 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
LArOFC2Ntuple::m_nSamples
unsigned m_nSamples
Definition
LArOFC2Ntuple.h:38
LArOFC2Ntuple::~LArOFC2Ntuple
virtual ~LArOFC2Ntuple()
LArOFC2Ntuple::m_ntName
std::string m_ntName
Definition
LArOFC2Ntuple.h:39
LArOFC2Ntuple::LArOFC2Ntuple
LArOFC2Ntuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArOFC2Ntuple.cxx:11
LArOFC2Ntuple::m_ntFile
std::string m_ntFile
Definition
LArOFC2Ntuple.h:40
LArOFC2Ntuple::stop
virtual StatusCode stop() override
Definition
LArOFC2Ntuple.cxx:32
LArOFC2Ntuple::m_ofcKey
SG::ReadCondHandleKey< ILArOFC > m_ofcKey
Definition
LArOFC2Ntuple.h:44
LArOFC2Ntuple::initialize
virtual StatusCode initialize() override
Definition
LArOFC2Ntuple.cxx:22
LArOnOffIdMapping
Definition
LArOnOffIdMapping.h:20
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition
ReadCondHandle.h:67
contains
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Definition
hcg.cxx:116
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition
CaloGain.h:18
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition
CaloGain.h:18
Generated on
for ATLAS Offline Software by
1.17.0