15#include "CaloDetDescr/CaloDetDescrElement.h"
26#include "CLHEP/Units/SystemOfUnits.h"
27#include "CLHEP/Units/PhysicalConstants.h"
35const double deta = 0.2;
36const double dphi =
twopi / 64. +
pi / 64.;
79 const double eps = 0.001;
88 deta_l = std::abs (
eta - elt_l->
eta_raw()) + eps;
97 deta_r = std::abs (
eta - elt_r->
eta_raw()) + eps;
100 deta = 2 * std::max (deta_r, deta_l);
126 dphi = 2 * std::max (dphi_l, dphi_r);
147 if(dd_man ==
nullptr){
227 bool dofill =
false) = 0;
291 bool allow_badpos =
false);
393 double seteta =
m_calc.etam();
394 double setphi =
m_calc.phim();
396 double fallback_eta =
eta;
397 double fallback_phi =
phi;
398 if ((seteta == -999 || setphi == -999) && fallback_layer >= 0 && fallback_layer < 4) {
400 fallback_eta =
m_cluster->etaSample (samplings[fallback_layer]);
401 fallback_phi =
m_cluster->phiSample (samplings[fallback_layer]);
407 if (seteta == -999) seteta = fallback_eta;
408 if (setphi == -999) setphi = fallback_phi;
515 return et(
a) <
et(b);
521 double et = cell->et();
575 bool dofill =
false);
582 virtual bool empty()
const;
701 bool dofill =
false);
707 virtual bool empty()
const;
756 return *std::max_element(std::as_const(*m_cluster).cell_begin(),
757 std::as_const(*m_cluster).cell_end(),
782 (
const std::string&
type,
783 const std::string& name,
784 const IInterface* parent)
804 return StatusCode::SUCCESS;
827 helper.calculate_and_set (
eta,
phi, 2, -1, samplings,
true);
829 double eta2 = helper.etam();
830 double phi2 = helper.phim();
832 if (eta2 == -999.) eta2 =
eta;
833 if (phi2 == -999.) phi2 =
phi;
836 helper.calculate_and_set (eta2, phi2, 1, -1, samplings);
837 double eta1 = helper.etam();
838 double phi1 = helper.phim();
840 if (eta1 == -999. || phi1 == -999.) {
842 if (eta1 == -999.) eta1 = eta2;
843 if (phi1 == -999.) phi1 = phi2;
850 if (samplings[1] == CaloSampling::EMB1)
851 xsample = CaloCell_ID::EMB1;
853 xsample = CaloCell_ID::EME1;
858 double detastr, dphistr;
863 if (detastr > 0 && dphistr > 0) {
864 helper.calculate_cluster (helper.etamax(), helper.phimax(),
865 detastr, dphistr, samplings[1]);
867 if (helper.etam()!=-999.) {
868 eta1 = helper.etam();
869 double eta1r = helper.etareal();
870 helper.cluster()->setEta(samplings[1], eta1r);
876 helper.calculate_and_set (eta1, phi2, 0, 1, samplings);
879 helper.calculate_and_set (eta2, phi2, 3, -1, samplings);
883 if ( helper.cluster()->hasSampling(CaloSampling::TileGap3) && samplings[0]==CaloSampling::PreSamplerE )
886 const CaloCellContainer* cc = helper.cluster()->getCellLinks()->getCellContainer();
893 <<
"Can't retrieve cell container " <<
m_cellsName.key();
902 <<
"Can't find cell container; cluster does not give a cell container";
913 for ( ; f_cell!=l_cell; ++f_cell)
917 if (CaloCell_ID::TileGap3 == cell->caloDDE()->getSampling()) {
919 if( fabs(cell->eta()) < 1.4 || fabs(cell->eta()) > 1.6 )
continue;
920 double phic = cell->phi();
921 double etac = cell->eta();
923 float diffeta = etac-eta2;
924 float diffphi = phic-phi2;
925 if (diffphi < -
pi) diffphi +=
twopi;
926 if (diffphi >
pi) diffphi -=
twopi;
928 if(fabs(diffeta)<deta && fabs(diffphi)<dphi){
929 eh_scint += cell->e();
934 helper.cluster()->setEnergy(CaloSampling::TileGap3,eh_scint);
936 helper.cluster()->setEta(CaloSampling::TileGap3, eta2);
937 helper.cluster()->setPhi(CaloSampling::TileGap3, phi2);
962 double aeta = fabs(
eta);
1010 { CaloSampling::PreSamplerB, CaloSampling::EMB1,
1011 CaloSampling::EMB2, CaloSampling::EMB3 };
1013 { CaloSampling::PreSamplerE, CaloSampling::EME1,
1014 CaloSampling::EME2, CaloSampling::EME3 };
1022 uint32_t samplingPattern_b=0xf;
1023 uint32_t samplingPattern_e=0xf0;
1024 uint32_t samplingPattern=0;
1027 samplingPattern |=samplingPattern_b;
1030 samplingPattern |=samplingPattern_e;
1032 if (aeta > 1.37 && aeta < 1.63)
1033 samplingPattern |=(1<<(uint32_t)CaloSampling::TileGap3);
1035 cluster->setSamplingPattern(samplingPattern);
1049 for(
int i=0; i<4; i++ ){
1050 cl_ene += cluster->
eSample(samplings_b[i]);
1051 cl_ene += cluster->
eSample(samplings_e[i]);
1053 cluster->
setE(cl_ene);
1076 if(!caloDetDescrMgrHandle.
isValid()){
1077 ATH_MSG_ERROR (
"Failed to retrieve CaloDetDescrManager : CaloMgr");
1080 const CaloDetDescrManager* calodetdescrmgr = *caloDetDescrMgrHandle;
1082 CaloClusterCorr::Segmentation seg (calodetdescrmgr);
1083 if (seg.m_detas2 == 0) {
1088 seg.m_detas2, seg.m_dphis2);
1093 const CaloCellContainer* cell_container = cluster->getCellLinks()->
getCellContainer();
1096 cluster->getOwnCellLinks()->clear();
1100 SG::ReadHandle<CaloCellContainer> cchand (
m_cellsName, myctx.ctx());
1101 if (!cchand.isValid()) {
1103 <<
"Can't retrieve cell container " <<
m_cellsName.key();
1106 cell_container = cchand.cptr();
1118 CaloCellList cell_list(calodetdescrmgr,cell_container);
1122 CaloClusterCorr::SamplingHelper_CaloCellList
helper (*
this,
1131 CaloClusterCorr::SamplingHelper_Cluster
helper (*
this,
windows, cluster);
1152 const CaloCell* max_et_cell = helper.max_et_cell();
1159 double phi_shift = elt->
phi()-elt->
phi_raw();
1160 double eta_shift = elt->
eta()-elt->
eta_raw();
1161 eta = cluster->
eta0()+eta_shift;
1193 if (std::abs (
eta - elt->
eta()) > helper.deta(2)/2) {
1213 (
const std::string& name)
1215 return this->
setProperty (StringProperty (
"cells_name", name));
1231 const double detas2,
1232 const double dphis2)
const
1237 w[0].first = detas2*neta;
1238 w[0].second = dphis2*4;
1245 w[1].first = w[0].first;
1246 w[1].second = w[0].second;
1248 w[2].first = detas2*neta;
1249 w[2].second = dphis2*nphi;
1251 w[3].first = (2*detas2)*(0.5 + (neta/2.));
1252 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
Initialize method.
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)