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
PFPhotonClusters Class Reference

#include <PFPhotonClusters.h>

Public Member Functions

double E5x5Element (int i, int j)
 
int EtaCrack ()
 
double EtaPhiWidth ()
 
double EtaWidth ()
 
void FillClusterShape ()
 
void FillClusterWidth ()
 
std::pair< double, double > GetCrysCoor ()
 
std::pair< double, double > GetCrysIndex ()
 
void PFCrystalCoor ()
 
 PFPhotonClusters (reco::PFClusterRef PFClusterRef)
 
double PhiWidth ()
 
void SetSeed ()
 

Private Attributes

float CrysEta_
 
int CrysIEta_
 
int CrysIEtaCrack_
 
int CrysIPhi_
 
int CrysIX_
 
int CrysIY_
 
float CrysPhi_
 
float CrysX_
 
float CrysY_
 
double e5x5_ [5][5]
 
DetId idseed_
 
bool isEB_
 
reco::PFClusterRef PFClusterRef_
 
math::XYZVector seedAxis_
 
math::XYZVector seedPosition_
 
double sigetaeta_
 
double sigetaphi_
 
double sigphiphi_
 

Detailed Description

Definition at line 12 of file PFPhotonClusters.h.

Constructor & Destructor Documentation

PFPhotonClusters::PFPhotonClusters ( reco::PFClusterRef  PFClusterRef)

Definition at line 9 of file PFPhotonClusters.cc.

References e5x5_, PFLayer::ECAL_BARREL, FillClusterShape(), FillClusterWidth(), i, isEB_, j, PFClusterRef_, PFCrystalCoor(), and SetSeed().

9  :
10  PFClusterRef_(PFClusterRef)
11 {
12  if(PFClusterRef_->layer()==PFLayer:: ECAL_BARREL )isEB_=true;
13  else isEB_=false;
14  SetSeed();
15  PFCrystalCoor();
16  for(int i=0; i<5; ++i)
17  for(int j=0; j<5; ++j)e5x5_[i][j]=0;
20 }
int i
Definition: DBlmapReader.cc:9
reco::PFClusterRef PFClusterRef_
int j
Definition: DBlmapReader.cc:9
double e5x5_[5][5]

Member Function Documentation

double PFPhotonClusters::E5x5Element ( int  i,
int  j 
)
inline

Definition at line 45 of file PFPhotonClusters.h.

References funct::abs(), and e5x5_.

Referenced by PFPhotonAlgo::EvaluateLCorrMVA().

45  {
46  //std::cout<<"i, j "<<i<<" , "<<j<<std::endl;
47  double E=0;
48  if(abs(i)>2 ||abs(j)>2)return E;
49  int ind1=i+2;
50  int ind2=j+2;
51  E=e5x5_[ind1][ind2];
52  //std::cout<<"E "<<E<<std::endl;
53  return E;
54  }
int i
Definition: DBlmapReader.cc:9
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
double e5x5_[5][5]
int PFPhotonClusters::EtaCrack ( )
inline

Definition at line 44 of file PFPhotonClusters.h.

References CrysIEtaCrack_.

Referenced by PFPhotonAlgo::EvaluateLCorrMVA().

44 {return CrysIEtaCrack_;}
double PFPhotonClusters::EtaPhiWidth ( )
inline

Definition at line 57 of file PFPhotonClusters.h.

References sigetaphi_.

57 {return sigetaphi_;}
double PFPhotonClusters::EtaWidth ( )
inline

Definition at line 56 of file PFPhotonClusters.h.

References sigetaeta_.

56 {return sigetaeta_;}
void PFPhotonClusters::FillClusterShape ( )

Definition at line 127 of file PFPhotonClusters.cc.

References funct::abs(), EBDetId::distanceEta(), EBDetId::distancePhi(), EEDetId::distanceX(), EEDetId::distanceY(), e5x5_, cropTnPTrees::frac, idseed_, EBDetId::ieta(), EBDetId::iphi(), isEB_, EEDetId::ix(), EEDetId::iy(), EBDetId::MAX_IPHI, PFClusterRef_, DetId::rawId(), and edm::shift.

Referenced by PFPhotonClusters().

