ATLAS Offline Software
HLTCaloCellCorrector.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 "HLTCaloCellCorrector.h"
6 
8 
9 #include <memory>
10 
11 namespace {
12  double get_average_energy(xAOD::HIEventShapeContainer const& eventShape,
13  int layer, double eta) {
14  for (const auto es : eventShape) {
15  if (es->layer() != layer || eta > es->etaMax() || eta <= es->etaMin())
16  continue;
17 
18  double et = es->et();
19 
20  /* energy in MeV; essentially zero */
21  if (std::abs(et) < 0.1)
22  continue;
23 
24  return et / es->nCells();
25  }
26 
27  return 0.;
28  }
29 }
30 
31 HLTCaloCellCorrector::HLTCaloCellCorrector(std::string const& name, ISvcLocator* pSvcLocator)
32  : AthReentrantAlgorithm(name, pSvcLocator) {
33 }
34 
39 
40  return StatusCode::SUCCESS;
41 }
42 
43 StatusCode HLTCaloCellCorrector::execute(EventContext const& context) const {
44  ATH_MSG_DEBUG("HLTCaloCellCorrector::execute()");
45 
48 
50 
51  auto eventShape = *eventShapeHandle;
52  //auto outputCells = std::make_unique<CaloConstCellContainer>(SG::VIEW_ELEMENTS);
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(CaloCell_ID::LAREM);
70 
71  outputCells->updateCaloIterators();
72 
73  ATH_CHECK(outputCellHandle.record(std::move(outputCells)));
74 
75  return StatusCode::SUCCESS;
76 }
HLTCaloCellCorrector.h
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition: CaloCell_Base_ID.h:46
et
Extra patterns decribing particle interation process.
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
HLTCaloCellCorrector::m_outputCellContainerKey
SG::WriteHandleKey< CaloConstCellContainer > m_outputCellContainerKey
Definition: HLTCaloCellCorrector.h:28
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition: CaloCell_Base_ID.h:46
HLTCaloCellCorrector::HLTCaloCellCorrector
HLTCaloCellCorrector(std::string const &name, ISvcLocator *pSvcLocator)
Definition: HLTCaloCellCorrector.cxx:31
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
HLTCaloCellCorrector::initialize
virtual StatusCode initialize() override
Definition: HLTCaloCellCorrector.cxx:35
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
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
HIEventShape.h
HLTCaloCellCorrector::m_eventShapeCollectionKey
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_eventShapeCollectionKey
Definition: HLTCaloCellCorrector.h:23
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCell_Base_ID::TILE
@ TILE
Definition: CaloCell_Base_ID.h:46
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
HLTCaloCellCorrector::m_inputCellContainerKey
SG::ReadHandleKey< CaloConstCellContainer > m_inputCellContainerKey
Definition: HLTCaloCellCorrector.h:25
calibdata.copy
bool copy
Definition: calibdata.py:27
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:46
HLTCaloCellCorrector::execute
virtual StatusCode execute(EventContext const &context) const override
Definition: HLTCaloCellCorrector.cxx:43