ATLAS Offline Software
CellsInConeThinning.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "CellsInCone.h"
10 
12  const std::string& type,
13  const std::string& name,
14  const IInterface* parent)
16  , m_selectionString("")
17  , m_dr(0.5)
18 {
19  declareInterface<DerivationFramework::IAugmentationTool>(this);
20  declareProperty("deltaR", m_dr = 0.5);
21 }
22 
25 {
26 
27  ATH_CHECK(m_SGKey.initialize());
28  ATH_CHECK(m_InputCellsSGKey.initialize());
29  ATH_CHECK(m_OutputClusterSGKey.initialize());
30  ATH_CHECK(m_OutputCellLinkSGKey.initialize());
31  ATH_CHECK(m_caloMgrKey.initialize());
32 
33  if (!m_selectionString.empty()) {
34  ATH_CHECK(initializeParser(m_selectionString));
35  }
36  return StatusCode::SUCCESS;
37 }
38 
41 {
42  ATH_CHECK(finalizeParser());
43  return StatusCode::SUCCESS;
44 }
45 
48 {
49 
51  SG::WriteHandle<xAOD::CaloClusterContainer> dclHdl(m_OutputClusterSGKey);
53 
56  const xAOD::EgammaContainer* egammas = egHdl.cptr();
57  if (!egammas) {
58  ATH_MSG_ERROR("Couldn't retrieve egamma container with key: " << m_SGKey);
59  return StatusCode::FAILURE;
60  }
61 
62  unsigned int nEgammas(egammas->size());
63  if (nEgammas == 0) {
64  return StatusCode::SUCCESS;
65  }
66 
67  SG::ReadHandle<CaloCellContainer> cellHdl(m_InputCellsSGKey);
68  const CaloCellContainer* cells = cellHdl.cptr();
69  if (!cells) {
71  "Couldn't retrieve cell container with key: " << m_InputCellsSGKey);
72  return StatusCode::FAILURE;
73  }
74 
75  SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{ m_caloMgrKey };
76  const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
77 
78  // We have a selection string
79  if (!m_selectionString.empty()) {
80  std::vector<int> entries = m_parser->evaluateAsVector();
81  unsigned int nEntries = entries.size();
82  // check the sizes are compatible
83  if (nEgammas != nEntries) {
84  ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string "
85  "used e-gamma objects");
86  return StatusCode::FAILURE;
87  }
88  // Loop over the egammas, pick the selected ones and fill the cluster
89  int index(0);
90  for (const xAOD::Egamma* eg : *egammas) {
91  if (static_cast<bool>(entries.at(index))) {
94  dummy, cells, caloDDMgr, eg, m_dr);
95  }
96  ++index;
97  }
98  }
100  else {
101  for (const xAOD::Egamma* eg : *egammas) {
104  dummy, cells, caloDDMgr, eg, m_dr);
105  }
106  }
109  m_OutputCellLinkSGKey);
112  return StatusCode::SUCCESS;
113 }
115 
CaloClusterStoreHelper::makeCluster
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
Definition: CaloClusterStoreHelper.cxx:13
DerivationFramework::CellsInConeThinning::m_dr
double m_dr
Definition: CellsInConeThinning.h:72
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
CaloClusterStoreHelper::finalizeClusters
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
Definition: CaloClusterStoreHelper.cxx:64
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
CaloClusterStoreHelper::AddContainerWriteHandle
static StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
Definition: CaloClusterStoreHelper.cxx:53
ParticleTest.eg
eg
Definition: ParticleTest.py:29
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
DerivationFramework::CellsInConeThinning::addBranches
StatusCode addBranches() const
Pass the thinning service
Definition: CellsInConeThinning.cxx:47
DerivationFramework::CellsInCone::egammaSelect
void egammaSelect(xAOD::CaloCluster *inputCl, const CaloCellContainer *inputcells, const CaloDetDescrManager *caloMgr, const xAOD::Egamma *eg, const double dr)
Definition: CellsInCone.cxx:13
DerivationFramework::CellsInConeThinning::CellsInConeThinning
CellsInConeThinning(const std::string &type, const std::string &name, const IInterface *parent)
Definition: CellsInConeThinning.cxx:11
CellsInConeThinning.h
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
test_pyathena.parent
parent
Definition: test_pyathena.py:15
python.xAODType.dummy
dummy
Definition: xAODType.py:4
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
DerivationFramework::CellsInConeThinning::initialize
StatusCode initialize()
Definition: CellsInConeThinning.cxx:24
ExpressionParserUser
Definition: ExpressionParserUser.h:107
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CellsInCone.h
CaloClusterStoreHelper.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
DeMoScan.index
string index
Definition: DeMoScan.py:364
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
entries
double entries
Definition: listroot.cxx:49
AthAlgTool
Definition: AthAlgTool.h:26
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DerivationFramework::CellsInConeThinning::finalize
StatusCode finalize()
Definition: CellsInConeThinning.cxx:40