ATLAS Offline Software
Loading...
Searching...
No Matches
HISubtractedCellMakerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "HICaloCellHelper.h"
11
14
15#include <algorithm>
16
17//**********************************************************************
18
19HISubtractedCellMakerTool::HISubtractedCellMakerTool(const std::string& type, const std::string& name, const IInterface* parent) : AthAlgTool(type, name, parent)
20{
21 declareInterface<ICaloCellMakerTool>(this);
22}
23
24//**********************************************************************
25
27{
28 ATH_CHECK( m_eventShapeKey.initialize() );
29 return StatusCode::SUCCESS;
30}
31
33 const EventContext& ctx) const
34{
35 const xAOD::HIEventShapeContainer* shape=0;
36
38 shape = readHandleEvtShape.cptr();
39
40 const HIEventShapeIndex* index=m_eventShapeMapTool->getIndexFromShape( shape );
41 if(index==nullptr)
42 {
43 ATH_MSG_ERROR("Could not retrieve HIEventShapeIndex for key " << m_eventShapeKey.key());
44 return StatusCode::FAILURE;
45 }
46
47 if(shape->size()==0)
48 {
49 ATH_MSG_WARNING("HIEventShapeContainer " << m_eventShapeKey.key() << " exists but has zero size");
50 return StatusCode::SUCCESS;
51 }
52
53 const xAOD::HIEventShape* modShape = nullptr;
54 ATH_CHECK( m_modulatorTool->getShape (modShape) );
55
56 for(auto pCell : *theCells)
57 {
58 unsigned int sample = (CaloSampling::CaloSample) pCell->caloDDE()->getSampling();
59 double eta=pCell->eta();
60 double phi=pCell->phi();
61
62 unsigned int bin=index->getIndex(eta,sample);
63 if( bin >= shape->size() )
64 {
65 if( std::abs(eta) - HICaloRange::getRange().getRangeMax(sample) )
66 {
67 double fp_round=(eta > 0.) ? -5e-3 : 5e-3;
68 bin=index->getIndex(eta+fp_round,sample);
69 }
70 }
71
72 const xAOD::HIEventShape* s=shape->at(bin);
73 float nCells=s->nCells();
74 float rho=0;
75 if(nCells!=0.) rho=s->rho()/nCells;
76 rho*=m_modulatorTool->getModulation(phi, modShape);
77 float ue=rho*HICaloCellHelper::getAreaEtaPhi(pCell)*std::cosh(eta);
78 pCell->addEnergy(-ue);
79 }
80 return StatusCode::SUCCESS;
81}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Container class for CaloCell.
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
static const HICaloRange & getRange()
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_eventShapeKey
ToolHandle< IHIUEModulatorTool > m_modulatorTool
ToolHandle< IHIEventShapeMapTool > m_eventShapeMapTool
HISubtractedCellMakerTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize() override
const_pointer_type cptr()
Dereference the pointer.
float getAreaEtaPhi(const CaloCell *theCell)
Definition index.py:1
HIEventShapeContainer_v2 HIEventShapeContainer
Define the latest version of the container.
HIEventShape_v2 HIEventShape
Definition of the latest event info version.