1 #ifndef __TrackFromParentImporter_H__ 2 #define __TrackFromParentImporter_H__ 13 template<
class Collection>
19 static const std::vector<reco::PFRecTrackRef>&
26 static const std::vector<reco::PFRecTrackRef>
_empty;
30 template<
class Collection,
class Adaptor=noop::ParentCollectionAdaptor<Collection> >
36 _src(sumes.consumes<Collection>(conf.getParameter<
edm::InputTag>(
"source"))) {}
46 template<
class Collection,
class Adaptor>
52 elems.reserve(elems.size() + 2*pfparents->size());
54 auto TKs_end = std::partition(elems.begin(),elems.end(),
55 [](
const ElementType&
a){
59 auto bpar = pfparents->cbegin();
60 auto epar = pfparents->cend();
63 for(
auto pfparent = bpar; pfparent != epar; ++pfparent ) {
64 if( Adaptor::check_importable(*pfparent) ) {
66 const auto& pftracks = Adaptor::get_track_refs(*pfparent);
67 for(
const auto& pftrack : pftracks ) {
68 auto tk_elem = std::find_if(elems.begin(),TKs_end,
69 [&](
const ElementType&
a){
70 return (
a->trackRef() ==
71 pftrack->trackRef() );
73 if( tk_elem != TKs_end ) {
74 Adaptor::set_element_info(tk_elem->get(),parentRef);
77 Adaptor::set_element_info(trkElem,parentRef);
78 TKs_end = elems.insert(TKs_end,ElementType(trkElem));
84 elems.shrink_to_fit();
static bool check_importable(const typename Collection::value_type &)
Abstract base class for a PFBlock element (track, cluster...)
static void set_element_info(reco::PFBlockElement *, const typename edm::Ref< Collection > &)
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 &)
static const std::vector< reco::PFRecTrackRef > _empty
edm::EDGetTokenT< Collection > _src
TrackFromParentImporter(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList