1 #ifndef __TrackFromParentImporter_H__
2 #define __TrackFromParentImporter_H__
14 template <
class Collection>
22 static const std::vector<reco::PFRecTrackRef>
empty_;
26 template <
class Collection,
class Adaptor = noop::ParentCollectionAdaptor<Collection>>
31 src_(cc.consumes<Collection>(conf.getParameter<edm::
InputTag>(
"source"))),
32 vetoEndcap_(conf.getParameter<bool>(
"vetoEndcap")) {
65 template <
class Collection,
class Adaptor>
72 typedef std::pair<edm::ProductID, unsigned> TrackProdIDKey;
73 std::vector<TrackProdIDKey> vetoed;
77 case pfRecTrackCollection: {
78 const auto& vetoes = e.
get(vetoPFTracksSrc_);
79 for (
const auto&
veto : vetoes) {
80 vetoed.emplace_back(
veto.trackRef().id(),
veto.trackRef().key());
84 case ticlSeedingRegion: {
85 const auto& vetoes = e.
get(vetoTICLSeedingSrc_);
87 for (
const auto&
veto : vetoes) {
89 vetoed.emplace_back(tracksH.id(),
veto.index);
94 const auto& vetoes = e.
get(vetoPFCandidatesSrc_);
95 for (
const auto&
veto : vetoes) {
96 if (
veto.trackRef().isNull())
98 vetoed.emplace_back(
veto.trackRef().id(),
veto.trackRef().key());
103 std::sort(vetoed.begin(), vetoed.end());
106 elems.reserve(elems.size() + 2 * pfparents->size());
108 auto TKs_end = std::partition(
111 auto bpar = pfparents->cbegin();
112 auto epar = pfparents->cend();
115 for (
auto pfparent = bpar; pfparent != epar; ++pfparent) {
116 if (Adaptor::check_importable(*pfparent)) {
118 const auto& pftracks = Adaptor::get_track_refs(*pfparent);
119 for (
const auto& pftrack : pftracks) {
121 TrackProdIDKey trk = std::make_pair(pftrack->trackRef().id(), pftrack->trackRef().key());
123 bool inVetoList = (lower != vetoed.end() && *lower == trk);
129 auto tk_elem = std::find_if(
130 elems.begin(), TKs_end, [&](
const ElementType&
a) {
return (
a->trackRef() == pftrack->trackRef()); });
131 if (tk_elem != TKs_end) {
132 Adaptor::set_element_info(tk_elem->get(), parentRef);
135 Adaptor::set_element_info(trkElem, parentRef);
136 TKs_end = elems.insert(TKs_end, ElementType(trkElem));
142 elems.shrink_to_fit();
static bool check_importable(const typename Collection::value_type &)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Abstract base class for a PFBlock element (track, cluster...)
static const std::vector< reco::PFRecTrackRef > empty_
edm::EDGetTokenT< reco::PFCandidateCollection > vetoPFCandidatesSrc_
edm::EDGetTokenT< reco::PFRecTrackCollection > vetoPFTracksSrc_
static void set_element_info(reco::PFBlockElement *, const typename edm::Ref< Collection > &)
std::vector< Track > TrackCollection
collection of Tracks
edm::EDGetTokenT< Collection > src_
edm::EDGetTokenT< reco::TrackCollection > tracksSrc_
tuple pfCandidateCollection
TrackFromParentImporter(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Container::value_type value_type
static const std::vector< reco::PFRecTrackRef > & get_track_refs(const typename Collection::value_type &)
bool get(ProductID const &oid, Handle< PROD > &result) const
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
T getParameter(std::string const &) const
void importToBlock(const edm::Event &, ElementList &) const override
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
edm::EDGetTokenT< std::vector< TICLSeedingRegion > > vetoTICLSeedingSrc_