ATLAS Offline Software
Loading...
Searching...
No Matches
CaloLCWeightTool Class Reference

calculates hadronic cell weights based on cluster and cell quantities More...

#include <CaloLCWeightTool.h>

Inheritance diagram for CaloLCWeightTool:
Collaboration diagram for CaloLCWeightTool:

Public Member Functions

virtual ~CaloLCWeightTool ()
virtual StatusCode weight (xAOD::CaloCluster *theCluster, const EventContext &ctx) const override
virtual StatusCode initialize () override

Private Attributes

SG::ReadCondHandleKey< CaloLocalHadCoeffm_key {this, "CorrectionKey", "HadWeights"}
 name of the key for had cell weights
Gaudi::Property< double > m_signalOverNoiseCut {this, "SignalOverNoiseCut", 2}
 minimal signal/elec_noise ratio for a cell to be weighted
Gaudi::Property< bool > m_useHadProbability {this, "UseHadProbability", false}
 look for em-probability moment and apply relative weight only
std::vector< std::string > m_sampnames
 vector of names of individual samplings
Gaudi::Property< bool > m_interpolate {this, "Interpolate", false}
 interpolate correction coefficients
Gaudi::Property< bool > m_updateSamplingVars {this, "UpdateSamplingVars", false}
 update also sampling variables
Gaudi::Property< 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
const CaloCell_IDm_calo_id {}
SG::ReadCondHandleKey< CaloNoisem_noiseCDOKey {this,"CaloNoiseKey","electronicNoise","SG Key of CaloNoise data object"}

Detailed Description

calculates hadronic cell weights based on cluster and cell quantities

Version
$Id: CaloLCWeightTool.h,v 1.8 2009-01-27 09:09:14 gunal Exp $
Author
Sven Menke menke.nosp@m.@mpp.nosp@m.mu.mp.nosp@m.g.de
Date
26-August-2009

concrete class implementing a IClusterCellWeightTool to calculate the H1-type cell hadronic weights for cells inside a cluster. The cluster moments and its energy are also used to derive the weights

  • therefore the weighting is not called cell-by-cell, but for the entire cluster This tool reads its data from pool containing TProfile2D based weighting data.

Definition at line 32 of file CaloLCWeightTool.h.

Constructor & Destructor Documentation

◆ ~CaloLCWeightTool()

CaloLCWeightTool::~CaloLCWeightTool ( )
virtualdefault

Member Function Documentation

◆ initialize()

StatusCode CaloLCWeightTool::initialize ( )
overridevirtual

Definition at line 34 of file CaloLCWeightTool.cxx.

35{
36 if(m_interpolate) {
37 msg(MSG::INFO) << "Interpolation is ON, dimensions: ";
38 for(std::vector<std::string>::iterator it=m_interpolateDimensionNames.begin(); it!=m_interpolateDimensionNames.end(); ++it){
39 msg(MSG::INFO) << " " << (*it);
40 }
41 msg() << endmsg;
42 for(std::vector<std::string>::iterator it=m_interpolateDimensionNames.begin(); it!=m_interpolateDimensionNames.end(); ++it){
45 m_interpolateDimensions.push_back(int(id));
46 }else{
47 ATH_MSG_WARNING( "Dimension '" << (*it) << "' is invalid and will be excluded." );
48 }
49 }
50 }
51
52 ATH_MSG_INFO( "Initializing " << name() );
53
54 ATH_CHECK( m_key.initialize() );
55
56 ATH_CHECK( detStore()->retrieve( m_calo_id, "CaloCell_ID") );
57
58 m_sampnames.reserve(CaloSampling::Unknown);
59 for (int iSamp=0;iSamp<CaloSampling::Unknown;iSamp++) {
61 }
62
63 ATH_CHECK(m_noiseCDOKey.initialize());
64
65 return StatusCode::SUCCESS;
66}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
static CaloLocalHadDefs::LocalHadDimensionId getDimensionId(const std::string &dimensionName)
Gaudi::Property< bool > m_interpolate
interpolate correction coefficients
const CaloCell_ID * m_calo_id
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
SG::ReadCondHandleKey< CaloLocalHadCoeff > m_key
name of the key for had cell weights
std::vector< int > m_interpolateDimensions
actual set of dimension id's to interpolate
std::vector< std::string > m_sampnames
vector of names of individual samplings
Gaudi::Property< std::vector< std::string > > m_interpolateDimensionNames
vector of names of dimensions in look-up tables to interpolate
static const std::string & getSamplingName(const CaloSampling::CaloSample theSample)
Returns a string (name) for each CaloSampling.
LocalHadDimensionId
enums to identify user dimensions id number DIMC_* - classification, DIMW_*-weighting,...
MsgStream & msg
Definition testRead.cxx:32

