CMS 3D CMS Logo

SpecialClusterImporter.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 template <reco::PFBlockElement::Type T>
16 public:
18  : BlockElementImporterBase(conf, sumes),
19  _src(sumes.consumes<reco::PFClusterCollection>(conf.getParameter<edm::InputTag>("source"))),
20  _assoc(sumes.consumes<edm::ValueMap<reco::CaloClusterPtr> >(conf.getParameter<edm::InputTag>("BCtoPFCMap"))) {}
21 
22  void importToBlock(const edm::Event&, ElementList&) const override;
23 
24 private:
27 };
28 
29 template <reco::PFBlockElement::Type T>
32  auto clusters = e.getHandle(_src);
33  auto assoc = e.getHandle(_assoc);
34  auto bclus = clusters->cbegin();
35  auto eclus = clusters->cend();
36  // get all the SCs in the element list
37  auto sc_end = std::partition(elems.begin(), elems.end(), [](const ElementList::value_type& o) {
38  return o->type() == reco::PFBlockElement::SC;
39  });
40  ecals.reserve(clusters->size());
41  for (auto clus = bclus; clus != eclus; ++clus) {
42  reco::PFClusterRef tempref(clusters, std::distance(bclus, clus));
44  for (auto scelem = elems.begin(); scelem != sc_end; ++scelem) {
45  const reco::PFBlockElementSuperCluster* elem_as_sc =
46  static_cast<const reco::PFBlockElementSuperCluster*>(scelem->get());
47  const reco::SuperClusterRef& this_sc = elem_as_sc->superClusterRef();
48 
49  const bool in_sc = (elem_as_sc->fromPFSuperCluster() ?
50  // use association map if from PFSC
51  ClusterClusterMapping::overlap(tempref, *this_sc, *assoc)
52  :
53  // match by overlapping rechit otherwise
54  ClusterClusterMapping::overlap(*tempref, *this_sc));
55  if (in_sc) {
56  newelem->setSuperClusterRef(this_sc);
57  break;
58  }
59  }
60  ecals.emplace_back(newelem);
61  }
62  elems.reserve(elems.size() + ecals.size());
63  for (auto& ecal : ecals) {
64  elems.emplace_back(ecal.release());
65  }
66 }
67 
70 
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
edm::Ptr< CaloCluster > CaloClusterPtr
edm::EDGetTokenT< reco::PFClusterCollection > _src
SpecialClusterImporter< reco::PFBlockElement::HGCAL > HGCalClusterImporter
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:547
SpecialClusterImporter< reco::PFBlockElement::ECAL > ECALClusterImporter
fixed size matrix
HLT enums.
SpecialClusterImporter(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
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 importToBlock(const edm::Event &, ElementList &) const override
void setSuperClusterRef(const SuperClusterRef &ref)
long double T