CMS 3D CMS Logo

Classes | Typedefs | Functions
egammaTools Namespace Reference

Classes

struct  DNNConfiguration
 
class  EgammaDNNHelper
 
struct  ScalerConfiguration
 

Typedefs

typedef std::function< uint(const std::map< std::string, float > &)> ModelSelector
 

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)
 

Typedef Documentation

◆ ModelSelector

typedef std::function<uint(const std::map<std::string, float>&)> egammaTools::ModelSelector

Definition at line 39 of file EgammaDNNHelper.h.

Function Documentation

◆ ecalEta()

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

Definition at line 71 of file ECALPositionCalculator.cc.

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

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  }
static constexpr float R_ECAL
#define ETA
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
static constexpr float etaBarrelEndcap
Log< level::Warning, false > LogWarning
constexpr double pi()
Definition: Pi.h:31
Geom::Theta< T > theta() const
static constexpr float Z_Endcap

◆ 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.

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

Referenced by MuonMETAlgo::correctMETforMuon().

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  }
T z() const
Definition: PV3DBase.h:61
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
static constexpr float etaBarrelEndcap
Log< level::Warning, false > LogWarning
constexpr double pi()
Definition: Pi.h:31
constexpr double twoPi()
Definition: Pi.h:32

◆ 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 13 of file EcalClusterLocal.cc.

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

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

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

◆ 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 87 of file EcalClusterLocal.cc.

References funct::abs(), cms::cuda::assert(), reco::deltaR(), hcalRecHitTable_cff::depth, DetId::Ecal, EcalEndcap, reco::CaloCluster::energy(), PV3DBase< T, PVType, FrameType >::eta(), reco::CaloCluster::eta(), dqmdumpme::first, relativeConstraints::geom, TruncatedPyramid::getPhiAxis(), TruncatedPyramid::getPosition(), CaloGeometry::getSubdetectorGeometry(), TruncatedPyramid::getThetaAxis(), reco::CaloCluster::hitsAndFractions(), EEDetId::ix(), ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::endcap::ix(), EEDetId::iy(), ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::endcap::iy(), dqm-mbProfile::log, PV3DBase< T, PVType, FrameType >::phi(), VtxSmearedParameters_cfi::Phi, reco::CaloCluster::position(), X, PV3DBase< T, PVType, FrameType >::x(), ecalPiZeroTask_cfi::X0, beamSpotPI::Y, and PV3DBase< T, PVType, FrameType >::y().

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

94  {
95  assert(bclus.hitsAndFractions().at(0).first.subdetId() == EcalEndcap);
96 
98  caloGeometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap); //EcalBarrel = 1
99 
100  const math::XYZPoint &position_ = bclus.position();
101  //double Theta = -position_.theta()+0.5*M_PI;
102  double Eta = position_.eta();
103  double Phi = TVector2::Phi_mpi_pi(position_.phi());
104  double X = position_.x();
105  double Y = position_.y();
106 
107  //Calculate expected depth of the maximum shower from energy (like in PositionCalc::Calculate_Location()):
108  // The parameters X0 and T0 are hardcoded here because these values were used to calculate the corrections:
109  const float X0 = 0.89;
110  float T0 = 1.2;
111  //different T0 value if outside of preshower coverage
112  if (std::abs(bclus.eta()) < 1.653)
113  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  EEDetId crystal(crystals_vector[icry].first);
124 
125  auto cell = geom->getGeometry(crystal);
126  const TruncatedPyramid *cpyr = dynamic_cast<const TruncatedPyramid *>(cell.get());
127  GlobalPoint center_pos = cpyr->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  ix = crystalseed.ix();
139  iy = crystalseed.iy();
140 
141  // Get center cell position from shower depth
142  auto cell = geom->getGeometry(crystalseed);
143  const TruncatedPyramid *cpyr = dynamic_cast<const TruncatedPyramid *>(cell.get());
144 
145  thetatilt = cpyr->getThetaAxis();
146  phitilt = cpyr->getPhiAxis();
147 
148  GlobalPoint center_pos = cpyr->getPosition(depth);
149 
150  double XCentr = center_pos.x();
151  double XWidth = 2.59;
152  xcry = (X - XCentr) / XWidth;
153 
154  double YCentr = center_pos.y();
155  double YWidth = 2.59;
156  ycry = (Y - YCentr) / YWidth;
157 
158  return;
159  }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:153
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:209
CCGFloat getPhiAxis() const
GlobalPoint getPosition(CCGFloat depth) const override
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
int ix() const
Definition: EEDetId.h:77
#define X(str)
Definition: MuonsGrabber.cc:38
assert(be >=bs)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
double energy() const
cluster energy
Definition: CaloCluster.h:148
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:180
int iy() const
Definition: EEDetId.h:83
CCGFloat getThetaAxis() const

◆ validateEgammaCandidate()

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

Definition at line 11 of file validateEgammaCandidate.h.

References ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), and validateGsfElectron().

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

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

◆ validateGsfElectron()

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

Definition at line 5 of file validateEgammaCandidate.cc.

References HPSPFTauProducerPuppi_cfi::electron, and Exception.

Referenced by validateEgammaCandidate().

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 }