40 #define init_param(type, varname) varname (ps.getParameter< type >( #varname ))
134 mutable std::vector<std::pair<double, unsigned> >
zAssoc;
143 init_param(edm::InputTag, FakePrimaryVertices),
172 produces<reco::PFCandidateCollection>();
182 reco::VertexCollection::const_iterator iv)
const
184 return !iv->isFake() &&
196 std::auto_ptr<reco::PFCandidateCollection>
212 <<
"ERROR in FFTJetPFPileupCleaner:"
213 " could not find fake vertices"
217 const unsigned ncand = pfCandidates->size();
218 for (
unsigned i=0;
i<ncand; ++
i)
225 bool fromFakeSet =
false;
227 *candptr, &fromFakeSet));
234 else if (vertexref.
key() == 0 &&
252 const double eta = candptr->p4().Eta();
253 remove = eta < etaMin || eta >
etaMax;
262 pOutput->push_back(cand);
274 const unsigned shift =
static_cast<unsigned>(ptype);
283 const unsigned shift =
static_cast<unsigned>(ptype);
285 const unsigned mask = (1U <<
shift);
301 typedef reco::VertexCollection::const_iterator IV;
304 *fromFakeSet =
false;
308 unsigned nFoundVertex = 0;
309 const IV vertend(vertices->end());
313 double bestweight = 0.0;
314 for (IV iv=vertices->begin(); iv!=vertend; ++iv, ++
index)
321 for (IT iTrack=vtx.
tracks_begin(); iTrack!=trackend; ++iTrack)
327 if (baseRef == trackBaseRef)
342 if (nFoundVertex > 0)
344 if (nFoundVertex != 1)
346 <<
"a track is shared by at least two vertices. "
347 <<
"Used to be an assert";
353 const double ztrack = pfcand.
vertex().z();
354 double dzmin =
std::abs(ztrack - ((*vertices)[iVertex]).
z());
356 const IV fakeEnd(fakeVertices->end());
358 for (IV iv=fakeVertices->begin(); iv!=fakeEnd; ++iv, ++
index)
361 const double dz =
std::abs(ztrack - iv->z());
371 return reco::VertexRef(*fromFakeSet ? fakeVertices : vertices, iVertex);
377 const double ztrack = pfcand.
vertex().z();
378 bool foundVertex =
false;
385 for (IV iv=vertices->begin(); iv!=vertend; ++iv, ++
index)
387 zAssoc.push_back(std::pair<double,unsigned>(iv->z(),
index));
388 const unsigned numRealVertices =
index;
394 const IV fakeEnd(fakeVertices->end());
395 for (IV iv=fakeVertices->begin(); iv!=fakeEnd; ++iv, ++
index)
397 zAssoc.push_back(std::pair<double,unsigned>(iv->z(),
index));
404 std::pair<double,unsigned> tPair(ztrack, UINT_MAX);
405 const unsigned iAbove = std::upper_bound(
412 unsigned ich[2] = {0U, 0U};
416 ich[0] = iAbove - 1U;
418 if (iAbove <
zAssoc.size())
422 double dzmin = 1.0e100;
423 unsigned bestVertexNum = UINT_MAX;
424 for (
unsigned icheck=0; icheck<nch; ++icheck)
426 const unsigned zAssocIndex = ich[icheck];
427 const unsigned vertexNum =
zAssoc[zAssocIndex].second;
429 if (vertexNum == numRealVertices ||
432 bestVertexNum = vertexNum;
440 bestVertexNum = vertexNum;
444 foundVertex = bestVertexNum < UINT_MAX;
447 iVertex = bestVertexNum;
448 if (iVertex >= numRealVertices)
451 iVertex -= numRealVertices;
460 double dzmin = 1.0e100;
462 for (IV iv=vertices->begin(); iv!=vertend; ++iv, ++
index)
465 const double dz =
std::abs(ztrack - iv->z());
476 const IV fakeEnd(fakeVertices->end());
478 for (IV iv=fakeVertices->begin(); iv!=fakeEnd; ++iv, ++
index)
481 const double dz =
std::abs(ztrack - iv->z());
494 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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< reco::VertexCollection > FakePrimaryVerticesToken
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...)
edm::EDGetTokenT< reco::VertexCollection > VerticesToken
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
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.
edm::EDGetTokenT< reco::PFCandidateCollection > PFCandidatesToken
#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