CMS 3D CMS Logo

Functions
egammaTools Namespace Reference

Functions

double ecalEta (const math::XYZVector &momentum, const math::XYZPoint &vertex)
 
double ecalPhi (const MagneticField &magField, const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge)
 
void localEcalClusterCoordsEB (const reco::CaloCluster &bclus, const CaloGeometry &geom, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt)
 
void localEcalClusterCoordsEE (const reco::CaloCluster &bclus, const CaloGeometry &geom, float &xcry, float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt)
 
template<class Candidate >
void validateEgammaCandidate (Candidate const &candidate)
 
void validateGsfElectron (reco::GsfElectron const &electron)
 

Function Documentation

◆ ecalEta()

double egammaTools::ecalEta ( const math::XYZVector momentum,
const math::XYZPoint vertex 
)

Definition at line 71 of file ECALPositionCalculator.cc.

71  {
72  // Get kinematic variables
73 
74  float etaParticle = momentum.eta();
75  float vZ = vertex.z();
76  float vRho = vertex.Rho();
77 
78  if (etaParticle != 0.0) {
79  float theta = 0.0;
80  float zEcal = (R_ECAL - vRho) * sinh(etaParticle) + vZ;
81 
82  if (zEcal != 0.0)
83  theta = atan(R_ECAL / zEcal);
84  if (theta < 0.0)
85  theta = theta + Geom::pi();
86 
87  float ETA = -log(tan(0.5 * theta));
88 
89  if (fabs(ETA) > etaBarrelEndcap) {
90  float Zend = Z_Endcap;
91  if (etaParticle < 0.0)
92  Zend = -Zend;
93  float Zlen = Zend - vZ;
94  float RR = Zlen / sinh(etaParticle);
95  theta = atan((RR + vRho) / Zend);
96  if (theta < 0.0)
97  theta = theta + Geom::pi();
98  ETA = -log(tan(0.5 * theta));
99  }
100  return ETA;
101 
102  } else {
103  edm::LogWarning("") << "[EcalPositionFromTrack::etaTransformation] Warning: "
104  << "Eta equals to zero, not correcting";
105  return etaParticle;
106  }
107  }

References ETA, etaBarrelEndcap, dqm-mbProfile::log, Geom::pi(), R_ECAL, funct::tan(), theta(), bphysicsOniaDQM_cfi::vertex, and Z_Endcap.

Referenced by ContainmentCorrectionAnalyzer::analyze(), and PreshowerAndECALLinker::testLink().

◆ ecalPhi()

double egammaTools::ecalPhi ( const MagneticField magField,
const math::XYZVector momentum,
const math::XYZPoint vertex,
const int  charge 
)

Definition at line 16 of file ECALPositionCalculator.cc.

19  {
20  // Get kinematic variables
21 
22  float ptParticle = momentum.Rho();
23  float etaParticle = momentum.eta();
24  float phiParticle = momentum.phi();
25  float vRho = vertex.Rho();
26 
27  // Magnetic field
28 
29  const float RBARM = 1.357; // was 1.31 , updated on 16122003
30  const float ZENDM = 3.186; // was 3.15 , updated on 16122003
31 
32  float rbend = RBARM - (vRho / 100.0); //Assumed vRho in cm
33  float bend = 0.3 * magField.inTesla(GlobalPoint(0., 0., 0.)).z() * rbend / 2.0;
34  float phi = 0.0;
35 
36  if (fabs(etaParticle) <= etaBarrelEndcap) {
37  if (fabs(bend / ptParticle) <= 1.) {
38  phi = phiParticle - asin(bend / ptParticle) * charge;
39  if (phi > Geom::pi())
40  phi = phi - Geom::twoPi();
41  if (phi < -Geom::pi())
42  phi = phi + Geom::twoPi();
43  } else {
44  edm::LogWarning("") << "[EcalPositionFromTrack::phiTransformation] Warning: "
45  << "Too low Pt, giving up";
46  return phiParticle;
47  }
48 
49  } // end if in the barrel
50 
51  if (fabs(etaParticle) > etaBarrelEndcap) {
52  float rHit = 0.0;
53  rHit = ZENDM / sinh(fabs(etaParticle));
54  if (fabs(((rHit - (vRho / 100.0)) / rbend) * bend / ptParticle) <= 1.0) {
55  phi = phiParticle - asin(((rHit - (vRho / 100.0)) / rbend) * bend / ptParticle) * charge;
56  if (phi > Geom::pi())
57  phi = phi - Geom::twoPi();
58  if (phi < -Geom::pi())
59  phi = phi + Geom::twoPi();
60  } else {
61  edm::LogWarning("") << "[EcalPositionFromTrack::phiTransformation] Warning: "
62  << "Too low Pt, giving up";
63  return phiParticle;
64  }
65 
66  } // end if in the endcap
67 
68  return phi;
69  }

