15#include "CaloDetDescr/CaloDetDescrElement.h"
27#include "CLHEP/Units/SystemOfUnits.h"
28#include "CLHEP/Units/PhysicalConstants.h"
32using std::numbers::pi;
35inline constexpr double twopi = 2*
pi;
36inline constexpr double deta = 0.2;
37inline constexpr double dphi =
twopi / 64. +
pi / 64.;
80 const double eps = 0.001;
89 deta_l = std::abs (
eta - elt_l->
eta_raw()) + eps;
98 deta_r = std::abs (
eta - elt_r->
eta_raw()) + eps;
101 deta = 2 * std::max (deta_r, deta_l);
127 dphi = 2 * std::max (dphi_l, dphi_r);
148 if(dd_man ==
nullptr){
228 bool dofill =
false) = 0;
292 bool allow_badpos =
false);
394 double seteta =
m_calc.etam();
395 double setphi =
m_calc.phim();
397 double fallback_eta =
eta;
398 double fallback_phi =
phi;
399 if ((seteta == -999 || setphi == -999) && fallback_layer >= 0 && fallback_layer < 4) {
401 fallback_eta =
m_cluster->etaSample (samplings[fallback_layer]);
402 fallback_phi =
m_cluster->phiSample (samplings[fallback_layer]);
408 if (seteta == -999) seteta = fallback_eta;
409 if (setphi == -999) setphi = fallback_phi;
516 return et(
a) <
et(b);
522 double et = cell->et();
576 bool dofill =
false);
583 virtual bool empty()
const;
702 bool dofill =
false);
708 virtual bool empty()
const;
757 return *std::max_element(std::as_const(*m_cluster).cell_begin(),
758 std::as_const(*m_cluster).cell_end(),
783 (
const std::string&
type,
784 const std::string& name,
785 const IInterface* parent)
805 return StatusCode::SUCCESS;
828 helper.calculate_and_set (
eta,
phi, 2, -1, samplings,
true);
830 double eta2 = helper.etam();
831 double phi2 = helper.phim();
833 if (eta2 == -999.) eta2 =
eta;
834 if (phi2 == -999.) phi2 =
phi;
837 helper.calculate_and_set (eta2, phi2, 1, -1, samplings);
838 double eta1 = helper.etam();
839 double phi1 = helper.phim();
841 if (eta1 == -999. || phi1 == -999.) {
843 if (eta1 == -999.) eta1 = eta2;
844 if (phi1 == -999.) phi1 = phi2;
851 if (samplings[1] == CaloSampling::EMB1)
852 xsample = CaloCell_ID::EMB1;
854 xsample = CaloCell_ID::EME1;
859 double detastr, dphistr;
864 if (detastr > 0 && dphistr > 0) {
865 helper.calculate_cluster (helper.etamax(), helper.phimax(),
866 detastr, dphistr, samplings[1]);
868 if (helper.etam()!=-999.) {
869 eta1 = helper.etam();
870 double eta1r = helper.etareal();
871 helper.cluster()->setEta(samplings[1], eta1r);
877 helper.calculate_and_set (eta1, phi2, 0, 1, samplings);
880 helper.calculate_and_set (eta2, phi2, 3, -1, samplings);
884 if ( helper.cluster()->hasSampling(CaloSampling::TileGap3) && samplings[0]==CaloSampling::PreSamplerE )
887 const CaloCellContainer* cc = helper.cluster()->getCellLinks()->getCellContainer();
894 <<
"Can't retrieve cell container " <<
m_cellsName.key();
903 <<
"Can't find cell container; cluster does not give a cell container";
914 for ( ; f_cell!=l_cell; ++f_cell)
918 if (CaloCell_ID::TileGap3 == cell->caloDDE()->getSampling()) {
920 if( fabs(cell->eta()) < 1.4 || fabs(cell->eta()) > 1.6 )
continue;
921 double phic = cell->phi();
922 double etac = cell->eta();
924 float diffeta = etac-eta2;
925 float diffphi = phic-phi2;
926 if (diffphi < -
pi) diffphi +=
twopi;
927 if (diffphi >
pi) diffphi -=
twopi;
929 if(fabs(diffeta)<deta && fabs(diffphi)<dphi){
930 eh_scint += cell->e();
935 helper.cluster()->setEnergy(CaloSampling::TileGap3,eh_scint);
937 helper.cluster()->setEta(CaloSampling::TileGap3, eta2);
938 helper.cluster()->setPhi(CaloSampling::TileGap3, phi2);
963 double aeta = fabs(
eta);
1011 { CaloSampling::PreSamplerB, CaloSampling::EMB1,
1012 CaloSampling::EMB2, CaloSampling::EMB3 };
1014 { CaloSampling::PreSamplerE, CaloSampling::EME1,
1015 CaloSampling::EME2, CaloSampling::EME3 };
1023 uint32_t samplingPattern_b=0xf;
1024 uint32_t samplingPattern_e=0xf0;
1025 uint32_t samplingPattern=0;
1028 samplingPattern |=samplingPattern_b;
1031 samplingPattern |=samplingPattern_e;
1033 if (aeta > 1.37 && aeta < 1.63)
1034 samplingPattern |=(1<<(uint32_t)CaloSampling::TileGap3);
1036 cluster->setSamplingPattern(samplingPattern);
1050 for(
int i=0; i<4; i++ ){
1051 cl_ene += cluster->
eSample(samplings_b[i]);
1052 cl_ene += cluster->
eSample(samplings_e[i]);
1054 cluster->
setE(cl_ene);
1077 if(!caloDetDescrMgrHandle.
isValid()){
1078 ATH_MSG_ERROR (
"Failed to retrieve CaloDetDescrManager : CaloMgr");
1081 const CaloDetDescrManager* calodetdescrmgr = *caloDetDescrMgrHandle;
1083 CaloClusterCorr::Segmentation seg (calodetdescrmgr);
1084 if (seg.m_detas2 == 0) {
1089 seg.m_detas2, seg.m_dphis2);
1094 const CaloCellContainer* cell_container = cluster->getCellLinks()->
getCellContainer();
1097 cluster->getOwnCellLinks()->clear();
1101 SG::ReadHandle<CaloCellContainer> cchand (
m_cellsName, myctx.ctx());
1102 if (!cchand.isValid()) {
1104 <<
"Can't retrieve cell container " <<
m_cellsName.key();
1107 cell_container = cchand.cptr();
1119 CaloCellList cell_list(calodetdescrmgr,cell_container);
1123 CaloClusterCorr::SamplingHelper_CaloCellList
helper (*
this,
1132 CaloClusterCorr::SamplingHelper_Cluster
helper (*
this,
windows, cluster);
1153 const CaloCell* max_et_cell = helper.max_et_cell();
1160 double phi_shift = elt->
phi()-elt->
phi_raw();
1161 double eta_shift = elt->
eta()-elt->
eta_raw();
1162 eta = cluster->
eta0()+eta_shift;
1194 if (std::abs (
eta - elt->
eta()) > helper.deta(2)/2) {
1214 (
const std::string& name)
1216 return this->
setProperty (StringProperty (
"cells_name", name));
1232 const double detas2,
1233 const double dphis2)
const
1238 w[0].first = detas2*neta;
1239 w[0].second = dphis2*4;
1246 w[1].first = w[0].first;
1247 w[1].second = w[0].second;
1249 w[2].first = detas2*neta;
1250 w[2].second = dphis2*nphi;
1252 w[3].first = (2*detas2)*(0.5 + (neta/2.));
1253 w[3].second = w[2].second;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition of CaloDetDescriptor.
Calculates the per-layer position, size, etc. of a cluster. Optionally, fills the cluster with cells ...
Calculate total energy, position, etc. for a given layer of a cluster.
CaloPhiRange class declaration.
Helpers for checking error return status codes and reporting errors.
#define REPORT_ERROR(SC)
Report an error.
#define CHECK(...)
Evaluate an expression and check for errors.
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
Handle class for reading from StoreGate.
Container class for CaloCell.
CaloSampling::CaloSample CaloSample
Data object for each calorimeter readout cell.
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
virtual bool empty() const
Test for empty candidate cell list.
virtual const CaloCell * max_et_cell() const
Return the cell with the maximum energy.
const CaloCellList & m_list
The cell list.
SamplingHelper_CaloCellList(const CaloClusterCorrection &parent, const CaloFillRectangularCluster::WindowArray_t &windows, CaloCluster *cluster, const CaloCellList &list, const CaloCellContainer *cell_container)
Constructor.
virtual void calculate(double eta, double phi, double deta, double dphi, CaloSampling::CaloSample sampling, bool dofill=false)
Calculate layer variables.
SamplingHelper_Cluster(const CaloClusterCorrection &parent, const CaloFillRectangularCluster::WindowArray_t &windows, CaloCluster *cluster)
Constructor.
virtual const CaloCell * max_et_cell() const
Return the cell with the maximum energy.
virtual void calculate(double eta, double phi, double deta, double dphi, CaloSampling::CaloSample sampling, bool dofill=false)
Calculate layer variables.
virtual bool empty() const
Test for empty candidate cell list.
Sampling calculator helper class.
double etamax() const
Return the maximum position from the last calculation.
double deta(int layer) const
CaloLayerCalculator m_calc
The calculator object.
virtual ~SamplingHelper()=default
Destructor — just to get a vtable.
virtual const CaloCell * max_et_cell() const =0
Return the cell with the maximum energy — abstract method.
SamplingHelper(const CaloClusterCorrection &parent, const CaloFillRectangularCluster::WindowArray_t &windows, CaloCluster *cluster)
Constructor.
virtual void calculate(double eta, double phi, double deta, double dphi, CaloSampling::CaloSample sampling, bool dofill=false)=0
Calculate layer variables — abstract method.
double phim() const
Return the position from the last calculation.
const CaloClusterCorrection & m_parent
The correction object using us.
double etam() const
Return the position from the last calculation.
double m_phim
position from last calculation.
void calculate_and_set(double eta, double phi, int layer, int fallback_layer, const CaloSampling::CaloSample samplings[4], bool allow_badpos=false)
Calculate layer variables and update cluster.
CaloCluster * m_cluster
The cluster we're updating.
CaloCluster * cluster()
Return the cluster we're updating.
double phimax() const
Return the maximum position from the last calculation.
double m_etam
position from last calculation.
virtual bool empty() const =0
Test for empty candidate cell list — abstract method.
CaloFillRectangularCluster::WindowArray_t m_windows
Window size, per layer.
void calculate_cluster(double eta, double phi, double deta, double dphi, CaloSampling::CaloSample sampling)
Calculate layer variables for cells in the cluster.
double dphi(int layer) const
double m_detas2
middle layer cell segmentation size
Segmentation(const CaloDetDescrManager *dd_man)
virtual StatusCode initialize() override
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Principal data class for CaloCell clusters.
double eta0() const
Returns raw of cluster seed.
void setRawEta(double eta)
Set raw eta.
double eSample(sampling_type sampling) const
Retrieve energy in a given sampling.
unsigned int getClusterEtaSize() const
void setRawPhi(double phi)
Set raw phi.
void setRawE(double e)
Set raw energy.
void setClusterSize(unsigned int theClusterSize)
Set cluster size.
unsigned int getClusterPhiSize() const
double phi0() const
Returns raw of cluster seed.
virtual void setE(double e)
Set energy.
const CaloCellContainer * getCellContainer(const CaloCell *pCell) const
Retrieve the pointer to the original cell container for a given cell.
This class groups all DetDescr information related to a CaloCell.
float eta_raw() const
cell eta_raw
float dphi() const
cell dphi
float eta() const
cell eta
bool is_lar_em_endcap_outer() const
cell belongs to the outer wheel of EM end cap
float phi() const
cell phi
float phi_raw() const
cell phi_raw
float deta() const
cell deta
bool is_lar_em_endcap_inner() const
cell belongs to the inner wheel of EM end cap
const CaloDetDescriptor * descriptor() const
cell descriptor
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
const CaloDetDescrElement * get_element_raw(CaloCell_ID::CaloSample sample, double eta, double phi) const
Get element from raw quantities (to build real fixed size clusters).
This class provides the client interface for accessing the detector description information common to...
double calo_eta_min() const
'ideal' geometry: eta minimal
double calo_eta_max() const
'ideal' geometry: eta maximal
Gaudi::Property< int > m_neta
cluster size. These are properties.
Gaudi::Property< bool > m_fill_cluster
Fill-cluster flag.
SG::ReadHandleKey< CaloCellContainer > m_cellsName
The StoreGate key for the container of our input cells.
Gaudi::Property< bool > m_setRawState
Property to tell if the raw energy, eta0 and phi0 should be saved as uncalibrated signal state.
virtual void get_seed(CaloClusterCorr::SamplingHelper &helper, const xAOD::CaloCluster *cluster, double &eta, double &phi) const
std::array< std::pair< double, double >, 4 > WindowArray_t
Holds the per-layer window sizes.
void makeCorrection2(const EventContext &ctx, const CaloDetDescrManager &dd_man, CaloClusterCorr::SamplingHelper &helper) const
CaloFillRectangularCluster()=delete
This isn't allowed.
virtual void makeCorrection(const Context &myctx, xAOD::CaloCluster *cluster) const override
CaloClusterCorrection virtual method.
void makeCorrection1(const EventContext &ctx, const CaloDetDescrManager &dd_man, CaloClusterCorr::SamplingHelper &helper, double eta, double phi, const CaloSampling::CaloSample samplings[4]) const
virtual WindowArray_t initWindows(const int neta, const int nphi, const double detas2, const double dphis2) const
Set up layer-by-layer cluster window sizes.
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Gaudi::Property< int > m_nphi
virtual StatusCode setCaloCellContainerName(const std::string &name) override
Change the name of the CaloCellContainer used by this tool.
static double fix(double phi)
DataModel_detail::const_iterator< DataVector > const_iterator
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
ClusterSize
Enumeration to identify different cluster sizes.
void etaphi_range(const CaloDetDescrManager &dd_man, double eta, double phi, CaloCell_ID::CaloSample sampling, double &deta, double &dphi)
Return eta/phi ranges encompassing +- 1 cell.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Helper to compare two cells by Et.
bool operator()(const CaloCell *a, const CaloCell *b)
static double et(const CaloCell *cell)
int windows(float distance, float eta_pivot, int thr, int sector)