◆ weight()

StatusCode CaloLCWeightTool::weight ( xAOD::CaloCluster * theCluster,
const EventContext & ctx ) const
overridevirtual

Definition at line 68 of file CaloLCWeightTool.cxx.

69{
70 const CaloLocalHadCoeff* data(nullptr);
71 SG::ReadCondHandle<CaloLocalHadCoeff> rch(m_key, ctx);
72
73 SG::ReadCondHandle<CaloNoise> noiseHdl{m_noiseCDOKey,ctx};
74 const CaloNoise* noiseCDO=*noiseHdl;
75
76 data = *rch;
77 if(data==nullptr) {
78 ATH_MSG_ERROR("Unable to access conditions object");
79 return StatusCode::FAILURE;
80 }
81 // this is not super effective, but try to put is here first, and optimize later
82 std::vector<int> isAmpMap(CaloSampling::Unknown,-1);
83 for (int iArea=0;iArea<data->getSizeAreaSet();iArea++) {
84 for (int iSamp=0;iSamp<CaloSampling::Unknown;iSamp++) {
85 if ( m_sampnames[iSamp] == data->getArea(iArea)->getTitle() ) {
87 isAmpMap[iSamp] = iArea;
88 break;
89 }
90 }
91 }
92
93 double eEM = theCluster->e();
94
95 std::vector<float> vars(5);
96
97 CaloLCCoeffHelper hp;
99
100 double pi0Prob = 0;
101 if ( m_useHadProbability) {
102 if (!theCluster->retrieveMoment(xAOD::CaloCluster::EM_PROBABILITY,pi0Prob)) {
103 ATH_MSG_WARNING ("Cannot find cluster moment EM_PROBABILITY");
104 }
105 }
106 else if (theCluster->recoStatus().checkStatus(CaloRecoStatus::TAGGEDEM)) {
107 pi0Prob = 1.;
108 }
109 if ( pi0Prob < 0 )
110 pi0Prob = 0;
111 if ( pi0Prob > 1 )
112 pi0Prob = 1;
113
114 if ( eEM > 0 ) {
115 // loop over all cells
116
117 xAOD::CaloCluster::cell_iterator itrCell = theCluster->cell_begin();
118 xAOD::CaloCluster::cell_iterator itrCellEnd = theCluster->cell_end();
119 for (;itrCell!=itrCellEnd; ++itrCell) {
120 CaloPrefetch::nextDDE(itrCell, itrCellEnd);
121 // check calo and sampling index for current cell
122 Identifier myId = itrCell->ID();
123 CaloCell_ID::CaloSample theSample = CaloCell_ID::CaloSample(m_calo_id->calo_sample(myId));
124 if ( isAmpMap[theSample] >= 0 ) {
125 double sigma = noiseCDO->getNoise(itrCell->ID(),itrCell->gain());
126 double energy = fabs(itrCell->e());
127 double ratio = 0;
128 if ( std::isfinite(sigma) && sigma > 0 )
130 if ( ratio > m_signalOverNoiseCut ) {
131 double volume = 0;
132 double density = 0;
133 const CaloDetDescrElement* myCDDE = itrCell->caloDDE();
134 if ( myCDDE ) {
135 volume = myCDDE->volume();
136 }
137 if ( volume > 0 )
138 density = energy/volume;
139 if ( density > 0 ) {
140 double abseta = fabs(itrCell->eta());
141 double log10edens = log10(density);
142 double log10cluse = log10(eEM);
143 const CaloLocalHadCoeff::LocalHadDimension *logeDim = data->getArea(isAmpMap[theSample])->getDimension(3);
144 double lemax = logeDim->getXmax()-0.5*logeDim->getDx();
145 if ( log10cluse > lemax ) log10cluse = lemax;
146
147 vars[CaloLocalHadDefs::DIMW_SIDE] = static_cast<float> ((itrCell->eta()<0?-1.0:1.0));
148 vars[CaloLocalHadDefs::DIMW_ETA] = static_cast<float> (abseta);
149 vars[CaloLocalHadDefs::DIMW_PHI] = static_cast<float> (itrCell->phi());
150 vars[CaloLocalHadDefs::DIMW_ENER] = static_cast<float> (log10cluse);
151 vars[CaloLocalHadDefs::DIMW_EDENS] = static_cast<float> (log10edens);
152
153 bool isDataOK = false;
154 double wData(0);
155
156 // accessing coefficients (non-interpolated)
157 int iBin = data->getBin(isAmpMap[theSample],vars);
158 if ( iBin >= 0 ) {
159 const CaloLocalHadCoeff::LocalHadCoeff * pData = data->getCoeff(iBin);
160 if ( pData && (*pData)[CaloLocalHadDefs::BIN_ENTRIES] > 10 ) {
161 isDataOK = true;
162 wData = (*pData)[CaloLocalHadDefs::BIN_WEIGHT];
163 }
164 if(m_interpolate) {
165 // accesing interpolated coefficients
166 bool isa = CaloLCCoeffHelper::Interpolate(data, isAmpMap[theSample], vars, parint, m_interpolateDimensions);
167 if(isa && parint[CaloLocalHadDefs::BIN_ENTRIES] > 10) {
168 isDataOK = true;
169 wData = parint[CaloLocalHadDefs::BIN_WEIGHT];
170 }
171 }
172 }
173
174 if(isDataOK) {
175 ATH_MSG_DEBUG(" weight("
176 << theSample << ", "
177 << vars[0] << ", "
178 << vars[1] << ", "
179 << vars[2] << ", "
180 << vars[3] << ", "
181 << vars[4] << ") = "
182 << wData);
183 double weight = itrCell.weight();//theCluster->getCellWeight(itrCell); // fastest!
184 weight *= (pi0Prob + (1-pi0Prob)*wData);
185 // reweight cell in cluster
186 theCluster->reweightCell(itrCell,weight);
187 }
188 } // density
189 } // noise cut
190 } // sampling
191 } // itrCell
193 } // eEM
194
195 // assume that the weighting could be called more than once. In that case
196 // eEM is the result of the previous step and the current e/eEM ratio
197 // should be multiplied with the existing HAD_WEIGHT moment
198 double new_weight (1);
199 if (!theCluster->retrieveMoment(xAOD::CaloCluster::HAD_WEIGHT,new_weight)) {
200 ATH_MSG_ERROR("Cannot retrieve HAD_WEIGHT cluster moment." );
201 return StatusCode::FAILURE;
202 }
203
204 if ( eEM > 0 || eEM < 0 ) {
205 new_weight *= theCluster->e()/eEM;
206 }
207 theCluster->insertMoment(xAOD::CaloCluster::HAD_WEIGHT,new_weight);
208
209 return StatusCode::SUCCESS;
210}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
CaloSampling::CaloSample CaloSample
Definition CaloCell_ID.h:53
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition CaloCell.h:333
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition CaloCell.h:375
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition CaloCell.h:382
CaloGain::CaloGain gain() const
get gain (data member )
Definition CaloCell.h:361
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
static void calculateKine(xAOD::CaloCluster *clu, const bool useweight=true, const bool updateLayers=true, const bool useGPUCriteria=false)
Helper class to calculate cluster kinematics based on cells.
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.)
Gaudi::Property< bool > m_useHadProbability
look for em-probability moment and apply relative weight only
Gaudi::Property< double > m_signalOverNoiseCut
minimal signal/elec_noise ratio for a cell to be weighted
Gaudi::Property< bool > m_updateSamplingVars
update also sampling variables
virtual StatusCode weight(xAOD::CaloCluster *theCluster, const EventContext &ctx) const override
float getDx() const
return size of bin
float getXmax() const
return maximum value for the last bin
std::vector< float > LocalHadCoeff
Correction parameters for one general bin.
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Definition CaloNoise.h:35
virtual bool checkStatus(const StatusIndicator &statusIndicator) const
Check status.
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
void reweightCell(cell_iterator it, const double weight)
Method to reweight a cell in the cluster (Beware: Kinematics not updated!)
CaloClusterCellLink::iterator cell_iterator
Iterator of the underlying CaloClusterCellLink (non-const version)
virtual double e() const
The total energy of the particle.
void insertMoment(MomentType type, double value)
const_cell_iterator cell_end() const
@ EM_PROBABILITY
Classification probability to be em-like.
@ HAD_WEIGHT
Hadronic weight (E_w/E_em)
const_cell_iterator cell_begin() const
Iterator of the underlying CaloClusterCellLink (const version)
CaloRecoStatus & recoStatus()
Accesssor to CaloRecoStatus (non-const)
void nextDDE(Iter iter, Iter endIter)
Prefetch next CaloDDE.

