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);
262 pOutput->back().setSourceCandidatePtr(candptr);
273 const unsigned shift =
static_cast<unsigned>(ptype);
282 const unsigned shift =
static_cast<unsigned>(ptype);
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)
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] = {0
U, 0
U};
415 ich[0] = iAbove - 1
U;
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)
475 const IV fakeEnd(fakeVertices->end());
477 for (IV iv=fakeVertices->begin(); iv!=fakeEnd; ++iv, ++
index)
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
~FFTJetPFPileupCleaner() override
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
key_type key() const
Accessor for product key.
reco::TrackRef trackRef() const
bool isRemovable(reco::PFCandidate::ParticleType ptype) const
const Point & vertex() const override
vertex position (overwritten by PF...)
FFTJetPFPileupCleaner & operator=(const FFTJetPFPileupCleaner &)=delete
FFTJetPFPileupCleaner()=delete
Abs< T >::type abs(const T &t)
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.
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