40 #define init_param(type, varname) varname (ps.getParameter< type >( #varname ))
134 mutable std::vector<std::pair<double, unsigned> >
zAssoc;
172 produces<reco::PFCandidateCollection>();
182 reco::VertexCollection::const_iterator iv)
const
184 return !iv->isFake() &&
196 auto pOutput = std::make_unique<reco::PFCandidateCollection>();
211 <<
"ERROR in FFTJetPFPileupCleaner:"
212 " could not find fake vertices"
216 const unsigned ncand = pfCandidates->size();
217 for (
unsigned i=0;
i<ncand; ++
i)
224 bool fromFakeSet =
false;
226 *candptr, &fromFakeSet));
233 else if (vertexref.
key() == 0 &&
251 const double eta = candptr->p4().Eta();
252 remove = eta < etaMin || eta >
etaMax;
261 pOutput->push_back(cand);
273 const unsigned shift =
static_cast<unsigned>(ptype);
282 const unsigned shift =
static_cast<unsigned>(ptype);
284 const unsigned mask = (1U <<
shift);
300 typedef reco::VertexCollection::const_iterator IV;
303 *fromFakeSet =
false;
307 unsigned nFoundVertex = 0;
308 const IV vertend(vertices->end());
312 double bestweight = 0.0;
313 for (IV iv=vertices->begin(); iv!=vertend; ++iv, ++
index)
320 for (IT iTrack=vtx.
tracks_begin(); iTrack!=trackend; ++iTrack)
326 if (baseRef == trackBaseRef)
341 if (nFoundVertex > 0)
343 if (nFoundVertex != 1)
345 <<
"a track is shared by at least two vertices. "
346 <<
"Used to be an assert";
352 const double ztrack = pfcand.
vertex().z();
353 double dzmin =
std::abs(ztrack - ((*vertices)[iVertex]).
z());
355 const IV fakeEnd(fakeVertices->end());
357 for (IV iv=fakeVertices->begin(); iv!=fakeEnd; ++iv, ++
index)
360 const double dz =
std::abs(ztrack - iv->z());
370 return reco::VertexRef(*fromFakeSet ? fakeVertices : vertices, iVertex);
376 const double ztrack = pfcand.
vertex().z();
377 bool foundVertex =
false;
384 for (IV iv=vertices->begin(); iv!=vertend; ++iv, ++
index)
386 zAssoc.push_back(std::pair<double,unsigned>(iv->z(),
index));
387 const unsigned numRealVertices =
index;
393 const IV fakeEnd(fakeVertices->end());
394 for (IV iv=fakeVertices->begin(); iv!=fakeEnd; ++iv, ++
index)
396 zAssoc.push_back(std::pair<double,unsigned>(iv->z(),
index));
403 std::pair<double,unsigned> tPair(ztrack, UINT_MAX);
404 const unsigned iAbove = std::upper_bound(
411 unsigned ich[2] = {0U, 0U};
415 ich[0] = iAbove - 1U;
417 if (iAbove <
zAssoc.size())
421 double dzmin = 1.0e100;
422 unsigned bestVertexNum = UINT_MAX;
423 for (
unsigned icheck=0; icheck<nch; ++icheck)
425 const unsigned zAssocIndex = ich[icheck];
426 const unsigned vertexNum =
zAssoc[zAssocIndex].second;
428 if (vertexNum == numRealVertices ||
431 bestVertexNum = vertexNum;
439 bestVertexNum = vertexNum;
443 foundVertex = bestVertexNum < UINT_MAX;
446 iVertex = bestVertexNum;
447 if (iVertex >= numRealVertices)
450 iVertex -= numRealVertices;
459 double dzmin = 1.0e100;
461 for (IV iv=vertices->begin(); iv!=vertend; ++iv, ++
index)
464 const double dz =
std::abs(ztrack - iv->z());
475 const IV fakeEnd(fakeVertices->end());
477 for (IV iv=fakeVertices->begin(); iv!=fakeEnd; ++iv, ++
index)
480 const double dz =
std::abs(ztrack - iv->z());
493 return reco::VertexRef(*fromFakeSet ? fakeVertices : vertices, iVertex);
void setRemovalBit(reco::PFCandidate::ParticleType ptype, bool onOff)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParticleType
particle types
bool useFakePrimaryVertex
trackRef_iterator tracks_end() const
last iterator over tracks
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< reco::VertexCollection > FakePrimaryVerticesToken
void setSourceCandidatePtr(const PFCandidatePtr &ptr)
key_type key() const
Accessor for product key.
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
reco::TrackRef trackRef() const
bool isRemovable(reco::PFCandidate::ParticleType ptype) const
Abs< T >::type abs(const T &t)
virtual const Point & vertex() const
vertex position (overwritten by PF...)
edm::EDGetTokenT< reco::VertexCollection > VerticesToken
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
bool reverseRemovalDecision
std::vector< LinkConnSpec >::const_iterator IT
void produce(edm::Event &, const edm::EventSetup &) override
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
bool isNull() const
Checks for null.
edm::InputTag PFCandidates
std::vector< std::pair< double, unsigned > > zAssoc
edm::EDGetTokenT< reco::PFCandidateCollection > PFCandidatesToken
#define init_param(type, varname)
Particle reconstructed by the particle flow algorithm.
FFTJetPFPileupCleaner & operator=(const FFTJetPFPileupCleaner &)
edm::InputTag FakePrimaryVertices
reco::VertexRef findSomeVertexWFakes(const edm::Handle< reco::VertexCollection > &vertices, const edm::Handle< reco::VertexCollection > &fakeVertices, const reco::PFCandidate &pfcand, bool *fromFakeSet) const
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
static unsigned int const shift
trackRef_iterator tracks_begin() const
first iterator over tracks
bool isAcceptableVtx(reco::VertexCollection::const_iterator iv) const