Member Data Documentation

◆ m_calo_id

const CaloCell_ID* CaloLCWeightTool::m_calo_id {}
private

Definition at line 88 of file CaloLCWeightTool.h.

88{};

◆ m_interpolate

Gaudi::Property<bool> CaloLCWeightTool::m_interpolate {this, "Interpolate", false}
private

interpolate correction coefficients

Definition at line 73 of file CaloLCWeightTool.h.

73{this, "Interpolate", false};

◆ m_interpolateDimensionNames

Gaudi::Property<std::vector<std::string> > CaloLCWeightTool::m_interpolateDimensionNames
private
Initial value:
{this, "InterpolateDimensionNames"
, {"DIMW_ETA", "DIMW_ENER", "DIMW_EDENS"}}

vector of names of dimensions in look-up tables to interpolate

Definition at line 81 of file CaloLCWeightTool.h.

81 {this, "InterpolateDimensionNames"
82 , {"DIMW_ETA", "DIMW_ENER", "DIMW_EDENS"}};

◆ m_interpolateDimensions

std::vector<int> CaloLCWeightTool::m_interpolateDimensions
private

actual set of dimension id's to interpolate

Definition at line 86 of file CaloLCWeightTool.h.

◆ m_key

SG::ReadCondHandleKey<CaloLocalHadCoeff> CaloLCWeightTool::m_key {this, "CorrectionKey", "HadWeights"}
private

