CMS 3D CMS Logo

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(), mps_fire::i, isEB_, 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 }
reco::PFClusterRef PFClusterRef_
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  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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 146 of file PFPhotonClusters.cc.

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

Referenced by PFPhotonClusters().

146  {
147  const std::vector< reco::PFRecHitFraction >& PFRecHits=PFClusterRef_->recHitFractions();
148  for(std::vector< reco::PFRecHitFraction >::const_iterator it = PFRecHits.begin(); it != PFRecHits.end(); ++it){
149  const PFRecHitRef& RefPFRecHit = it->recHitRef();
150  DetId id=RefPFRecHit->detId();
151  double frac=it->fraction();
152  float E=RefPFRecHit->energy()*frac;
153  if(isEB_){
154  int deta=EBDetId::distanceEta(id,idseed_);
155  int dphi=EBDetId::distancePhi(id,idseed_);
156 
157  if(std::abs(deta)>2 ||std::abs(dphi)>2)continue;
158 
159  //if(std::abs(dphi)<=2 && std::abs(deta)<=2){
160  EBDetId EBidSeed=EBDetId(idseed_.rawId());
161  EBDetId EBid=EBDetId(id.rawId());
162  int ind1=EBidSeed.ieta()-EBid.ieta();
163  int ind2=EBidSeed.iphi()-EBid.iphi();
164  if(EBidSeed.ieta() * EBid.ieta() > 0){
165  ind1=EBid.ieta()-EBidSeed.ieta();
166  }
167  else{ //near EB+ EB-
168  int shift(EBidSeed.ieta()>0 ? -1 : 1);
169  ind1=EBidSeed.ieta()-EBid.ieta()+shift;
170  }
171 
172  // more tricky edges in phi. Note that distance is already <2 at this point
173  if( (EBidSeed.iphi()<5&&EBid.iphi()>355) || (EBidSeed.iphi()>355&&EBid.iphi()<5)) {
174  int shift(EBidSeed.iphi()<180 ? EBDetId::MAX_IPHI:-EBDetId::MAX_IPHI) ;
175  ind2 = shift + EBidSeed.iphi() - EBid.iphi();
176  // std::cout << " Phi check " << EBidSeed.iphi() << " " << EBid.iphi() << " " << ind2 << std::endl;
177  }
178 
179  int iEta=ind1+2;
180  int iPhi=ind2+2;
181  //std::cout<<"IEta, IPhi "<<iEta<<", "<<iPhi<<std::endl;
182 // if(iPhi >= 5 || iPhi <0) {
183 // std::cout << "dphi "<< EBDetId::distancePhi(id,idseed_) << " iphi " << EBid.iphi() << " iphiseed " << EBidSeed.iphi() << " iPhi " << iPhi << std::endl;}
184 // if(iEta >= 5 || iEta <0) {
185 // std::cout << "deta "<< EBDetId::distanceEta(id,idseed_) << " ieta " << EBid.ieta() << " ietaseed " << EBidSeed.ieta() << "ind1 " << ind1 << " iEta " << iEta << " " ;
186 // ind1=ind1prime;
187 // iEta=ind1+2;
188 // std::cout << " new iEta " << iEta << std::endl;
189 // }
190 // assert(iEta < 5);
191 // assert(iEta >= 0);
192 // assert(iPhi < 5);
193 // assert(iPhi >= 0);
194  e5x5_[iEta][iPhi]=E;
195  }
196  else{
197  int dx=EEDetId::distanceX(id,idseed_);
198  int dy=EEDetId::distanceY(id,idseed_);
199  if(std::abs(dx)>2 ||std::abs(dy)>2) continue;
200  EEDetId EEidSeed=EEDetId(idseed_.rawId());
201  EEDetId EEid=EEDetId(id.rawId());
202  int ind1=EEid.ix()-EEidSeed.ix();
203  int ind2=EEid.iy()-EEidSeed.iy();
204  int ix=ind1+2;
205  int iy=ind2+2;
206  //std::cout<<"IX, IY "<<ix<<", "<<iy<<std::endl;
207 // assert(ix < 5);
208 // assert(ix >= 0);
209 // assert(iy < 5);
210 // assert(iy >= 0);
211  e5x5_[ix][iy]=E;
212  }
213  }
214 }
int ix() const
Definition: EEDetId.h:77
static int distanceX(const EEDetId &a, const EEDetId &b)
Definition: EEDetId.cc:474
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
reco::PFClusterRef PFClusterRef_
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
static int distanceEta(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:118
static int distancePhi(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:125
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int iy() const
Definition: EEDetId.h:83
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
static int distanceY(const EEDetId &a, const EEDetId &b)
Definition: EEDetId.cc:476
Definition: DetId.h:18
static const int MAX_IPHI
Definition: EBDetId.h:137
double e5x5_[5][5]
static unsigned int const shift
void PFPhotonClusters::FillClusterWidth ( )

Definition at line 216 of file PFPhotonClusters.cc.

References funct::abs(), pfDeepCMVADiscriminatorsJetTags_cfi::denominator, particleFlow_cfi::dEta, particleFlow_cfi::dPhi, PFClusterRef_, Pi, sigetaeta_, sigetaphi_, sigphiphi_, mathSSE::sqrt(), and TwoPi.

Referenced by PFPhotonClusters().

216  {
217  double numeratorEtaWidth = 0.;
218  double numeratorPhiWidth = 0.;
219  double numeratorEtaPhiWidth = 0.;
220  double ClustEta=PFClusterRef_->eta();
221  double ClustPhi=PFClusterRef_->phi();
222  const std::vector< reco::PFRecHitFraction >& PFRecHits=PFClusterRef_->recHitFractions();
223  for(std::vector< reco::PFRecHitFraction >::const_iterator it = PFRecHits.begin(); it != PFRecHits.end(); ++it){
224  const PFRecHitRef& RefPFRecHit = it->recHitRef();
225  float E=RefPFRecHit->energy() * it->fraction();
226  double dEta = RefPFRecHit->position().eta() - ClustEta;
227  double dPhi = RefPFRecHit->position().phi() - ClustPhi;
228  if (dPhi > + TMath::Pi()) { dPhi = TMath::TwoPi() - dPhi; }
229  if (dPhi < - TMath::Pi()) { dPhi = TMath::TwoPi() + dPhi; }
230  numeratorEtaWidth += E * dEta * dEta;
231  numeratorPhiWidth += E * dPhi * dPhi;
232  numeratorEtaPhiWidth += E * std::abs(dPhi) * std::abs(dEta);
233  }
234  double denominator=PFClusterRef_->energy();
235  sigetaeta_ = sqrt(numeratorEtaWidth / denominator);
236  sigphiphi_ = sqrt(numeratorPhiWidth / denominator);
237  sigetaphi_ = sqrt(numeratorEtaPhiWidth / denominator);
238 }
const double TwoPi
const double Pi
reco::PFClusterRef PFClusterRef_
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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 49 of file PFPhotonClusters.cc.

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

Referenced by PFPhotonClusters().

49  {
50  if(PFClusterRef_->layer()==PFLayer:: ECAL_BARREL ){//is Barrel
51  isEB_=true;
52  EBDetId EBidSeed=EBDetId(idseed_.rawId());
53  CrysIEta_=EBidSeed.ieta();
54  CrysIPhi_=EBidSeed.iphi();
55  double depth = PFClusterRef_->getDepthCorrection(PFClusterRef_->energy(), false, false);
56  math::XYZVector center_pos = seedPosition_+depth*seedAxis_;
57  //Crystal Coordinates:
58  double Pi=TMath::Pi();
59  float Phi=PFClusterRef_->position().phi();
60  double Theta = -(PFClusterRef_->position().theta())+0.5* Pi;
61  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
62  double PhiWidth = (Pi/180.);
63  double PhiCry = (TVector2::Phi_mpi_pi(Phi-PhiCentr))/PhiWidth;
64  double ThetaCentr = -center_pos.theta()+0.5*Pi;
65  double ThetaWidth = (Pi/180.)*cos(ThetaCentr);
66 
67  double EtaCry = (Theta-ThetaCentr)/ThetaWidth;
68  CrysEta_=EtaCry;
69  CrysPhi_=PhiCry;
70  switch(std::abs(CrysIEta_)) {
71  case 24:
73  break;
74  case 25:
76  break;
77  case 26:
79  break;
80  case 27:
82  break;
83  case 44:
85  break;
86  case 45:
87  CrysIEtaCrack_=10;
88  break;
89  case 46:
90  CrysIEtaCrack_=11;
91  break;
92  case 47:
93  CrysIEtaCrack_=12;
94  break;
95  case 64:
96  CrysIEtaCrack_=14;
97  break;
98  case 65:
99  CrysIEtaCrack_=15;
100  break;
101  case 66:
102  CrysIEtaCrack_=16;
103  break;
104  case 67:
105  CrysIEtaCrack_=17;
106  break;
107  case 84:
108  CrysIEtaCrack_=19;
109  break;
110  case 85:
111  CrysIEtaCrack_=20;
112  break;
113  default:
114  if(std::abs(CrysIEta_)==1 || std::abs(CrysIEta_)==2 )
115  CrysIEtaCrack_=std::abs(CrysIEta_);
116  else if(std::abs(CrysIEta_)>2 && std::abs(CrysIEta_)<24)
117  CrysIEtaCrack_=3;
118  else if(std::abs(CrysIEta_)>27 && std::abs(CrysIEta_)<44)
119  CrysIEtaCrack_=8;
120  else if(std::abs(CrysIEta_)>47 && std::abs(CrysIEta_)<64)
121  CrysIEtaCrack_=13;
122  else if(std::abs(CrysIEta_)>67 && std::abs(CrysIEta_)<84)
123  CrysIEtaCrack_=18;
124  break;
125  }
126  }
127  else{
128  isEB_=false;
129  EEDetId EEidSeed=EEDetId(idseed_.rawId());
130  CrysIX_=EEidSeed.ix();
131  CrysIY_=EEidSeed.iy();
132  float X0 = 0.89; float T0 = 1.2;
133  if(std::abs(PFClusterRef_->eta())>1.653)T0=3.1;
134  double depth = X0 * (T0 + log(PFClusterRef_->energy()));
135  math::XYZVector center_pos=(seedPosition_)+depth*seedAxis_;
136  double XCentr = center_pos.x();
137  double YCentr = center_pos.y();
138  double XWidth = 2.59;
139  double YWidth = 2.59;
140 
141  CrysX_=(PFClusterRef_->x()-XCentr)/XWidth;
142  CrysY_=(PFClusterRef_->y()-YCentr)/YWidth;
143  }
144 }
const double Pi
int ix() const
Definition: EEDetId.h:77
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
reco::PFClusterRef PFClusterRef_
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
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:83
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
static const double X0
math::XYZVector seedPosition_
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 DivergingColor::frac, TruncatedPyramid::getPosition(), idseed_, PFClusterRef_, position, seedAxis_, and seedPosition_.

Referenced by PFPhotonClusters().

22  {
23  double PFSeedE=0;
24  math::XYZVector axis;
26  DetId idseed;
27  const auto & PFRecHits=
28  PFClusterRef_->recHitFractions();
29 
30  for(auto it = PFRecHits.begin();
31  it != PFRecHits.end(); ++it){
32  const auto & RefPFRecHit = it->recHitRef();
33  auto frac=it->fraction();
34  float E= RefPFRecHit->energy()* frac;
35  if(E>PFSeedE){
36  PFSeedE=E;
37  // FIXME will optimize later...
38  auto const & pyr = dynamic_cast<TruncatedPyramid const &>(RefPFRecHit->caloCell());
39  axis = pyr.getPosition(1) - pyr.getPosition(0);
40  position=RefPFRecHit->position();
41  idseed = RefPFRecHit->detId();
42  }
43  }
44  idseed_=idseed;
46  seedAxis_=axis;
47 }
GlobalPoint getPosition(CCGFloat depth) const override
reco::PFClusterRef PFClusterRef_
math::XYZVector seedAxis_
Definition: DetId.h:18
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
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().