8#include "GaudiKernel/MsgStream.h"
9#include <CLHEP/Units/SystemOfUnits.h>
15 const std::string& name,
16 const IInterface* parent)
26 return StatusCode::SUCCESS;
33 if ( msgSvc()->outputLevel(name()) <= MSG::DEBUG ) {
35 msg(MSG::DEBUG) <<
" old cluster eta = " << theCluster->
eta()
36 <<
" phi = " << theCluster->
phi() <<
endmsg;
48 const double absEClus = fabs(theCluster->
e());
51 const double inv_absEClus = 1. / absEClus;
52 std::vector<double> weightSample(CaloCell_ID::Unknown,0);
53 std::vector<double> etaSample(CaloCell_ID::Unknown,0);
54 std::vector<double> phiSample(CaloCell_ID::Unknown,0);
56 double weightAll(0),etaAll(0),phiAll(0);
60 for (;itrCell!=itrCellEnd; ++itrCell) {
62 double weight = itrCell.
weight();
65 double absE = fabs(weight*thisCell->
e());
68 double lw =
m_offset + log(absE*inv_absEClus);
72 << thisCell->
eta() <<
" phi " << thisCell->
phi()
73 <<
" energy " << thisCell->
e() <<
" weight " << weight
74 <<
" sampling " << theSample <<
" cluster e "
75 << theCluster->
e() <<
" log weight " << lw);
78 etaAll += thisCell->
eta()*lw;
87 phiAll += (thisCell->
phi()-360*
deg)*lw;
88 else if ( weightAll > 0
91 phiAll += (thisCell->
phi()+360*
deg)*lw;
93 phiAll += thisCell->
phi()*lw;
97 etaSample[theSample] += thisCell->
eta()*lw;
98 if ( weightSample[theSample] > 0
99 && phiSample[theSample]/weightSample[theSample]
102 phiSample[theSample] += (thisCell->
phi()-360*
deg)*lw;
103 else if ( weightSample[theSample] > 0
104 && phiSample[theSample]/weightSample[theSample]
107 phiSample[theSample] += (thisCell->
phi()+360*
deg)*lw;
109 phiSample[theSample] += thisCell->
phi()*lw;
110 weightSample[theSample] += lw;
116 if ( weightAll > 0 ) {
117 const double inv_weightAll = 1. / weightAll;
118 theCluster->
setEta(etaAll * inv_weightAll);
130 for(
int i=0;i<CaloCell_ID::Unknown;i++) {
132 if ( theCluster->
hasSampling(s) && weightSample[i] > 0 ) {
133 float etaSample=theCluster->
etaSample(s);
134 float phiSample=theCluster->
phiSample(s);
135 etaSample /= weightSample[i];
136 phiSample /= weightSample[i];
138 theCluster->
setEta(s,etaSample);
139 theCluster->
setPhi(s,phiSample);
144 if ( msgSvc()->outputLevel(name()) <= MSG::DEBUG ) {
147 <<
" phi = " << theCluster->
phi());
160 return StatusCode::SUCCESS;
#define ATH_MSG_VERBOSE(x)
CaloPhiRange class declaration.
Data object for each calorimeter readout cell.
virtual double e() const override final
get energy (data member) (synonym to method energy()
virtual double phi() const override final
get phi (through CaloDetDescrElement)
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
virtual double eta() const override final
get eta (through CaloDetDescrElement)
weight_t weight() const
Accessor for weight associated to this cell.
CaloClusterLogPos(const std::string &type, const std::string &name, const IInterface *parent)
Standard AlgTool constructor.
StatusCode initialize() override
Gaudi::Property< double > m_offset
StatusCode execute(const EventContext &ctx, xAOD::CaloCluster *theCluster) const override
Execute on a single cluster.
CaloClusterProcessor(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
CaloCell_ID::CaloSample getSampling() const
cell sampling
static double fix(double phi)
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
float phiSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
virtual double eta() const
The pseudorapidity ( ) of the particle.
CaloClusterCellLink::iterator cell_iterator
Iterator of the underlying CaloClusterCellLink (non-const version)
virtual double e() const
The total energy of the particle.
const_cell_iterator cell_end() const
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
virtual double phi() const
The azimuthal angle ( ) of the particle.
const_cell_iterator cell_begin() const
Iterator of the underlying CaloClusterCellLink (const version)
float etaSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.