ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDMaker
CaloD3PDMaker
src
ClusterEMSamplingFillerTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// $Id$
12
13
14
#include "
ClusterEMSamplingFillerTool.h
"
15
#include "CaloEvent/CaloCluster.h"
16
#include "
AthenaKernel/errorcheck.h
"
17
#include <sstream>
18
19
20
namespace
D3PD
{
21
22
29
ClusterEMSamplingFillerTool::ClusterEMSamplingFillerTool
30
(
const
std::string&
type
,
31
const
std::string& name,
32
const
IInterface* parent)
33
:
Base
(
type
, name, parent)
34
{
35
declareProperty (
"WriteEnergy"
,
m_writeEnergy
=
true
,
36
"Should energies be written?"
);
37
declareProperty (
"WriteEta"
,
m_writeEta
=
true
,
38
"Should eta values be written?"
);
39
declareProperty (
"WritePhi"
,
m_writePhi
=
true
,
40
"Should phi values be written?"
);
41
declareProperty (
"Samplings"
,
m_samplings
,
42
"List of samplings to write (in the range 0-3). "
43
"An empty list means to write everything."
);
44
45
std::fill (
m_Es
,
m_Es
+
NEMSAMP
, (
float
*)0);
46
std::fill (
m_etas
,
m_etas
+
NEMSAMP
, (
float
*)0);
47
std::fill (
m_phis
,
m_phis
+
NEMSAMP
, (
float
*)0);
48
}
49
50
54
StatusCode
ClusterEMSamplingFillerTool::book
()
55
{
56
if
(
m_samplings
.empty()) {
57
m_samplings
.resize (
NEMSAMP
);
58
for
(
unsigned
int
i = 0; i <
NEMSAMP
; i++)
59
m_samplings
[i] = i;
60
}
61
62
for
(
unsigned
int
i = 0; i <
m_samplings
.size(); i++) {
63
unsigned
int
samp =
m_samplings
[i];
64
if
(samp >=
NEMSAMP
) {
65
REPORT_MESSAGE
(MSG::ERROR) <<
"Bad sampling index "
<< samp;
66
return
StatusCode::FAILURE;
67
}
68
69
if
(
m_writeEnergy
) {
70
std::ostringstream ename;
71
ename <<
"Es"
<< samp;
72
CHECK
(
addVariable
(ename.str(),
m_Es
[samp]) );
73
}
74
75
if
(
m_writeEta
) {
76
std::ostringstream etaname;
77
etaname <<
"etas"
<< samp;
78
CHECK
(
addVariable
(etaname.str(),
m_etas
[samp]) );
79
}
80
81
if
(
m_writePhi
) {
82
std::ostringstream phiname;
83
phiname <<
"phis"
<< samp;
84
CHECK
(
addVariable
(phiname.str(),
m_phis
[samp]) );
85
}
86
}
87
88
return
StatusCode::SUCCESS;
89
}
90
91
100
StatusCode
ClusterEMSamplingFillerTool::fill
(
const
CaloCluster
& p)
101
{
102
CHECK
(
fillT
(p) );
103
return
StatusCode::SUCCESS;
104
}
105
106
115
StatusCode
ClusterEMSamplingFillerTool::fill
(
const
xAOD::CaloCluster
& p)
116
{
117
CHECK
(
fillT
(p) );
118
return
StatusCode::SUCCESS;
119
}
120
121
128
template
<
class
T>
129
StatusCode
ClusterEMSamplingFillerTool::fillT
(
const
T& p)
130
{
131
for
(
unsigned
int
i = 0; i <
m_samplings
.size(); i++) {
132
unsigned
int
samp =
m_samplings
[i];
133
if
(
m_writeEnergy
)
134
*
m_Es
[samp] =
static_cast<
float
>
(p.energyBE (samp));
135
if
(
m_writeEta
) {
136
*
m_etas
[samp] =
static_cast<
float
>
(p.etaBE (samp));
137
if
(*
m_etas
[samp] == -999) *
m_etas
[samp] = 0;
// temp compat
138
}
139
if
(
m_writePhi
) {
140
*
m_phis
[samp] =
static_cast<
float
>
(p.phiBE (samp));
141
if
(*
m_phis
[samp] == -999) *
m_phis
[samp] = 0;
// temp compat
142
}
143
}
144
145
return
StatusCode::SUCCESS;
146
}
147
148
149
}
// namespace D3PD
ClusterEMSamplingFillerTool.h
Block filler tool for EM samplings from a CaloCluster.
errorcheck.h
Helpers for checking error return status codes and reporting errors.
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:365
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
CaloCluster
Principal data class for CaloCell clusters.
Definition
Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
D3PD::BlockFillerTool< Types< CaloCluster, xAOD::CaloCluster > >::addVariable
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Definition
AddVariable.cxx:85
D3PD::ClusterEMSamplingFillerTool::book
virtual StatusCode book() override
Book variables for this block.
Definition
ClusterEMSamplingFillerTool.cxx:54
D3PD::ClusterEMSamplingFillerTool::m_etas
float * m_etas[NEMSAMP]
Variable: Sampling eta centroids.
Definition
ClusterEMSamplingFillerTool.h:106
D3PD::ClusterEMSamplingFillerTool::m_writePhi
bool m_writePhi
Property: Should phi be written?
Definition
ClusterEMSamplingFillerTool.h:96
D3PD::ClusterEMSamplingFillerTool::m_writeEnergy
bool m_writeEnergy
Property: Should energies be written?
Definition
ClusterEMSamplingFillerTool.h:90
D3PD::ClusterEMSamplingFillerTool::fill
virtual StatusCode fill(const CaloCluster &p) override
Fill one block — type-safe version.
Definition
ClusterEMSamplingFillerTool.cxx:100
D3PD::ClusterEMSamplingFillerTool::m_Es
float * m_Es[NEMSAMP]
Variable: Sampling energies.
Definition
ClusterEMSamplingFillerTool.h:103
D3PD::ClusterEMSamplingFillerTool::NEMSAMP
static const unsigned int NEMSAMP
Definition
ClusterEMSamplingFillerTool.h:87
D3PD::ClusterEMSamplingFillerTool::m_samplings
std::vector< int > m_samplings
Property: List of samplings to write (in the range 0-3).
Definition
ClusterEMSamplingFillerTool.h:100
D3PD::ClusterEMSamplingFillerTool::Base
BlockFillerTool< Types< CaloCluster, xAOD::CaloCluster > > Base
Definition
ClusterEMSamplingFillerTool.h:36
D3PD::ClusterEMSamplingFillerTool::m_phis
float * m_phis[NEMSAMP]
Variable: Sampling phi centroids.
Definition
ClusterEMSamplingFillerTool.h:109
D3PD::ClusterEMSamplingFillerTool::fillT
StatusCode fillT(const T &p)
Fill one block.
Definition
ClusterEMSamplingFillerTool.cxx:129
D3PD::ClusterEMSamplingFillerTool::ClusterEMSamplingFillerTool
ClusterEMSamplingFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition
ClusterEMSamplingFillerTool.cxx:30
D3PD::ClusterEMSamplingFillerTool::m_writeEta
bool m_writeEta
Property: Should eta be written?
Definition
ClusterEMSamplingFillerTool.h:93
D3PD
Block filler tool for noisy FEB information.
Definition
CaloCellDetailsFillerTool.cxx:29
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
type
Generated on
for ATLAS Offline Software by
1.17.0