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)
788 declareProperty(
"eta_size",
m_neta = 5);
789 declareProperty(
"phi_size",
m_nphi = 5);
791 declareProperty(
"cells_name",
m_cellsName =
"AllCalo");
810 return StatusCode::SUCCESS;
833 helper.calculate_and_set (
eta,
phi, 2, -1, samplings,
true);
835 double eta2 = helper.etam();
836 double phi2 = helper.phim();
838 if (eta2 == -999.) eta2 =
eta;
839 if (phi2 == -999.) phi2 =
phi;
842 helper.calculate_and_set (eta2, phi2, 1, -1, samplings);
843 double eta1 = helper.etam();
844 double phi1 = helper.phim();
846 if (eta1 == -999. || phi1 == -999.) {
848 if (eta1 == -999.) eta1 = eta2;
849 if (phi1 == -999.) phi1 = phi2;
856 if (samplings[1] == CaloSampling::EMB1)
857 xsample = CaloCell_ID::EMB1;
859 xsample = CaloCell_ID::EME1;
864 double detastr, dphistr;
869 if (detastr > 0 && dphistr > 0) {
870 helper.calculate_cluster (helper.etamax(), helper.phimax(),
871 detastr, dphistr, samplings[1]);
873 if (helper.etam()!=-999.) {
874 eta1 = helper.etam();
875 double eta1r = helper.etareal();
876 helper.cluster()->setEta(samplings[1], eta1r);
882 helper.calculate_and_set (eta1, phi2, 0, 1, samplings);
885 helper.calculate_and_set (eta2, phi2, 3, -1, samplings);
889 if ( helper.cluster()->hasSampling(CaloSampling::TileGap3) && samplings[0]==CaloSampling::PreSamplerE )
892 const CaloCellContainer* cc = helper.cluster()->getCellLinks()->getCellContainer();
899 <<
"Can't retrieve cell container " <<
m_cellsName.key();
908 <<
"Can't find cell container; cluster does not give a cell container";
919 for ( ; f_cell!=l_cell; ++f_cell)
923 if (CaloCell_ID::TileGap3 == cell->caloDDE()->getSampling()) {
925 if( fabs(cell->eta()) < 1.4 || fabs(cell->eta()) > 1.6 )
continue;
926 double phic = cell->phi();
927 double etac = cell->eta();
929 float diffeta = etac-eta2;
930 float diffphi = phic-phi2;
931 if (diffphi < -
pi) diffphi +=
twopi;
932 if (diffphi >
pi) diffphi -=
twopi;
934 if(fabs(diffeta)<deta && fabs(diffphi)<dphi){
935 eh_scint += cell->e();
940 helper.cluster()->setEnergy(CaloSampling::TileGap3,eh_scint);
942 helper.cluster()->setEta(CaloSampling::TileGap3, eta2);
943 helper.cluster()->setPhi(CaloSampling::TileGap3, phi2);
968 double aeta = fabs(
eta);
1016 { CaloSampling::PreSamplerB, CaloSampling::EMB1,
1017 CaloSampling::EMB2, CaloSampling::EMB3 };
1019 { CaloSampling::PreSamplerE, CaloSampling::EME1,
1020 CaloSampling::EME2, CaloSampling::EME3 };
1028 uint32_t samplingPattern_b=0xf;
1029 uint32_t samplingPattern_e=0xf0;
1030 uint32_t samplingPattern=0;
1033 samplingPattern |=samplingPattern_b;
1036 samplingPattern |=samplingPattern_e;
1038 if (aeta > 1.37 && aeta < 1.63)
1039 samplingPattern |=(1<<(uint32_t)CaloSampling::TileGap3);
1041 cluster->setSamplingPattern(samplingPattern);
1055 for(
int i=0; i<4; i++ ){
1056 cl_ene += cluster->
eSample(samplings_b[i]);
1057 cl_ene += cluster->
eSample(samplings_e[i]);
1059 cluster->
setE(cl_ene);
1082 if(!caloDetDescrMgrHandle.
isValid()){
1083 ATH_MSG_ERROR (
"Failed to retrieve CaloDetDescrManager : CaloMgr");
1086 const CaloDetDescrManager* calodetdescrmgr = *caloDetDescrMgrHandle;
1088 CaloClusterCorr::Segmentation seg (calodetdescrmgr);
1089 if (seg.m_detas2 == 0) {
1094 seg.m_detas2, seg.m_dphis2);
1099 const CaloCellContainer* cell_container = cluster->getCellLinks()->
getCellContainer();
1102 cluster->getOwnCellLinks()->clear();
1106 SG::ReadHandle<CaloCellContainer> cchand (
m_cellsName, myctx.ctx());
1107 if (!cchand.isValid()) {
1109 <<
"Can't retrieve cell container " <<
m_cellsName.key();
1112 cell_container = cchand.cptr();
1124 CaloCellList cell_list(calodetdescrmgr,cell_container);
1128 CaloClusterCorr::SamplingHelper_CaloCellList
helper (*
this,
1137 CaloClusterCorr::SamplingHelper_Cluster
helper (*
this,
windows, cluster);
1158 const CaloCell* max_et_cell = helper.max_et_cell();
1165 double phi_shift = elt->
phi()-elt->
phi_raw();
1166 double eta_shift = elt->
eta()-elt->
eta_raw();
1167 eta = cluster->
eta0()+eta_shift;
1199 if (std::abs (
eta - elt->
eta()) > helper.deta(2)/2) {
1219 (
const std::string& name)
1221 return this->
setProperty (StringProperty (
"cells_name", name));
1237 const double detas2,
1238 const double dphis2)
const
1243 w[0].first = detas2*neta;
1244 w[0].second = dphis2*4;
1251 w[1].first = w[0].first;
1252 w[1].second = w[0].second;
1254 w[2].first = detas2*neta;
1255 w[2].second = dphis2*nphi;
1257 w[3].first = (2*detas2)*(0.5 + (neta/2.));
1258 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
SG::ReadHandleKey< CaloCellContainer > m_cellsName
The StoreGate key for the container of our input cells.
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
bool m_fill_cluster
Fill-cluster flag.
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.
virtual StatusCode setCaloCellContainerName(const std::string &name) override
Change the name of the CaloCellContainer used by this tool.
int m_neta
cluster size. These are properties.
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)