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>
11 
12 // =============================================================================
13 
14 RoIPEBInfoWriterTool::RoIPEBInfoWriterTool(const std::string& type, const std::string& name, const IInterface* parent)
16 
17 // =============================================================================
18 
20  ATH_MSG_DEBUG("Initialising RoIPEBInfoWriterTool/" << name());
21 
22  ATH_CHECK(m_regionSelectorTools.retrieve());
23 
24  m_extraPebInfo.robs.insert(m_extraROBs.begin(), m_extraROBs.end());
25  m_extraPebInfo.subdets.insert(m_extraSubDets.begin(), m_extraSubDets.end());
26  ATH_MSG_DEBUG("Extra PEBInfo attached to every passed event: " << m_extraPebInfo);
27 
28  return StatusCode::SUCCESS;
29 }
30 
31 // =============================================================================
32 
34  // Create output PEBInfo starting from the static extra PEBInfo
35  PEBInfo pebi = m_extraPebInfo;
36 
37  ATH_MSG_DEBUG("Processing RoI " << **(input.roiEL));
38  // Assert we're not being passed a full-scan RoI which makes no sense for RoI-based PEB
39  if ((*input.roiEL)->isFullscan()) {
40  auto met_feature_vec = TrigCompositeUtils::findLinks<xAOD::TrigMissingETContainer>(input.decision, TrigCompositeUtils::featureString(), TrigDefs::lastFeatureOfType);
41  if (not met_feature_vec.empty()) {
42  ATH_MSG_DEBUG("Ignoring MET leg passed to RoIPEBInfoWriterTool");
43  return pebi;
44  } else {
45  ATH_MSG_ERROR("Full-scan RoI passed as input to RoIPEBInfoWriterTool");
46  return {};
47  }
48  }
49 
50  float eta = (*input.roiEL)->eta();
51  float etaMin = eta - m_etaWidth;
52  float etaMax = eta + m_etaWidth;
53  // Stop further execution if RoI is entirely outside the max |eta| range
54  if (etaMin > m_etaEdge || etaMax < -m_etaEdge) {
55  ATH_MSG_DEBUG("The eta range (" << etaMin << ", " << etaMax << ") is outside |eta|<" << m_etaEdge
56  << " - skipping this RoI");
57  return pebi;
58  }
59  // Restrict the eta range
60  etaMin = std::max(-m_etaEdge.value(), etaMin);
61  etaMax = std::min( m_etaEdge.value(), etaMax);
62 
63  float phi = (*input.roiEL)->phi();
64  float phiMin = CxxUtils::wrapToPi(phi - m_phiWidth); // range (-pi, pi)
65  float phiMax = CxxUtils::wrapToPi(phi + m_phiWidth); // range (-pi, pi)
66 
67  TrigRoiDescriptor roiForPEB(eta, etaMin, etaMax, phi, phiMin, phiMax);
68 
69  for (const auto& tool : m_regionSelectorTools) {
70  std::vector<uint32_t> detROBs;
71  tool->lookup(Gaudi::Hive::currentContext())->ROBIDList(roiForPEB, detROBs);
72  pebi.robs.insert(detROBs.begin(),detROBs.end());
73  }
74 
75  ATH_MSG_DEBUG("Created PEBInfo = " << pebi);
76  return pebi;
77 }
RoIPEBInfoWriterTool.h
RoIPEBInfoWriterTool::m_etaWidth
Gaudi::Property< float > m_etaWidth
Definition: RoIPEBInfoWriterTool.h:38
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
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
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
RoIPEBInfoWriterTool::createPEBInfo
virtual PEBInfoWriterToolBase::PEBInfo createPEBInfo(const PEBInfoWriterToolBase::Input &input) const override
Implementation of PEBInfoWriterToolBase::createPEBInfo.
Definition: RoIPEBInfoWriterTool.cxx:33
PEBInfoWriterToolBase::PEBInfo::robs
std::set< uint32_t > robs
Definition: PEBInfoWriterToolBase.h:45
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:19
RoIPEBInfoWriterTool::RoIPEBInfoWriterTool
RoIPEBInfoWriterTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: RoIPEBInfoWriterTool.cxx:14
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
TrigMissingETContainer.h
PEBInfoWriterToolBase
Base class for tools used by PEBInfoWriterAlg.
Definition: PEBInfoWriterToolBase.h:21
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:899
PEBInfoWriterToolBase::PEBInfo::subdets
std::set< uint32_t > subdets
Definition: PEBInfoWriterToolBase.h:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:452
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
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:44
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