ATLAS Offline Software
egammaLargeClusterMaker.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
16 #include "StoreGate/ReadHandle.h"
17 #include "StoreGate/WriteHandle.h"
18 
20  const std::string& name,
21  const IInterface* parent)
23 {
24 
25  // declare interface
26  declareInterface<CaloClusterCollectionProcessor>(this);
27 }
28 
31 {
35  return StatusCode::SUCCESS;
36 }
37 
39 egammaLargeClusterMaker::execute(const EventContext& ctx,
40  xAOD::CaloClusterContainer* collection) const
41 {
42 
43  if (!collection) {
44  ATH_MSG_ERROR("A null collection was passed, which should never happen");
45  return StatusCode::FAILURE;
46  }
47 
50  // retrieve the cell containers
52 
53  // retrieve CaloDetDescr
54  SG::ReadCondHandle<CaloDetDescrManager> caloDetDescrMgrHandle{
56  };
57  ATH_CHECK(caloDetDescrMgrHandle.isValid());
58 
59  const CaloDetDescrManager* calodetdescrmgr = *caloDetDescrMgrHandle;
60 
61  DataLink<CaloCellContainer> cellLink (cellcoll.ptr(), ctx);
62 
63  // The main loop over clusters
64  for (const auto* cluster : *inputClusters) {
65 
66  if (!m_isFWD) {
67 
68  if (cluster->et() < m_centEtThr)
69  continue;
70 
71  // find the center of the cluster, copying the logic of
72  // egammaMiddleShape.cxx
73 
74  // check if cluster is in barrel or end-cap
75  if (!cluster->inBarrel() && !cluster->inEndcap()) {
76  continue;
77  }
78 
79  // check if cluster is in barrel or end-cap
80  bool in_barrel = egammaEnergyPositionAllSamples::inBarrel(*cluster, 2);
82  if (!in_barrel) {
83  sam = CaloSampling::EME2;
84  }
85 
86  // granularity in (eta,phi) in the pre sampler
87  // CaloCellList needs both enums: subCalo and CaloSample
88  auto eta = cluster->etaSample(sam);
89  auto phi = cluster->phiSample(sam);
90 
91  if ((eta == 0. && phi == 0.) || std::abs(eta) > 100) {
92  ATH_MSG_WARNING("Weird input cluster, eta = " << eta
93  << " phi = " << phi);
94  continue;
95  }
96 
97  // Should get overritten
98  bool barrel = false;
100  int sampling_or_module = 0;
101 
103  subcalo, barrel, sampling_or_module, (CaloCell_ID::CaloSample)sam);
104 
105  // Get the corresponding grannularities : needs to know where you are
106  // the easiest is to look for the CaloDetDescrElement
107 
108  const CaloDetDescrElement* dde = calodetdescrmgr->get_element(
109  CaloCell_ID::LAREM, sampling_or_module, barrel, eta, phi);
110 
111  // if object does not exist then return
112  if (!dde) {
113  ATH_MSG_WARNING("Weird input cluster eta = " << eta
114  << " phi = " << phi);
115  ATH_MSG_WARNING("No detetector element for seeding");
116  continue;
117  }
118 
119  // local granularity
120  auto deta = dde->deta();
121  auto dphi = dde->dphi();
122 
123  // search the hottest cell around the (eta,phi)
124  // (eta,phi) are defined as etaSample() and phiSample
125  // around this position a hot cell is searched for in a window
126  // (m_neta*m_deta,m_nphi*m_dphi), by default (m_neta,m_nphi)=(7,7)
128  StatusCode sc =
129  calc.fill(*calodetdescrmgr, cellcoll.ptr(), cluster->etaSample(sam),
130  cluster->phiSample(sam), m_neta * deta, m_nphi * dphi,
132  if (sc.isFailure()) {
133  ATH_MSG_WARNING("CaloLayerCalculator failed fill ");
134  continue;
135  }
136  double etamax = calc.etarmax();
137  double phimax = calc.phirmax();
138 
139  // create the new cluster
140  xAOD::CaloCluster* newCluster =
141  CaloClusterStoreHelper::makeCluster(collection, cellLink);
142  newCluster->setEta0(etamax);
143  newCluster->setPhi0(phimax);
145 
146  } else {
147  // FWD cluster collection
148  if (cluster->et() < m_fwdEtThr){
149  continue;
150  }
151 
152  // check if cluster is in EMEC or FCAL
153  if (cluster->inBarrel()) {
154  continue;
155  }
156 
157  // need some positive energy in EME2 or FCAL0 to be a good candidate
158  if (cluster->eSample(CaloSampling::EME2) <= 0 &&
159  cluster->eSample(CaloSampling::FCAL0) <= 0){
160  continue;
161  }
162 
163  // check if cluster is in FCAL or EMEC
165  bool in_EMEC = !(xAOD::EgammaHelpers::isFCAL(cluster));
166  if(in_EMEC){
167  sam = CaloSampling::EME2;
168  }
169  // granularity in (eta,phi) in the pre sampler
170  // CaloCellList needs both enums: subCalo and CaloSample
171  auto eta = cluster->etaSample(sam);
172  auto phi = cluster->phiSample(sam);
173 
174  if ((eta == 0. && phi == 0.) || std::abs(eta) > 100) {
175  ATH_MSG_WARNING("Weird input cluster, maxeta = "
176  << eta << " phi = " << phi << " Eeme2 = "
177  << cluster->eSample(CaloSampling::EME2) << " Efcal = "
178  << cluster->eSample(CaloSampling::FCAL0));
179  continue;
180  }
181 
182  // Should get overritten
183  bool emec = false;
185  int sampling_or_module = 0;
186 
188  subcalo, emec, sampling_or_module, (CaloCell_ID::CaloSample)sam);
189 
190  // Get the corresponding grannularities : needs to know where you are
191  // the easiest is to look for the CaloDetDescrElement
192  // const CaloDetDescrElement* get_element_FCAL (const
193  // CaloDetDescriptor* reg, double eta, double phi) const;
194  const CaloDetDescrElement* dde = calodetdescrmgr->get_element(
195  subcalo, sampling_or_module, emec, eta, phi);
196 
197  // if object does not exist then return
198  if (!dde) {
199  ATH_MSG_WARNING("Weird input cluster eta = " << eta
200  << " phi = " << phi);
201  ATH_MSG_WARNING("No detetector element for seeding");
202  continue;
203  }
204 
205  // local granularity
206  auto deta = dde->deta();
207  auto dphi = dde->dphi();
208 
209  // search the hottest cell around the (eta,phi)
210  // (eta,phi) are defined as etaSample() and phiSample
211  // around this position a hot cell is searched for in a window
212  // (m_neta*m_deta,m_nphi*m_dphi), by default (m_neta,m_nphi)=(6,6)
213  // for EMEC-OUTER FWD much bigger cell size
214 
215  // create the new cluster
216  xAOD::CaloCluster* newCluster =
217  CaloClusterStoreHelper::makeCluster(collection, cellLink);
218 
219  // if In EMEC
221  StatusCode sc = calc.fill(
222  *calodetdescrmgr, cellcoll.ptr(), cluster->etaSample(sam),
223  cluster->phiSample(sam), m_netaFWD * deta, m_nphiFWD * dphi,
224  (CaloSampling::CaloSample)sam, in_EMEC ? newCluster : nullptr);
225 
226  if (sc.isFailure()) {
227  ATH_MSG_WARNING("CaloLayerCalculator failed fill for FWD cluster");
228  continue;
229  }
230  double etamax = calc.etarmax();
231  double phimax = calc.phirmax();
232 
233  newCluster->setEta0(etamax);
234  newCluster->setPhi0(phimax);
235 
236  std::map<CaloSampling::CaloSample, double> caloSamV;
237  if (!in_EMEC) {
238  caloSamV[CaloSampling::FCAL0] = m_drFWD;
239  }
241  caloSamV[CaloSampling::EME1] = m_drEM;
242  if (in_EMEC) {
243  caloSamV[CaloSampling::FCAL0] = m_drFWD;
244  } else {
245  caloSamV[CaloSampling::EME2] = m_drFWD;
246  }
247  }
248 
249  if (!caloSamV.empty()) {
250  // If FCAL need to add cell to cluster in a cone.
251  // Also if we want cells from other samplings
252  std::vector<const CaloCell*> cells;
253  cells.reserve(300);
254  CaloCellList myList(calodetdescrmgr, cellcoll.ptr());
255  for (auto s : caloSamV) {
256  myList.select(cluster->etaSample(sam), cluster->phiSample(sam),
257  s.second, (CaloSampling::CaloSample)s.first);
258  cells.insert(cells.end(), myList.begin(), myList.end());
259  }
260  for (const auto* cell : cells) {
261  if (!cell || !cell->caloDDE()) {
262  continue;
263  }
264  int index = cellcoll.ptr()->findIndex(cell->caloDDE()->calo_hash());
265  if (index == -1) {
266  continue;
267  }
268  newCluster->addCell(index, 1.);
269  }
270  }
271  } // end isFWD
272  } // main loop over clusters
273  return StatusCode::SUCCESS;
274 }
CaloDetDescrElement::deta
float deta() const
cell deta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:356
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
egammaLargeClusterMaker::m_fwdEtThr
Gaudi::Property< double > m_fwdEtThr
Et cut on input forward clusters to produce large clusters.
Definition: egammaLargeClusterMaker.h:132
egammaLargeClusterMaker::m_isFWD
Gaudi::Property< bool > m_isFWD
do FWD cell
Definition: egammaLargeClusterMaker.h:77
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition: CaloCell_Base_ID.h:46
egammaLargeClusterMaker::m_centEtThr
Gaudi::Property< double > m_centEtThr
Et cut on input central clusters to produce large clusters.
Definition: egammaLargeClusterMaker.h:97
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
CaloCellList::begin
list_iterator begin() const
Definition: CaloCellList.h:87
CaloCellList
Definition: CaloCellList.h:40
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
CaloCellList::select
void select(double eta, double phi, double deta, double dphi)
Definition: CaloCellList.cxx:67
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
CaloCellList.h
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
egammaEnergyPositionAllSamples::inBarrel
bool inBarrel(const xAOD::CaloCluster &cluster, int is)
return boolean to know if we are in barrel/end-cap
egammaLargeClusterMaker::m_nphiFWD
Gaudi::Property< double > m_nphiFWD
Definition: egammaLargeClusterMaker.h:110
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
egammaLargeClusterMaker::m_cellsKey
SG::ReadHandleKey< CaloCellContainer > m_cellsKey
Cell container.
Definition: egammaLargeClusterMaker.h:62
CaloClusterAuxContainer.h
egammaLargeClusterMaker::initialize
virtual StatusCode initialize() override final
initialize method
Definition: egammaLargeClusterMaker.cxx:30
egammaLargeClusterMaker::m_addCellsFromOtherSamplings
Gaudi::Property< bool > m_addCellsFromOtherSamplings
Et cut on input forward clusters to produce large clusters.
Definition: egammaLargeClusterMaker.h:139
xAOD::CaloCluster_v1::setEta0
void setEta0(flt_t)
xAOD::CaloCluster_v1::SW_7_11
@ SW_7_11
Definition: CaloCluster_v1.h:105
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloCellList::end
list_iterator end() const
Definition: CaloCellList.h:93
WriteHandle.h
Handle class for recording to StoreGate.
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
EgammaxAODHelpers.h
egammaLargeClusterMaker::m_nphi
Gaudi::Property< double > m_nphi
Definition: egammaLargeClusterMaker.h:89
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
xAOD::CaloCluster_v1::setPhi0
void setPhi0(flt_t)
Set raw of cluster seed.
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloCluster.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
egammaLargeClusterMaker::m_netaFWD
Gaudi::Property< double > m_netaFWD
Definition: egammaLargeClusterMaker.h:103
CaloCell_Base_ID::SUBCALO
SUBCALO
enumeration of sub calorimeters
Definition: CaloCell_Base_ID.h:46
test_pyathena.parent
parent
Definition: test_pyathena.py:15
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
egammaLargeClusterMaker::m_drEM
Gaudi::Property< double > m_drEM
Definition: egammaLargeClusterMaker.h:124
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
egammaEnergyPositionAllSamples.h
egammaLargeClusterMaker::m_neta
Gaudi::Property< double > m_neta
Definition: egammaLargeClusterMaker.h:82
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
egammaLargeClusterMaker::execute
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *collection) const override final
execute on container
Definition: egammaLargeClusterMaker.cxx:39
xAOD::EgammaHelpers::isFCAL
bool isFCAL(const xAOD::CaloCluster *cluster)
return true if the cluster (or the majority of its energy) is in the FCAL0
Definition: EgammaxAODHelpers.cxx:46
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCellContainer.h
CaloClusterStoreHelper.h
SG::ReadHandle::ptr
const_pointer_type ptr()
Dereference the pointer.
CaloDetDescrElement::dphi
float dphi() const
cell dphi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:358
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
xAOD::CaloCluster_v1::setClusterSize
void setClusterSize(const ClusterSize)
Get cluster size.
Definition: CaloCluster_v1.cxx:369
egammaLargeClusterMaker::m_drFWD
Gaudi::Property< double > m_drFWD
Definition: egammaLargeClusterMaker.h:117
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloLayerCalculator
Definition: CaloLayerCalculator.h:82
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloDetDescrManager_Base::decode_sample
static void decode_sample(CaloCell_ID::SUBCALO &subCalo, bool &barrel, int &sampling_or_module, CaloCell_ID::CaloSample sample)
translate between the 2 ways to label a sub-detector:
Definition: CaloDetDescrManager.cxx:1468
DetectorZone::barrel
@ barrel
CaloCellContainer::findIndex
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
Definition: CaloCellContainer.cxx:363
ReadHandle.h
Handle class for reading from StoreGate.
AthAlgTool
Definition: AthAlgTool.h:26
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:46
egammaLargeClusterMaker::m_inputClusterCollection
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClusterCollection
The name of the cluster container for electrons and photons.
Definition: egammaLargeClusterMaker.h:54
CaloCell_ID_FCS::FCAL0
@ FCAL0
Definition: FastCaloSim_CaloCell_ID.h:40
beamspotnt.calc
calc
Definition: bin/beamspotnt.py:1252
egammaLargeClusterMaker::egammaLargeClusterMaker
egammaLargeClusterMaker(const std::string &type, const std::string &name, const IInterface *parent)
@bried constructor
Definition: egammaLargeClusterMaker.cxx:19
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
egammaLargeClusterMaker.h
CaloLayerCalculator.h
Calculate total energy, position, etc. for a given layer of a cluster.
egammaLargeClusterMaker::m_caloDetDescrMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
Definition: egammaLargeClusterMaker.h:69