References trklet::bend(), ALCARECOTkAlJpsiMuMu_cff::charge, etaBarrelEndcap, MagneticField::inTesla(), Geom::pi(), Geom::twoPi(), bphysicsOniaDQM_cfi::vertex, and PV3DBase< T, PVType, FrameType >::z().

Referenced by MuonMETAlgo::correctMETforMuon(), and PreshowerAndECALLinker::testLink().

◆ localEcalClusterCoordsEB()

void egammaTools::localEcalClusterCoordsEB ( const reco::CaloCluster bclus,
const CaloGeometry geom,
float &  etacry,
float &  phicry,
int &  ieta,
int &  iphi,
float &  thetatilt,
float &  phitilt 
)

Definition at line 14 of file EcalClusterLocal.cc.

21  {
22  assert(bclus.hitsAndFractions().at(0).first.subdetId() == EcalBarrel);
23 
25  caloGeometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel); //EcalBarrel = 1
26 
27  const math::XYZPoint &position_ = bclus.position();
28  double Theta = -position_.theta() + 0.5 * TMath::Pi();
29  double Eta = position_.eta();
30  double Phi = TVector2::Phi_mpi_pi(position_.phi());
31 
32  //Calculate expected depth of the maximum shower from energy (like in PositionCalc::Calculate_Location()):
33  // The parameters X0 and T0 are hardcoded here because these values were used to calculate the corrections:
34  const float X0 = 0.89;
35  const float T0 = 7.4;
36  double depth = X0 * (T0 + log(bclus.energy()));
37 
38  //find max energy crystal
39  std::vector<std::pair<DetId, float> > crystals_vector = bclus.hitsAndFractions();
40  float drmin = 999.;
41  EBDetId crystalseed;
42  //printf("starting loop over crystals, etot = %5f:\n",bclus.energy());
43  for (unsigned int icry = 0; icry != crystals_vector.size(); ++icry) {
44  EBDetId crystal(crystals_vector[icry].first);
45 
46  auto cell = geom->getGeometry(crystal);
47  const TruncatedPyramid *cpyr = dynamic_cast<const TruncatedPyramid *>(cell.get());
48  GlobalPoint center_pos = cpyr->getPosition(depth);
49  double EtaCentr = center_pos.eta();
50  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
51 
52  float dr = reco::deltaR(Eta, Phi, EtaCentr, PhiCentr);
53  if (dr < drmin) {
54  drmin = dr;
55  crystalseed = crystal;
56  }
57  }
58 
59  ieta = crystalseed.ieta();
60  iphi = crystalseed.iphi();
61 
62  // Get center cell position from shower depth
63  auto cell = geom->getGeometry(crystalseed);
64  const TruncatedPyramid *cpyr = dynamic_cast<const TruncatedPyramid *>(cell.get());
65 
66  thetatilt = cpyr->getThetaAxis();
67  phitilt = cpyr->getPhiAxis();
68 
69  GlobalPoint center_pos = cpyr->getPosition(depth);
70 
71  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
72  double PhiWidth = (TMath::Pi() / 180.);
73  phicry = (TVector2::Phi_mpi_pi(Phi - PhiCentr)) / PhiWidth;
74  //Some flips to take into account ECAL barrel symmetries:
75  if (ieta < 0)
76  phicry *= -1.;
77 
78  double ThetaCentr = -center_pos.theta() + 0.5 * TMath::Pi();
79  double ThetaWidth = (TMath::Pi() / 180.) * TMath::Cos(ThetaCentr);
80  etacry = (Theta - ThetaCentr) / ThetaWidth;
81  //flip to take into account ECAL barrel symmetries:
82  if (ieta < 0)
83  etacry *= -1.;
84 
85  return;
86  }

