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>
53 elems.reserve(elems.size() + 2*pfparents->size());
55 auto TKs_end = std::partition(elems.begin(),elems.end(),
56 [](
const ElementType&
a){
60 auto bpar = pfparents->cbegin();
61 auto epar = pfparents->cend();
64 for(
auto pfparent = bpar; pfparent != epar; ++pfparent ) {
65 if( Adaptor::check_importable(*pfparent) ) {
67 const auto& pftracks = Adaptor::get_track_refs(*pfparent);
68 for(
const auto& pftrack : pftracks ) {
69 auto tk_elem = std::find_if(elems.begin(),TKs_end,
70 [&](
const ElementType&
a){
71 return (
a->trackRef() ==
72 pftrack->trackRef() );
74 if( tk_elem != TKs_end ) {
75 Adaptor::set_element_info(tk_elem->get(),parentRef);
78 Adaptor::set_element_info(trkElem,parentRef);
79 TKs_end = elems.insert(TKs_end,ElementType(trkElem));
85 elems.shrink_to_fit();
static bool check_importable(const typename Collection::value_type &)
Abstract base class for a PFBlock element (track, cluster...)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
static void set_element_info(reco::PFBlockElement *, const typename edm::Ref< Collection > &)
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
void importToBlock(const edm::Event &, ElementList &) const override
TrackFromParentImporter(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList