ATLAS Offline Software
Loading...
Searching...
No Matches
findMaxECell.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
6
9
10namespace egammaCellUtils
11{
13 const xAOD::CaloCluster *clus,
14 const std::string &cellCKey, bool UseWeightForMaxCell) :
15 AthMessaging("egammaCellUtils::MaxECell") {
16
17 const CaloClusterCellLink* cellLinks = clus->getCellLinks();
18 if (!cellLinks) {
19 ATH_MSG_WARNING("No cell link for cluster. Do nothing");
20 } else {
21
22 // First check :
23 const CaloCellContainer *caloCells = cellLinks->getCellContainer();
24 if (!caloCells) {
25 ATH_MSG_WARNING("No cells for cluster. Do nothing");
26 } else if (cellLinks->getCellContainerLink().dataID() != cellCKey) {
27 // Second check :
28 // one might have used a custom cell container for the linked cells
29 ATH_MSG_ERROR("Wrong key for the calo cells");
30 } else {
31
32 CaloClusterCellLink::const_iterator it_cell = cellLinks->begin(),
33 it_cell_e = cellLinks->end();
34
35 // find maximum cell energy in layer 2
36 double emax = 0.;
37 std::pair<const CaloCell*,double> maxcell{nullptr,0}; //just for debug
38 for(; it_cell != it_cell_e; ++it_cell) {
39 const CaloCell* cell = (*it_cell);
40 if (cell) {
41 if (!cell->caloDDE()) {
42 ATH_MSG_WARNING("Calo cell without detector element ?? eta = "
43 << cell->eta() << " phi = " << cell->phi());
44 continue;
45 }
46 int layer = cell->caloDDE()->getSampling();
47 if (layer == CaloSampling::EMB2 || layer == CaloSampling::EME2) {
48 double w = it_cell.weight();
49 double eCell = cell->energy();
50 if (UseWeightForMaxCell) eCell *= w;
51 if (eCell > emax) {
52 emax = eCell;
53 maxcell.first = cell;
54 maxcell.second = w;
55 }
56 }
57 }
58 }
59
60 if (emax > 0) {
61 etaCell = maxcell.first->caloDDE()->eta_raw();
62 phiCell = maxcell.first->caloDDE()->phi_raw();
63 if (msgLvl(MSG::DEBUG)) {
64 CaloSampling::CaloSample sam = maxcell.first->caloDDE()->getSampling();
65 double etaAmax = clus->etamax(sam);
66 double phiAmax = clus->phimax(sam);
67 double vemax = clus->energy_max(sam);
68 ATH_MSG_DEBUG("Cluster energy in sampling 2 = " << clus->energyBE(2)
69 << " maximum layer 2 energy cell, E = " << maxcell.first->energy()
70 << " check E = " << vemax
71 << " w = " << maxcell.second << "\n"
72 << " in calo frame, eta = " << etaCell << " phi = " << phiCell << "\n"
73 << " in ATLAS frame, eta = " << etaAmax << " phi = " << phiAmax);
74 }
75 } else {
76 ATH_MSG_WARNING("No layer 2 cell with positive energy ! Should never happen");
77 sc = StatusCode::FAILURE;
78 }
79 sc = StatusCode::SUCCESS;
80 } // links OK, good cell container
81 } // no links
82 } // end function
83}
84
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
bool msgLvl(const MSG::Level lvl) const
Test the output level.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Container class for CaloCell.
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
float energy_max(const CaloSample sampling) const
Retrieve maximum cell energy in given sampling.
float energyBE(const unsigned layer) const
Get the energy in one layer of the EM Calo.
float etamax(const CaloSample sampling) const
Retrieve of cell with maximum energy in given sampling.
float phimax(const CaloSample sampling) const
Retrieve of cell with maximum energy in given sampling.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.