5#ifndef EGAMMAMVACALIB_EGAMMAMVAFUNCTIONS
6#define EGAMMAMVACALIB_EGAMMAMVAFUNCTIONS
17#include "TLorentzVector.h"
21#include <unordered_map>
54 throw std::runtime_error(
"etaCalo not found in CaloCluster object");
61 throw std::runtime_error(
"phiCalo not found in CaloCluster object");
79 return acc.isAvailable(cl) ? acc(cl) : cl.energyBE(0);
83 return acc.isAvailable(cl) ? acc(cl) : cl.energyBE(1);
87 return acc.isAvailable(cl) ? acc(cl) : cl.energyBE(2);
91 return acc.isAvailable(cl) ? acc(cl) : cl.energyBE(3);
103 const float denominator = cl[0] + cl[1] + cl[2] + cl[3];
104 if (denominator == 0)
return 0.;
109 return (radius[0] * cl[0]
112 + radius[3] * cl[3]) / denominator;
137 const float e = cl.e();
138 const float eta = cl.eta();
139 const float c = std::cosh(
eta);
140 return (c != 0.f) ? (e / c) : 0.f;
147 if (!cl.retrieveMoment(m, tmp)) {
148 throw std::runtime_error(std::string(
"Forward-electron missing moment: ") + name);
150 return static_cast<float>(tmp);
177 return -std::log(std::tan(
theta/2.));
186 return std::fmod(std::abs(cl.eta()),0.1);
189 return std::floor(std::abs(cl.eta())/0.1);
192 static const float cz = std::numbers::pi/16.;
193 float phi_mod = std::fmod(cl.phi(), cz);
194 if (phi_mod < 0) phi_mod += cz;
198 return float(cl.energy_max(CaloSampling::EME1)/cl.energy_max(CaloSampling::EME2));
215 if (original == 3)
return 2;
216 else if (original != 0)
return 1;
217 else return original;
224 for (
unsigned int i = 0; i < tp->numberOfParameters(); ++i) {
226 return hypot(tp->parameterPX(i), tp->parameterPY(i));
241 return vx ? std::hypot(accPx(*vx), accPy(*vx)) : 0.0;
251 if (vx->trackParticle(0)) sum += vx->trackParticle(0)->p4();
252 if (vx->trackParticle(1)) sum += vx->trackParticle(1)->p4();
284 template<
int itrack, xAOD::SummaryType summary>
286 const auto vx = ph->
vertex();
289 if (vx->trackParticle(0)) {
291 if (vx->trackParticle(itrack)->summaryValue(hits, summary)) {
328 m_vertex(ph ? ph->vertex() : nullptr),
346 ATH_MSG_WARNING(
"pt1/pt2 not available, will approximate from first measurements");
358 if (!
m_tp0) {
return 0; }
367 if (!
m_tp1)
return 0;
376 if (!
m_tp0) {
return 0; }
385 if (!
m_tp1) {
return 0; }
Scalar eta() const
pseudorapidity method
Scalar theta() const
theta method
#define ATH_MSG_WARNING(x)
Helper class to provide constant type-safe access to aux data.
SG::Accessor< T, ALLOC > Accessor
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Class mimicking the AthMessaging class from the offline software.
AsgMessaging(const std::string &name)
Constructor with a name.
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
MomentType
Enums to identify different moments.
@ SECOND_ENG_DENS
Second Moment in E/V.
@ SECOND_LAMBDA
Second Moment in .
@ ETACALOFRAME
Eta in the calo frame (for egamma)
@ LATERAL
Normalized lateral moment.
@ LONGITUDINAL
Normalized longitudinal moment.
@ ENG_FRAC_MAX
Energy fraction of hottest cell.
@ SECOND_R
Second Moment in .
@ PHICALOFRAME
Phi in the calo frame (for egamma)
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
@ SIGNIFICANCE
Cluster significance.
@ CENTER_Z
Cluster Centroid ( )
@ CENTER_X
Cluster Centroid ( )
@ CENTER_Y
Cluster Centroid ( )
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
const xAOD::Vertex * vertex(size_t index=0) const
Pointer to the xAOD::Vertex/es that match the photon candidate.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
std::array< float, 4 > get_MVAradius(float eta)
helper function to compute shower depth
These functions are for calculating variables used by the MVA calibration.
float compute_rawcl_calibHitsShowerDepth(const xAOD::CaloCluster &cl)
float compute_correctedcl_f0(const xAOD::CaloCluster &cl)
float compute_cl_phiCalo(const xAOD::CaloCluster &cluster)
float compute_ptconv(const xAOD::Photon *ph)
This ptconv is the old one used by MVACalib.
std::unique_ptr< funcMap_t > initializeUnconvertedPhotonFuncs(bool useLayerCorrected)
A function to build the map for uncoverted photons.
float compute_cl_y(const xAOD::CaloCluster &cl)
float compute_correctedcl_Eacc(const xAOD::CaloCluster &cl)
float compute_cl_longitudinal(const xAOD::CaloCluster &cl)
float compute_cl_phi(const xAOD::CaloCluster &cluster)
float compute_el_charge(const xAOD::Electron &el)
float compute_rawcl_Es1(const xAOD::CaloCluster &cl)
float compute_etaMod_FCAL(const xAOD::CaloCluster &cl)
float compute_cl_z(const xAOD::CaloCluster &cl)
std::unique_ptr< funcMap_t > initializeElectronFuncs(bool useLayerCorrected)
A function to build the map for electrons.
float compute_correctedcl_Es3(const xAOD::CaloCluster &cl)
float compute_cellIndex_EMEC(const xAOD::CaloCluster &cl)
float compute_cl_secondR(const xAOD::CaloCluster &cl)
float compute_cl_centerLambda(const xAOD::CaloCluster &cl)
float compute_rawcl_Eacc(const xAOD::CaloCluster &cl)
int compute_convtrkXhits(const xAOD::Photon *ph)
float compute_cl_etas2(const xAOD::CaloCluster &cluster)
float compute_el_trackpt(const xAOD::Electron &el)
std::unique_ptr< funcMap_t > initializeForwardElectronFuncs(bool useLayerCorrected)
NEW: A function to build the map for forward electrons.
float compute_cl_etaCalo(const xAOD::CaloCluster &cluster)
float compute_cl_e(const xAOD::CaloCluster &cluster)
float compute_rawcl_Es2(const xAOD::CaloCluster &cl)
float compute_correctedcl_Es1(const xAOD::CaloCluster &cl)
float compute_pt2conv(const xAOD::Photon *ph)
float compute_rawcl_Es0(const xAOD::CaloCluster &cl)
float compute_cl_secondR_fudge(const xAOD::Egamma &eg)
float compute_cl_lateral(const xAOD::CaloCluster &cl)
float compute_calibHitsShowerDepth(const std::array< float, 4 > &cl, float eta)
float compute_rawcl_Es3(const xAOD::CaloCluster &cl)
float compute_ptconv_decor(const xAOD::Photon *ph)
This ptconv function uses the vertex decorations.
float cl_getMoment(const xAOD::CaloCluster &cl, xAOD::CaloCluster::MomentType m, const char *name)
float compute_el_tracketa(const xAOD::Electron &el)
int compute_el_author(const xAOD::Electron &el)
float compute_cellIndex_FCAL(const xAOD::CaloCluster &cl)
float compute_correctedcl_Es2(const xAOD::CaloCluster &cl)
float compute_et(const xAOD::CaloCluster &cl)
float compute_cl_eta(const xAOD::CaloCluster &cluster)
int compute_convtrk2nSCTHits(const xAOD::Photon *ph)
int compute_convtrk1nPixHits(const xAOD::Photon *ph)
float compute_cl_secondLambda(const xAOD::CaloCluster &cl)
float compute_el_refittedTrack_qoverp(const xAOD::Electron &el)
float compute_R12_EMEC(const xAOD::CaloCluster &cl)
float compute_etaMod_EMEC(const xAOD::CaloCluster &cl)
int compute_ph_convFlag(const xAOD::Photon &ph)
std::unique_ptr< funcMap_t > initializeConvertedPhotonFuncs(bool useLayerCorrected)
A function to build the map for converted photons.
float compute_eta_FCAL(const xAOD::CaloCluster &cl)
float compute_correctedcl_Es0(const xAOD::CaloCluster &cl)
float getPtAtFirstMeasurement(const xAOD::TrackParticle *tp)
float compute_el_trackz0(const xAOD::Electron &el)
float compute_cl_etas1(const xAOD::CaloCluster &cluster)
float compute_cl_x(const xAOD::CaloCluster &cl)
float compute_cl_significance(const xAOD::CaloCluster &cl)
float compute_cl_secondDensity(const xAOD::CaloCluster &cl)
float compute_correctedcl_calibHitsShowerDepth(const xAOD::CaloCluster &cl)
float compute_phiMod_EMEC(const xAOD::CaloCluster &cl)
float compute_rawcl_f0(const xAOD::CaloCluster &cl)
std::unordered_map< std::string, std::function< float(const xAOD::Egamma *, const xAOD::CaloCluster *)> > funcMap_t
Define the map type since it's long.
int compute_convtrk2nPixHits(const xAOD::Photon *ph)
float compute_cl_fracMax(const xAOD::CaloCluster &cl)
float compute_pt1conv(const xAOD::Photon *ph)
int compute_convtrk1nSCTHits(const xAOD::Photon *ph)
xAOD::EgammaParameters::ConversionType conversionType(const xAOD::Photon *ph)
return the photon conversion type (see EgammaEnums)
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
Egamma_v1 Egamma
Definition of the current "egamma version".
Photon_v1 Photon
Definition of the current "egamma version".
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
Electron_v1 Electron
Definition of the current "egamma version".
@ FirstMeasurement
Parameter defined at the position of the 1st measurement.
const xAOD::Vertex * m_vertex
int ph_convtrk1nPixHits() const
const xAOD::TrackParticle * m_tp0
ConversionHelper(const xAOD::Photon *ph)
ConversionHelper(const xAOD::Photon &ph)
int ph_convtrk1nSCTHits() const
const xAOD::TrackParticle * m_tp1
int ph_convtrk2nSCTHits() const
int ph_convtrk2nPixHits() const