1 #ifndef __TrackFromParentImporter_H__
2 #define __TrackFromParentImporter_H__
12 template <
class Collection>
20 static const std::vector<reco::PFRecTrackRef>
_empty;
24 template <
class Collection,
class Adaptor = noop::ParentCollectionAdaptor<Collection> >
29 _src(sumes.consumes<Collection>(conf.getParameter<
edm::
InputTag>(
"source"))) {}
37 template <
class Collection,
class Adaptor>
41 auto pfparents =
e.getHandle(_src);
42 elems.reserve(elems.size() + 2 * pfparents->size());
44 auto TKs_end = std::partition(
47 auto bpar = pfparents->cbegin();
48 auto epar = pfparents->cend();
51 for (
auto pfparent = bpar; pfparent != epar; ++pfparent) {
52 if (Adaptor::check_importable(*pfparent)) {
54 const auto& pftracks = Adaptor::get_track_refs(*pfparent);
55 for (
const auto& pftrack : pftracks) {
56 auto tk_elem = std::find_if(
57 elems.begin(), TKs_end, [&](
const ElementType&
a) {
return (
a->trackRef() == pftrack->trackRef()); });
58 if (tk_elem != TKs_end) {
59 Adaptor::set_element_info(tk_elem->get(), parentRef);
62 Adaptor::set_element_info(trkElem, parentRef);
63 TKs_end = elems.insert(TKs_end, ElementType(trkElem));
69 elems.shrink_to_fit();