References cms::cuda::assert(), reco::deltaR(), LEDCalibrationChannels::depth, flavorHistoryFilter_cfi::dr, DetId::Ecal, EcalBarrel, reco::CaloCluster::energy(), PV3DBase< T, PVType, FrameType >::eta(), first, relativeConstraints::geom, TruncatedPyramid::getPhiAxis(), TruncatedPyramid::getPosition(), CaloGeometry::getSubdetectorGeometry(), TruncatedPyramid::getThetaAxis(), reco::CaloCluster::hitsAndFractions(), EBDetId::ieta(), LEDCalibrationChannels::ieta, EBDetId::iphi(), LEDCalibrationChannels::iphi, dqm-mbProfile::log, PV3DBase< T, PVType, FrameType >::phi(), VtxSmearedParameters_cfi::Phi, Pi, reco::CaloCluster::position(), PV3DBase< T, PVType, FrameType >::theta(), and MonitorAlCaEcalPi0_cfi::X0.

Referenced by EGEnergyCorrector::CorrectedEnergyWithError(), EGEnergyCorrector::CorrectedEnergyWithErrorV3(), EcalRegressionData::fill(), EGRegressionModifierV3::getSeedCrysCoord(), SuperClusterHelper::localCoordinates(), EGRegressionModifierV2::modifyObject(), and EGRegressionModifierV1::modifyObject().

◆ localEcalClusterCoordsEE()

void egammaTools::localEcalClusterCoordsEE ( const reco::CaloCluster bclus,
const CaloGeometry geom,
float &  xcry,
float &  ycry,
int &  ix,
int &  iy,
float &  thetatilt,
float &  phitilt 
)

Definition at line 88 of file EcalClusterLocal.cc.

95  {
96  assert(bclus.hitsAndFractions().at(0).first.subdetId() == EcalEndcap);
97 
99  caloGeometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap); //EcalBarrel = 1
100 
101  const math::XYZPoint &position_ = bclus.position();
102  //double Theta = -position_.theta()+0.5*TMath::Pi();
103  double Eta = position_.eta();
104  double Phi = TVector2::Phi_mpi_pi(position_.phi());
105  double X = position_.x();
106  double Y = position_.y();
107 
108  //Calculate expected depth of the maximum shower from energy (like in PositionCalc::Calculate_Location()):
109  // The parameters X0 and T0 are hardcoded here because these values were used to calculate the corrections:
110  const float X0 = 0.89;
111  float T0 = 1.2;
112  //different T0 value if outside of preshower coverage
113  if (TMath::Abs(bclus.eta()) < 1.653)
114  T0 = 3.1;
115 
116  double depth = X0 * (T0 + log(bclus.energy()));
117 
118  //find max energy crystal
119  std::vector<std::pair<DetId, float> > crystals_vector = bclus.hitsAndFractions();
120  float drmin = 999.;
121  EEDetId crystalseed;
122  //printf("starting loop over crystals, etot = %5f:\n",bclus.energy());
123  for (unsigned int icry = 0; icry != crystals_vector.size(); ++icry) {
124  EEDetId crystal(crystals_vector[icry].first);
125 
126  auto cell = geom->getGeometry(crystal);
127  const TruncatedPyramid *cpyr = dynamic_cast<const TruncatedPyramid *>(cell.get());
128  GlobalPoint center_pos = cpyr->getPosition(depth);
129  double EtaCentr = center_pos.eta();
130  double PhiCentr = TVector2::Phi_mpi_pi(center_pos.phi());
131 
132  float dr = reco::deltaR(Eta, Phi, EtaCentr, PhiCentr);
133  if (dr < drmin) {
134  drmin = dr;
135  crystalseed = crystal;
136  }
137  }
138 
139  ix = crystalseed.ix();
140  iy = crystalseed.iy();
141 
142  // Get center cell position from shower depth
143  auto cell = geom->getGeometry(crystalseed);
144  const TruncatedPyramid *cpyr = dynamic_cast<const TruncatedPyramid *>(cell.get());
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  double YCentr = center_pos.y();
156  double YWidth = 2.59;
157  ycry = (Y - YCentr) / YWidth;
158 
159  return;
160  }

References Abs(), cms::cuda::assert(), reco::deltaR(), LEDCalibrationChannels::depth, flavorHistoryFilter_cfi::dr, DetId::Ecal, EcalEndcap, reco::CaloCluster::energy(), PV3DBase< T, PVType, FrameType >::eta(), reco::CaloCluster::eta(), first, relativeConstraints::geom, TruncatedPyramid::getPhiAxis(), TruncatedPyramid::getPosition(), CaloGeometry::getSubdetectorGeometry(), TruncatedPyramid::getThetaAxis(), reco::CaloCluster::hitsAndFractions(), EEDetId::ix(), EEDetId::iy(), dqm-mbProfile::log, VtxSmearedParameters_cfi::Phi, reco::CaloCluster::position(), X, PV3DBase< T, PVType, FrameType >::x(), MonitorAlCaEcalPi0_cfi::X0, BeamSpotPI::Y, and PV3DBase< T, PVType, FrameType >::y().

