ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArSamplesMon
src
LArShapeCompleteMaker.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LArSamplesMon/LArShapeCompleteMaker.h
"
6
7
#include "
CaloIdentifier/CaloGain.h
"
8
#include "
LArCafJobs/DataStore.h
"
9
#include "
LArSamplesMon/TreeShapeErrorGetter.h
"
10
11
#include "
LArIdentifier/LArOnlineID.h
"
12
#include "
StoreGate/StoreGateSvc.h
"
13
#include "
StoreGate/ReadCondHandle.h
"
14
#include "GaudiKernel/MsgStream.h"
15
#include "
LArRawConditions/LArShapeComplete.h
"
16
#include "
LArSamplesMon/ShapeErrorData.h
"
17
#include "
LArCafJobs/DataContainer.h
"
18
#include "
LArSamplesMon/History.h
"
19
#include "
LArCafJobs/EventData.h
"
20
#include <memory>
21
22
using namespace
LArSamples
;
23
24
LArShapeCompleteMaker::LArShapeCompleteMaker
(
const
std::string & name, ISvcLocator * pSvcLocator) :
25
AthAlgorithm
(name, pSvcLocator),
26
m_template
(nullptr),
27
m_dumperTool
(
"LArShapeDumperTool"
)
28
{
29
declareProperty
(
"NSamples"
,
m_nSamples
= 5);
30
declareProperty
(
"NPhases"
,
m_nPhases
= 17);
31
declareProperty
(
"IPhase"
,
m_iPhase
= 8);
32
declareProperty
(
"ShapeErrorFileName"
,
m_shapeErrorFileName
);
33
declareProperty
(
"OutputFileName"
,
m_outputFileName
);
34
declareProperty
(
"OutputTemplateFileName"
,
m_outputTemplateFileName
);
35
declareProperty
(
"StoreGateKey"
,
m_sgKey
=
"LArResiduals"
);
36
declareProperty
(
"MinNPulses"
,
m_minNPulses
= 0);
37
declareProperty
(
"GroupingType"
,
m_groupingType
=
"ExtendedSubDetector"
);
38
}
39
40
41
LArShapeCompleteMaker::~LArShapeCompleteMaker
()
42
{
43
}
44
45
46
StatusCode
LArShapeCompleteMaker::initialize
()
47
{
48
49
ATH_CHECK
(
detStore
()->retrieve(
m_onlineHelper
,
"LArOnlineID"
));
50
51
ATH_CHECK
(
m_onOffMapKey
.initialize() );
52
53
return
StatusCode::SUCCESS;
54
}
55
56
57
StatusCode
LArShapeCompleteMaker::execute
(
const
EventContext& ctx)
58
{
59
if
(
m_template
)
return
StatusCode::SUCCESS;
60
m_template
=
new
DataStore
();
61
62
auto
lsc = std::make_unique<LArShapeComplete>();
63
64
if
(lsc->setGroupingType(
m_groupingType
,
msg
()).isFailure() || lsc->initialize().isFailure()) {
65
ATH_MSG_ERROR
(
"Unable to initialize LArShapeComplete"
);
66
return
StatusCode::FAILURE;
67
};
68
69
SG::ReadCondHandle<LArOnOffIdMapping>
onOffMap (
m_onOffMapKey
, ctx);
70
71
auto
errorGetter = std::make_unique<TreeShapeErrorGetter>(
m_shapeErrorFileName
);
72
73
for
(
unsigned
int
k = 0; k <
LArSamples::Definitions::nChannels
; k++) {
74
75
HWIdentifier
channelID =
m_onlineHelper
->channel_Id((
IdentifierHash
)k);
76
const
Identifier
id
= onOffMap->cnvToIdentifier(channelID);
77
if
(
id
.get_compact() == 0xffffffff) {
78
ATH_MSG_WARNING
(
"Skipping invalid hash = "
<< k <<
"."
);
79
continue
;
80
}
81
82
CellInfo
* info =
m_dumperTool
->makeCellInfo(channelID,
id
);
83
if
(!info) {
84
ATH_MSG_ERROR
(
"Problem making cell info for hash = "
<< k <<
", terminating..."
);
85
return
StatusCode::FAILURE;
86
}
87
88
HistoryContainer
* histCont =
m_template
->makeNewHistory(k, info);
89
std::vector<std::unique_ptr<const EventData> > events;
90
for
(
unsigned
int
g = 0; g < 3; g++) {
91
DataContainer
* data =
new
DataContainer
((
CaloGain::CaloGain
)g, std::vector<short>(), 0, 0, 0, -1, std::vector<float>());
92
events.push_back(std::make_unique<EventData>(-1,-1,-1,-1));
93
histCont->
add
(data);
94
}
95
History
* history =
new
History
(*histCont, std::move(events), k, errorGetter.get());
96
97
for
(
unsigned
int
g = 0; g < 3; g++) {
98
CaloGain::CaloGain
gain = (
CaloGain::CaloGain
)g;
99
std::unique_ptr<const LArSamples::ShapeErrorData> sed;
100
if
(history) sed = history->
shapeErrorData
(gain,
LArSamples::BestShapeError
);
101
102
// The containers
103
104
// Fill them with 0's to start with
105
std::vector<float> phaseVect(
m_nSamples
,0);
106
std::vector<std::vector<float> > deltaVal(
m_nPhases
, phaseVect);
107
std::vector<std::vector<float> > deltaDer(
m_nPhases
, phaseVect);
108
109
110
if
(sed && sed->
n
() >
m_minNPulses
) {
111
ATH_MSG_DEBUG
(
"--> Setting channel "
<< k <<
", id = "
<< channelID <<
", gain = "
<< gain <<
", size = "
112
<< deltaVal.size() <<
" "
<< deltaDer.size());
113
for
(
unsigned
int
i = 0; i <
m_nSamples
; i++) {
114
deltaVal[
m_iPhase
][i] = sed->
xi
()(i);
115
deltaDer[
m_iPhase
][i] = sed->
xip
()(i);
116
ATH_MSG_DEBUG
(
" xi["
<< i <<
" ] = "
<< deltaVal[
m_iPhase
][i]);
117
}
118
}
119
else
{
120
ATH_MSG_DEBUG
(
"--> No information for channel "
<< k<<
", id = "
<< channelID <<
", gain = "
<< gain);
121
}
122
lsc->set(channelID, gain, deltaVal, deltaDer);
123
}
124
delete
history;
125
}
126
127
ATH_MSG_INFO
(
"Writing LArShapeComplete output to "
<<
m_outputFileName
);
128
//TFile* out = TFile::Open(m_outputFileName.c_str(), "RECREATE");
129
//out->WriteObjectAny(lsc, "LArShapeComplete", "LArShape");
130
//delete out;
131
if
(
detStore
()->record(std::move(lsc),
m_sgKey
).isFailure()) {
132
ATH_MSG_ERROR
(
"Unable to write LArShapeComplete"
);
133
return
StatusCode::FAILURE;
134
};
135
136
ATH_MSG_INFO
(
"Done!"
);
137
138
return
StatusCode::SUCCESS;
139
}
140
141
142
StatusCode
LArShapeCompleteMaker::finalize
()
143
{
144
ATH_MSG_INFO
(
"Writing template..."
);
145
m_template
->writeTrees(
m_outputTemplateFileName
.c_str());
146
ATH_MSG_INFO
(
"done..."
);
147
return
StatusCode::SUCCESS;
148
}
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
DataContainer.h
EventData.h
History.h
DataStore.h
LArOnlineID.h
LArShapeCompleteMaker.h
LArShapeComplete.h
ReadCondHandle.h
ShapeErrorData.h
StoreGateSvc.h
TreeShapeErrorGetter.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
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
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
HWIdentifier
Definition
HWIdentifier.h:13
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
LArSamples::CellInfo
Definition
CellInfo.h:31
LArSamples::DataContainer
Definition
DataContainer.h:25
LArSamples::DataStore
storage of the time histories of all the cells
Definition
LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:32
LArSamples::HistoryContainer
Definition
HistoryContainer.h:29
LArSamples::HistoryContainer::add
void add(const DataContainer *data)
append data (takes ownership)
Definition
HistoryContainer.h:46
LArSamples::History
Definition
History.h:36
LArSamples::History::shapeErrorData
std::unique_ptr< const ShapeErrorData > shapeErrorData(CaloGain::CaloGain gain, ShapeErrorType shapeErrorType=BestShapeError, const Residual *res=0) const
Definition
History.cxx:293
LArSamples::ShapeErrorData::xi
const TVectorD & xi() const
Definition
ShapeErrorData.h:40
LArSamples::ShapeErrorData::xip
const TVectorD & xip() const
Definition
ShapeErrorData.h:41
LArSamples::ShapeErrorData::n
int n() const
Definition
ShapeErrorData.h:54
LArShapeCompleteMaker::m_outputTemplateFileName
std::string m_outputTemplateFileName
Definition
LArShapeCompleteMaker.h:51
LArShapeCompleteMaker::m_shapeErrorFileName
std::string m_shapeErrorFileName
Definition
LArShapeCompleteMaker.h:51
LArShapeCompleteMaker::m_dumperTool
ToolHandle< ILArShapeDumperTool > m_dumperTool
Definition
LArShapeCompleteMaker.h:47
LArShapeCompleteMaker::~LArShapeCompleteMaker
~LArShapeCompleteMaker()
Definition
LArShapeCompleteMaker.cxx:41
LArShapeCompleteMaker::m_groupingType
std::string m_groupingType
Definition
LArShapeCompleteMaker.h:52
LArShapeCompleteMaker::m_nSamples
unsigned int m_nSamples
Definition
LArShapeCompleteMaker.h:49
LArShapeCompleteMaker::m_sgKey
std::string m_sgKey
Definition
LArShapeCompleteMaker.h:51
LArShapeCompleteMaker::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition
LArShapeCompleteMaker.h:43
LArShapeCompleteMaker::m_nPhases
unsigned int m_nPhases
Definition
LArShapeCompleteMaker.h:49
LArShapeCompleteMaker::m_onOffMapKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_onOffMapKey
Definition
LArShapeCompleteMaker.h:55
LArShapeCompleteMaker::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
LArShapeCompleteMaker.cxx:57
LArShapeCompleteMaker::m_template
LArSamples::DataStore * m_template
Definition
LArShapeCompleteMaker.h:45
LArShapeCompleteMaker::m_outputFileName
std::string m_outputFileName
Definition
LArShapeCompleteMaker.h:51
LArShapeCompleteMaker::m_iPhase
unsigned int m_iPhase
Definition
LArShapeCompleteMaker.h:49
LArShapeCompleteMaker::finalize
virtual StatusCode finalize() override
Definition
LArShapeCompleteMaker.cxx:142
LArShapeCompleteMaker::m_minNPulses
int m_minNPulses
Definition
LArShapeCompleteMaker.h:50
LArShapeCompleteMaker::initialize
virtual StatusCode initialize() override
Definition
LArShapeCompleteMaker.cxx:46
LArShapeCompleteMaker::LArShapeCompleteMaker
LArShapeCompleteMaker(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArShapeCompleteMaker.cxx:24
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
CaloGain::CaloGain
CaloGain
Definition
CaloGain.h:11
Identifier
Definition
IdentifierFieldParser.cxx:14
LArSamples
Definition
AbsShape.h:24
LArSamples::BestShapeError
@ BestShapeError
Definition
LArCalorimeter/LArCafJobs/LArCafJobs/Definitions.h:26
LArSamples::Definitions::nChannels
static const unsigned int nChannels
Definition
LArCalorimeter/LArCafJobs/LArCafJobs/Definitions.h:14
Generated on
for ATLAS Offline Software by
1.17.0