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)
15  : base_class(type, name, parent)
16  , m_selectionString("")
17  , m_dr(0.5)
18 {
19  declareProperty("deltaR", m_dr = 0.5);
20 }
21 
24 {
25 
26  ATH_CHECK(m_SGKey.initialize());
27  ATH_CHECK(m_InputCellsSGKey.initialize());
28  ATH_CHECK(m_OutputClusterSGKey.initialize());
29  ATH_CHECK(m_OutputCellLinkSGKey.initialize());
30  ATH_CHECK(m_caloMgrKey.initialize());
31 
32  if (!m_selectionString.empty()) {
33  ATH_CHECK(initializeParser(m_selectionString));
34  }
35  return StatusCode::SUCCESS;
36 }
37 
40 {
41  ATH_CHECK(finalizeParser());
42  return StatusCode::SUCCESS;
43 }
44 
47 {
48 
50  SG::WriteHandle<xAOD::CaloClusterContainer> dclHdl(m_OutputClusterSGKey);
52 
55  const xAOD::EgammaContainer* egammas = egHdl.cptr();
56  if (!egammas) {
57  ATH_MSG_ERROR("Couldn't retrieve egamma container with key: " << m_SGKey);
58  return StatusCode::FAILURE;
59  }
60 
61  unsigned int nEgammas(egammas->size());
62  if (nEgammas == 0) {
63  return StatusCode::SUCCESS;
64  }
65 
66  SG::ReadHandle<CaloCellContainer> cellHdl(m_InputCellsSGKey);
67  const CaloCellContainer* cells = cellHdl.cptr();
68  if (!cells) {
70  "Couldn't retrieve cell container with key: " << m_InputCellsSGKey);
71  return StatusCode::FAILURE;
72  }
73 
74  SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{ m_caloMgrKey };
75  const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
76 
77  // We have a selection string
78  if (!m_selectionString.empty()) {
79  std::vector<int> entries = m_parser->evaluateAsVector();
80  unsigned int nEntries = entries.size();
81  // check the sizes are compatible
82  if (nEgammas != nEntries) {
83  ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string "
84  "used e-gamma objects");
85  return StatusCode::FAILURE;
86  }
87  // Loop over the egammas, pick the selected ones and fill the cluster
88  int index(0);
89  for (const xAOD::Egamma* eg : *egammas) {
90  if (static_cast<bool>(entries.at(index))) {
93  dummy, cells, caloDDMgr, eg, m_dr);
94  }
95  ++index;
96  }
97  }
99  else {
100  for (const xAOD::Egamma* eg : *egammas) {
103  dummy, cells, caloDDMgr, eg, m_dr);
104  }
105  }
108  m_OutputCellLinkSGKey);
111  return StatusCode::SUCCESS;
112 }
114 
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:70
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:281
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:67
index
Definition: index.py:1
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
DerivationFramework::CellsInConeThinning::addBranches
StatusCode addBranches() const
Definition: CellsInConeThinning.cxx:46
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
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
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:62
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.
CalibDbCompareRT.dummy
dummy
Definition: CalibDbCompareRT.py:59
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:794
DerivationFramework::CellsInConeThinning::initialize
StatusCode initialize()
Definition: CellsInConeThinning.cxx:23
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CellsInCone.h
CaloClusterStoreHelper.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
DeMoScan.index
string index
Definition: DeMoScan.py:362
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
entries
double entries
Definition: listroot.cxx:49
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:72
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DerivationFramework::CellsInConeThinning::finalize
StatusCode finalize()
Definition: CellsInConeThinning.cxx:39