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_(sumes.consumes<Collection>(conf.getParameter<
edm::
InputTag>(
"source"))),
66 template <
class Collection,
class Adaptor>
70 auto pfparents =
e.getHandle(src_);
73 typedef std::pair<edm::ProductID, unsigned> TrackProdIDKey;
74 std::vector<TrackProdIDKey> vetoed;
78 case pfRecTrackCollection: {
79 const auto& vetoes =
e.get(vetoPFTracksSrc_);
80 for (
const auto&
veto : vetoes) {
81 vetoed.emplace_back(
veto.trackRef().id(),
veto.trackRef().key());
85 case ticlSeedingRegion: {
86 const auto& vetoes =
e.get(vetoTICLSeedingSrc_);
87 auto tracksH =
e.getHandle(tracksSrc_);
88 for (
const auto&
veto : vetoes) {
90 vetoed.emplace_back(tracksH.id(),
veto.index);
95 const auto& vetoes =
e.get(vetoPFCandidatesSrc_);
96 for (
const auto&
veto : vetoes) {
97 if (
veto.trackRef().isNull())
99 vetoed.emplace_back(
veto.trackRef().id(),
veto.trackRef().key());
107 elems.reserve(elems.size() + 2 * pfparents->size());
109 auto TKs_end = std::partition(
112 auto bpar = pfparents->cbegin();
113 auto epar = pfparents->cend();
116 for (
auto pfparent = bpar; pfparent != epar; ++pfparent) {
117 if (Adaptor::check_importable(*pfparent)) {
119 const auto& pftracks = Adaptor::get_track_refs(*pfparent);
120 for (
const auto& pftrack : pftracks) {
122 TrackProdIDKey trk = std::make_pair(pftrack->trackRef().id(), pftrack->trackRef().key());
124 bool inVetoList = (lower != vetoed.end() && *lower == trk);
130 auto tk_elem = std::find_if(
131 elems.begin(), TKs_end, [&](
const ElementType&
a) {
return (
a->trackRef() == pftrack->trackRef()); });
132 if (tk_elem != TKs_end) {
133 Adaptor::set_element_info(tk_elem->get(), parentRef);
136 Adaptor::set_element_info(trkElem, parentRef);
137 TKs_end = elems.insert(TKs_end, ElementType(trkElem));
143 elems.shrink_to_fit();