89 std::unordered_map<uint32_t, CaloParticleRef> tcToCalo;
92 std::unordered_map<uint32_t, std::pair<double, double>>
95 for (
auto const&
he : hitToEnergy) {
98 uint32_t tcId(
geometry.getTriggerCellFromCell(hitId));
99 tcToEnergies[tcId].first +=
he.second;
103 std::map<int, CaloParticleRef> orderedCaloRefs;
107 if (caloParticle.g4Tracks().at(0).eventId().event() != 0)
113 for (
auto const& simCluster : simClusters) {
114 for (
auto const& hAndF : simCluster->hits_and_fractions()) {
115 DetId hitId(hAndF.first);
118 tcId =
geometry.getTriggerCellFromCell(hitId);
124 tcToCalo.emplace(tcId, ref);
125 tcToEnergies[tcId].second += hitToEnergy[hAndF.first] * hAndF.second;
130 int genIndex(caloParticle.g4Tracks().at(0).genpartIndex() - 1);
131 orderedCaloRefs[genIndex] = ref;
134 auto outMap(std::make_unique<CaloToCellsMap>(caloParticlesHandle, triggerCellsHandle));
135 std::unique_ptr<l1t::HGCalTriggerCellBxCollection> outCollection;
137 outCollection = std::make_unique<l1t::HGCalTriggerCellBxCollection>();
143 std::vector<TriggerCellPtr> triggerCellPtrs;
148 auto const& cell(*cItr);
150 auto mapElem(tcToCalo.find(cell.detId()));
151 if (mapElem == tcToCalo.end())
154 outMap->insert(mapElem->second,
158 auto const& simEnergies(tcToEnergies.at(cell.detId()));
159 if (simEnergies.first > 0.) {
160 double eFraction(simEnergies.second / simEnergies.first);
162 outCollection->push_back(
bx, cell);
163 auto& newCell((*outCollection)[outCollection->size() - 1]);
165 newCell.setMipPt(cell.mipPt() * eFraction);
166 newCell.setP4(cell.p4() * eFraction);
170 triggerCellPtrs.emplace_back(triggerCellsHandle,
triggerCells.key(cItr));
178 auto outClusters(std::make_unique<l1t::HGCalClusterBxCollection>());
181 [](TriggerCellPtr
const& lhs, TriggerCellPtr
const& rhs) ->
bool {
return lhs->mipPt() > rhs->mipPt(); });
183 std::sort(triggerCellPtrs.begin(), triggerCellPtrs.end(), sortCellPtrs);
186 std::unordered_map<unsigned, std::vector<unsigned>> caloToClusterIndices;
187 for (
unsigned iC(0); iC != outClusters->size(); ++iC) {
188 auto const& cluster((*outClusters)[iC]);
190 auto caloRef(tcToCalo.at(cluster.detId()));
191 caloToClusterIndices[caloRef.key()].push_back(iC);
196 auto outMulticlusters(std::make_unique<l1t::HGCalMulticlusterBxCollection>());
198 for (
auto const& ocr : orderedCaloRefs) {
199 auto const& ref(ocr.second);
204 auto const& caloParticle(*ref);
208 for (
unsigned iC : caloToClusterIndices[ref.key()]) {
209 ClusterPtr clPtr(clustersHandle, iC);
214 multicluster.
setDetId(caloParticle.g4Tracks().at(0).genpartIndex() - 1);
216 auto const& centre(multicluster.
centre());
218 multicluster.
setP4(multiclusterP4);
227 outMulticlusters->push_back(0, multicluster);
void addConstituent(const edm::Ptr< C > &c, bool updateCentre=true, float fraction=1.)
HGCalClusteringDummyImpl dummyClustering_
void setDetId(uint32_t id)
void setGeometry(const HGCalTriggerGeometryBase *const geom)
edm::ESGetToken< HGCalTriggerGeometryBase, CaloGeometryRecord > triggerGeomToken_
Log< level::Error, false > LogError
void clusterizeDummy(const std::vector< edm::Ptr< l1t::HGCalTriggerCell >> &triggerCellsPtrs, l1t::HGCalClusterBxCollection &clusters)
const GlobalPoint & centre() const
std::unordered_map< uint32_t, double > makeHitMap(edm::Event const &, edm::EventSetup const &, HGCalTriggerGeometryBase const &) const
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
edm::EDGetTokenT< l1t::HGCalTriggerCellBxCollection > triggerCellsToken_
void setGeometry(const HGCalTriggerGeometryBase *const geom)
void fillShapes(l1t::HGCalMulticluster &, const HGCalTriggerGeometryBase &) const
edm::EDGetTokenT< CaloParticleCollection > caloParticlesToken_
bool makeCellsCollection_
HGCalTriggerTools triggerTools_
HGCalShowerShape showerShape_
char const * what() const noexcept override
void setP4(const LorentzVector &p4) final
set 4-momentum