ATLAS Offline Software
Loading...
Searching...
No Matches
HLTCaloCellCorrector.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9#include <memory>
10#include <cmath>
11
12namespace {
13 double get_average_energy(xAOD::HIEventShapeContainer const& eventShape,
14 int layer, double eta) {
15 for (const auto es : eventShape) {
16 if (es->layer() != layer || eta > es->etaMax() || eta <= es->etaMin())
17 continue;
18
19 double et = es->et();
20
21 /* energy in MeV; essentially zero */
22 if (std::abs(et) < 0.1)
23 continue;
24
25 return et / es->nCells();
26 }
27
28 return 0.;
29 }
30}
31
32HLTCaloCellCorrector::HLTCaloCellCorrector(std::string const& name, ISvcLocator* pSvcLocator)
33 : AthReentrantAlgorithm(name, pSvcLocator) {
34}
35
40
41 return StatusCode::SUCCESS;
42}
43
44StatusCode HLTCaloCellCorrector::execute(EventContext const& context) const {
45 ATH_MSG_DEBUG("HLTCaloCellCorrector::execute()");
46
49
51
52 const auto & eventShape = *eventShapeHandle;
53 auto outputCells = std::make_unique<CaloConstCellContainer>();
54
55 for (auto const* cell : *inputCellHandle) {
56 std::unique_ptr<CaloCell> copy = cell->clone();
57
58 int layer = copy->caloDDE()->getSampling();
59
60 double eavg = get_average_energy(eventShape, layer, copy->eta());
61 double etotal = (copy->et() - eavg) / copy->sinTh();
62
63 copy->setEnergy(etotal);
64 outputCells->push_back(std::move(copy));
65 }
66
68 if (inputCellHandle->hasCalo(id))
69 outputCells->setHasCalo(id);
70
71 outputCells->updateCaloIterators();
72
73 ATH_CHECK(outputCellHandle.record(std::move(outputCells)));
74
75 return StatusCode::SUCCESS;
76}
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
HLTCaloCellCorrector(std::string const &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_eventShapeCollectionKey
SG::ReadHandleKey< CaloConstCellContainer > m_inputCellContainerKey
virtual StatusCode execute(EventContext const &context) const override
virtual StatusCode initialize() override
SG::WriteHandleKey< CaloConstCellContainer > m_outputCellContainerKey
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
HIEventShapeContainer_v2 HIEventShapeContainer
Define the latest version of the container.
Extra patterns decribing particle interation process.