ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1CaloCalibUtils
src
L1CaloLinearCalibration.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrigT1CaloCalibUtils/L1CaloLinearCalibration.h
"
6
7
#include "CoralBase/Blob.h"
8
#include "GaudiKernel/MsgStream.h"
9
#include "
AthenaPoolUtilities/CondAttrListCollection.h
"
10
#include "
AthenaPoolUtilities/AthenaAttributeList.h
"
11
12
#include "
TrigT1CaloCalibConditions/L1CaloCoolChannelId.h
"
13
#include "
TrigT1CaloCalibConditions/L1CaloRampDataContainer.h
"
14
#include "
TrigT1CaloCalibConditions/ChanFitErrorCode.h
"
15
#include "
TrigT1CaloCalibConditions/L1CaloEnergyScanResultsContainer.h
"
16
#include "
TrigT1CaloCalibConditions/L1CaloEnergyScanRunInfoContainer.h
"
17
18
#include <TF1.h>
19
#include <TGraphErrors.h>
20
21
L1CaloLinearCalibration::L1CaloLinearCalibration
(
const
std::string& name, ISvcLocator *pSvcLocator)
22
:
AthAlgorithm
(name, pSvcLocator),
23
m_l1CaloRampDataContainerKey
(
""
),
24
m_energyScanResultsContainer
(nullptr),
25
m_energyScanRunInfoContainer
(nullptr)
26
{
27
declareProperty
(
"L1CaloRampDataContainerKey"
,
m_l1CaloRampDataContainerKey
);
28
}
29
30
L1CaloLinearCalibration::~L1CaloLinearCalibration
()
31
{
32
}
33
34
StatusCode
L1CaloLinearCalibration::initialize
()
35
{
36
37
m_energyScanResultsContainer
.reset(
new
L1CaloEnergyScanResultsContainer
());
38
m_energyScanRunInfoContainer
.reset(
new
L1CaloEnergyScanRunInfoContainer
());
39
40
return
StatusCode::SUCCESS;
41
}
42
43
StatusCode
L1CaloLinearCalibration::execute
(
const
EventContext&
/*ctx*/
)
44
{
45
return
StatusCode::SUCCESS;
46
}
47
48
StatusCode
L1CaloLinearCalibration::finalize
()
49
{
50
StatusCode
sc
;
51
52
const
L1CaloRampDataContainer
*rampData;
53
sc
=
detStore
()->retrieve(rampData,
m_l1CaloRampDataContainerKey
);
54
if
(
sc
.isFailure()) {
55
msg
(MSG::FATAL) <<
"Could not retrieve L1CaloRampDataContainer."
<<
endmsg
;
56
return
sc
;
57
}
58
59
L1CaloRampDataContainer::const_iterator
it = rampData->
begin
();
60
L1CaloRampDataContainer::const_iterator
itEnd = rampData->
end
();
61
std::vector<double>
x
, ex,
y
, ey;
62
std::unique_ptr<TGraphErrors> graph(
nullptr
);
63
std::unique_ptr<TF1> func(
new
TF1(
"func"
,
"pol1"
, 5., 255.));
64
double
val(0.);
65
int
errCount = 0;
66
for
(; it != itEnd; ++it) {
67
x
.clear(); ex.clear();
y
.clear(); ey.clear();
68
func->SetParameters(0., 1.);
69
70
// we plot calo over adc. in this way the slope is the calibration constant
71
for
(
unsigned
int
step = 0; step < it->second.getNSteps(); ++step) {
72
// protection against NaN - don't have a better idea right now, suggestions welcome
73
val = it->second.getLevel1(step)->mean();
74
if
(val != val)
continue
;
75
val = it->second.getLevel1(step)->rms();
76
if
(val != val)
continue
;
77
val = it->second.getCalo(step)->mean();
78
if
(val != val)
continue
;
79
val = it->second.getCalo(step)->rms();
80
if
(val != val)
continue
;
81
82
if
(step && it->second.getLevel1(step)->mean() <
x
.back()) {
83
//msg(MSG::WARNING) << "Decreasing step energy - ignoring." << endmsg;
84
errCount++;
85
continue
;
86
}
87
88
x
.push_back(it->second.getLevel1(step)->mean());
89
// add the systematic error because of intrinsic resolution
90
ex.push_back(sqrt(it->second.getLevel1(step)->rms()*it->second.getLevel1(step)->rms() + 0.0052083333333333348));
91
y
.push_back(it->second.getCalo(step)->mean());
92
ey.push_back(it->second.getCalo(step)->rms());
93
}
94
graph.reset(
new
TGraphErrors(
x
.size(), &
x
.front(), &
y
.front(), &ex.front(), &ey.front()));
95
96
if
(graph->Fit(func.get(),
"QRF0"
) != 0) {
97
// if fit failed, don't store fit data for now
98
L1CaloEnergyScanResults
energyScanResults(it->first,
99
0.,
100
-1.,
101
-1.,
102
1,
103
coral::Blob(0),
104
L1CaloEnergyScanResults::NotUsed
,
105
ChanFitErrorCode
(0x1));
106
m_energyScanResultsContainer
->addEnergyScanResults(it->first, energyScanResults);
107
}
else
{
108
L1CaloEnergyScanResults
energyScanResults(it->first,
109
func->GetParameter(0),
110
func->GetParameter(1),
111
func->GetChisquare(),
112
func->GetNDF(),
113
coral::Blob(0),
114
L1CaloEnergyScanResults::NotUsed
,
115
ChanFitErrorCode
(0x0));
116
m_energyScanResultsContainer
->addEnergyScanResults(it->first, energyScanResults);
117
}
118
}
119
120
if
(errCount > 0) {
121
msg
(MSG::WARNING) <<
"Decreasing step energy - ignoring. ("
122
<< errCount <<
" occurances)"
<<
endmsg
;
123
}
124
125
sc
=
detStore
()->record(
dynamic_cast<
CondAttrListCollection
*
>
(
m_energyScanResultsContainer
->makePersistent()),
126
m_energyScanResultsContainer
->coolOutputKey());
127
if
(
sc
.isFailure()) {
128
msg
(MSG::FATAL) <<
"Could not record EnergyScanResultsContainer."
<<
endmsg
;
129
return
sc
;
130
}
131
m_energyScanRunInfoContainer
->setRunNumber(rampData->
runNumber
());
132
m_energyScanRunInfoContainer
->setGainStrategy(rampData->
gainStrategy
());
133
sc
=
detStore
()->record(
dynamic_cast<
AthenaAttributeList
*
>
(
m_energyScanRunInfoContainer
->makePersistent()),
134
m_energyScanRunInfoContainer
->coolOutputKey());
135
if
(
sc
.isFailure()) {
136
msg
(MSG::FATAL) <<
"Could not record EnergyScanRunInfoContainer."
<<
endmsg
;
137
return
sc
;
138
}
139
140
return
StatusCode::SUCCESS;
141
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
AthenaAttributeList.h
ChanFitErrorCode.h
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
L1CaloCoolChannelId.h
L1CaloEnergyScanResultsContainer.h
L1CaloEnergyScanRunInfoContainer.h
L1CaloLinearCalibration.h
L1CaloRampDataContainer.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
y
#define y
x
#define x
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
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table.
Definition
PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:46
ChanFitErrorCode
ChanFitErrorCode stores information about the calibration fit quality.
Definition
ChanFitErrorCode.h:17
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number.
Definition
CondAttrListCollection.h:51
L1CaloEnergyScanResultsContainer
Container of L1CaloEnergyScanResults objects, inherit from the abstract base class AbstractL1CaloCond...
Definition
L1CaloEnergyScanResultsContainer.h:28
L1CaloEnergyScanResults
Class that holds transient information about the calibration for trigger towers.
Definition
L1CaloEnergyScanResults.h:19
L1CaloEnergyScanResults::NotUsed
@ NotUsed
Definition
L1CaloEnergyScanResults.h:22
L1CaloEnergyScanRunInfoContainer
Container of L1CaloEnergyScanRunInfo metadata, inherit from the abstract base class AbstractL1CaloCon...
Definition
L1CaloEnergyScanRunInfoContainer.h:28
L1CaloLinearCalibration::m_energyScanResultsContainer
std::unique_ptr< L1CaloEnergyScanResultsContainer > m_energyScanResultsContainer
Definition
L1CaloLinearCalibration.h:42
L1CaloLinearCalibration::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
L1CaloLinearCalibration.cxx:43
L1CaloLinearCalibration::finalize
StatusCode finalize()
Definition
L1CaloLinearCalibration.cxx:48
L1CaloLinearCalibration::m_l1CaloRampDataContainerKey
std::string m_l1CaloRampDataContainerKey
Definition
L1CaloLinearCalibration.h:40
L1CaloLinearCalibration::~L1CaloLinearCalibration
virtual ~L1CaloLinearCalibration()
Definition
L1CaloLinearCalibration.cxx:30
L1CaloLinearCalibration::m_energyScanRunInfoContainer
std::unique_ptr< L1CaloEnergyScanRunInfoContainer > m_energyScanRunInfoContainer
Definition
L1CaloLinearCalibration.h:43
L1CaloLinearCalibration::initialize
StatusCode initialize()
Definition
L1CaloLinearCalibration.cxx:34
L1CaloLinearCalibration::L1CaloLinearCalibration
L1CaloLinearCalibration(const std::string &name, ISvcLocator *pSvcLocator)
Definition
L1CaloLinearCalibration.cxx:21
L1CaloRampDataContainer
Container of L1CaloRampData objects.
Definition
L1CaloRampDataContainer.h:23
L1CaloRampDataContainer::runNumber
unsigned int runNumber() const
Definition
L1CaloRampDataContainer.h:43
L1CaloRampDataContainer::gainStrategy
const std::string & gainStrategy() const
Definition
L1CaloRampDataContainer.h:44
L1CaloRampDataContainer::const_iterator
L1CaloRampDataMap::const_iterator const_iterator
Definition
L1CaloRampDataContainer.h:26
L1CaloRampDataContainer::end
const_iterator end() const
Definition
L1CaloRampDataContainer.h:41
L1CaloRampDataContainer::begin
const_iterator begin() const
Definition
L1CaloRampDataContainer.h:40
Generated on
for ATLAS Offline Software by
1.17.0