40 #define init_param(type, varname) varname (ps.getParameter< type >( #varname ))
127 mutable std::vector<std::pair<double, unsigned> >
zAssoc;
136 init_param(edm::InputTag, FakePrimaryVertices),
158 produces<reco::PFCandidateCollection>();
168 reco::VertexCollection::const_iterator iv)
const
170 return !iv->isFake() &&
181 std::auto_ptr<reco::PFCandidateCollection>
197 <<
"ERROR in FFTJetPFPileupCleaner:"
198 " could not find fake vertices"
202 const unsigned ncand = pfCandidates->size();
203 for (
unsigned i=0;
i<ncand; ++
i)
210 bool fromFakeSet =
false;
212 *candptr, &fromFakeSet));
219 else if (vertexref.
key() == 0 &&
237 const double eta = candptr->p4().Eta();
238 remove = eta < etaMin || eta >
etaMax;
247 pOutput->push_back(cand);
259 const unsigned shift =
static_cast<unsigned>(ptype);
268 const unsigned shift =
static_cast<unsigned>(ptype);
270 const unsigned mask = (1U <<
shift);
286 typedef reco::VertexCollection::const_iterator IV;
289 *fromFakeSet =
false;
293 unsigned nFoundVertex = 0;
294 const IV vertend(vertices->end());
298 double bestweight = 0.0;
299 for (IV iv=vertices->begin(); iv!=vertend; ++iv, ++
index)
306 for (IT iTrack=vtx.
tracks_begin(); iTrack!=trackend; ++iTrack)
312 if (baseRef == trackBaseRef)
327 if (nFoundVertex > 0)
329 if (nFoundVertex != 1)
331 <<
"a track is shared by at least two vertices. "
332 <<
"Used to be an assert";
338 const double ztrack = pfcand.
vertex().z();
339 double dzmin =
std::abs(ztrack - ((*vertices)[iVertex]).
z());
341 const IV fakeEnd(fakeVertices->end());
343 for (IV iv=fakeVertices->begin(); iv!=fakeEnd; ++iv, ++
index)
346 const double dz =
std::abs(ztrack - iv->z());
356 return reco::VertexRef(*fromFakeSet ? fakeVertices : vertices, iVertex);
362 const double ztrack = pfcand.
vertex().z();
363 bool foundVertex =
false;
370 for (IV iv=vertices->begin(); iv!=vertend; ++iv, ++
index)
372 zAssoc.push_back(std::pair<double,unsigned>(iv->z(),
index));
373 const unsigned numRealVertices =
index;
379 const IV fakeEnd(fakeVertices->end());
380 for (IV iv=fakeVertices->begin(); iv!=fakeEnd; ++iv, ++
index)
382 zAssoc.push_back(std::pair<double,unsigned>(iv->z(),
index));
389 std::pair<double,unsigned> tPair(ztrack, UINT_MAX);
390 const unsigned iAbove = std::upper_bound(
397 unsigned ich[2] = {0U, 0U};
401 ich[0] = iAbove - 1U;
403 if (iAbove <
zAssoc.size())
407 double dzmin = 1.0e100;
408 unsigned bestVertexNum = UINT_MAX;
409 for (
unsigned icheck=0; icheck<nch; ++icheck)
411 const unsigned zAssocIndex = ich[icheck];
412 const unsigned vertexNum =
zAssoc[zAssocIndex].second;
414 if (vertexNum == numRealVertices ||
417 bestVertexNum = vertexNum;
425 bestVertexNum = vertexNum;
429 foundVertex = bestVertexNum < UINT_MAX;
432 iVertex = bestVertexNum;
433 if (iVertex >= numRealVertices)
436 iVertex -= numRealVertices;
445 double dzmin = 1.0e100;
447 for (IV iv=vertices->begin(); iv!=vertend; ++iv, ++
index)
450 const double dz =
std::abs(ztrack - iv->z());
461 const IV fakeEnd(fakeVertices->end());
463 for (IV iv=fakeVertices->begin(); iv!=fakeEnd; ++iv, ++
index)
466 const double dz =
std::abs(ztrack - iv->z());
479 return reco::VertexRef(*fromFakeSet ? fakeVertices : vertices, iVertex);
void setRemovalBit(reco::PFCandidate::ParticleType ptype, bool onOff)
ParticleType
particle types
bool useFakePrimaryVertex
trackRef_iterator tracks_end() const
last iterator over tracks
#define DEFINE_FWK_MODULE(type)
void setSourceCandidatePtr(const PFCandidatePtr &ptr)
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
reco::TrackRef trackRef() const
bool isRemovable(reco::PFCandidate::ParticleType ptype) const
bool isNull() const
Checks for null.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
float trackWeight(const TrackBaseRef &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Abs< T >::type abs(const T &t)
virtual const Point & vertex() const
vertex position (overwritten by PF...)
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 getByLabel(InputTag const &tag, Handle< PROD > &result) const
edm::InputTag PFCandidates
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
std::vector< std::pair< double, unsigned > > zAssoc
key_type key() const
Accessor for product key.
#define init_param(type, varname)
Particle reconstructed by the particle flow algorithm.
FFTJetPFPileupCleaner & operator=(const FFTJetPFPileupCleaner &)
edm::InputTag FakePrimaryVertices
std::vector< VertexType > Vertices
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