16 #include <vdt/vdtMath.h> 63 eleCond50nsTokens_{conf.
getParameterSet(
"electron_config"),
"regressionKey_50ns",
"uncertaintyKey_50ns",
cc},
64 phoCond50nsTokens_{conf.getParameterSet(
"photon_config"),
"regressionKey_50ns",
"uncertaintyKey_50ns",
cc},
65 eleCond25nsTokens_{conf.getParameterSet(
"electron_config"),
"regressionKey_25ns",
"uncertaintyKey_25ns",
cc},
66 phoCond25nsTokens_{conf.getParameterSet(
"photon_config"),
"regressionKey_25ns",
"uncertaintyKey_25ns",
cc},
67 autoDetectBunchSpacing_(conf.getParameter<
bool>(
"autoDetectBunchSpacing")),
68 bunchspacing_(autoDetectBunchSpacing_ ? 450 : conf.getParameter<
int>(
"manualBunchSpacing")),
69 rhoToken_(
cc.consumes(conf.getParameter<
edm::InputTag>(
"rhoCollection"))),
70 vtxToken_(
cc.consumes(conf.getParameter<
edm::InputTag>(
"vertexCollection"))),
71 caloGeomToken_{
cc.esConsumes()},
72 applyExtraHighEnergyProtection_(conf.getParameter<
bool>(
"applyExtraHighEnergyProtection")) {
73 if (autoDetectBunchSpacing_)
74 bunchSpacingToken_ =
cc.consumes(conf.getParameter<
edm::InputTag>(
"bunchSpacingTag"));
76 auto const&
electrons = conf.getParameterSet(
"electron_config");
108 const int numberOfClusters = superClus->clusters().size();
109 const bool missing_clusters = !superClus->clusters()[numberOfClusters - 1].
isAvailable();
111 if (missing_clusters)
114 std::array<float, 33> eval;
115 const double rawEnergy = superClus->rawEnergy();
121 eval[2] = superClus->eta();
122 eval[3] = superClus->phi();
123 eval[4] = superClus->etaWidth();
124 eval[5] = superClus->phiWidth();
129 eval[10] = (ess.eLeft + ess.eRight != 0.f ? (ess.eLeft - ess.eRight) / (ess.eLeft + ess.eRight) : 0.f);
130 eval[11] = (ess.eTop + ess.eBottom != 0.f ? (ess.eTop - ess.eBottom) / (ess.eTop + ess.eBottom) : 0.f);
131 eval[12] = ess.sigmaIetaIeta;
132 eval[13] = ess.sigmaIetaIphi;
133 eval[14] = ess.sigmaIphiIphi;
134 eval[15] =
std::max(0, numberOfClusters - 1);
137 std::vector<float> clusterRawEnergy;
138 clusterRawEnergy.resize(
std::max(3, numberOfClusters), 0);
139 std::vector<float> clusterDEtaToSeed;
140 clusterDEtaToSeed.resize(
std::max(3, numberOfClusters), 0);
141 std::vector<float> clusterDPhiToSeed;
142 clusterDPhiToSeed.resize(
std::max(3, numberOfClusters), 0);
143 float clusterMaxDR = 999.;
144 float clusterMaxDRDPhi = 999.;
145 float clusterMaxDRDEta = 999.;
146 float clusterMaxDRRawEnergy = 0.;
151 for (
auto const& pclus : superClus->clusters()) {
152 if (theseed == pclus)
154 clusterRawEnergy[iclus] = pclus->energy();
156 clusterDEtaToSeed[iclus] = pclus->eta() - theseed->
eta();
160 if (the_dr >
maxDR) {
162 clusterMaxDR =
maxDR;
163 clusterMaxDRDPhi = clusterDPhiToSeed[iclus];
164 clusterMaxDRDEta = clusterDEtaToSeed[iclus];
165 clusterMaxDRRawEnergy = clusterRawEnergy[iclus];
170 eval[16] = clusterMaxDR;
171 eval[17] = clusterMaxDRDPhi;
172 eval[18] = clusterMaxDRDEta;
173 eval[19] = clusterMaxDRRawEnergy /
rawEnergy;
174 eval[20] = clusterRawEnergy[0] /
rawEnergy;
175 eval[21] = clusterRawEnergy[1] /
rawEnergy;
176 eval[22] = clusterRawEnergy[2] /
rawEnergy;
177 eval[23] = clusterDPhiToSeed[0];
178 eval[24] = clusterDPhiToSeed[1];
179 eval[25] = clusterDPhiToSeed[2];
180 eval[26] = clusterDEtaToSeed[0];
181 eval[27] = clusterDEtaToSeed[1];
182 eval[28] = clusterDEtaToSeed[2];
202 eval[29] = superClus->preshowerEnergy() / superClus->rawEnergy();
209 constexpr double meanoffset = meanlimlow + 0.5 * (meanlimhigh - meanlimlow);
210 constexpr double meanscale = 0.5 * (meanlimhigh - meanlimlow);
214 constexpr double sigmaoffset = sigmalimlow + 0.5 * (sigmalimhigh - sigmalimlow);
215 constexpr double sigmascale = 0.5 * (sigmalimhigh - sigmalimlow);
217 const int coridx =
isEB ? 0 : 1;
224 double mean = meanoffset + meanscale * vdt::fast_sin(rawmean);
225 double sigma = sigmaoffset + sigmascale * vdt::fast_sin(rawsigma);
229 double ecor =
mean * (eval[1]);
231 ecor =
mean * (eval[1] + superClus->preshowerEnergy());
232 const double sigmacor = sigma * ecor;
238 std::array<float, 11> eval_ep;
241 const float tot_energy = superClus->rawEnergy() + superClus->preshowerEnergy();
245 eval_ep[0] = tot_energy *
mean;
246 eval_ep[1] = sigma /
mean;
248 eval_ep[3] = trkMomentumRelError;
249 eval_ep[4] = sigma /
mean / trkMomentumRelError;
250 eval_ep[5] = tot_energy *
mean /
ep;
251 eval_ep[6] = tot_energy *
mean /
ep *
sqrt(sigma /
mean * sigma /
mean + trkMomentumRelError * trkMomentumRelError);
277 oldMomentum.y() * combinedMomentum / oldMomentum.t(),
278 oldMomentum.z() * combinedMomentum / oldMomentum.t(),
287 std::array<float, 35> eval;
291 const int numberOfClusters = superClus->clusters().size();
292 const bool missing_clusters = !superClus->clusters()[numberOfClusters - 1].
isAvailable();
294 if (missing_clusters)
297 const double rawEnergy = superClus->rawEnergy();
303 eval[2] = superClus->etaWidth();
304 eval[3] = superClus->phiWidth();
305 eval[4] =
std::max(0, numberOfClusters - 1);
309 eval[8] = theseed->
eta() - superClus->position().Eta();
312 eval[11] = ess.e3x3 / ess.e5x5;
313 eval[12] = ess.sigmaIetaIeta;
314 eval[13] = ess.sigmaIphiIphi;
315 eval[14] = ess.sigmaIetaIphi / (ess.sigmaIphiIphi * ess.sigmaIetaIeta);
316 eval[15] = ess.maxEnergyXtal / ess.e5x5;
317 eval[16] = ess.e2nd / ess.e5x5;
318 eval[17] = ess.eTop / ess.e5x5;
319 eval[18] = ess.eBottom / ess.e5x5;
320 eval[19] = ess.eLeft / ess.e5x5;
321 eval[20] = ess.eRight / ess.e5x5;
322 eval[21] = ess.e2x5Max / ess.e5x5;
323 eval[22] = ess.e2x5Left / ess.e5x5;
324 eval[23] = ess.e2x5Right / ess.e5x5;
325 eval[24] = ess.e2x5Top / ess.e5x5;
326 eval[25] = ess.e2x5Bottom / ess.e5x5;
332 int ieta = ebseedid.ieta();
333 int iphi = ebseedid.iphi();
336 int signieta =
ieta > 0 ? +1 : -1;
337 eval[29] = (
ieta - signieta) % 5;
338 eval[30] = (
iphi - 1) % 2;
340 eval[32] = (
iphi - 1) % 20;
345 eval[26] = superClus->preshowerEnergy() /
rawEnergy;
346 eval[27] = superClus->preshowerEnergyPlane1() /
rawEnergy;
347 eval[28] = superClus->preshowerEnergyPlane2() /
rawEnergy;
348 eval[29] = eeseedid.ix();
349 eval[30] = eeseedid.iy();
354 const double meanlimlow = 0.2;
355 const double meanlimhigh = 2.0;
356 const double meanoffset = meanlimlow + 0.5 * (meanlimhigh - meanlimlow);
357 const double meanscale = 0.5 * (meanlimhigh - meanlimlow);
359 const double sigmalimlow = 0.0002;
360 const double sigmalimhigh = 0.5;
361 const double sigmaoffset = sigmalimlow + 0.5 * (sigmalimhigh - sigmalimlow);
362 const double sigmascale = 0.5 * (sigmalimhigh - sigmalimlow);
364 const int coridx =
isEB ? 0 : 1;
367 const double rawmean =
phoForestsMean_[coridx]->GetResponse(eval.data());
370 const double mean = meanoffset + meanscale * vdt::fast_sin(rawmean);
371 const double sigma = sigmaoffset + sigmascale * vdt::fast_sin(rawsigma);
375 const double ecor =
isEB ?
mean * eval[0] :
mean * (eval[0] + superClus->preshowerEnergy());
377 const double sigmacor = sigma * ecor;
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
constexpr double deltaPhi(double phi1, double phi2)
Analysis-level Photon class.
edm::ESGetToken< GBRForest, GBRWrapperRcd > condNamesWeight25nsToken_
void setEventContent(const edm::EventSetup &) final
edm::ESGetToken< GBRForest, GBRWrapperRcd > condNamesWeight50nsToken_
EGRegressionModifierCondTokens phoCond50nsTokens_
EGRegressionModifierV1(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
std::vector< edm::ESGetToken< GBRForestD, GBRDWrapperRcd > > mean
bool get(ProductID const &oid, Handle< PROD > &result) const
void setCorrectedEnergy(P4type type, float E, float dE, bool toCand=true)
bool trackerDrivenSeed() const
const ShowerShape & showerShapeVariables() const
uint32_t cc[maxCellsPerHit]
float trackMomentumError() const
DetId seed() const
return DetId of seed
void correctMomentum(const LorentzVector &p4, float trackMomentumError, float p4Error)
EGRegressionModifierCondTokens phoCond25nsTokens_
ParameterSet const & getParameterSet(std::string const &) const
void modifyObject(reco::GsfElectron &) const final
const bool autoDetectBunchSpacing_
EGRegressionModifierCondTokens eleCond50nsTokens_
CaloGeometry const * caloGeom_
double phi() const
azimuthal angle of cluster centroid
Classification classification() const
void setEvent(const edm::Event &) final
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
std::vector< const GBRForestD * > phoForestsMean_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void setCorrectedEcalEnergyError(float newEnergyError)
void modifyObject(pat::Electron &ele) const final
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
std::vector< const GBRForestD * > eleForestsSigma_
std::vector< const GBRForestD * > eleForestsMean_
Abs< T >::type abs(const T &t)
math::XYZVectorF trackMomentumAtVtx() const
edm::EDGetTokenT< double > rhoToken_
const LorentzVector & p4(P4Kind kind) const
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
double energy() const
cluster energy
const GBRForest * epForest_
std::vector< const GBRForestD * > phoForestsSigma_
float hadronicOverEm(int depth=0) const
Analysis-level electron class.
std::vector< edm::ESGetToken< GBRForestD, GBRDWrapperRcd > > sigma
const ShowerShape & showerShape() const
void modifyObject(pat::Photon &pho) const final
std::vector< const GBRForestD * > retrieveGBRForests(edm::EventSetup const &evs, std::vector< edm::ESGetToken< GBRForestD, GBRDWrapperRcd >> const &tokens)
double GetResponse(const float *vector) const
void setCorrectedEcalEnergy(float newEnergy)
#define DEFINE_EDM_PLUGIN(factory, type, name)
double eta() const
pseudorapidity of cluster centroid
EGRegressionModifierCondTokens eleCond25nsTokens_
const bool applyExtraHighEnergyProtection_
edm::EDGetTokenT< unsigned int > bunchSpacingToken_
SuperClusterRef superCluster() const override
reference to a SuperCluster