Referenced by EcalRegressionData::fill(), EGRegressionModifierV3::getSeedCrysCoord(), SuperClusterHelper::localCoordinates(), EGRegressionModifierV2::modifyObject(), and EGRegressionModifierV1::modifyObject().

◆ validateEgammaCandidate()

template<class Candidate >
void egammaTools::validateEgammaCandidate ( Candidate const &  candidate)

Definition at line 11 of file validateEgammaCandidate.h.

11  {
12  if constexpr (std::is_same<Candidate, reco::GsfElectron>()) {
13  validateGsfElectron(candidate);
14  }
15  }

References validateGsfElectron().

Referenced by MVAValueMapProducer< ParticleType >::produce().

◆ validateGsfElectron()

void egammaTools::validateGsfElectron ( reco::GsfElectron const &  electron)

Definition at line 5 of file validateEgammaCandidate.cc.

5  {
6  if (electron.convVtxFitProb() > 1.0f) {
7  throw cms::Exception("EgammaError")
8  << "invalid value " << electron.convVtxFitProb() << " for reco::GsfElectron.conversionRejection_.vtxFitProb\n"
9  << "It should be either beween 0.0f and 1.0f or negative in case no matching conversion was found.\n"
10  << "Probably you need to update the electron collection with the EG9X105XObjectUpdateModifier plugin:\n"
11  << "see PhysicsTools/NanoAOD/python/electrons_cff.py for an example.\n";
12  }
13 }

References metsig::electron, and Exception.

Referenced by validateEgammaCandidate().

MagneticField::inTesla
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
EBDetId::ieta
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
X
#define X(str)
Definition: MuonsGrabber.cc:38
EBDetId
Definition: EBDetId.h:17
PV3DBase::theta
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
cms::cuda::assert
assert(be >=bs)
TruncatedPyramid
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code.
Definition: TruncatedPyramid.h:19
EEDetId::ix
int ix() const
Definition: EEDetId.h:77
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
EcalBarrel
Definition: EcalSubdetector.h:10
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
Abs
T Abs(T a)
Definition: MathUtil.h:49
metsig::electron
Definition: SignAlgoResolutions.h:48
Geom::pi
constexpr double pi()
Definition: Pi.h:31
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
Geom::twoPi
constexpr double twoPi()
Definition: Pi.h:32
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
VtxSmearedParameters_cfi.Phi
Phi
Definition: VtxSmearedParameters_cfi.py:112
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
EEDetId
Definition: EEDetId.h:14
EcalEndcap
Definition: EcalSubdetector.h:10
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
reco::CaloCluster::eta
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181
PVValHelper::phi
Definition: PVValidationHelpers.h:69
reco::CaloCluster::hitsAndFractions
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
TruncatedPyramid::getThetaAxis
CCGFloat getThetaAxis() const
Definition: TruncatedPyramid.cc:49
MonitorAlCaEcalPi0_cfi.X0
X0
Definition: MonitorAlCaEcalPi0_cfi.py:77
DetId::Ecal
Definition: DetId.h:27
EEDetId::iy
int iy() const
Definition: EEDetId.h:83
reco::CaloCluster::position
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
TruncatedPyramid::getPosition
GlobalPoint getPosition(CCGFloat depth) const override
Definition: TruncatedPyramid.cc:45
trklet::bend
double bend(double r, double rinv, double stripPitch)
Definition: Util.h:166
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
Exception
Definition: hltDiff.cc:245
ETA
#define ETA
Definition: GenericBenchmark.cc:28
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
BeamSpotPI::Y
Definition: BeamSpotPayloadInspectorHelper.h:32
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
TruncatedPyramid::getPhiAxis
CCGFloat getPhiAxis() const
Definition: TruncatedPyramid.cc:51
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
EBDetId::iphi
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
reco::CaloCluster::energy
double energy() const
cluster energy
Definition: CaloCluster.h:149
egammaTools::validateGsfElectron
void validateGsfElectron(reco::GsfElectron const &electron)
Definition: validateEgammaCandidate.cc:5
Z_Endcap
static constexpr float Z_Endcap
Definition: ECALPositionCalculator.cc:11
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
R_ECAL
static constexpr float R_ECAL
Definition: ECALPositionCalculator.cc:10
etaBarrelEndcap
static constexpr float etaBarrelEndcap
Definition: ECALPositionCalculator.cc:12