name of the key for had cell weights

Definition at line 45 of file CaloLCWeightTool.h.

45{this, "CorrectionKey", "HadWeights"};

◆ m_noiseCDOKey

SG::ReadCondHandleKey<CaloNoise> CaloLCWeightTool::m_noiseCDOKey {this,"CaloNoiseKey","electronicNoise","SG Key of CaloNoise data object"}
private

Definition at line 90 of file CaloLCWeightTool.h.

90{this,"CaloNoiseKey","electronicNoise","SG Key of CaloNoise data object"};

◆ m_sampnames

std::vector<std::string> CaloLCWeightTool::m_sampnames
private

vector of names of individual samplings

needed to not call many times CaloSamplingHelper::getSamplingName

Definition at line 69 of file CaloLCWeightTool.h.

◆ m_signalOverNoiseCut

Gaudi::Property<double> CaloLCWeightTool::m_signalOverNoiseCut {this, "SignalOverNoiseCut", 2}
private

minimal signal/elec_noise ratio for a cell to be weighted

Only cells with |energy| above this value times the RMS of the electronics noise are considered in weighting.

Definition at line 52 of file CaloLCWeightTool.h.

52{this, "SignalOverNoiseCut", 2};

◆ m_updateSamplingVars

Gaudi::Property<bool> CaloLCWeightTool::m_updateSamplingVars {this, "UpdateSamplingVars", false}
private

update also sampling variables

Definition at line 77 of file CaloLCWeightTool.h.

77{this, "UpdateSamplingVars", false};

◆ m_useHadProbability

Gaudi::Property<bool> CaloLCWeightTool::m_useHadProbability {this, "UseHadProbability", false}
private

look for em-probability moment and apply relative weight only

The classification provides the probability p for the current cluster to be em-like. Hadronic weights are applied with the additional hadronic probablity factor (1-p) to all clusters for the cases EM and HAD.

Definition at line 61 of file CaloLCWeightTool.h.

61{this, "UseHadProbability", false} ;

The documentation for this class was generated from the following files: