ATLAS Offline Software
Loading...
Searching...
No Matches
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
15#include "CaloEvent/CaloCluster.h"
17#include <sstream>
18
19
20namespace D3PD {
21
22
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
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
101{
102 CHECK( fillT (p) );
103 return StatusCode::SUCCESS;
104}
105
106
116{
117 CHECK( fillT (p) );
118 return StatusCode::SUCCESS;
119}
120
121
128template <class T>
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
Block filler tool for EM samplings from a CaloCluster.
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
#define CHECK(...)
Evaluate an expression and check for errors.
Principal data class for CaloCell clusters.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
virtual StatusCode book() override
Book variables for this block.
float * m_etas[NEMSAMP]
Variable: Sampling eta centroids.
bool m_writePhi
Property: Should phi be written?
bool m_writeEnergy
Property: Should energies be written?
virtual StatusCode fill(const CaloCluster &p) override
Fill one block — type-safe version.
float * m_Es[NEMSAMP]
Variable: Sampling energies.
std::vector< int > m_samplings
Property: List of samplings to write (in the range 0-3).
BlockFillerTool< Types< CaloCluster, xAOD::CaloCluster > > Base
float * m_phis[NEMSAMP]
Variable: Sampling phi centroids.
StatusCode fillT(const T &p)
Fill one block.
ClusterEMSamplingFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
bool m_writeEta
Property: Should eta be written?
Block filler tool for noisy FEB information.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.