7 #include "Math/ProbFunc.h"
10 std::vector<float> vd2vf(
const std::vector<double> &
vd) {
11 std::vector<float>
ret;
12 ret.insert(ret.end(), vd.begin(), vd.end());
17 using namespace l1tpf_impl;
21 puppiPriors_(vd2vf(iConfig.getParameter<std::
vector<double>>(
"puppiPriors"))),
22 puppiPriorsPhotons_(vd2vf(iConfig.getParameter<std::
vector<double>>(
"puppiPriorsPhotons"))),
23 puppiPtSlopes_(vd2vf(iConfig.getParameter<std::
vector<double>>(
"puppiPtSlopes"))),
24 puppiPtSlopesPhotons_(vd2vf(iConfig.getParameter<std::
vector<double>>(
"puppiPtSlopesPhotons"))),
25 puppiPtZeros_(vd2vf(iConfig.getParameter<std::
vector<double>>(
"puppiPtZeros"))),
26 puppiPtZerosPhotons_(vd2vf(iConfig.getParameter<std::
vector<double>>(
"puppiPtZerosPhotons"))),
27 puppiAlphaSlopes_(vd2vf(iConfig.getParameter<std::
vector<double>>(
"puppiAlphaSlopes"))),
28 puppiAlphaSlopesPhotons_(vd2vf(iConfig.getParameter<std::
vector<double>>(
"puppiAlphaSlopesPhotons"))),
29 puppiAlphaZeros_(vd2vf(iConfig.getParameter<std::
vector<double>>(
"puppiAlphaZeros"))),
30 puppiAlphaZerosPhotons_(vd2vf(iConfig.getParameter<std::
vector<double>>(
"puppiAlphaZerosPhotons"))),
31 puppiAlphaCrops_(vd2vf(iConfig.getParameter<std::
vector<double>>(
"puppiAlphaCrops"))),
32 puppiAlphaCropsPhotons_(vd2vf(iConfig.getParameter<std::
vector<double>>(
"puppiAlphaCropsPhotons"))) {
34 throw cms::Exception(
"Configuration",
"Mismatched lenght for puppiPriors\n");
36 throw cms::Exception(
"Configuration",
"Mismatched lenght for puppiPtSlopes\n");
38 throw cms::Exception(
"Configuration",
"Mismatched lenght for puppiPtZeros\n");
40 throw cms::Exception(
"Configuration",
"Mismatched lenght for puppiAlphaSlopes\n");
42 throw cms::Exception(
"Configuration",
"Mismatched lenght for puppiAlphaZeros\n");
44 throw cms::Exception(
"Configuration",
"Mismatched lenght for puppiAlphaCrops\n");
46 throw cms::Exception(
"Configuration",
"Mismatched lenght for puppiPriorsPhotons\n");
48 throw cms::Exception(
"Configuration",
"Mismatched lenght for puppiPtSlopesPhotons\n");
50 throw cms::Exception(
"Configuration",
"Mismatched lenght for puppiPtZerosPhotons\n");
52 throw cms::Exception(
"Configuration",
"Mismatched lenght for puppiAlphaSlopesPhotons\n");
54 throw cms::Exception(
"Configuration",
"Mismatched lenght for puppiAlphaZerosPhotons\n");
56 throw cms::Exception(
"Configuration",
"Mismatched lenght for puppiAlphaCropsPhotons\n");
62 static const std::vector<std::string> names_{};
69 std::vector<float> alphaC, alphaF;
77 const std::vector<float> &alphaC,
78 const std::vector<float> &alphaF)
const {
80 dbgPrintf(
"LinPup\t npu estimate %7.2f --> log(npu/200) = %+6.2f \n", npu,
std::log(npu / 200.
f));
81 for (
unsigned int ip = 0,
np = r.
pf.size(); ip <
np; ++ip) {
89 "LinPup\t charged id %1d pt %7.2f eta %+5.2f phi %+5.2f fromPV %1d "
90 " --> puppi weight %.3f puppi pt %7.2f \n",
97 p.floatPt() * p.floatPuppiW());
105 float alpha = central ? alphaC[ip] : alphaF[ip];
106 alpha = (alpha > 0 ?
std::log(alpha) : 0);
108 unsigned int ietaBin = 0, lastBin =
puppiEtaCuts_.size() - 1;
109 while (ietaBin < lastBin && absEta >
puppiEtaCuts_[ietaBin]) {
115 float x2a = std::clamp(alphaSlope * (alpha - alphaZero), -alphaCrop, alphaCrop);
119 float x2pt = ptSlope * (p.floatPt() - ptZero);
122 float x2prior = (npu > 0 ?
std::log(npu / 200.
f) : 0) + prior;
124 float x2 = x2a + x2pt - x2prior;
125 p.setPuppiW(1.0 / (1.0 +
std::exp(-x2)));
128 "LinPup\t neutral id %1d pt %7.2f eta %+5.2f phi %+5.2f alpha %+6.2f x2a %+5.2f x2pt %+6.2f x2prior "
129 "%+6.2f --> x2 %+6.2f --> puppi weight %.3f puppi pt %7.2f \n",
140 p.floatPt() * p.floatPuppiW());
tuple ret
prodAgent to be discontinued
const bool relativeCoordinates
static std::vector< std::string > checklist log
std::vector< float > puppiPriorsPhotons_
std::vector< float > puppiAlphaZeros_
~LinearizedPuppiAlgo() override
const std::vector< std::string > & puGlobalNames() const override
std::vector< float > puppiPtSlopesPhotons_
Exp< T >::type exp(const T &t)
float globalAbsEta(float localEta) const
std::vector< float > puppiPriors_
void dbgPrintf(const char *formatString, Args &&...args)
void runNeutralsPU(Region &r, float npu, const std::vector< float > &globals) const override
virtual void fillPuppi(Region &r) const
void computePuppiWeights(Region &r, float npu, const std::vector< float > &alphaC, const std::vector< float > &alphaF) const
Abs< T >::type abs(const T &t)
std::vector< PFParticle > pf
std::vector< DeviationSensor2D * > vd
std::vector< float > puppiPtSlopes_
std::vector< float > puppiAlphaSlopes_
std::vector< float > puppiAlphaSlopesPhotons_
std::vector< float > puppiPtZeros_
void doPUGlobals(const std::vector< Region > &rs, float npu, std::vector< float > &globals) const override
std::vector< float > puppiAlphaCrops_
LinearizedPuppiAlgo(const edm::ParameterSet &)
std::vector< float > puppiEtaCuts_
std::vector< float > puppiAlphaZerosPhotons_
virtual void computePuppiAlphas(const Region &r, std::vector< float > &alphaC, std::vector< float > &alphaF) const
std::vector< float > puppiAlphaCropsPhotons_
std::vector< float > puppiPtZerosPhotons_