73 auto const& emTracksters = *emTracksters_h;
76 auto egammaSuperclusters = std::make_unique<reco::SuperClusterCollection>();
77 auto caloClustersEM = std::make_unique<reco::CaloClusterCollection>();
81 std::vector<std::pair<DetId, float>> hitsAndFractions;
83 std::for_each(std::begin(emTrackster.vertices()), std::end(emTrackster.vertices()), [&](
unsigned int lcId) {
84 const auto fraction = 1.f / emTrackster.vertex_multiplicity(iLC++);
85 for (
const auto& cell :
layerClusters[lcId].hitsAndFractions()) {
86 hitsAndFractions.emplace_back(cell.first, cell.second *
fraction);
91 emTrackster.raw_energy(),
96 hitsAndFractions.at(0)
105 assert(ticlSuperclusters.size() == ticlSuperclusterLinks.size());
106 const unsigned int regressionFeatureCount = 8;
107 std::vector<float> regressionInputs;
108 regressionInputs.reserve(ticlSuperclusters.size() * regressionFeatureCount);
109 unsigned int superclustersPassingSelectionsCount = 0;
110 for (std::size_t sc_i = 0; sc_i < ticlSuperclusters.size(); sc_i++) {
114 std::vector<unsigned int>
const& superclusterLink = ticlSuperclusterLinks[sc_i];
115 assert(!superclusterLink.empty());
122 for (
unsigned int tsInSc_id : superclusterLink) {
130 egammaSuperclusters->emplace_back(
134 superclusterLink[0]),
135 trackstersEMInSupercluster,
140 superclustersPassingSelectionsCount++;
143 regressionInputs.insert(
144 regressionInputs.end(),
149 max_phi - min_phi >
M_PI ? 2 *
static_cast<float>(
M_PI) - (max_phi - min_phi) : max_phi - min_phi,
150 emTracksters[superclusterLink[0]].raw_energy() -
151 (superclusterLink.
size() >= 2 ? emTracksters[superclusterLink.back()].raw_energy() : 0.
f),
152 emTracksters[superclusterLink[0]].raw_energy() / ticlSupercluster.raw_energy(),
153 static_cast<
float>(superclusterLink.
size())});
160 std::vector<std::vector<float>> inputs_for_onnx{{
std::move(regressionInputs)}};
162 globalCache()->run({
"input"}, inputs_for_onnx, {}, {}, superclustersPassingSelectionsCount)[0];
165 for (std::size_t sc_i = 0; sc_i < egammaSuperclusters->size(); sc_i++) {
166 (*egammaSuperclusters)[sc_i].setCorrectedEnergy(
outputs[sc_i]);
const float raw_pt() const
const Vector & barycenter() const
edm::EDGetTokenT< ticl::TracksterCollection > ticlSuperClustersToken_
edm::EDGetTokenT< reco::CaloClusterCollection > layerClustersToken_
void setCorrectedEnergy(double cenergy)
const float raw_energy() const
edm::EDGetTokenT< ticl::TracksterCollection > ticlTrackstersEMToken_
Abs< T >::type abs(const T &t)
XYZPointD XYZPoint
point in space with cartesian internal representation
float superclusterEtThreshold_
edm::EDGetTokenT< std::vector< std::vector< unsigned int > > > superClusterLinksToken_