CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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, const EBRecHitCollection *ebRecHits=0, const EERecHitCollection *eeRecHits=0)
 
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,
const EBRecHitCollection ebRecHits = 0,
const EERecHitCollection eeRecHits = 0 
)

Definition at line 13 of file PFClusterWidthAlgo.cc.

References cuy::denominator, dPhi(), alignCSCRings::e, DetId::Ecal, EcalBarrel, EcalEndcap, edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), getHLTprescales::index, edm::Ref< C, T, F >::isAvailable(), Pi, mathSSE::sqrt(), and TwoPi.

15  {
16 
17 
18  double numeratorEtaWidth = 0.;
19  double numeratorPhiWidth = 0.;
20  double sclusterE = 0.;
21  double posX = 0.;
22  double posY = 0.;
23  double posZ = 0.;
24  sigmaEtaEta_ = 0.;
25 
26  unsigned int nclust= pfclust.size();
27  if(nclust == 0 ) {
28  etaWidth_ = 0.;
29  phiWidth_ = 0.;
30  sigmaEtaEta_ = 0.;
31  }
32  else {
33 
34  for(unsigned int icl=0;icl<nclust;++icl) {
35  double e = pfclust[icl]->energy();
36  sclusterE += e;
37  posX += e * pfclust[icl]->position().X();
38  posY += e * pfclust[icl]->position().Y();
39  posZ += e * pfclust[icl]->position().Z();
40  }
41 
42  posX /=sclusterE;
43  posY /=sclusterE;
44  posZ /=sclusterE;
45 
46  double denominator = sclusterE;
47 
48  math::XYZPoint pflowSCPos(posX,posY,posZ);
49 
50  double scEta = pflowSCPos.eta();
51  double scPhi = pflowSCPos.phi();
52 
53  double SeedClusEnergy = -1.;
54  unsigned int SeedDetID = 0;
55  double SeedEta = -1.;
56 
57  for(unsigned int icl=0; icl<nclust; ++icl) {
58  const std::vector< reco::PFRecHitFraction >& PFRecHits = pfclust[icl]->recHitFractions();
59 
60 
61  for ( std::vector< reco::PFRecHitFraction >::const_iterator it = PFRecHits.begin();
62  it != PFRecHits.end(); ++it) {
63  const PFRecHitRef& RefPFRecHit = it->recHitRef();
64  double energyHit=0;
65  // if the PFRecHit is not available, try to get it from the collections
66  // if(!RefPFRecHit.isAvailable() && ebRecHits && eeRecHits )
67  if(ebRecHits && eeRecHits )
68  {
69  // std::cout << " Recomputing " << std::endl;
70  unsigned index=it-PFRecHits.begin();
71  DetId id=pfclust[icl]->hitsAndFractions()[index].first;
72  // look for the hit; do not forget to multiply by the fraction
73  if(id.det()==DetId::Ecal && id.subdetId()==EcalBarrel)
74  {
75  EBRecHitCollection::const_iterator itcheck=ebRecHits->find(id);
76  if(itcheck!=ebRecHits->end())
77  energyHit= itcheck->energy();
78  // The cluster shapes do not take into account the RecHit fraction !
79  // * pfclust[icl]->hitsAndFractions()[index].second;
80  }
81  if(id.det()==DetId::Ecal && id.subdetId()==EcalEndcap)
82  {
83  EERecHitCollection::const_iterator itcheck=eeRecHits->find(id);
84  if(itcheck!=eeRecHits->end())
85  energyHit= itcheck->energy();
86  // The cluster shapes do not take into account the RecHit fraction !
87  // * pfclust[icl]->hitsAndFractions()[index].second;
88  }
89  }
90  else
91  energyHit = RefPFRecHit->energy();
92 
93  //only for the first cluster (from GSF) find the seed
94  if(icl==0) {
95  if (energyHit > SeedClusEnergy) {
96  SeedClusEnergy = energyHit;
97  SeedEta = RefPFRecHit->position().eta();
98  SeedDetID = RefPFRecHit->detId();
99  }
100  }
101 
102 
103  double dPhi = RefPFRecHit->position().phi() - scPhi;
104  if (dPhi > + TMath::Pi()) { dPhi = TMath::TwoPi() - dPhi; }
105  if (dPhi < - TMath::Pi()) { dPhi = TMath::TwoPi() + dPhi; }
106  double dEta = RefPFRecHit->position().eta() - scEta;
107  if ( energyHit > 0 ) {
108  numeratorEtaWidth += energyHit * dEta * dEta;
109  numeratorPhiWidth += energyHit * dPhi * dPhi;
110  }
111  }
112  } // end for ncluster
113 
114  //for the first cluster (from GSF) computed sigmaEtaEta
115  const std::vector< reco::PFRecHitFraction >& PFRecHits = pfclust[0]->recHitFractions();
116  for ( std::vector< reco::PFRecHitFraction >::const_iterator it = PFRecHits.begin();
117  it != PFRecHits.end(); ++it) {
118  const PFRecHitRef& RefPFRecHit = it->recHitRef();
119  if(!RefPFRecHit.isAvailable())
120  return;
121  double energyHit = RefPFRecHit->energy();
122  if (RefPFRecHit->detId() != SeedDetID) {
123  float diffEta = RefPFRecHit->position().eta() - SeedEta;
124  sigmaEtaEta_ += (diffEta*diffEta) * (energyHit/SeedClusEnergy);
125  }
126  }
127  if (sigmaEtaEta_ == 0.) sigmaEtaEta_ = 0.00000001;
128 
129  etaWidth_ = sqrt(numeratorEtaWidth / denominator);
130  phiWidth_ = sqrt(numeratorPhiWidth / denominator);
131 
132 
133  } // endif ncluster > 0
134 }
const double TwoPi
const double Pi
std::vector< EcalRecHit >::const_iterator const_iterator
bool isAvailable() const
Definition: Ref.h:276
list denominator
Definition: cuy.py:484
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:48
const_iterator end() const
Definition: DetId.h:20
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
iterator find(key_type k)
PFClusterWidthAlgo::~PFClusterWidthAlgo ( )

Definition at line 135 of file PFClusterWidthAlgo.cc.

136 {
137 }

Member Function Documentation

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

Definition at line 20 of file PFClusterWidthAlgo.h.

References sigmaEtaEta_.

Referenced by PFElectronAlgo::SetIDOutputs().

20 {return sigmaEtaEta_;}

Member Data Documentation

double PFClusterWidthAlgo::etaWidth_
private

Definition at line 26 of file PFClusterWidthAlgo.h.

Referenced by pflowEtaWidth().

double PFClusterWidthAlgo::phiWidth_
private

Definition at line 25 of file PFClusterWidthAlgo.h.

Referenced by pflowPhiWidth().

double PFClusterWidthAlgo::sigmaEtaEta_
private

Definition at line 27 of file PFClusterWidthAlgo.h.

Referenced by pflowSigmaEtaEta().