ATLAS Offline Software
Loading...
Searching...
No Matches
TrigCaloTowerMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5// ********************************************************************
6//
7// NAME: TrigCaloTowerMaker.cxx
8// PACKAGE: Trigger/TrigAlgorithms/TrigCaloRec
9//
10// AUTHOR: P.A. Delsart
11// This is an Hlt algorithm that creates Calorimeter towers
12// It assumes CaloCellContainers are already produced and accessable
13// through the input TriggerElement. Based on TrigCaloRec
14//
15// ********************************************************************
16//
17//
18#include <sstream>
19#include "GaudiKernel/IToolSvc.h"
20#include "GaudiKernel/TypeNameString.h"
21#include "GaudiKernel/StatusCode.h"
22
23#include "CxxUtils/phihelper.h"
26
30
31#include "CaloEvent/CaloTowerContainer.h"
34
35#include "TrigCaloTowerMaker.h"
36
37class ISvcLocator;
38
40 ISvcLocator* pSvcLocator)
41 : AthReentrantAlgorithm(name, pSvcLocator),
42 m_includeFcal(false) {
43
44}
45
47// INITIALIZE:
48// The initialize method will create all the required algorithm objects
49// Note that it is NOT NECESSARY to run the initialize of individual
50// sub-algorithms. The framework takes care of it.
52
54 ATH_MSG_DEBUG("in initialize()");
55
56 if (!m_monTool.empty()) {
57 ATH_MSG_DEBUG("Retrieving monTool");
58 CHECK(m_monTool.retrieve());
59 } else {
60 ATH_MSG_INFO("No monTool configured => NO MONITOING");
61 }
62
63 ATH_CHECK(m_towerMakerTools.retrieve());
64
66 for (auto& tool: m_towerMakerTools) {
67 tool->setTowerSeg(theTowerSeg);
68 }
69 // presence of tool with the name FC triggers use of FCal
70 for (auto& tool: m_towerMakerTools) {
71 if ( tool->name().find("FC") != std::string::npos) {
72 m_includeFcal = true;
73 ATH_MSG_INFO("Tool " << tool->name() << " is configured, will use FCal");
74 }
75 }
76
78
80 ATH_CHECK(m_inputCellsKey.initialize());
81 ATH_CHECK(m_outputTowerKey.initialize());
83
84 ATH_MSG_DEBUG("Initialization of TrigCaloTowerMaker completed successfully");
85
86 return StatusCode::SUCCESS;
87}
88
89StatusCode TrigCaloTowerMaker::execute(const EventContext& ctx) const {
90 // Monitoring initialization...
91 auto timer = Monitored::Timer("TIME_execute");
92 auto time_tools = Monitored::Timer("TIME_tools");
93 auto mon_towerContainerSize = Monitored::Scalar("towerContainerSize", 0.);
94
95 auto monitorIt =
96 Monitored::Group(m_monTool, timer, time_tools, mon_towerContainerSize);
97
98 ATH_MSG_DEBUG("in execute()");
99
100
101 // Get RoiDescriptor
102 const bool seedLess = m_inputRoiKey.empty();
103 TrigRoiDescriptor roiDescriptor;
104 if (!seedLess) {
107 if ( !roiCollection.isValid()) {
108 ATH_MSG_ERROR("Cell maker did not get a valid RoIs collection");
109 return StatusCode::FAILURE;
110 }
111 if (roiCollection->size() == 0) {
112 ATH_MSG_DEBUG(" RoI collection size = 0");
113 return StatusCode::SUCCESS;
114 }
115 if (roiCollection->size() > 1)
116 ATH_MSG_WARNING("Misconfiguration - Called with "
117 << roiCollection->size()
118 << " ROI, but it should be called with 1 RoI - Will only "
119 "process the first RoI");
120
121 roiDescriptor = roiCollection->front();
122 ATH_MSG_DEBUG("Operating on " << roiCollection->size() << "RoI(s)");
123 } else {
124 roiDescriptor = TrigRoiDescriptor(true);
125 }
126 ATH_MSG_DEBUG(" RoI id " << roiDescriptor.roiId()
127 << " located at phi = " << roiDescriptor.phi()
128 << ", eta = " << roiDescriptor.eta());
129
130 auto caloTowerContainer = SG::makeHandle(m_outputTowerKey, ctx);
131
135
136 if (roiDescriptor.composite()) {
138 " Attempting to use composite RoI as a normal RoI - this is probably "
139 "*not* what you want to do "
140 << roiDescriptor);
141 }
142
143 double eta0 = roiDescriptor.eta();
144 double phi0 = roiDescriptor.phi();
145
146 phi0 = CxxUtils::wrapToPi(phi0);
147 double etamin = eta0 - m_deta / 2.;
148 double etamax = eta0 + m_deta / 2.;
149 // What if phimin < 0 or phimax > 2Pi ?? question
150 double phimin = phi0 - m_dphi / 2.;
151 double phimax = phi0 + m_dphi / 2.;
152
153 ATH_MSG_DEBUG(" eta0 = " << eta0 << " phi0 = " << phi0
154 << " etamin = " << etamin << " etamax = " << etamax
155 << " phimin = " << phimin << " phimax = " << phimax);
156
158 CaloTowerSeg::SubSeg subseg =
159 myseg.subseg(roiDescriptor.eta(), m_deta, roiDescriptor.phi(), m_dphi);
160 if (m_includeFcal) {
161 ATH_CHECK(
162 caloTowerContainer.record(std::make_unique<CaloTowerContainer>(myseg)));
163 } else {
164 ATH_CHECK(caloTowerContainer.record(
165 std::make_unique<CaloTowerContainer>(subseg.segmentation())));
166 }
167 CaloTowerContainer* pCaloTowerContainer = caloTowerContainer.ptr();
168
169 ATH_CHECK(caloTowerContainer.symLink(m_caloTowerNav4LinkKey));
170 ATH_MSG_DEBUG("CaloTowerContainer"
171 << caloTowerContainer.name()
172 << " symlinked to INavigable4MomentumCollection in StoreGate");
173
174 auto caloCellContainer = SG::makeHandle(m_inputCellsKey, ctx);
175 ATH_CHECK( caloCellContainer.isValid() );
176
177 // Get the last container in the vector. Should be th one produced by the
178 // previous TrigCaloCellMaker.
179 const CaloCellContainer* theCellCont = caloCellContainer.ptr();
180
182 " REGTEST: Retrieved a Cell Container of Size= " << theCellCont->size());
183
184 // Now Build the towers
185 // -----------------------------------------------------------------
186 time_tools.start();
187
188 for ( auto& tool: m_towerMakerTools ) {
189 if (m_includeFcal) {
190 ATH_CHECK(tool->execute(ctx, pCaloTowerContainer, theCellCont));
191 ATH_MSG_DEBUG("Executed tool " << tool.name());
192 } else {
193 ATH_CHECK(tool->execute(ctx, pCaloTowerContainer, theCellCont, &subseg));
194 ATH_MSG_DEBUG("Executed tool " << tool.name());
195 }
196 }
197 time_tools.stop();
198
199 ATH_MSG_DEBUG(" REGTEST: Produced a Tower Container "
200 << caloTowerContainer.name() << " at "
201 << caloTowerContainer.cptr()
202 << " of Size= " << pCaloTowerContainer->size());
203 ATH_MSG_DEBUG(" handle info: " << caloTowerContainer);
204 mon_towerContainerSize = static_cast<float>(pCaloTowerContainer->size());
205
206 return StatusCode::SUCCESS;
207}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
Header file to be included by clients of the Monitored infrastructure.
Athena::TPCnvVers::Current TrigRoiDescriptor
An algorithm that can be simultaneously executed in multiple threads.
Container class for CaloCell.
Storable container class for CaloTower.
A rectangular window within the segmentation.
CaloTowerSeg segmentation() const
Return a new segmentation object corresponding to this window.
Data object stores CaloTower segmentation.
SubSeg subseg(double eta, double deta, double phi, double dphi) const
Return a window within the current segmentation.
size_type size() const noexcept
Returns the number of elements in the collection.
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
A monitored timer.
virtual double phi() const override final
Methods to retrieve data members.
virtual double eta() const override final
virtual bool composite() const override final
SuperRoI compatability methods.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TrigCaloTowerMaker(const std::string &name, ISvcLocator *pSvcLocator)
constructor
Gaudi::Property< unsigned int > m_nEtaTowers
Number of eta segments in which we divide the calorimeter.
bool m_includeFcal
To help structure Tower container.
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_inputRoiKey
Gaudi::Property< double > m_maxEta
Gaudi::Property< double > m_deta
Gaudi::Property< unsigned int > m_nPhiTowers
Number of phi segments in which we divide the calorimeter.
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadHandleKey< CaloCellContainer > m_inputCellsKey
virtual StatusCode initialize() override
HLT method to initialize.
ToolHandleArray< CaloTowerBuilderToolBase > m_towerMakerTools
Gaudi::Property< double > m_dphi
ToolHandle< GenericMonitoringTool > m_monTool
SG::WriteHandleKey< CaloTowerContainer > m_outputTowerKey
Gaudi::Property< double > m_minEta
Eta limits of the region where the towers are built.
SG::WriteHandleKey< INavigable4MomentumCollection > m_caloTowerNav4LinkKey
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
virtual unsigned int roiId() const override final
these quantities probably don't need to be used any more
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition phihelper.h:24
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Helper for azimuthal angle calculations.