ATLAS Offline Software
PFClusterWidthCalculator.cxx
Go to the documentation of this file.
2 
3 #include "eflowRec/eflowUtil.h"
4 
5 #include <cmath>
6 
7 PFClusterWidthCalculator::PFClusterWidthCalculator() : m_etaPhiLowerLimit(0.0025),m_etaMean(0.0),m_phiMean(0.0) {}
8 
9 
10 
11 std::pair<double,double> PFClusterWidthCalculator::getPFClusterCoordinateWidth(const std::vector<double>& eta, const std::vector<double>& phi, const double& clusterEta, const double& clusterPhi, unsigned int nCells){
12 
13  if (nCells <= 1) {
14  m_etaMean = clusterEta;
15  m_phiMean = clusterPhi;
16  return std::make_pair(m_etaPhiLowerLimit,m_etaPhiLowerLimit);
17  }
18 
19  double etaSum(0.0);
20  double etaSum2(0.0);
21  double phiSum(0.0);
22  double phiSum2(0.0);
23 
24  for(unsigned int iCell=0; iCell<nCells; ++iCell){
25  etaSum += eta[iCell];
26  etaSum2 += eta[iCell]*eta[iCell];
27  double thisCellPhi = eflowAzimuth(phi[iCell]).cycle(clusterPhi);
28  phiSum += thisCellPhi;
29  phiSum2 += thisCellPhi*thisCellPhi;
30 
31  }
32 
33  m_etaMean = etaSum/static_cast<double>(nCells);
34  m_phiMean = phiSum/static_cast<double>(nCells);
35 
36  double varianceCorrection = (double)nCells / (double)(nCells-1);
37  double etaVariance = std::max(m_etaPhiLowerLimit,varianceCorrection * (etaSum2/static_cast<double>(nCells) - m_etaMean*m_etaMean));
38  double phiVariance = std::max(m_etaPhiLowerLimit,varianceCorrection * (phiSum2/static_cast<double>(nCells) - m_phiMean*m_phiMean));
39 
40  return std::make_pair(etaVariance,phiVariance);
41 }
PFClusterWidthCalculator::m_etaPhiLowerLimit
double m_etaPhiLowerLimit
Definition: PFClusterWidthCalculator.h:19
eflowUtil.h
max
#define max(a, b)
Definition: cfImp.cxx:41
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
PFClusterWidthCalculator::m_etaMean
double m_etaMean
Definition: PFClusterWidthCalculator.h:20
eflowAzimuth::cycle
double cycle(const eflowAzimuth &other)
Definition: eflowUtil.h:51
xAOD::nCells
setRawEt setRawPhi nCells
Definition: TrigCaloCluster_v1.cxx:33
eflowAzimuth
eflowAzimuth represents phi and has kinematic functions which correctly deal with phi wraparound etc.
Definition: eflowUtil.h:21
PFClusterWidthCalculator::PFClusterWidthCalculator
PFClusterWidthCalculator()
Definition: PFClusterWidthCalculator.cxx:7
PFClusterWidthCalculator::m_phiMean
double m_phiMean
Definition: PFClusterWidthCalculator.h:21
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
PFClusterWidthCalculator.h
PFClusterWidthCalculator::getPFClusterCoordinateWidth
std::pair< double, double > getPFClusterCoordinateWidth(const std::vector< double > &eta, const std::vector< double > &phi, const double &clusterEta, const double &clusterPhi, unsigned int nCells)
Definition: PFClusterWidthCalculator.cxx:11