CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
EcalClusterLocal Class Reference

#include <EcalClusterLocal.h>

Public Member Functions

 EcalClusterLocal ()
 
void localCoordsEB (const reco::BasicCluster &bclus, const edm::EventSetup &es, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt) const
 
void localCoordsEE (const reco::BasicCluster &bclus, const edm::EventSetup &es, float &xcry, float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt) const
 
 ~EcalClusterLocal ()
 

Detailed Description

Function to compute local coordinates of Ecal clusters (adapted from RecoEcal/EgammaCoreTools/plugins/EcalClusterLocal) $Id: EcalClusterLocal.h $Date: $Revision:

Author
Josh Bendavid, MIT, 2011

Definition at line 19 of file EcalClusterLocal.h.

Constructor & Destructor Documentation

EcalClusterLocal::EcalClusterLocal ( )

Definition at line 16 of file EcalClusterLocal.cc.

17 {}
EcalClusterLocal::~EcalClusterLocal ( )

Definition at line 19 of file EcalClusterLocal.cc.

20 {}

Member Function Documentation

void EcalClusterLocal::localCoordsEB ( const reco::BasicCluster bclus,
const edm::EventSetup es,
float &  etacry,
float &  phicry,
int &  ieta,
int &  iphi,
float &  thetatilt,
float &  phitilt 
) const

Definition at line 22 of file EcalClusterLocal.cc.

References reco::deltaR(), DetId::Ecal, EcalBarrel, reco::tau::disc::Eta(), PV3DBase< T, PVType, FrameType >::eta(), first, relativeConstraints::geom, edm::EventSetup::get(), CaloSubdetectorGeometry::getGeometry(), EBDetId::ieta(), EBDetId::iphi(), create_public_lumi_plots::log, colinearityKinematic::Phi, PV3DBase< T, PVType, FrameType >::phi(), Phi_mpi_pi(), Pi, PV3DBase< T, PVType, FrameType >::theta(), and X0.

Referenced by EGEnergyCorrector::CorrectedEnergyWithError().

23 {
24 
25  assert(bclus.hitsAndFractions().at(0).first.subdetId()==EcalBarrel);
26 
28  es.get<CaloGeometryRecord>().get(pG);
29 
30  const CaloSubdetectorGeometry* geom=pG->getSubdetectorGeometry(DetId::Ecal,EcalBarrel);//EcalBarrel = 1
31 
32  const math::XYZPoint position_ = bclus.position();
33  double Theta = -position_.theta()+0.5*TMath::Pi();
34  double Eta = position_.eta();
35  double Phi = TVector2::Phi_mpi_pi(position_.phi());
36 
37  //Calculate expected depth of the maximum shower from energy (like in PositionCalc::Calculate_Location()):
38  // The parameters X0 and T0 are hardcoded here because these values were used to calculate the corrections:
39  const float X0 = 0.89; const float T0 = 7.4;
40  double depth = X0 * (T0 + log(bclus.energy()));
41 
42  //find max energy crystal
43  std::vector< std::pair<DetId, float> > crystals_vector = bclus.hitsAndFractions();
44  float drmin = 999.;
45  EBDetId crystalseed;
46  //printf("starting loop over crystals, etot = %5f:\n",bclus.energy());
47  for (unsigned int icry=0; icry!=crystals_vector.size(); ++icry) {
48 
49  EBDetId crystal(crystals_vector[icry].first);
50 
51  const CaloCellGeometry* cell=geom->getGeometry(crystal);
52  GlobalPoint center_pos = (dynamic_cast<const TruncatedPyramid*>(cell))->getPosition(depth);
53  double EtaCentr = center_pos.eta();
54  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
55 
56  float dr = reco::deltaR(Eta,Phi,EtaCentr,PhiCentr);
57  if (dr<drmin) {
58  drmin = dr;
59  crystalseed = crystal;
60  }
61 
62  }
63 
64  ieta = crystalseed.ieta();
65  iphi = crystalseed.iphi();
66 
67  // Get center cell position from shower depth
68  const CaloCellGeometry* cell=geom->getGeometry(crystalseed);
69  const TruncatedPyramid *cpyr = dynamic_cast<const TruncatedPyramid*>(cell);
70 
71  thetatilt = cpyr->getThetaAxis();
72  phitilt = cpyr->getPhiAxis();
73 
74  GlobalPoint center_pos = cpyr->getPosition(depth);
75 
76  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
77  double PhiWidth = (TMath::Pi()/180.);
78  phicry = (TVector2::Phi_mpi_pi(Phi-PhiCentr))/PhiWidth;
79  //Some flips to take into account ECAL barrel symmetries:
80  if (ieta<0) phicry *= -1.;
81 
82  double ThetaCentr = -center_pos.theta()+0.5*TMath::Pi();
83  double ThetaWidth = (TMath::Pi()/180.)*TMath::Cos(ThetaCentr);
84  etacry = (Theta-ThetaCentr)/ThetaWidth;
85  //flip to take into account ECAL barrel symmetries:
86  if (ieta<0) etacry *= -1.;
87 
88  return;
89 
90 }
const double Pi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
double Phi_mpi_pi(double x)
Definition: JetUtil.h:24
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
int iphi() const
get the crystal iphi
Definition: EBDetId.h:54
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
int ieta() const
get the crystal ieta
Definition: EBDetId.h:52
bool first
Definition: L1TdeRCT.cc:94
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
const T & get() const
Definition: EventSetup.h:55
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
T eta() const
Definition: PV3DBase.h:76
static const double X0
void EcalClusterLocal::localCoordsEE ( const reco::BasicCluster bclus,
const edm::EventSetup es,
float &  xcry,
float &  ycry,
int &  ix,
int &  iy,
float &  thetatilt,
float &  phitilt 
) const

