ATLAS Offline Software
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$
15 #include "CaloEvent/CaloCluster.h"
17 #include <sstream>
18 
19 
20 namespace 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 
128 template <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
D3PD::ClusterEMSamplingFillerTool::fill
virtual StatusCode fill(const CaloCluster &p) override
Fill one block — type-safe version.
Definition: ClusterEMSamplingFillerTool.cxx:100
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
D3PD::ClusterEMSamplingFillerTool::m_Es
float * m_Es[NEMSAMP]
Variable: Sampling energies.
Definition: ClusterEMSamplingFillerTool.h:103
D3PD::ClusterEMSamplingFillerTool::m_writeEnergy
bool m_writeEnergy
Property: Should energies be written?
Definition: ClusterEMSamplingFillerTool.h:90
D3PD::ClusterEMSamplingFillerTool::m_writeEta
bool m_writeEta
Property: Should eta be written?
Definition: ClusterEMSamplingFillerTool.h:93
D3PD::ClusterEMSamplingFillerTool::ClusterEMSamplingFillerTool
ClusterEMSamplingFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition: ClusterEMSamplingFillerTool.cxx:30
D3PD::AddVariable::addVariable
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Add a variable to the tuple.
Definition: AddVariable.cxx:85
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
D3PD::ClusterEMSamplingFillerTool::NEMSAMP
static const unsigned int NEMSAMP
Definition: ClusterEMSamplingFillerTool.h:87
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CaloCluster
Principal data class for CaloCell clusters.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
D3PD::BlockFillerTool< Types< CaloCluster, xAOD::CaloCluster > >
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::ClusterEMSamplingFillerTool::m_etas
float * m_etas[NEMSAMP]
Variable: Sampling eta centroids.
Definition: ClusterEMSamplingFillerTool.h:106
D3PD::ClusterEMSamplingFillerTool::m_phis
float * m_phis[NEMSAMP]
Variable: Sampling phi centroids.
Definition: ClusterEMSamplingFillerTool.h:109
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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
ClusterEMSamplingFillerTool.h
Block filler tool for EM samplings from a CaloCluster.
D3PD::ClusterEMSamplingFillerTool::m_samplings
std::vector< int > m_samplings
Property: List of samplings to write (in the range 0-3).
Definition: ClusterEMSamplingFillerTool.h:100
lumiFormat.fill
fill
Definition: lumiFormat.py:111
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
D3PD::ClusterEMSamplingFillerTool::m_writePhi
bool m_writePhi
Property: Should phi be written?
Definition: ClusterEMSamplingFillerTool.h:96
D3PD::ClusterEMSamplingFillerTool::fillT
StatusCode fillT(const T &p)
Fill one block.
Definition: ClusterEMSamplingFillerTool.cxx:129
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
D3PD::ClusterEMSamplingFillerTool::book
virtual StatusCode book() override
Book variables for this block.
Definition: ClusterEMSamplingFillerTool.cxx:54