ATLAS Offline Software
RoIPEBInfoWriterTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "RoIPEBInfoWriterTool.h"
6 #include "CxxUtils/phihelper.h"
7 #include <algorithm>
8 #include <unordered_map>
9 #include <string_view>
10 
11 // =============================================================================
12 
13 RoIPEBInfoWriterTool::RoIPEBInfoWriterTool(const std::string& type, const std::string& name, const IInterface* parent)
15 
16 // =============================================================================
17 
19  ATH_MSG_DEBUG("Initialising RoIPEBInfoWriterTool/" << name());
20 
21  ATH_CHECK(m_regionSelectorTools.retrieve());
22 
23  m_extraPebInfo.robs.insert(m_extraROBs.begin(), m_extraROBs.end());
24  m_extraPebInfo.subdets.insert(m_extraSubDets.begin(), m_extraSubDets.end());
25  ATH_MSG_DEBUG("Extra PEBInfo attached to every passed event: " << m_extraPebInfo);
26 
27  return StatusCode::SUCCESS;
28 }
29 
30 // =============================================================================
31 
33  // Create output PEBInfo starting from the static extra PEBInfo
34  PEBInfo pebi = m_extraPebInfo;
35 
36  ATH_MSG_DEBUG("Processing RoI " << **(input.roiEL));
37  // Assert we're not being passed a full-scan RoI which makes no sense for RoI-based PEB
38  if ((*input.roiEL)->isFullscan()) {
39  ATH_MSG_ERROR("Full-scan RoI passed as input to RoIPEBInfoWriterTool");
40  return {};
41  }
42 
43  float eta = (*input.roiEL)->eta();
44  float etaMin = eta - m_etaWidth;
45  float etaMax = eta + m_etaWidth;
46  // Stop further execution if RoI is entirely outside the max |eta| range
47  if (etaMin > m_etaEdge || etaMax < -m_etaEdge) {
48  ATH_MSG_DEBUG("The eta range (" << etaMin << ", " << etaMax << ") is outside |eta|<" << m_etaEdge
49  << " - skipping this RoI");
50  return pebi;
51  }
52  // Restrict the eta range
53  etaMin = std::max(-m_etaEdge.value(), etaMin);
54  etaMax = std::min( m_etaEdge.value(), etaMax);
55 
56  float phi = (*input.roiEL)->phi();
57  float phiMin = CxxUtils::wrapToPi(phi - m_phiWidth); // range (-pi, pi)
58  float phiMax = CxxUtils::wrapToPi(phi + m_phiWidth); // range (-pi, pi)
59 
60  TrigRoiDescriptor roiForPEB(eta, etaMin, etaMax, phi, phiMin, phiMax);
61 
62  for (const auto& tool : m_regionSelectorTools) {
63  std::vector<uint32_t> detROBs;
64  tool->ROBIDList(roiForPEB, detROBs);
65  pebi.robs.insert(detROBs.begin(),detROBs.end());
66  }
67 
68  ATH_MSG_DEBUG("Created PEBInfo = " << pebi);
69  return pebi;
70 }
RoIPEBInfoWriterTool.h
RoIPEBInfoWriterTool::m_etaWidth
Gaudi::Property< float > m_etaWidth
Definition: RoIPEBInfoWriterTool.h:38
max
#define max(a, b)
Definition: cfImp.cxx:41
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
CxxUtils::wrapToPi
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition: phihelper.h:24
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
RoIPEBInfoWriterTool::createPEBInfo
virtual PEBInfoWriterToolBase::PEBInfo createPEBInfo(const PEBInfoWriterToolBase::Input &input) const override
Implementation of PEBInfoWriterToolBase::createPEBInfo.
Definition: RoIPEBInfoWriterTool.cxx:32
PEBInfoWriterToolBase::PEBInfo::robs
std::set< uint32_t > robs
Definition: PEBInfoWriterToolBase.h:41
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
RoIPEBInfoWriterTool::m_etaEdge
Gaudi::Property< float > m_etaEdge
Definition: RoIPEBInfoWriterTool.h:35
RoIPEBInfoWriterTool::initialize
virtual StatusCode initialize() override
Implementation of AthAlgTool::initialize()
Definition: RoIPEBInfoWriterTool.cxx:18
RoIPEBInfoWriterTool::RoIPEBInfoWriterTool
RoIPEBInfoWriterTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: RoIPEBInfoWriterTool.cxx:13
RoIPEBInfoWriterTool::m_extraPebInfo
PEBInfoWriterToolBase::PEBInfo m_extraPebInfo
Static PEB Info which contains ExtraROBs and ExtraSubDets.
Definition: RoIPEBInfoWriterTool.h:54
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
RoIPEBInfoWriterTool::m_extraROBs
Gaudi::Property< std::vector< uint32_t > > m_extraROBs
Definition: RoIPEBInfoWriterTool.h:44
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PEBInfoWriterToolBase
Base class for tools used by PEBInfoWriterAlg.
Definition: PEBInfoWriterToolBase.h:21
min
#define min(a, b)
Definition: cfImp.cxx:40
PEBInfoWriterToolBase::PEBInfo::subdets
std::set< uint32_t > subdets
Definition: PEBInfoWriterToolBase.h:42
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
phihelper.h
Helper for azimuthal angle calculations.
RoIPEBInfoWriterTool::m_regionSelectorTools
ToolHandleArray< IRegSelTool > m_regionSelectorTools
Definition: RoIPEBInfoWriterTool.h:30
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
PEBInfoWriterToolBase::Input
Input to the tool's decide method.
Definition: PEBInfoWriterToolBase.h:25
PEBInfoWriterToolBase::PEBInfo
Structure holding the list of ROBs and SubDets.
Definition: PEBInfoWriterToolBase.h:40
RoIPEBInfoWriterTool::m_extraSubDets
Gaudi::Property< std::vector< uint32_t > > m_extraSubDets
Definition: RoIPEBInfoWriterTool.h:48
RoIPEBInfoWriterTool::m_phiWidth
Gaudi::Property< float > m_phiWidth
Definition: RoIPEBInfoWriterTool.h:41