34 : layer_clusters_token_(consumes<
std::vector<
reco::CaloCluster>>(ps.getParameter<
edm::
InputTag>(
"LayerClusters"))),
35 tracksters_token_(consumes<
std::vector<
ticl::Trackster>>(ps.getParameter<
edm::
InputTag>(
"Tracksters"))) {
36 produces<std::vector<reco::HGCalMultiCluster>>();
45 descriptions.
add(
"multiClustersFromTrackstersProducer", desc);
49 auto multiclusters = std::make_unique<std::vector<reco::HGCalMultiCluster>>();
56 auto const& tracksters = *tracksterHandle;
57 auto const& layerClusters = *layer_clustersHandle;
60 for (
unsigned i = 0;
i < layerClusters.size(); ++
i) {
65 std::for_each(
std::begin(tracksters),
std::end(tracksters), [&](
auto const& trackster) {
68 if (!trackster.vertices().empty()) {
69 std::array<double, 3> baricenter{{0., 0., 0.}};
70 double total_weight = 0.;
73 std::for_each(
std::begin(trackster.vertices()),
std::end(trackster.vertices()), [&](
unsigned int idx) {
74 temp.push_back(clusterPtrs[
idx]);
76 for (
auto const& cell : clusterPtrs[
idx]->hitsAndFractions()) {
77 temp.addHitAndFraction(cell.first, cell.second *
fraction);
81 baricenter[0] += clusterPtrs[
idx]->x() *
weight;
82 baricenter[1] += clusterPtrs[
idx]->y() *
weight;
83 baricenter[2] += clusterPtrs[
idx]->z() *
weight;
87 return val / total_weight;
89 temp.setEnergy(total_weight);
90 temp.setCorrectedEnergy(total_weight);
93 temp.setTime(trackster.time(), trackster.timeError());
94 multiclusters->push_back(
temp);