CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PFClusterWidthAlgo Class Reference

#include <PFClusterWidthAlgo.h>

Public Member Functions

 PFClusterWidthAlgo (const std::vector< const reco::PFCluster * > &pfclust)
 
double pflowEtaWidth () const
 
double pflowPhiWidth () const
 
double pflowSigmaEtaEta () const
 
 ~PFClusterWidthAlgo ()
 

Private Attributes

double etaWidth_
 
double phiWidth_
 
double sigmaEtaEta_
 

Detailed Description

Definition at line 6 of file PFClusterWidthAlgo.h.

Constructor & Destructor Documentation

PFClusterWidthAlgo::PFClusterWidthAlgo ( const std::vector< const reco::PFCluster * > &  pfclust)

Definition at line 14 of file PFClusterWidthAlgo.cc.

References reco::deltaPhi(), pfDeepCMVADiscriminatorsJetTags_cfi::denominator, particleFlow_cfi::dEta, particleFlow_cfi::dPhi, RecoTauValidation_cfi::posX, RecoTauValidation_cfi::posY, and mathSSE::sqrt().

14  {
15 
16 
17  double numeratorEtaWidth = 0.;
18  double numeratorPhiWidth = 0.;
19  double sclusterE = 0.;
20  double posX = 0.;
21  double posY = 0.;
22  double posZ = 0.;
23  sigmaEtaEta_ = 0.;
24 
25  unsigned int nclust= pfclust.size();
26  if(nclust == 0 ) {
27  etaWidth_ = 0.;
28  phiWidth_ = 0.;
29  sigmaEtaEta_ = 0.;
30  }
31  else {
32 
33  //first loop, compute supercluster position at ecal face, and energy sum from rechit loop
34  //in order to be consistent with variance calculation
35  for(unsigned int icl=0; icl<nclust; ++icl) {
36  const std::vector< reco::PFRecHitFraction >& PFRecHits = pfclust[icl]->recHitFractions();
37 
38  for ( std::vector< reco::PFRecHitFraction >::const_iterator it = PFRecHits.begin();
39  it != PFRecHits.end(); ++it) {
40  const PFRecHitRef& RefPFRecHit = it->recHitRef();
41  //compute rechit energy taking into account fractions
42  double energyHit = RefPFRecHit->energy()*it->fraction();
43 
44  sclusterE += energyHit;
45  posX += energyHit*RefPFRecHit->position().x();
46  posY += energyHit*RefPFRecHit->position().y();
47  posZ += energyHit*RefPFRecHit->position().z();
48 
49  }
50  } // end for ncluster
51 
52  double denominator = sclusterE;
53 
54  posX /=sclusterE;
55  posY /=sclusterE;
56  posZ /=sclusterE;
57 
58  math::XYZPoint pflowSCPos(posX,posY,posZ);
59 
60  double scEta = pflowSCPos.eta();
61  double scPhi = pflowSCPos.phi();
62 
63  double SeedClusEnergy = -1.;
64  unsigned int SeedDetID = 0;
65  double SeedEta = -1.;
66 
67  //second loop, compute variances
68  for(unsigned int icl=0; icl<nclust; ++icl) {
69  const auto & PFRecHits = pfclust[icl]->recHitFractions();
70 
71  for ( auto it = PFRecHits.begin();
72  it != PFRecHits.end(); ++it) {
73  const PFRecHitRef& RefPFRecHit = it->recHitRef();
74  //compute rechit energy taking into account fractions
75  double energyHit = RefPFRecHit->energy()*it->fraction();
76 
77  //only for the first cluster (from GSF) find the seed
78  if(icl==0) {
79  if (energyHit > SeedClusEnergy) {
80  SeedClusEnergy = energyHit;
81  SeedEta = RefPFRecHit->position().eta();
82  SeedDetID = RefPFRecHit->detId();
83  }
84  }
85 
86  double dPhi = reco::deltaPhi(RefPFRecHit->positionREP().phi(),scPhi);
87  double dEta = RefPFRecHit->positionREP().eta() - scEta;
88  numeratorEtaWidth += energyHit * dEta * dEta;
89  numeratorPhiWidth += energyHit * dPhi * dPhi;
90  }
91  } // end for ncluster
92 
93  //for the first cluster (from GSF) computed sigmaEtaEta
94  const auto & PFRecHits = pfclust[0]->recHitFractions();
95  for ( auto it = PFRecHits.begin();
96  it != PFRecHits.end(); ++it) {
97  const auto & RefPFRecHit = it->recHitRef();
98  if(!RefPFRecHit.isAvailable())
99  return;
100  double energyHit = RefPFRecHit->energy();
101  if (RefPFRecHit->detId() != SeedDetID) {
102  float diffEta = RefPFRecHit->positionREP().eta() - SeedEta;
103  sigmaEtaEta_ += (diffEta*diffEta) * (energyHit/SeedClusEnergy);
104  }
105  }
106  if (sigmaEtaEta_ == 0.) sigmaEtaEta_ = 0.00000001;
107 
108  etaWidth_ = std::sqrt(numeratorEtaWidth / denominator);
109  phiWidth_ = std::sqrt(numeratorPhiWidth / denominator);
110 
111 
112  } // endif ncluster > 0
113 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
bool isAvailable() const
Definition: Ref.h:575
T sqrt(T t)
Definition: SSEVec.h:18
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
PFClusterWidthAlgo::~PFClusterWidthAlgo ( )

Definition at line 114 of file PFClusterWidthAlgo.cc.

115 {
116 }

Member Function Documentation

double PFClusterWidthAlgo::pflowEtaWidth ( ) const
inline
double PFClusterWidthAlgo::pflowPhiWidth ( ) const
inline
double PFClusterWidthAlgo::pflowSigmaEtaEta ( ) const
inline

Definition at line 18 of file PFClusterWidthAlgo.h.

References sigmaEtaEta_.

Referenced by PFEGammaAlgo::calculateEleMVA(), and PFElectronAlgo::SetIDOutputs().

18 {return sigmaEtaEta_;}

Member Data Documentation

double PFClusterWidthAlgo::etaWidth_
private

Definition at line 24 of file PFClusterWidthAlgo.h.

Referenced by pflowEtaWidth().

double PFClusterWidthAlgo::phiWidth_
private

Definition at line 23 of file PFClusterWidthAlgo.h.

Referenced by pflowPhiWidth().

double PFClusterWidthAlgo::sigmaEtaEta_
private

Definition at line 25 of file PFClusterWidthAlgo.h.

Referenced by pflowSigmaEtaEta().