40 #define init_param(type, varname) varname(ps.getParameter<type>(#varname))
68 bool* fromFakeSet)
const;
132 mutable std::vector<std::pair<double, unsigned> >
zAssoc;
169 produces<reco::PFCandidateCollection>();
182 auto pOutput = std::make_unique<reco::PFCandidateCollection>();
195 throw cms::Exception(
"FFTJetBadConfig") <<
"ERROR in FFTJetPFPileupCleaner:"
196 " could not find fake vertices"
200 const unsigned ncand = pfCandidates->size();
201 for (
unsigned i = 0;
i < ncand; ++
i) {
206 bool fromFakeSet =
false;
226 const double eta = candptr->p4().Eta();
227 remove = eta < etaMin || eta >
etaMax;
235 pOutput->push_back(cand);
244 const unsigned shift =
static_cast<unsigned>(ptype);
250 const unsigned shift =
static_cast<unsigned>(ptype);
252 const unsigned mask = (1U <<
shift);
265 bool* fromFakeSet)
const {
266 typedef reco::VertexCollection::const_iterator IV;
269 *fromFakeSet =
false;
273 unsigned nFoundVertex = 0;
274 const IV vertend(vertices->end());
278 double bestweight = 0.0;
279 for (IV
iv = vertices->begin();
iv != vertend; ++
iv, ++
index)
285 for (IT iTrack = vtx.
tracks_begin(); iTrack != trackend; ++iTrack) {
290 if (baseRef == trackBaseRef) {
293 if (w > bestweight) {
303 if (nFoundVertex > 0) {
304 if (nFoundVertex != 1)
305 edm::LogWarning(
"TrackOnTwoVertex") <<
"a track is shared by at least two vertices. "
306 <<
"Used to be an assert";
311 const double ztrack = pfcand.
vertex().z();
312 double dzmin =
std::abs(ztrack - ((*vertices)[iVertex]).
z());
314 const IV fakeEnd(fakeVertices->end());
316 for (IV
iv = fakeVertices->begin();
iv != fakeEnd; ++
iv, ++
index)
327 return reco::VertexRef(*fromFakeSet ? fakeVertices : vertices, iVertex);
332 const double ztrack = pfcand.
vertex().z();
333 bool foundVertex =
false;
339 for (IV
iv = vertices->begin();
iv != vertend; ++
iv, ++
index)
341 zAssoc.push_back(std::pair<double, unsigned>(
iv->z(),
index));
342 const unsigned numRealVertices =
index;
347 const IV fakeEnd(fakeVertices->end());
348 for (IV
iv = fakeVertices->begin();
iv != fakeEnd; ++
iv, ++
index)
350 zAssoc.push_back(std::pair<double, unsigned>(
iv->z(),
index));
356 std::pair<double, unsigned> tPair(ztrack, UINT_MAX);
363 unsigned ich[2] = {0U, 0U};
366 ich[0] = iAbove - 1U;
368 if (iAbove <
zAssoc.size())
372 double dzmin = 1.0e100;
373 unsigned bestVertexNum = UINT_MAX;
374 for (
unsigned icheck = 0; icheck < nch; ++icheck) {
375 const unsigned zAssocIndex = ich[icheck];
376 const unsigned vertexNum =
zAssoc[zAssocIndex].second;
379 bestVertexNum = vertexNum;
386 bestVertexNum = vertexNum;
390 foundVertex = bestVertexNum < UINT_MAX;
392 iVertex = bestVertexNum;
393 if (iVertex >= numRealVertices) {
395 iVertex -= numRealVertices;
402 double dzmin = 1.0e100;
404 for (IV
iv = vertices->begin();
iv != vertend; ++
iv, ++
index)
415 const IV fakeEnd(fakeVertices->end());
417 for (IV
iv = fakeVertices->begin();
iv != fakeEnd; ++
iv, ++
index)
431 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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< reco::VertexCollection > FakePrimaryVerticesToken
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
void setSourceCandidatePtr(const PFCandidatePtr &ptr)
key_type key() const
Accessor for product key.
reco::TrackRef trackRef() const
bool isRemovable(reco::PFCandidate::ParticleType ptype) const
FFTJetPFPileupCleaner & operator=(const FFTJetPFPileupCleaner &)=delete
FFTJetPFPileupCleaner()=delete
Abs< T >::type abs(const T &t)
trackRef_iterator tracks_end() const
last iterator over tracks
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
trackRef_iterator tracks_begin() const
first iterator over tracks
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
const Point & vertex() const override
vertex position (overwritten by PF...)
#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
static unsigned int const shift
Log< level::Warning, false > LogWarning
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
bool isAcceptableVtx(reco::VertexCollection::const_iterator iv) const