ATLAS Offline Software
Loading...
Searching...
No Matches
CaloLCClassificationTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5//-----------------------------------------------------------------------
6// File and Version Information:
7// $Id: CaloLCClassificationTool.cxx,v 1.7 2009-01-27 09:09:15 gunal Exp $
8//
9// Description: see CaloLCClassificationTool.h
10//
11// Environment:
12// Software developed for the ATLAS Detector at CERN LHC
13//
14// Author List:
15// Sven Menke
16//
17//-----------------------------------------------------------------------
18
19//-----------------------
20// This Class's Header --
21//-----------------------
25
27
29
31 const std::string& name,
32 const IInterface* parent)
33 : AthAlgTool(type,name,parent)
34{
35 declareInterface<IClusterClassificationTool>(this);
36}
37
39{
40 ATH_MSG_INFO( "Initializing " << name() );
41
42 ATH_CHECK( m_key.initialize() );
43
44 if(m_interpolate) {
45 msg(MSG::INFO) << "Interpolation is ON, dimensions: ";
46 for(std::vector<std::string>::iterator it=m_interpolateDimensionNames.begin(); it!=m_interpolateDimensionNames.end(); ++it){
47 msg() << " " << (*it);
48 }
49 msg() << endmsg;
50 for(std::vector<std::string>::iterator it=m_interpolateDimensionNames.begin(); it!=m_interpolateDimensionNames.end(); ++it){
53 m_interpolateDimensions.push_back(int(id));
54 }else{
55 ATH_MSG_WARNING( "Dimension '" << (*it) << "' is invalid and will be excluded." );
56 }
57 }
58 }
59
60 return StatusCode::SUCCESS;
61}
62
64{
65 const CaloLocalHadCoeff* condObject(nullptr);
67 condObject = *rch;
68 if(condObject==nullptr) {
69 ATH_MSG_ERROR("Unable to access conditions object");
71 }
72
75
77 double probPi0 = 0;
78 // on ESD only
79 std::vector<float> vars(6);
80 if ( thisCluster->e() > 0 || m_absOpt ) { //with abs option, always weight cluster
81 double log10cluse = log10(thisCluster->e());
82 if( m_absOpt ) log10cluse = log10(fabs(thisCluster->e()));
83 double log10cluseOrig = log10cluse;
84
85 const CaloLocalHadCoeff::LocalHadDimension *logeDim = condObject->getArea(0)->getDimension(3);
86 double lemax = logeDim->getXmax()-0.5*logeDim->getDx();
87 double lemin = logeDim->getXmin()+0.5*logeDim->getDx();
88 if ( log10cluse > lemax )
89 log10cluse = lemax;
90 if ( log10cluse < lemin )
91 log10cluse = lemin;
92
93 double m1_dens,center_lambda;
94 //Fixme ... check moavailability ..
95 if (thisCluster->retrieveMoment(CaloCluster::FIRST_ENG_DENS,m1_dens) &&
96 thisCluster->retrieveMoment(CaloCluster::CENTER_LAMBDA,center_lambda)) {
97 if ( m1_dens > 0 && center_lambda > 0) {
98 const double abseta = fabs(thisCluster->eta());
99 double log10edens = log10(m1_dens);
100 if ( m_useNormalizedEnergyDensity ) log10edens -= log10cluseOrig;
101 double log10lambda = log10(center_lambda);
102
103 vars[CaloLocalHadDefs::DIMC_SIDE] = static_cast<float> ((thisCluster->eta()<0?-1.0:1.0));
104 vars[CaloLocalHadDefs::DIMC_ETA] = static_cast<float> (abseta);
105 vars[CaloLocalHadDefs::DIMC_PHI] = static_cast<float> (thisCluster->phi());
106 vars[CaloLocalHadDefs::DIMC_ENER] = static_cast<float> (log10cluse);
107 vars[CaloLocalHadDefs::DIMC_EDENS] = static_cast<float> (log10edens);
108 vars[CaloLocalHadDefs::DIMC_LAMBDA] = static_cast<float> (log10lambda);
109
110 bool isDataOK = false;
111 double emProb(0);
112
113 int iBin = condObject->getBin(0,vars);
114 if ( iBin >= 0 ) {
115 const CaloLocalHadCoeff::LocalHadCoeff * pData = condObject->getCoeff(iBin);
116 if ( pData && (*pData)[CaloLocalHadDefs::BIN_ENTRIES] > 0 ) {
117 isDataOK = true;
118 emProb = (*pData)[CaloLocalHadDefs::BIN_WEIGHT];
119 if (m_useSpread) {
120 double emErr = sqrt((*pData)[CaloLocalHadDefs::BIN_ENTRIES])*(*pData)[CaloLocalHadDefs::BIN_ERROR];
121 emProb += emErr;
122 }
123
124 if(m_interpolate) {
125 // accesing interpolated coefficients
126 bool isa = CaloLCCoeffHelper::Interpolate(condObject, 0,vars,parint, m_interpolateDimensions);
127 if(isa) {
128 if ( parint[CaloLocalHadDefs::BIN_ENTRIES] > 0 ) {
129 isDataOK = true;
130 emProb = parint[CaloLocalHadDefs::BIN_WEIGHT];
131 if (m_useSpread) {
132 double emErr = sqrt(parint[CaloLocalHadDefs::BIN_ENTRIES])*parint[CaloLocalHadDefs::BIN_ERROR];
133 emProb += emErr;
134 }
135 }
136 }//end if isa
137 }//end if m_interpolate
138 } //end if pData
139 } //end if iBin
140
141 if(isDataOK) {
142 probPi0 = emProb;
143 if ( emProb < m_maxProbability )
145 else
146 recStat = CaloRecoStatus::TAGGEDEM;
147 }
148
149 } // if >0
150 } //if got sucessfully retrieved moments
151 else {
152 ATH_MSG_ERROR( "Can not retrieve one or more of the cluster moments "
153 << "CENTER_LAMBDA, FIRST_ENG_DENS for current cluster"
154 << "- classification not possible - "
155 << "you need to enable those moments in the cluster maker!"
156 );
158 }
159 }
160
161 thisCluster->insertMoment(CaloCluster::EM_PROBABILITY,probPi0);
162 thisCluster->insertMoment(CaloCluster::HAD_WEIGHT,1.0);
163 thisCluster->insertMoment(CaloCluster::OOC_WEIGHT,1.0);
164 thisCluster->insertMoment(CaloCluster::DM_WEIGHT,1.0);
165
166 return recStat;
167}
168
170= default;
171
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
MsgStream & msg() const
Principal data class for CaloCell clusters.
bool retrieveMoment(const moment_type &momType, moment_value &momValue, bool useLink=true) const
Retrieve individual moment.
virtual double e() const
Retrieve energy independent of signal state.
void insertMoment(const moment_type &momType, const moment_value &momValue, bool useLink=true)
Set individual moment.
virtual double eta() const
Retrieve eta independent of signal state.
virtual double phi() const
Retrieve phi independent of signal state.
SG::ReadCondHandleKey< CaloLocalHadCoeff > m_key
name of the key for em fraction data
Gaudi::Property< bool > m_useNormalizedEnergyDensity
old data depends on energy density while new data depends on energy density over energy.
virtual StatusCode initialize() override
std::vector< int > m_interpolateDimensions
actual set of dimension id's to interpolate
Gaudi::Property< bool > m_absOpt
is set to true, classify neg.
virtual CaloRecoStatus::StatusIndicator classify(xAOD::CaloCluster *thisCluster) const override
method to return the classification status of a cluster.
Gaudi::Property< bool > m_interpolate
interpolate correction coefficients
Gaudi::Property< std::vector< std::string > > m_interpolateDimensionNames
vector of names of dimensions in look-up tables to interpolate
Gaudi::Property< bool > m_useSpread
if set to true the spread of EM probabilities in each bin is taken into account for classification ot...
virtual ~CaloLCClassificationTool()
Gaudi::Property< double > m_maxProbability
cut value on EM probability below which all clusters are classified as hadronic
CaloLCClassificationTool(const std::string &type, const std::string &name, const IInterface *parent)
static bool Interpolate(const CaloLocalHadCoeff *m_data, const unsigned int n_area, std::vector< float > &x, CaloLocalHadCoeff::LocalHadCoeff &pars, const std::vector< int > &dim, double xfit=0.)
static CaloLocalHadDefs::LocalHadDimensionId getDimensionId(const std::string &dimensionName)
const CaloLocalHadCoeff::LocalHadDimension * getDimension(int n_dim) const
to get dimension
Class defines binning for user dimension.
float getDx() const
return size of bin
float getXmax() const
return maximum value for the last bin
float getXmin() const
return minimum value for the first bin
Hold binned correction data for local hadronic calibration procedure.
const LocalHadCoeff * getCoeff(const int &iBin) const
get data for given general bin number
const LocalHadArea * getArea(int n_area) const
return area
int getBin(const int n_area, std::vector< float > &vars) const
calculate general bin from vector of input cluster variables
std::vector< float > LocalHadCoeff
Correction parameters for one general bin.
StatusIndicator
reconstruction status word
@ OOC_WEIGHT
Out-of-cluster weight (E_ooc/E_w)
@ EM_PROBABILITY
Classification probability to be em-like.
@ DM_WEIGHT
Dead-material weight (E_dm/E_ooc)
@ FIRST_ENG_DENS
First Moment in E/V.
@ HAD_WEIGHT
Hadronic weight (E_w/E_em)
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
LocalHadDimensionId
enums to identify user dimensions id number DIMC_* - classification, DIMW_*-weighting,...