ATLAS Offline Software
Loading...
Searching...
No Matches
CaloLCClassificationTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 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 m_key("EMFracClassify"),
35 m_useSpread(false),
39 m_interpolate(false),
40 m_absOpt(false)
41{
42
43 declareInterface<IClusterClassificationTool>(this);
44 // Name of data object in conditions store
45 declareProperty("ClassificationKey",m_key);
46 // Use Spread of EM probability for estimate
47 declareProperty("UseSpread",m_useSpread);
48 // Use normalized energy density
49 declareProperty("UseNormalizedEnergyDensity",m_useNormalizedEnergyDensity);
50 // Maximal EM probability below which all clusters are considered hadronic
51 declareProperty("MaxProbability",m_maxProbability);
52 // Store the classification Probability as a cluster moment in AOD
53 // (if false it goes to ESD only)
54 declareProperty("StoreClassificationProbabilityInAOD",m_storeClassificationProbabilityInAOD);
55 // Use Interpolation or not
56 declareProperty("Interpolate",m_interpolate);
57 //Use weighting of negative clusters?
58 declareProperty("WeightingOfNegClusters",m_absOpt);
59
61 m_interpolateDimensionNames[0] = "DIMC_ETA";
62 m_interpolateDimensionNames[1] = "DIMC_EDENS";
63 m_interpolateDimensionNames[2] = "DIMC_LAMBDA";
64 declareProperty("InterpolateDimensionNames", m_interpolateDimensionNames);
65}
66
68{
69 ATH_MSG_INFO( "Initializing " << name() );
70
71 ATH_CHECK( m_key.initialize() );
72
73 if(m_interpolate) {
74 msg(MSG::INFO) << "Interpolation is ON, dimensions: ";
75 for(std::vector<std::string>::iterator it=m_interpolateDimensionNames.begin(); it!=m_interpolateDimensionNames.end(); ++it){
76 msg() << " " << (*it);
77 }
78 msg() << endmsg;
79 for(std::vector<std::string>::iterator it=m_interpolateDimensionNames.begin(); it!=m_interpolateDimensionNames.end(); ++it){
82 m_interpolateDimensions.push_back(int(id));
83 }else{
84 ATH_MSG_WARNING( "Dimension '" << (*it) << "' is invalid and will be excluded." );
85 }
86 }
87 }
88
89 return StatusCode::SUCCESS;
90}
91
93{
94 const CaloLocalHadCoeff* condObject(nullptr);
96 condObject = *rch;
97 if(condObject==nullptr) {
98 ATH_MSG_ERROR("Unable to access conditions object");
100 }
101
104
106 double probPi0 = 0;
107 // on ESD only
108 std::vector<float> vars(6);
109 if ( thisCluster->e() > 0 || m_absOpt ) { //with abs option, always weight cluster
110 double log10cluse = log10(thisCluster->e());
111 if( m_absOpt ) log10cluse = log10(fabs(thisCluster->e()));
112 double log10cluseOrig = log10cluse;
113
114 const CaloLocalHadCoeff::LocalHadDimension *logeDim = condObject->getArea(0)->getDimension(3);
115 double lemax = logeDim->getXmax()-0.5*logeDim->getDx();
116 double lemin = logeDim->getXmin()+0.5*logeDim->getDx();
117 if ( log10cluse > lemax )
118 log10cluse = lemax;
119 if ( log10cluse < lemin )
120 log10cluse = lemin;
121
122 double m1_dens,center_lambda;
123 //Fixme ... check moavailability ..
124 if (thisCluster->retrieveMoment(CaloCluster::FIRST_ENG_DENS,m1_dens) &&
125 thisCluster->retrieveMoment(CaloCluster::CENTER_LAMBDA,center_lambda)) {
126 if ( m1_dens > 0 && center_lambda > 0) {
127 const double abseta = fabs(thisCluster->eta());
128 double log10edens = log10(m1_dens);
129 if ( m_useNormalizedEnergyDensity ) log10edens -= log10cluseOrig;
130 double log10lambda = log10(center_lambda);
131
132 vars[CaloLocalHadDefs::DIMC_SIDE] = static_cast<float> ((thisCluster->eta()<0?-1.0:1.0));
133 vars[CaloLocalHadDefs::DIMC_ETA] = static_cast<float> (abseta);
134 vars[CaloLocalHadDefs::DIMC_PHI] = static_cast<float> (thisCluster->phi());
135 vars[CaloLocalHadDefs::DIMC_ENER] = static_cast<float> (log10cluse);
136 vars[CaloLocalHadDefs::DIMC_EDENS] = static_cast<float> (log10edens);
137 vars[CaloLocalHadDefs::DIMC_LAMBDA] = static_cast<float> (log10lambda);
138
139 bool isDataOK = false;
140 double emProb(0);
141
142 int iBin = condObject->getBin(0,vars);
143 if ( iBin >= 0 ) {
144 const CaloLocalHadCoeff::LocalHadCoeff * pData = condObject->getCoeff(iBin);
145 if ( pData && (*pData)[CaloLocalHadDefs::BIN_ENTRIES] > 0 ) {
146 isDataOK = true;
147 emProb = (*pData)[CaloLocalHadDefs::BIN_WEIGHT];
148 if (m_useSpread) {
149 double emErr = sqrt((*pData)[CaloLocalHadDefs::BIN_ENTRIES])*(*pData)[CaloLocalHadDefs::BIN_ERROR];
150 emProb += emErr;
151 }
152
153 if(m_interpolate) {
154 // accesing interpolated coefficients
155 bool isa = CaloLCCoeffHelper::Interpolate(condObject, 0,vars,parint, m_interpolateDimensions);
156 if(isa) {
157 if ( parint[CaloLocalHadDefs::BIN_ENTRIES] > 0 ) {
158 isDataOK = true;
159 emProb = parint[CaloLocalHadDefs::BIN_WEIGHT];
160 if (m_useSpread) {
161 double emErr = sqrt(parint[CaloLocalHadDefs::BIN_ENTRIES])*parint[CaloLocalHadDefs::BIN_ERROR];
162 emProb += emErr;
163 }
164 }
165 }//end if isa
166 }//end if m_interpolate
167 } //end if pData
168 } //end if iBin
169
170 if(isDataOK) {
171 probPi0 = emProb;
172 if ( emProb < m_maxProbability )
174 else
175 recStat = CaloRecoStatus::TAGGEDEM;
176 }
177
178 } // if >0
179 } //if got sucessfully retrieved moments
180 else {
181 ATH_MSG_ERROR( "Can not retrieve one or more of the cluster moments "
182 << "CENTER_LAMBDA, FIRST_ENG_DENS for current cluster"
183 << "- classification not possible - "
184 << "you need to enable those moments in the cluster maker!"
185 );
187 }
188 }
189
190 thisCluster->insertMoment(CaloCluster::EM_PROBABILITY,probPi0);
191 thisCluster->insertMoment(CaloCluster::HAD_WEIGHT,1.0);
192 thisCluster->insertMoment(CaloCluster::OOC_WEIGHT,1.0);
193 thisCluster->insertMoment(CaloCluster::DM_WEIGHT,1.0);
194
195 return recStat;
196}
197
199= default;
200
#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:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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
bool m_absOpt
is set to true, classify neg.
bool m_useSpread
if set to true the spread of EM probabilities in each bin is taken into account for classification ot...
virtual StatusCode initialize() override
bool m_useNormalizedEnergyDensity
old data depends on energy density while new data depends on energy density over energy.
std::vector< std::string > m_interpolateDimensionNames
vector of names of dimensions in look-up tables to interpolate
std::vector< int > m_interpolateDimensions
actual set of dimension id's to interpolate
virtual CaloRecoStatus::StatusIndicator classify(xAOD::CaloCluster *thisCluster) const override
method to return the classification status of a cluster.
double m_maxProbability
cut value on EM probability below which all clusters are classified as hadronic
bool m_interpolate
interpolate correction coefficients
virtual ~CaloLCClassificationTool()
bool m_storeClassificationProbabilityInAOD
if true the phase space probability based on single pions that the current cluster stems from a pi0 i...
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,...