88 auto const&
geometry(*geometryHandle);
90 std::unordered_map<uint32_t, CaloParticleRef> tcToCalo;
93 std::unordered_map<uint32_t, std::pair<double, double>>
96 for (
auto const&
he : hitToEnergy) {
99 uint32_t tcId(
geometry.getTriggerCellFromCell(hitId));
100 tcToEnergies[tcId].first +=
he.second;
104 std::map<int, CaloParticleRef> orderedCaloRefs;
108 if (caloParticle.g4Tracks().at(0).eventId().event() != 0)
114 for (
auto const& simCluster : simClusters) {
115 for (
auto const& hAndF : simCluster->hits_and_fractions()) {
116 DetId hitId(hAndF.first);
119 tcId =
geometry.getTriggerCellFromCell(hitId);
125 tcToCalo.emplace(tcId, ref);
126 tcToEnergies[tcId].second += hitToEnergy[hAndF.first] * hAndF.second;
131 int genIndex(caloParticle.g4Tracks().at(0).genpartIndex() - 1);
132 orderedCaloRefs[genIndex] = ref;
135 auto outMap(std::make_unique<CaloToCellsMap>(caloParticlesHandle, triggerCellsHandle));
136 std::unique_ptr<l1t::HGCalTriggerCellBxCollection> outCollection;
138 outCollection = std::make_unique<l1t::HGCalTriggerCellBxCollection>();
144 std::vector<TriggerCellPtr> triggerCellPtrs;
149 auto const& cell(*cItr);
151 auto mapElem(tcToCalo.find(cell.detId()));
152 if (mapElem == tcToCalo.end())
155 outMap->insert(mapElem->second,
159 auto const& simEnergies(tcToEnergies.at(cell.detId()));
160 if (simEnergies.first > 0.) {
161 double eFraction(simEnergies.second / simEnergies.first);
163 outCollection->push_back(
bx, cell);
164 auto& newCell((*outCollection)[outCollection->size() - 1]);
166 newCell.setMipPt(cell.mipPt() * eFraction);
167 newCell.setP4(cell.p4() * eFraction);
171 triggerCellPtrs.emplace_back(triggerCellsHandle,
triggerCells.key(cItr));
179 auto outClusters(std::make_unique<l1t::HGCalClusterBxCollection>());
182 [](TriggerCellPtr
const& lhs, TriggerCellPtr
const& rhs) ->
bool {
return lhs->mipPt() > rhs->mipPt(); });
184 std::sort(triggerCellPtrs.begin(), triggerCellPtrs.end(), sortCellPtrs);
187 std::unordered_map<unsigned, std::vector<unsigned>> caloToClusterIndices;
188 for (
unsigned iC(0); iC != outClusters->size(); ++iC) {
189 auto const& cluster((*outClusters)[iC]);
191 auto caloRef(tcToCalo.at(cluster.detId()));
192 caloToClusterIndices[caloRef.key()].push_back(iC);
197 auto outMulticlusters(std::make_unique<l1t::HGCalMulticlusterBxCollection>());
199 for (
auto const& ocr : orderedCaloRefs) {
200 auto const& ref(ocr.second);
205 auto const& caloParticle(*ref);
209 for (
unsigned iC : caloToClusterIndices[ref.key()]) {
210 ClusterPtr clPtr(clustersHandle, iC);
215 multicluster.
setDetId(caloParticle.g4Tracks().at(0).genpartIndex() - 1);
217 auto const& centre(multicluster.
centre());
219 multicluster.
setP4(multiclusterP4);
228 outMulticlusters->push_back(0, multicluster);
void addConstituent(const edm::Ptr< C > &c, bool updateCentre=true, float fraction=1.)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
HGCalClusteringDummyImpl dummyClustering_
void eventSetup(const edm::EventSetup &es)
void setDetId(uint32_t id)
char const * what() const override
void clusterizeDummy(const std::vector< edm::Ptr< l1t::HGCalTriggerCell >> &triggerCellsPtrs, l1t::HGCalClusterBxCollection &clusters)
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
edm::EDGetTokenT< l1t::HGCalTriggerCellBxCollection > triggerCellsToken_
const GlobalPoint & centre() const
edm::EDGetTokenT< CaloParticleCollection > caloParticlesToken_
bool makeCellsCollection_
void eventSetup(const edm::EventSetup &es)
void fillShapes(l1t::HGCalMulticluster &, const HGCalTriggerGeometryBase &) const
ESHandle< TrackerGeometry > geometry
HGCalTriggerTools triggerTools_
HGCalShowerShape showerShape_
void setP4(const LorentzVector &p4) final
set 4-momentum
std::unordered_map< uint32_t, double > makeHitMap(edm::Event const &, edm::EventSetup const &, HGCalTriggerGeometryBase const &) const