4 #include "fastjet/internal/base.hh"
5 #include "Math/QuantFuncMathCore.h"
6 #include "Math/SpecFuncMathCore.h"
7 #include "Math/ProbFunc.h"
18 std::vector<edm::ParameterSet> lAlgos = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"puppiAlgos");
21 for(
unsigned int i0 = 0; i0 < lAlgos.size(); i0++) {
22 int pAlgoId = lAlgos[i0].getParameter<
int > (
"algoId");
23 bool pCharged = lAlgos[i0].getParameter<
bool> (
"useCharged");
24 bool pWeight0 = lAlgos[i0].getParameter<
bool> (
"applyLowPUCorr");
25 int pComb = lAlgos[i0].getParameter<
int> (
"combOpt");
26 double pConeSize = lAlgos[i0].getParameter<
double>(
"cone");
27 double pRMSPtMin = lAlgos[i0].getParameter<
double>(
"rmsPtMin");
28 double pRMSSF = lAlgos[i0].getParameter<
double>(
"rmsScaleFactor");
40 fRMS .push_back(pRMS);
42 fMean .push_back(pMean);
53 for(
unsigned int i0 = 0; i0 <
fNAlgos; i0++) {
60 void PuppiAlgo::add(
const fastjet::PseudoJet &iParticle,
const double &iVal,
const unsigned int iAlgo) {
61 if(iParticle.pt() <
fRMSPtMin[iAlgo])
return;
66 int puppi_register = std::numeric_limits<int>::lowest();
67 if ( iParticle.has_user_info() ) {
73 if ( puppi_register == std::numeric_limits<int>::lowest() ) {
74 throw cms::Exception(
"PuppiRegisterNotSet") <<
"The puppi register is not set. This must be set before use.\n";
79 fPups.push_back(iVal);
86 for(
unsigned int i0 = 0; i0 < iAlgo; i0++) lNBefore +=
fNCount[i0];
90 if(
fAdjust[iAlgo]) lCorr *= 1. - iPVFrac;
92 for(
int i0 = lNBefore; i0 < lNBefore+
fNCount[iAlgo]; i0++) {
93 if(
fPups[i0] == 0) lNum0 = i0-lNBefore;
96 int lNHalfway = lNBefore + lNum0 + int(
double( fNCount[iAlgo]-lNum0 )*0.50*lCorr);
101 for(
int i0 = lNBefore; i0 < lNBefore+fNCount[iAlgo]; i0++) {
103 if(
fPups[i0] == 0)
continue;
109 fMean[iAlgo]/=fNCount[iAlgo];
110 if(lNRMS > 0)
fRMS [iAlgo]/=lNRMS;
119 int lNPV = 0;
for(
unsigned int i0 = 0; i0 <
fPupsPV.size(); i0++)
if(
fPupsPV[i0] <= lMed ) lNPV++;
120 double lAdjust = 1.5*double(lNPV)/double(
fPupsPV.size()+fNCount[iAlgo]);
121 if(lAdjust > 0)
fMedian[iAlgo] -=
sqrt(ROOT::Math::chisquared_quantile(lAdjust,1.)*
fRMS[iAlgo]);
129 for(
unsigned int i0 = 0; i0 <
fNAlgos; i0++) {
130 if(
fNCount[i0] == 0)
return 1.;
131 if(
fCombId[i0] == 1 && i0 > 0) {
132 double pPVal = ROOT::Math::chisquared_cdf(lVal,lNDOF);
137 double pVal = iVals[i0];
144 if(i0 == 0 && iChi2 != 0) lNDOF++;
145 if(i0 == 0 && iChi2 != 0) lVal+=iChi2;
148 lPVal *= ROOT::Math::chisquared_cdf(lVal,lNDOF);
T getParameter(std::string const &) const
void add(const fastjet::PseudoJet &iParticle, const double &iVal, const unsigned int iAlgo)
std::vector< bool > fAdjust
PuppiAlgo(edm::ParameterSet &iConfig)
std::vector< double > fConeSize
int puppi_register() const
std::vector< double > fRMS
Abs< T >::type abs(const T &t)
std::vector< float > fPupsPV
double compute(std::vector< double > const &iVals, double iChi2) const
std::vector< float > fPups
std::vector< double > fMean
std::vector< int > fAlgoId
std::vector< double > fRMSPtMin
std::vector< int > fCombId
std::vector< double > fRMSScaleFactor
void computeMedRMS(const unsigned int &iAlgo, const double &iPVFrac)
std::vector< bool > fCharged
std::vector< int > fNCount
std::vector< double > fMedian