ATLAS Offline Software
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 
12 #include "StoreGate/ReadHandle.h"
13 #include "StoreGate/WriteHandle.h"
14 
15 #include <algorithm>
16 
17 //**********************************************************************
18 
19 HISubtractedCellMakerTool::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->setEnergy(pCell->energy()-ue);
79  }
80  return StatusCode::SUCCESS;
81 }
HICaloCellHelper::getAreaEtaPhi
float getAreaEtaPhi(const CaloCell *theCell)
Definition: HICaloCellHelper.cxx:15
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
HISubtractedCellMakerTool::HISubtractedCellMakerTool
HISubtractedCellMakerTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: HISubtractedCellMakerTool.cxx:19
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
HICaloRange::getRangeMax
float getRangeMax(int layer) const
Definition: HICaloRange.h:20
HICaloRange::getRange
static const HICaloRange & getRange()
Definition: HICaloRange.cxx:13
bin
Definition: BinsDiffFromStripMedian.h:43
HIEventDefs.h
HISubtractedCellMakerTool::m_modulatorTool
ToolHandle< IHIUEModulatorTool > m_modulatorTool
Definition: HISubtractedCellMakerTool.h:33
HICaloRange.h
xAOD::HIEventShape_v2
Interface class for the HI reconstruction EDM.
Definition: HIEventShape_v2.h:31
WriteHandle.h
Handle class for recording to StoreGate.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
xAOD::nCells
setRawEt setRawPhi nCells
Definition: TrigCaloCluster_v1.cxx:33
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
HISubtractedCellMakerTool::initialize
virtual StatusCode initialize() override
Definition: HISubtractedCellMakerTool.cxx:26
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HIEventShapeContainer.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
HICaloCellHelper.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
HIEventShapeIndex
Definition: HIEventShapeIndex.h:17
HISubtractedCellMakerTool::m_eventShapeMapTool
ToolHandle< IHIEventShapeMapTool > m_eventShapeMapTool
Definition: HISubtractedCellMakerTool.h:34
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
HISubtractedCellMakerTool.h
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
ReadHandle.h
Handle class for reading from StoreGate.
AthAlgTool
Definition: AthAlgTool.h:26
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
HISubtractedCellMakerTool::process
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
Definition: HISubtractedCellMakerTool.cxx:32
fitman.rho
rho
Definition: fitman.py:532
HISubtractedCellMakerTool::m_eventShapeKey
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_eventShapeKey
Definition: HISubtractedCellMakerTool.h:32