CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ECALClusterImporter.cc
Go to the documentation of this file.
10 
11 // NOTE! This should come *after* and importers that bring in super clusters
12 // of their own (like electron seeds or photons)
13 // otherwise ECAL <-> ECAL linking will not work correctly
14 
16 public:
18  edm::ConsumesCollector& sumes) :
19  BlockElementImporterBase(conf,sumes),
20  _src(sumes.consumes<reco::PFClusterCollection>(conf.getParameter<edm::InputTag>("source"))),
21  _assoc(sumes.consumes<edm::ValueMap<reco::CaloClusterPtr> >(conf.getParameter<edm::InputTag>("BCtoPFCMap"))) {}
22 
23  void importToBlock( const edm::Event& ,
24  ElementList& ) const override;
25 
26 private:
29 };
30 
33  "ECALClusterImporter");
34 
41  e.getByToken(_src,clusters);
42  e.getByToken(_assoc,assoc);
43  auto bclus = clusters->cbegin();
44  auto eclus = clusters->cend();
45  // get all the SCs in the element list
46  auto sc_end = std::partition(elems.begin(),elems.end(),
47  [](const ElementList::value_type& o){
48  return o->type() == reco::PFBlockElement::SC;
49  });
50  ecals.reserve(clusters->size());
51  for( auto clus = bclus; clus != eclus; ++clus ) {
52  reco::PFClusterRef tempref(clusters, std::distance(bclus,clus));
53  reco::PFBlockElementCluster* newelem =
55  for( auto scelem = elems.begin(); scelem != sc_end; ++scelem ) {
56  const reco::PFBlockElementSuperCluster* elem_as_sc =
57  static_cast<const reco::PFBlockElementSuperCluster*>(scelem->get());
58  const reco::SuperClusterRef& this_sc = elem_as_sc->superClusterRef();
59  const bool in_sc = ( elem_as_sc->fromPFSuperCluster() ?
60  // use association map if from PFSC
62  *this_sc,
63  *assoc) :
64  // match by overlapping rechit otherwise
66  *this_sc) );
67  if( in_sc ) {
68  newelem->setSuperClusterRef(this_sc);
69  break;
70  }
71  }
72  ecals.emplace_back(newelem);
73  }
74  elems.reserve(elems.size()+ecals.size());
75  for( auto& ecal : ecals ) {
76  elems.emplace_back(ecal.release());
77  }
78 }
const SuperClusterRef & superClusterRef() const
static bool overlap(const reco::CaloCluster &sc1, const reco::CaloCluster &sc, float minfrac=0.01, bool debug=false)
edm::EDGetTokenT< edm::ValueMap< reco::CaloClusterPtr > > _assoc
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::Ptr< CaloCluster > CaloClusterPtr
edm::EDGetTokenT< reco::PFClusterCollection > _src
Container::value_type value_type
tuple conf
Definition: dbtoconf.py:185
void importToBlock(const edm::Event &, ElementList &) const override
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
void setSuperClusterRef(const SuperClusterRef &ref)
ECALClusterImporter(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)