CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
PuppiContainer Class Reference

#include <PuppiContainer.h>

Public Member Functions

void initialize (const std::vector< RecoObj > &iRecoObjects)
 
std::vector< PuppiCandidate > const & pfParticles () const
 
const std::vector< double > & puppiAlphas ()
 
const std::vector< double > & puppiAlphasMed ()
 
const std::vector< double > & puppiAlphasRMS ()
 
 PuppiContainer (const edm::ParameterSet &iConfig)
 
int puppiNAlgos ()
 
std::vector< PuppiCandidate > const & puppiParticles () const
 
const std::vector< double > & puppiRawAlphas ()
 
std::vector< double > const & puppiWeights ()
 
std::vector< PuppiCandidate > const & pvParticles () const
 
const std::vector< int > & recoToPup () const
 
void setNPV (int iNPV)
 
 ~PuppiContainer ()
 

Protected Member Functions

double getChi2FromdZ (double iDZ)
 
int getPuppiId (float iPt, float iEta)
 
void getRawAlphas (int iOpt, std::vector< PuppiCandidate > const &iConstits, std::vector< PuppiCandidate > const &iParticles, std::vector< PuppiCandidate > const &iChargeParticles)
 
void getRMSAvg (int iOpt, std::vector< PuppiCandidate > const &iConstits, std::vector< PuppiCandidate > const &iParticles, std::vector< PuppiCandidate > const &iChargeParticles)
 
double goodVar (PuppiCandidate const &iPart, std::vector< PuppiCandidate > const &iParts, int iOpt, const double iRCone)
 
double var_within_R (int iId, const std::vector< PuppiCandidate > &particles, const PuppiCandidate &centre, const double R)
 

Protected Attributes

std::vector< double > fAlphaMed
 
std::vector< double > fAlphaRMS
 
bool fApplyCHS
 
std::vector< PuppiCandidatefChargedPV
 
bool fInvert
 
int fNAlgos
 
double fNeutralMinPt
 
double fNeutralSlope
 
int fNPV
 
std::vector< PuppiCandidatefPFParticles
 
double fPtMax
 
double fPtMaxNeutralsStartSlope
 
std::vector< PuppiCandidatefPupParticles
 
std::vector< PuppiAlgofPuppiAlgo
 
bool fPuppiDiagnostics
 
double fPuppiWeightCut
 
double fPVFrac
 
std::vector< double > fRawAlphas
 
const std::vector< RecoObj > * fRecoParticles
 
std::vector< int > fRecoToPup
 
bool fUseExp
 
std::vector< double > fVals
 
std::vector< double > fWeights
 

Detailed Description

Definition at line 8 of file PuppiContainer.h.

Constructor & Destructor Documentation

PuppiContainer::PuppiContainer ( const edm::ParameterSet iConfig)

Definition at line 12 of file PuppiContainer.cc.

References edm::ParameterSet::getParameter().

12  {
13  fPuppiDiagnostics = iConfig.getParameter<bool>("puppiDiagnostics");
14  fApplyCHS = iConfig.getParameter<bool>("applyCHS");
15  fInvert = iConfig.getParameter<bool>("invertPuppi");
16  fUseExp = iConfig.getParameter<bool>("useExp");
17  fPuppiWeightCut = iConfig.getParameter<double>("MinPuppiWeight");
18  fPtMax = iConfig.getParameter<double>("PtMaxNeutrals");
19  fPtMaxNeutralsStartSlope = iConfig.getParameter<double>("PtMaxNeutralsStartSlope");
20  std::vector<edm::ParameterSet> lAlgos = iConfig.getParameter<std::vector<edm::ParameterSet> >("algos");
21  fNAlgos = lAlgos.size();
22  for(unsigned int i0 = 0; i0 < lAlgos.size(); i0++) {
23  PuppiAlgo pPuppiConfig(lAlgos[i0]);
24  fPuppiAlgo.push_back(pPuppiConfig);
25  }
26 }
T getParameter(std::string const &) const
double fPtMaxNeutralsStartSlope
double fPuppiWeightCut
std::vector< PuppiAlgo > fPuppiAlgo
PuppiContainer::~PuppiContainer ( )

Definition at line 72 of file PuppiContainer.cc.

72 {}

Member Function Documentation

double PuppiContainer::getChi2FromdZ ( double  iDZ)
protected

Definition at line 200 of file PuppiContainer.cc.

References funct::abs(), and MillePedeFileConverter_cfg::e.

Referenced by puppiParticles().

200  {
201  //We need to obtain prob of PU + (1-Prob of LV)
202  // Prob(LV) = Gaus(dZ,sigma) where sigma = 1.5mm (its really more like 1mm)
203  //double lProbLV = ROOT::Math::normal_cdf_c(std::abs(iDZ),0.2)*2.; //*2 is to do it double sided
204  //Take iDZ to be corrected by sigma already
205  double lProbLV = ROOT::Math::normal_cdf_c(std::abs(iDZ),1.)*2.; //*2 is to do it double sided
206  double lProbPU = 1-lProbLV;
207  if(lProbPU <= 0) lProbPU = 1e-16; //Quick Trick to through out infs
208  if(lProbPU >= 0) lProbPU = 1-1e-16; //Ditto
209  double lChi2PU = TMath::ChisquareQuantile(lProbPU,1);
210  lChi2PU*=lChi2PU;
211  return lChi2PU;
212 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int PuppiContainer::getPuppiId ( float  iPt,
float  iEta 
)
protected

Definition at line 183 of file PuppiContainer.cc.

References funct::abs(), ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, and ptMin.

Referenced by puppiParticles().

183  {
184  int lId = -1;
185  for(int i0 = 0; i0 < fNAlgos; i0++) {
186  int nEtaBinsPerAlgo = fPuppiAlgo[i0].etaBins();
187  for (int i1 = 0; i1 < nEtaBinsPerAlgo; i1++){
188  if ( (std::abs(iEta) > fPuppiAlgo[i0].etaMin(i1)) && (std::abs(iEta) < fPuppiAlgo[i0].etaMax(i1)) ){
189  fPuppiAlgo[i0].fixAlgoEtaBin( i1 );
190  if(iPt > fPuppiAlgo[i0].ptMin()){
191  lId = i0;
192  break;
193  }
194  }
195  }
196  }
197  //if(lId == -1) std::cerr << "Error : Full fiducial range is not defined " << std::endl;
198  return lId;
199 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< PuppiAlgo > fPuppiAlgo
void PuppiContainer::getRawAlphas ( int  iOpt,
std::vector< PuppiCandidate > const &  iConstits,
std::vector< PuppiCandidate > const &  iParticles,
std::vector< PuppiCandidate > const &  iChargeParticles 
)
protected

Definition at line 164 of file PuppiContainer.cc.

References edm::isFinite(), and LogDebug.

Referenced by puppiParticles().

164  {
165  for(int j0 = 0; j0 < fNAlgos; j0++){
166  for(unsigned int i0 = 0; i0 < iConstits.size(); i0++ ) {
167  double pVal = -1;
168  //Get the Puppi Sub Algo (given iteration)
169  int pAlgo = fPuppiAlgo[j0].algoId (iOpt);
170  bool pCharged = fPuppiAlgo[j0].isCharged(iOpt);
171  double pCone = fPuppiAlgo[j0].coneSize (iOpt);
172  //Compute the Puppi Metric
173  if(!pCharged) pVal = goodVar(iConstits[i0],iParticles ,pAlgo,pCone);
174  if( pCharged) pVal = goodVar(iConstits[i0],iChargedParticles,pAlgo,pCone);
175  fRawAlphas.push_back(pVal);
176  if( ! edm::isFinite(pVal)) {
177  LogDebug( "NotFound" ) << "====> Value is Nan " << pVal << " == " << iConstits[i0].pt() << " -- " << iConstits[i0].eta() << endl;
178  continue;
179  }
180  }
181  }
182 }
#define LogDebug(id)
constexpr bool isFinite(T x)
std::vector< double > fRawAlphas
double goodVar(PuppiCandidate const &iPart, std::vector< PuppiCandidate > const &iParts, int iOpt, const double iRCone)
std::vector< PuppiAlgo > fPuppiAlgo
void PuppiContainer::getRMSAvg ( int  iOpt,
std::vector< PuppiCandidate > const &  iConstits,
std::vector< PuppiCandidate > const &  iParticles,
std::vector< PuppiCandidate > const &  iChargeParticles 
)
protected

Definition at line 120 of file PuppiContainer.cc.

References PVValHelper::eta, edm::isFinite(), LogDebug, and EnergyCorrector::pt.

Referenced by puppiParticles().

120  {
121  for(unsigned int i0 = 0; i0 < iConstits.size(); i0++ ) {
122  double pVal = -1;
123  //Calculate the Puppi Algo to use
124  int pPupId = getPuppiId(iConstits[i0].pt(),iConstits[i0].eta());
125  if(pPupId == -1 || fPuppiAlgo[pPupId].numAlgos() <= iOpt){
126  fVals.push_back(-1);
127  continue;
128  }
129  //Get the Puppi Sub Algo (given iteration)
130  int pAlgo = fPuppiAlgo[pPupId].algoId (iOpt);
131  bool pCharged = fPuppiAlgo[pPupId].isCharged(iOpt);
132  double pCone = fPuppiAlgo[pPupId].coneSize (iOpt);
133  //Compute the Puppi Metric
134  if(!pCharged) pVal = goodVar(iConstits[i0],iParticles ,pAlgo,pCone);
135  if( pCharged) pVal = goodVar(iConstits[i0],iChargedParticles,pAlgo,pCone);
136  fVals.push_back(pVal);
137  //if(std::isnan(pVal) || std::isinf(pVal)) cerr << "====> Value is Nan " << pVal << " == " << iConstits[i0].pt() << " -- " << iConstits[i0].eta() << endl;
138  if( ! edm::isFinite(pVal)) {
139  LogDebug( "NotFound" ) << "====> Value is Nan " << pVal << " == " << iConstits[i0].pt() << " -- " << iConstits[i0].eta() << endl;
140  continue;
141  }
142 
143  // // fPuppiAlgo[pPupId].add(iConstits[i0],pVal,iOpt);
144  //code added by Nhan, now instead for every algorithm give it all the particles
145  for(int i1 = 0; i1 < fNAlgos; i1++){
146  pAlgo = fPuppiAlgo[i1].algoId (iOpt);
147  pCharged = fPuppiAlgo[i1].isCharged(iOpt);
148  pCone = fPuppiAlgo[i1].coneSize (iOpt);
149  double curVal = -1;
150  if (i1 != pPupId){
151  if(!pCharged) curVal = goodVar(iConstits[i0],iParticles ,pAlgo,pCone);
152  if( pCharged) curVal = goodVar(iConstits[i0],iChargedParticles,pAlgo,pCone);
153  } else {//no need to repeat the computation
154  curVal = pVal;
155  }
156  //std::cout << "i1 = " << i1 << ", curVal = " << curVal << ", eta = " << iConstits[i0].eta() << ", pupID = " << pPupId << std::endl;
157  fPuppiAlgo[i1].add(iConstits[i0],curVal,iOpt);
158  }
159 
160  }
161  for(int i0 = 0; i0 < fNAlgos; i0++) fPuppiAlgo[i0].computeMedRMS(iOpt,fPVFrac);
162 }
#define LogDebug(id)
std::vector< double > fVals
constexpr bool isFinite(T x)
int getPuppiId(float iPt, float iEta)
double goodVar(PuppiCandidate const &iPart, std::vector< PuppiCandidate > const &iParts, int iOpt, const double iRCone)
std::vector< PuppiAlgo > fPuppiAlgo
double PuppiContainer::goodVar ( PuppiCandidate const &  iPart,
std::vector< PuppiCandidate > const &  iParts,
int  iOpt,
const double  iRCone 
)
protected

Definition at line 74 of file PuppiContainer.cc.

Referenced by puppiParticles().

74  {
75  return var_within_R(iOpt,iParts,iPart,iRCone);
76 }
double var_within_R(int iId, const std::vector< PuppiCandidate > &particles, const PuppiCandidate &centre, const double R)
void PuppiContainer::initialize ( const std::vector< RecoObj > &  iRecoObjects)

Definition at line 28 of file PuppiContainer.cc.

References funct::abs(), edm::isFinite(), or, and PuppiCandidate::set_info().

28  {
29  //Clear everything
30  fPFParticles .resize(0);
31  fChargedPV .resize(0);
32  fPupParticles .resize(0);
33  fWeights .resize(0);
34  fVals.resize(0);
35  fRawAlphas.resize(0);
36  fAlphaMed .resize(0);
37  fAlphaRMS .resize(0);
38  //fChargedNoPV.resize(0);
39  //Link to the RecoObjects
40  fPVFrac = 0.;
41  fNPV = 1.;
42  fRecoParticles = &iRecoObjects;
43  fRecoToPup.clear();
44  fRecoToPup.reserve(fRecoParticles->size());
45  for (auto const& rParticle : *fRecoParticles){
46  PuppiCandidate curPseudoJet;
47  // float nom = sqrt((rParticle.m)*(rParticle.m) + (rParticle.pt)*(rParticle.pt)*(cosh(rParticle.eta))*(cosh(rParticle.eta))) + (rParticle.pt)*sinh(rParticle.eta);//hacked
48  // float denom = sqrt((rParticle.m)*(rParticle.m) + (rParticle.pt)*(rParticle.pt));//hacked
49  // float rapidity = log(nom/denom);//hacked
50  if (edm::isFinite(rParticle.rapidity)){
51  curPseudoJet.reset_PtYPhiM(rParticle.pt,rParticle.rapidity,rParticle.phi,rParticle.m);//hacked
52  } else {
53  curPseudoJet.reset_PtYPhiM(0, 99., 0, 0);//skipping may have been a better choice
54  }
55  //curPseudoJet.reset_PtYPhiM(rParticle.pt,rParticle.eta,rParticle.phi,rParticle.m);
56  int puppi_register = 0;
57  if(rParticle.id == 0 or rParticle.charge == 0) puppi_register = 0; // zero is neutral hadron
58  if(rParticle.id == 1 and rParticle.charge != 0) puppi_register = rParticle.charge; // from PV use the
59  if(rParticle.id == 2 and rParticle.charge != 0) puppi_register = rParticle.charge+5; // from NPV use the charge as key +5 as key
60  curPseudoJet.set_info( puppi_register );
61  // fill vector of pseudojets for internal references
62  fPFParticles.push_back(curPseudoJet);
63  //Take Charged particles associated to PV
64  if(std::abs(rParticle.id) == 1) fChargedPV.push_back(curPseudoJet);
65  if(std::abs(rParticle.id) >= 1 ) fPVFrac+=1.;
66  //if(rParticle.id == 3) _chargedNoPV.push_back(curPseudoJet);
67  // if(fNPV < rParticle.vtxId) fNPV = rParticle.vtxId;
68  }
69  if (fPVFrac != 0) fPVFrac = double(fChargedPV.size())/fPVFrac;
70  else fPVFrac = 0;
71 }
std::vector< PuppiCandidate > fPFParticles
std::vector< double > fVals
constexpr bool isFinite(T x)
void set_info(int puppi_register)
std::vector< double > fRawAlphas
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > fAlphaMed
std::vector< PuppiCandidate > fChargedPV
const std::vector< RecoObj > * fRecoParticles
std::vector< int > fRecoToPup
std::vector< double > fWeights
std::vector< PuppiCandidate > fPupParticles
std::vector< double > fAlphaRMS
std::vector<PuppiCandidate> const& PuppiContainer::pfParticles ( ) const
inline

Definition at line 15 of file PuppiContainer.h.

References fPFParticles.

15 { return fPFParticles; }
std::vector< PuppiCandidate > fPFParticles
const std::vector<double>& PuppiContainer::puppiAlphas ( )
inline

Definition at line 19 of file PuppiContainer.h.

References fVals.

19 { return fVals; }
std::vector< double > fVals
const std::vector<double>& PuppiContainer::puppiAlphasMed ( )
inline

Definition at line 21 of file PuppiContainer.h.

References fAlphaMed.

21 {return fAlphaMed;}
std::vector< double > fAlphaMed
const std::vector<double>& PuppiContainer::puppiAlphasRMS ( )
inline

Definition at line 22 of file PuppiContainer.h.

References fAlphaRMS.

22 {return fAlphaRMS;}
std::vector< double > fAlphaRMS
int PuppiContainer::puppiNAlgos ( )
inline

Definition at line 25 of file PuppiContainer.h.

References fNAlgos.

25 { return fNAlgos; }
std::vector<PuppiCandidate> const& PuppiContainer::puppiParticles ( ) const
inline
const std::vector<double>& PuppiContainer::puppiRawAlphas ( )
inline

Definition at line 18 of file PuppiContainer.h.

References fRawAlphas.

18 { return fRawAlphas; }
std::vector< double > fRawAlphas
std::vector< double > const & PuppiContainer::puppiWeights ( )

Definition at line 213 of file PuppiContainer.cc.

References MillePedeFileConverter_cfg::e, edm::isFinite(), LogDebug, SiStripPI::max, pfDeepBoostedJetPreprocessParams_cfi::median, EnergyCorrector::pt, reset(), and SiStripPI::rms.

Referenced by pvParticles().

213  {
214  int lNParticles = fRecoParticles->size();
215 
216  fPupParticles .clear();
217  fPupParticles.reserve(lNParticles);
218  fWeights .clear();
219  fWeights.reserve(lNParticles);
220  fVals .clear();
221  fVals.reserve(lNParticles);
222  for(int i0 = 0; i0 < fNAlgos; i0++) fPuppiAlgo[i0].reset();
223 
224  int lNMaxAlgo = 1;
225  for(int i0 = 0; i0 < fNAlgos; i0++) lNMaxAlgo = std::max(fPuppiAlgo[i0].numAlgos(),lNMaxAlgo);
226  //Run through all compute mean and RMS
227  for(int i0 = 0; i0 < lNMaxAlgo; i0++) {
229  }
231 
232  std::vector<double> pVals;
233  pVals.reserve(lNParticles);
234  for(int i0 = 0; i0 < lNParticles; i0++) {
235  //Refresh
236  pVals.clear();
237  double pWeight = 1;
238  //Get the Puppi Id and if ill defined move on
239  const auto& rParticle = (*fRecoParticles)[i0];
240  int pPupId = getPuppiId(rParticle.pt,rParticle.eta);
241  if(pPupId == -1) {
242  fWeights .push_back(pWeight);
243  fAlphaMed.push_back(-10);
244  fAlphaRMS.push_back(-10);
245  fRecoToPup.push_back(-1);
246  continue;
247  } else {
248  fRecoToPup.push_back(fPupParticles.size());//watch out: there should be no skips after this
249  }
250  // fill the p-values
251  double pChi2 = 0;
252  if(fUseExp){
253  //Compute an Experimental Puppi Weight with delta Z info (very simple example)
254  pChi2 = getChi2FromdZ(rParticle.dZ);
255  //Now make sure Neutrals are not set
256  if(rParticle.pfType > 3) pChi2 = 0;
257  }
258  //Fill and compute the PuppiWeight
259  int lNAlgos = fPuppiAlgo[pPupId].numAlgos();
260  for(int i1 = 0; i1 < lNAlgos; i1++) pVals.push_back(fVals[lNParticles*i1+i0]);
261 
262  pWeight = fPuppiAlgo[pPupId].compute(pVals,pChi2);
263  //Apply the CHS weights
264  if(rParticle.id == 1 && fApplyCHS ) pWeight = 1;
265  if(rParticle.id == 2 && fApplyCHS ) pWeight = 0;
266  //Basic Weight Checks
267  if( ! edm::isFinite(pWeight)) {
268  pWeight = 0.0;
269  LogDebug("PuppiWeightError") << "====> Weight is nan : " << pWeight << " : pt " << rParticle.pt << " -- eta : " << rParticle.eta << " -- Value" << fVals[i0] << " -- id : " << rParticle.id << " -- NAlgos: " << lNAlgos << std::endl;
270  }
271  //Basic Cuts
272  if(pWeight*fPFParticles[i0].pt() < fPuppiAlgo[pPupId].neutralPt(fNPV) && rParticle.id == 0 ) pWeight = 0; //threshold cut on the neutral Pt
273  if((fPtMax>0) && (rParticle.id == 0))
274  pWeight = std::clamp((fPFParticles[i0].pt() - fPtMaxNeutralsStartSlope) / (fPtMax - fPtMaxNeutralsStartSlope),
275  pWeight,
276  1.);
277  if(pWeight < fPuppiWeightCut) pWeight = 0; //==> Elminate the low Weight stuff
278  if(fInvert) pWeight = 1.-pWeight;
279  //std::cout << "rParticle.pt = " << rParticle.pt << ", rParticle.charge = " << rParticle.charge << ", rParticle.id = " << rParticle.id << ", weight = " << pWeight << std::endl;
280 
281  fWeights .push_back(pWeight);
282  fAlphaMed.push_back(fPuppiAlgo[pPupId].median());
283  fAlphaRMS.push_back(fPuppiAlgo[pPupId].rms());
284  //Now get rid of the thrown out weights for the particle collection
285 
286  // leave these lines in, in case want to move eventually to having no 1-to-1 correspondence between puppi and pf cands
287  // if( std::abs(pWeight) < std::numeric_limits<double>::denorm_min() ) continue; // this line seems not to work like it's supposed to...
288  // if(std::abs(pWeight) <= 0. ) continue;
289 
290  //Produce
291  PuppiCandidate curjet( pWeight*fPFParticles[i0].px(), pWeight*fPFParticles[i0].py(), pWeight*fPFParticles[i0].pz(), pWeight*fPFParticles[i0].e() );
292  curjet.set_user_index(i0);
293  fPupParticles.push_back(curjet);
294  }
295  return fWeights;
296 }
#define LogDebug(id)
double getChi2FromdZ(double iDZ)
std::vector< PuppiCandidate > fPFParticles
std::vector< double > fVals
constexpr bool isFinite(T x)
double fPtMaxNeutralsStartSlope
void getRMSAvg(int iOpt, std::vector< PuppiCandidate > const &iConstits, std::vector< PuppiCandidate > const &iParticles, std::vector< PuppiCandidate > const &iChargeParticles)
void getRawAlphas(int iOpt, std::vector< PuppiCandidate > const &iConstits, std::vector< PuppiCandidate > const &iParticles, std::vector< PuppiCandidate > const &iChargeParticles)
std::vector< double > fAlphaMed
std::vector< PuppiCandidate > fChargedPV
double fPuppiWeightCut
int getPuppiId(float iPt, float iEta)
const std::vector< RecoObj > * fRecoParticles
std::vector< int > fRecoToPup
std::vector< double > fWeights
std::vector< PuppiCandidate > fPupParticles
std::vector< double > fAlphaRMS
std::vector< PuppiAlgo > fPuppiAlgo
void reset(double vett[256])
Definition: TPedValues.cc:11
std::vector<PuppiCandidate> const& PuppiContainer::pvParticles ( ) const
inline

Definition at line 16 of file PuppiContainer.h.

References fChargedPV, and puppiWeights().

16 { return fChargedPV; }
std::vector< PuppiCandidate > fChargedPV
const std::vector<int>& PuppiContainer::recoToPup ( ) const
inline

Definition at line 23 of file PuppiContainer.h.

References fRecoToPup.

23 {return fRecoToPup;}
std::vector< int > fRecoToPup
void PuppiContainer::setNPV ( int  iNPV)
inline

Definition at line 13 of file PuppiContainer.h.

References fNPV.

13 { fNPV = iNPV; }
double PuppiContainer::var_within_R ( int  iId,
const std::vector< PuppiCandidate > &  particles,
const PuppiCandidate centre,
const double  R 
)
protected

Definition at line 78 of file PuppiContainer.cc.

References funct::abs(), reco::deltaR2(), mps_fire::i, cmsBatch::log, min(), EnergyCorrector::pt, dttmaxenums::R, diffTwoXMLs::r2, and JetChargeProducer_cfi::var.

Referenced by puppiParticles().

78  {
79  if(iId == -1) return 1;
80 
81  //this is a circle in rapidity-phi
82  //it would make more sense to have var definition consistent
83  //fastjet::Selector sel = fastjet::SelectorCircle(R);
84  //sel.set_reference(centre);
85  //the original code used Selector infrastructure: it is too heavy here
86  //logic of SelectorCircle is preserved below
87 
88  vector<double > near_dR2s; near_dR2s.reserve(std::min(50UL, particles.size()));
89  vector<double > near_pts; near_pts.reserve(std::min(50UL, particles.size()));
90  const double r2 = R*R;
91  for (auto const& part : particles){
92  //squared_distance is in (y,phi) coords: rap() has faster access -> check it first
93  if ( std::abs(part.rap()-centre.rap()) < R && part.squared_distance(centre) < r2 ){
94  near_dR2s.push_back(reco::deltaR2(part, centre));
95  near_pts.push_back(part.pt());
96  }
97  }
98  double var = 0;
99  //double lSumPt = 0;
100  //if(iId == 1) for(auto pt : near_pts) lSumPt += pt;
101  auto nParts = near_dR2s.size();
102  for(auto i = 0UL; i < nParts; ++i){
103  auto dr2 = near_dR2s[i];
104  auto pt = near_pts[i];
105  if(dr2 < 0.0001) continue;
106  if(iId == 0) var += (pt/dr2);
107  else if(iId == 1) var += pt;
108  else if(iId == 2) var += (1./dr2);
109  else if(iId == 3) var += (1./dr2);
110  else if(iId == 4) var += pt;
111  else if(iId == 5) var += (pt * pt/dr2);
112  }
113  if(iId == 1) var += centre.pt(); //Sum in a cone
114  else if(iId == 0 && var != 0) var = log(var);
115  else if(iId == 3 && var != 0) var = log(var);
116  else if(iId == 5 && var != 0) var = log(var);
117  return var;
118 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
part
Definition: HCALResponse.h:20

Member Data Documentation

std::vector<double> PuppiContainer::fAlphaMed
protected

Definition at line 44 of file PuppiContainer.h.

Referenced by puppiAlphasMed().

std::vector<double> PuppiContainer::fAlphaRMS
protected

Definition at line 45 of file PuppiContainer.h.

Referenced by puppiAlphasRMS().

bool PuppiContainer::fApplyCHS
protected

Definition at line 48 of file PuppiContainer.h.

std::vector<PuppiCandidate> PuppiContainer::fChargedPV
protected

Definition at line 39 of file PuppiContainer.h.

Referenced by pvParticles().

bool PuppiContainer::fInvert
protected

Definition at line 49 of file PuppiContainer.h.

int PuppiContainer::fNAlgos
protected

Definition at line 56 of file PuppiContainer.h.

Referenced by puppiNAlgos().

double PuppiContainer::fNeutralMinPt
protected

Definition at line 51 of file PuppiContainer.h.

double PuppiContainer::fNeutralSlope
protected

Definition at line 52 of file PuppiContainer.h.

int PuppiContainer::fNPV
protected

Definition at line 57 of file PuppiContainer.h.

Referenced by setNPV().

std::vector<PuppiCandidate> PuppiContainer::fPFParticles
protected

Definition at line 38 of file PuppiContainer.h.

Referenced by pfParticles().

double PuppiContainer::fPtMax
protected

Definition at line 54 of file PuppiContainer.h.

double PuppiContainer::fPtMaxNeutralsStartSlope
protected

Definition at line 55 of file PuppiContainer.h.

std::vector<PuppiCandidate> PuppiContainer::fPupParticles
protected

Definition at line 40 of file PuppiContainer.h.

Referenced by puppiParticles().

std::vector<PuppiAlgo> PuppiContainer::fPuppiAlgo
protected

Definition at line 59 of file PuppiContainer.h.

bool PuppiContainer::fPuppiDiagnostics
protected

Definition at line 36 of file PuppiContainer.h.

double PuppiContainer::fPuppiWeightCut
protected

Definition at line 53 of file PuppiContainer.h.

double PuppiContainer::fPVFrac
protected

Definition at line 58 of file PuppiContainer.h.

std::vector<double> PuppiContainer::fRawAlphas
protected

Definition at line 43 of file PuppiContainer.h.

Referenced by puppiRawAlphas().

const std::vector<RecoObj>* PuppiContainer::fRecoParticles
protected

Definition at line 37 of file PuppiContainer.h.

std::vector<int> PuppiContainer::fRecoToPup
protected

Definition at line 46 of file PuppiContainer.h.

Referenced by recoToPup().

bool PuppiContainer::fUseExp
protected

Definition at line 50 of file PuppiContainer.h.

std::vector<double> PuppiContainer::fVals
protected

Definition at line 42 of file PuppiContainer.h.

Referenced by puppiAlphas().

std::vector<double> PuppiContainer::fWeights
protected

Definition at line 41 of file PuppiContainer.h.