127  {
128  const std::vector< reco::PFRecHitFraction >& PFRecHits=PFClusterRef_->recHitFractions();
129  for(std::vector< reco::PFRecHitFraction >::const_iterator it = PFRecHits.begin(); it != PFRecHits.end(); ++it){
130  const PFRecHitRef& RefPFRecHit = it->recHitRef();
131  DetId id=RefPFRecHit->detId();
132  double frac=it->fraction();
133  float E=RefPFRecHit->energy()*frac;
134  if(isEB_){
135  int deta=EBDetId::distanceEta(id,idseed_);
136  int dphi=EBDetId::distancePhi(id,idseed_);
137 
138  if(abs(deta)>2 ||abs(dphi)>2)continue;
139 
140  //f(abs(dphi)<=2 && abs(deta)<=2){
141  EBDetId EBidSeed=EBDetId(idseed_.rawId());
142  EBDetId EBid=EBDetId(id.rawId());
143  int ind1=EBidSeed.ieta()-EBid.ieta();
144  int ind2=EBidSeed.iphi()-EBid.iphi();
145  if(EBidSeed.ieta() * EBid.ieta() > 0){
146  ind1=EBid.ieta()-EBidSeed.ieta();
147  }
148  else{ //near EB+ EB-
149  int shift(EBidSeed.ieta()>0 ? -1 : 1);
150  ind1=EBidSeed.ieta()-EBid.ieta()+shift;
151  }
152 
153  // more tricky edges in phi. Note that distance is already <2 at this point
154  if( (EBidSeed.iphi()<5&&EBid.iphi()>355) || (EBidSeed.iphi()>355&&EBid.iphi()<5)) {
155  int shift(EBidSeed.iphi()<180 ? EBDetId::MAX_IPHI:-EBDetId::MAX_IPHI) ;
156  ind2 = shift + EBidSeed.iphi() - EBid.iphi();
157  // std::cout << " Phi check " << EBidSeed.iphi() << " " << EBid.iphi() << " " << ind2 << std::endl;
158  }
159 
160  int iEta=ind1+2;
161  int iPhi=ind2+2;
162  //std::cout<<"IEta, IPhi "<<iEta<<", "<<iPhi<<std::endl;
163 // if(iPhi >= 5 || iPhi <0) {
164 // std::cout << "dphi "<< EBDetId::distancePhi(id,idseed_) << " iphi " << EBid.iphi() << " iphiseed " << EBidSeed.iphi() << " iPhi " << iPhi << std::endl;}
165 // if(iEta >= 5 || iEta <0) {
166 // std::cout << "deta "<< EBDetId::distanceEta(id,idseed_) << " ieta " << EBid.ieta() << " ietaseed " << EBidSeed.ieta() << "ind1 " << ind1 << " iEta " << iEta << " " ;
167 // ind1=ind1prime;
168 // iEta=ind1+2;
169 // std::cout << " new iEta " << iEta << std::endl;
170 // }
171 // assert(iEta < 5);
172 // assert(iEta >= 0);
173 // assert(iPhi < 5);
174 // assert(iPhi >= 0);
175  e5x5_[iEta][iPhi]=E;
176  }
177  else{
178  int dx=EEDetId::distanceX(id,idseed_);
179  int dy=EEDetId::distanceY(id,idseed_);
180  if(abs(dx)>2 ||abs(dy>2))continue;
181  EEDetId EEidSeed=EEDetId(idseed_.rawId());
182  EEDetId EEid=EEDetId(id.rawId());
183  int ind1=EEid.ix()-EEidSeed.ix();
184  int ind2=EEid.iy()-EEidSeed.iy();
185  int ix=ind1+2;
186  int iy=ind2+2;
187  //std::cout<<"IX, IY "<<ix<<", "<<iy<<std::endl;
188 // assert(ix < 5);
189 // assert(ix >= 0);
190 // assert(iy < 5);
191 // assert(iy >= 0);
192  e5x5_[ix][iy]=E;
193  }
194  }
195 }
int ix() const
Definition: EEDetId.h:76
static int distanceX(const EEDetId &a, const EEDetId &b)
Definition: EEDetId.cc:577
reco::PFClusterRef PFClusterRef_
int iphi() const
get the crystal iphi
Definition: EBDetId.h:53
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
static int distanceEta(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:135
static int distancePhi(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:143
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int iy() const
Definition: EEDetId.h:82
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
static int distanceY(const EEDetId &a, const EEDetId &b)
Definition: EEDetId.cc:582
Definition: DetId.h:18
static const int MAX_IPHI
Definition: EBDetId.h:144
double e5x5_[5][5]
static unsigned int const shift
void PFPhotonClusters::FillClusterWidth ( )

Definition at line 197 of file PFPhotonClusters.cc.

References cuy::denominator, dPhi(), PFClusterRef_, Pi, sigetaeta_, sigetaphi_, sigphiphi_, mathSSE::sqrt(), and TwoPi.

Referenced by PFPhotonClusters().

197  {
198  double numeratorEtaWidth = 0.;
199  double numeratorPhiWidth = 0.;
200  double numeratorEtaPhiWidth = 0.;
201  double ClustEta=PFClusterRef_->eta();
202  double ClustPhi=PFClusterRef_->phi();
203  const std::vector< reco::PFRecHitFraction >& PFRecHits=PFClusterRef_->recHitFractions();
204  for(std::vector< reco::PFRecHitFraction >::const_iterator it = PFRecHits.begin(); it != PFRecHits.end(); ++it){
205  const PFRecHitRef& RefPFRecHit = it->recHitRef();
206  float E=RefPFRecHit->energy() * it->fraction();
207  double dEta = RefPFRecHit->position().eta() - ClustEta;
208  double dPhi = RefPFRecHit->position().phi() - ClustPhi;
209  if (dPhi > + TMath::Pi()) { dPhi = TMath::TwoPi() - dPhi; }
210  if (dPhi < - TMath::Pi()) { dPhi = TMath::TwoPi() + dPhi; }
211  numeratorEtaWidth += E * dEta * dEta;
212  numeratorPhiWidth += E * dPhi * dPhi;
213  numeratorEtaPhiWidth += E * fabs(dPhi) * fabs(dEta);
214  }
215  double denominator=PFClusterRef_->energy();
216  sigetaeta_ = sqrt(numeratorEtaWidth / denominator);
217  sigphiphi_ = sqrt(numeratorPhiWidth / denominator);
218  sigetaphi_ = sqrt(numeratorEtaPhiWidth / denominator);
219 }
const double TwoPi
const double Pi
reco::PFClusterRef PFClusterRef_
list denominator
Definition: cuy.py:484
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:48
std::pair<double, double> PFPhotonClusters::GetCrysCoor ( )
inline

Definition at line 20 of file PFPhotonClusters.h.

References CrysEta_, CrysPhi_, CrysX_, CrysY_, and isEB_.

Referenced by PFPhotonAlgo::EvaluateLCorrMVA().

20  {
21  std::pair<double, double> crys;
22  if(isEB_){
23  crys.first=CrysEta_;
24  crys.second=CrysPhi_;
25  }
26  else{
27  crys.first=CrysX_;
28  crys.second=CrysY_;
29  }
30  return crys;
31  }
std::pair<double, double> PFPhotonClusters::GetCrysIndex ( )
inline

Definition at line 32 of file PFPhotonClusters.h.

References CrysIEta_, CrysIPhi_, CrysIX_, CrysIY_, and isEB_.

Referenced by PFPhotonAlgo::EvaluateLCorrMVA().

32  {
33  std::pair<int, int> crysI;
34  if(isEB_){
35  crysI.first=CrysIEta_;
36  crysI.second=CrysIPhi_;
37  }
38  else{
39  crysI.first=CrysIX_;
40  crysI.second=CrysIY_;
41  }
42  return crysI;
43  }
void PFPhotonClusters::PFCrystalCoor ( )

Definition at line 47 of file PFPhotonClusters.cc.

References funct::abs(), funct::cos(), CrysEta_, CrysIEta_, CrysIEtaCrack_, CrysIPhi_, CrysIX_, CrysIY_, CrysPhi_, CrysX_, CrysY_, HLT_25ns14e33_v1_cff::depth, PFLayer::ECAL_BARREL, idseed_, EBDetId::ieta(), EBDetId::iphi(), isEB_, EEDetId::ix(), EEDetId::iy(), cmsBatch::log, PFClusterRef_, colinearityKinematic::Phi, Phi_mpi_pi(), PhiWidth(), Pi, DetId::rawId(), seedAxis_, seedPosition_, and X0.

Referenced by PFPhotonClusters().

47  {
48  if(PFClusterRef_->layer()==PFLayer:: ECAL_BARREL ){//is Barrel
49  isEB_=true;
50  EBDetId EBidSeed=EBDetId(idseed_.rawId());
51  CrysIEta_=EBidSeed.ieta();
52  CrysIPhi_=EBidSeed.iphi();
53  double depth = PFClusterRef_->getDepthCorrection(PFClusterRef_->energy(), false, false);
54  math::XYZVector center_pos = seedPosition_+depth*seedAxis_;
55  //Crystal Coordinates:
56  double Pi=TMath::Pi();
57  float Phi=PFClusterRef_->position().phi();
58  double Theta = -(PFClusterRef_->position().theta())+0.5* Pi;
59  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
60  double PhiWidth = (Pi/180.);
61  double PhiCry = (TVector2::Phi_mpi_pi(Phi-PhiCentr))/PhiWidth;
62  double ThetaCentr = -center_pos.theta()+0.5*Pi;
63  double ThetaWidth = (Pi/180.)*cos(ThetaCentr);
64 
65  double EtaCry = (Theta-ThetaCentr)/ThetaWidth;
66  CrysEta_=EtaCry;
67  CrysPhi_=PhiCry;
68 
69  if(abs(CrysIEta_)==1 || abs(CrysIEta_)==2 )
70  CrysIEtaCrack_=abs(CrysIEta_);
71  if(abs(CrysIEta_)>2 && abs(CrysIEta_)<24)
73  if(abs(CrysIEta_)==24)
75  if(abs(CrysIEta_)==25)
77  if(abs(CrysIEta_)==26)
79  if(abs(CrysIEta_)==27)
81  if(abs(CrysIEta_)>27 && abs(CrysIEta_)<44)
83  if(abs(CrysIEta_)==44)
85  if(abs(CrysIEta_)==45)
86  CrysIEtaCrack_=10;
87  if(abs(CrysIEta_)==46)
88  CrysIEtaCrack_=11;
89  if(abs(CrysIEta_)==47)
90  CrysIEtaCrack_=12;
91  if(abs(CrysIEta_)>47 && abs(CrysIEta_)<64)
92  CrysIEtaCrack_=13;
93  if(abs(CrysIEta_)==64)
94  CrysIEtaCrack_=14;
95  if(abs(CrysIEta_)==65)
96  CrysIEtaCrack_=15;
97  if(abs(CrysIEta_)==66)
98  CrysIEtaCrack_=16;
99  if(abs(CrysIEta_)==67)
100  CrysIEtaCrack_=17;
101  if(abs(CrysIEta_)>67 && abs(CrysIEta_)<84)
102  CrysIEtaCrack_=18;
103  if(abs(CrysIEta_)==84)
104  CrysIEtaCrack_=19;
105  if(abs(CrysIEta_)==85)
106  CrysIEtaCrack_=20;
107  }
108  else{
109  isEB_=false;
110  EEDetId EEidSeed=EEDetId(idseed_.rawId());
111  CrysIX_=EEidSeed.ix();
112  CrysIY_=EEidSeed.iy();
113  float X0 = 0.89; float T0 = 1.2;
114  if(fabs(PFClusterRef_->eta())>1.653)T0=3.1;
115  double depth = X0 * (T0 + log(PFClusterRef_->energy()));
116  math::XYZVector center_pos=(seedPosition_)+depth*seedAxis_;
117  double XCentr = center_pos.x();
118  double YCentr = center_pos.y();
119  double XWidth = 2.59;
120  double YWidth = 2.59;
121 
122  CrysX_=(PFClusterRef_->x()-XCentr)/XWidth;
123  CrysY_=(PFClusterRef_->y()-YCentr)/YWidth;
124  }
125 }
const double Pi
int ix() const
Definition: EEDetId.h:76
double Phi_mpi_pi(double x)
Definition: JetUtil.h:24
reco::PFClusterRef PFClusterRef_
int iphi() const
get the crystal iphi
Definition: EBDetId.h:53
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
math::XYZVector seedAxis_
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int iy() const
Definition: EEDetId.h:82
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
static const double X0
math::XYZVector seedPosition_
tuple log
Definition: cmsBatch.py:347
double PFPhotonClusters::PhiWidth ( )
inline

Definition at line 55 of file PFPhotonClusters.h.

References sigphiphi_.

Referenced by PFCrystalCoor().

55 {return sigphiphi_;}
void PFPhotonClusters::SetSeed ( )

Definition at line 22 of file PFPhotonClusters.cc.

References cropTnPTrees::frac, idseed_, PFClusterRef_, position, seedAxis_, and seedPosition_.

Referenced by PFPhotonClusters().

22  {
23  double PFSeedE=0;
24  math::XYZVector axis;
26  DetId idseed;
27  const std::vector< reco::PFRecHitFraction >& PFRecHits=
28  PFClusterRef_->recHitFractions();
29 
30  for(std::vector< reco::PFRecHitFraction >::const_iterator it = PFRecHits.begin();
31  it != PFRecHits.end(); ++it){
32  const PFRecHitRef& RefPFRecHit = it->recHitRef();
33  double frac=it->fraction();
34  float E= RefPFRecHit->energy()* frac;
35  if(E>PFSeedE){
36  PFSeedE=E;
37  axis=RefPFRecHit->getAxisXYZ();
38  position=RefPFRecHit->position();
39  idseed = RefPFRecHit->detId();
40  }
41  }
42  idseed_=idseed;
44  seedAxis_=axis;
45 }
reco::PFClusterRef PFClusterRef_
math::XYZVector seedAxis_
Definition: DetId.h:18
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
static int position[264][3]
Definition: ReadPGInfo.cc:509
math::XYZVector seedPosition_

Member Data Documentation

float PFPhotonClusters::CrysEta_
private

Definition at line 65 of file PFPhotonClusters.h.

Referenced by GetCrysCoor(), and PFCrystalCoor().

int PFPhotonClusters::CrysIEta_
private

Definition at line 66 of file PFPhotonClusters.h.

Referenced by GetCrysIndex(), and PFCrystalCoor().

int PFPhotonClusters::CrysIEtaCrack_
private

Definition at line 66 of file PFPhotonClusters.h.

Referenced by EtaCrack(), and PFCrystalCoor().

int PFPhotonClusters::CrysIPhi_
private

Definition at line 66 of file PFPhotonClusters.h.

Referenced by GetCrysIndex(), and PFCrystalCoor().

int PFPhotonClusters::CrysIX_
private

Definition at line 66 of file PFPhotonClusters.h.

Referenced by GetCrysIndex(), and PFCrystalCoor().

int PFPhotonClusters::CrysIY_
private

Definition at line 66 of file PFPhotonClusters.h.

Referenced by GetCrysIndex(), and PFCrystalCoor().

float PFPhotonClusters::CrysPhi_
private

Definition at line 65 of file PFPhotonClusters.h.

Referenced by GetCrysCoor(), and PFCrystalCoor().

float PFPhotonClusters::CrysX_
private

Definition at line 65 of file PFPhotonClusters.h.

Referenced by GetCrysCoor(), and PFCrystalCoor().

float PFPhotonClusters::CrysY_
private

Definition at line 65 of file PFPhotonClusters.h.

Referenced by GetCrysCoor(), and PFCrystalCoor().

double PFPhotonClusters::e5x5_[5][5]
private

Definition at line 68 of file PFPhotonClusters.h.

Referenced by E5x5Element(), FillClusterShape(), and PFPhotonClusters().

DetId PFPhotonClusters::idseed_
private

Definition at line 61 of file PFPhotonClusters.h.

Referenced by FillClusterShape(), PFCrystalCoor(), and SetSeed().

bool PFPhotonClusters::isEB_
private
reco::PFClusterRef PFPhotonClusters::PFClusterRef_
private
math::XYZVector PFPhotonClusters::seedAxis_
private

Definition at line 62 of file PFPhotonClusters.h.

Referenced by PFCrystalCoor(), and SetSeed().

math::XYZVector PFPhotonClusters::seedPosition_
private

Definition at line 62 of file PFPhotonClusters.h.

Referenced by PFCrystalCoor(), and SetSeed().

double PFPhotonClusters::sigetaeta_
private

Definition at line 69 of file PFPhotonClusters.h.

Referenced by EtaWidth(), and FillClusterWidth().

double PFPhotonClusters::sigetaphi_
private

Definition at line 69 of file PFPhotonClusters.h.

Referenced by EtaPhiWidth(), and FillClusterWidth().

double PFPhotonClusters::sigphiphi_
private

Definition at line 69 of file PFPhotonClusters.h.

Referenced by FillClusterWidth(), and PhiWidth().