Definition at line 92 of file EcalClusterLocal.cc.

References reco::deltaR(), DetId::Ecal, EcalEndcap, reco::tau::disc::Eta(), PV3DBase< T, PVType, FrameType >::eta(), first, relativeConstraints::geom, edm::EventSetup::get(), CaloSubdetectorGeometry::getGeometry(), EEDetId::ix(), EEDetId::iy(), create_public_lumi_plots::log, colinearityKinematic::Phi, PV3DBase< T, PVType, FrameType >::phi(), Phi_mpi_pi(), X, PV3DBase< T, PVType, FrameType >::x(), X0, and PV3DBase< T, PVType, FrameType >::y().

93 {
94 
95  assert(bclus.hitsAndFractions().at(0).first.subdetId()==EcalEndcap);
96 
98  es.get<CaloGeometryRecord>().get(pG);
99 
100  const CaloSubdetectorGeometry* geom=pG->getSubdetectorGeometry(DetId::Ecal,EcalEndcap);//EcalBarrel = 1
101 
102  const math::XYZPoint position_ = bclus.position();
103  //double Theta = -position_.theta()+0.5*TMath::Pi();
104  double Eta = position_.eta();
105  double Phi = TVector2::Phi_mpi_pi(position_.phi());
106  double X = position_.x();
107  double Y = position_.y();
108 
109  //Calculate expected depth of the maximum shower from energy (like in PositionCalc::Calculate_Location()):
110  // The parameters X0 and T0 are hardcoded here because these values were used to calculate the corrections:
111  const float X0 = 0.89; float T0 = 1.2;
112  //different T0 value if outside of preshower coverage
113  if (TMath::Abs(bclus.eta())<1.653) T0 = 3.1;
114 
115  double depth = X0 * (T0 + log(bclus.energy()));
116 
117  //find max energy crystal
118  std::vector< std::pair<DetId, float> > crystals_vector = bclus.hitsAndFractions();
119  float drmin = 999.;
120  EEDetId crystalseed;
121  //printf("starting loop over crystals, etot = %5f:\n",bclus.energy());
122  for (unsigned int icry=0; icry!=crystals_vector.size(); ++icry) {
123 
124  EEDetId crystal(crystals_vector[icry].first);
125 
126  const CaloCellGeometry* cell=geom->getGeometry(crystal);
127  GlobalPoint center_pos = (dynamic_cast<const TruncatedPyramid*>(cell))->getPosition(depth);
128  double EtaCentr = center_pos.eta();
129  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
130 
131  float dr = reco::deltaR(Eta,Phi,EtaCentr,PhiCentr);
132  if (dr<drmin) {
133  drmin = dr;
134  crystalseed = crystal;
135  }
136 
137  }
138 
139  ix = crystalseed.ix();
140  iy = crystalseed.iy();
141 
142  // Get center cell position from shower depth
143  const CaloCellGeometry* cell=geom->getGeometry(crystalseed);
144  const TruncatedPyramid *cpyr = dynamic_cast<const TruncatedPyramid*>(cell);
145 
146  thetatilt = cpyr->getThetaAxis();
147  phitilt = cpyr->getPhiAxis();
148 
149  GlobalPoint center_pos = cpyr->getPosition(depth);
150 
151  double XCentr = center_pos.x();
152  double XWidth = 2.59;
153  xcry = (X-XCentr)/XWidth;
154 
155 
156  double YCentr = center_pos.y();
157  double YWidth = 2.59;
158  ycry = (Y-YCentr)/YWidth;
159 
160  return;
161 
162 }
int ix() const
Definition: EEDetId.h:77
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
#define X(str)
Definition: MuonsGrabber.cc:49
double Phi_mpi_pi(double x)
Definition: JetUtil.h:24
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
int iy() const
Definition: EEDetId.h:83
bool first
Definition: L1TdeRCT.cc:94
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
const T & get() const
Definition: EventSetup.h:55
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
T eta() const
Definition: PV3DBase.h:76
static const double X0
T x() const
Definition: PV3DBase.h:62