ATLAS Offline Software
CookieCutterHelpers.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 namespace CookieCutterHelpers
9 {
11  const std::vector<const xAOD::CaloCluster*>& clusters,
12  const CaloDetDescrManager& mgr)
13  : AthMessaging("CookieCutterHelpers::CentralPosition")
14 {
15  for (const auto* cluster : clusters) {
16  if (cluster->hasSampling(CaloSampling::EMB2)) {
17  const float thisEmax = cluster->energy_max(CaloSampling::EMB2);
18  if (thisEmax > emaxB) {
19  emaxB = thisEmax;
20  etaB = cluster->etamax(CaloSampling::EMB2);
21  phiB = cluster->phimax(CaloSampling::EMB2);
22  }
23  }
24  if (cluster->hasSampling(CaloSampling::EME2)) {
25  const float thisEmax = cluster->energy_max(CaloSampling::EME2);
26  if (thisEmax > emaxEC) {
27  emaxEC = thisEmax;
28  etaEC = cluster->etamax(CaloSampling::EME2);
29  phiEC = cluster->phimax(CaloSampling::EME2);
30  }
31  }
32  if (cluster->hasSampling(CaloSampling::FCAL0)) {
33  const float thisEmax = cluster->energy_max(CaloSampling::FCAL0);
34  if (thisEmax > emaxF) {
35  emaxF = thisEmax;
36  etaF = cluster->etamax(CaloSampling::FCAL0);
37  phiF = cluster->phimax(CaloSampling::FCAL0);
38  }
39  }
40  }
41 
42  if (emaxB > 0) {
43  const CaloDetDescrElement* dde =
44  mgr.get_element(CaloCell_ID::EMB2, etaB, phiB);
45  if (dde) {
46  etaB = dde->eta_raw();
47  phiB = dde->phi_raw();
48  } else {
49  ATH_MSG_WARNING("Couldn't get CaloDetDescrElement from mgr for eta = "
50  << etaB << ", phi = " << phiB);
51  }
52  }
53  if (emaxEC > 0) {
54  const CaloDetDescrElement* dde =
55  mgr.get_element(CaloCell_ID::EME2, etaEC, phiEC);
56  if (dde) {
57  etaEC = dde->eta_raw();
58  phiEC = dde->phi_raw();
59  } else {
60  ATH_MSG_WARNING("Couldn't get CaloDetDescrElement from mgr for eta = "
61  << etaEC << ", phi = " << phiEC);
62  }
63  }
64  if (emaxF > 0) {
65  const CaloDetDescrElement* dde =
66  mgr.get_element(CaloCell_ID::FCAL0, etaF, phiF);
67  if (dde) {
68  etaF = dde->eta_raw();
69  phiF = dde->phi_raw();
70  } else {
71  ATH_MSG_WARNING("Couldn't get CaloDetDescrElement from mgr for eta = "
72  << etaF << ", phi = " << phiF);
73  }
74  }
75 }
76 
78 {
79  auto cell_itr = cluster.cell_cbegin();
80  auto cell_end = cluster.cell_cend();
81  for (; cell_itr != cell_end; ++cell_itr) {
82 
83  const CaloCell* cell = *cell_itr;
84  if (!cell) {
85  continue;
86  }
87 
88  const CaloDetDescrElement* dde = cell->caloDDE();
89  if (!dde) {
90  continue;
91  }
92 
93  if (cp0.emaxB > 0 && CaloCell_ID::EMB2 == dde->getSampling()) {
94  const float phi0 = cp0.phiB;
95  double cell_phi = proxim(dde->phi_raw(), phi0);
96  if (cell_phi > phi0) {
97  auto diff = cell_phi - phi0;
98  if (diff > plusB) {
99  plusB = diff;
100  }
101  } else {
102  auto diff = phi0 - cell_phi;
103  if (diff > minusB) {
104  minusB = diff;
105  }
106  }
107  } else if (cp0.emaxEC > 0 && CaloCell_ID::EME2 == dde->getSampling()) {
108  const float phi0 = cp0.phiEC;
109  double cell_phi = proxim(dde->phi_raw(), phi0);
110  if (cell_phi > phi0) {
111  auto diff = cell_phi - phi0;
112  if (diff > plusEC) {
113  plusEC = diff;
114  }
115  } else {
116  auto diff = phi0 - cell_phi;
117  if (diff > minusEC) {
118  minusEC = diff;
119  }
120  }
121  }
122  }
123 }
124 }
125 
CookieCutterHelpers::CentralPosition
Find the reference position (eta, phi) relative to which cells are restricted.
Definition: CookieCutterHelpers.h:19
CookieCutterHelpers::PhiSize::minusEC
float minusEC
Definition: CookieCutterHelpers.h:53
CookieCutterHelpers::CentralPosition::phiF
float phiF
Definition: CookieCutterHelpers.h:27
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
InDetAccessor::phi0
@ phi0
Definition: InDetAccessor.h:33
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
proxim
double proxim(double b, double a)
Definition: proxim.h:17
CookieCutterHelpers::PhiSize::PhiSize
PhiSize()=default
mc.diff
diff
Definition: mc.SFGenPy8_MuMu_DD.py:14
CaloDetDescrElement::eta_raw
float eta_raw() const
cell eta_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:350
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
proxim.h
CookieCutterHelpers::PhiSize::plusB
float plusB
Definition: CookieCutterHelpers.h:50
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
CookieCutterHelpers::PhiSize::plusEC
float plusEC
Definition: CookieCutterHelpers.h:52
CookieCutterHelpers::CentralPosition::etaB
float etaB
Definition: CookieCutterHelpers.h:20
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
CookieCutterHelpers::CentralPosition::etaF
float etaF
Definition: CookieCutterHelpers.h:26
CookieCutterHelpers::PhiSize::minusB
float minusB
Definition: CookieCutterHelpers.h:51
CookieCutterHelpers.h
xAOD::CaloCluster_v1::cell_cend
const_cell_iterator cell_cend() const
Definition: CaloCluster_v1.h:803
CookieCutterHelpers::CentralPosition::phiB
float phiB
Definition: CookieCutterHelpers.h:21
CookieCutterHelpers::CentralPosition::phiEC
float phiEC
Definition: CookieCutterHelpers.h:24
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
CookieCutterHelpers::CentralPosition::emaxB
float emaxB
Definition: CookieCutterHelpers.h:22
xAOD::CaloCluster_v1::cell_cbegin
const_cell_iterator cell_cbegin() const
Definition: CaloCluster_v1.h:795
CookieCutterHelpers
Definition: CookieCutterHelpers.h:14
CookieCutterHelpers::CentralPosition::CentralPosition
CentralPosition()=delete
CaloCell_ID_FCS::FCAL0
@ FCAL0
Definition: FastCaloSim_CaloCell_ID.h:40
CookieCutterHelpers::CentralPosition::emaxEC
float emaxEC
Definition: CookieCutterHelpers.h:25
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
CookieCutterHelpers::CentralPosition::etaEC
float etaEC
Definition: CookieCutterHelpers.h:23
CookieCutterHelpers::CentralPosition::emaxF
float emaxF
Definition: CookieCutterHelpers.h:28
CaloDetDescrElement::phi_raw
float phi_raw() const
cell phi_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:352