123 auto L1EGXtalClusters = std::make_unique<l1tp2::CaloCrystalClusterCollection>();
124 auto L1CaloTowers = std::make_unique<l1tp2::CaloTowerCollection>();
132 std::vector<p2eg::SimpleCaloHit> ecalhits;
134 for (
const auto&
hit : *pcalohits.product()) {
135 if (
hit.encodedEt() > 0)
138 float et =
hit.encodedEt() * 0.125;
151 (ap_uint<10>)
hit.encodedEt() >>
154 ecalhits.push_back(ehit);
161 std::vector<p2eg::SimpleCaloHit> hcalhits;
166 float et = decoder.hcaletValue(
hit.
id(),
hit.t0());
167 ap_uint<10> encodedEt =
hit.t0().compressedEt();
173 LogError(
"Phase2L1CaloEGammaEmulator")
174 <<
" -- Hcal hit DetID not present in HCAL Geom: " <<
hit.
id() << std::endl;
178 const std::vector<HcalDetId>& hcId = theTrigTowerGeometry.detIds(
hit.
id());
180 LogError(
"Phase2L1CaloEGammaEmulator") <<
"Cannot find any HCalDetId corresponding to " <<
hit.
id() << std::endl;
184 if (hcId[0].subdetId() > 1) {
188 for (
const auto& hcId_i : hcId) {
189 if (hcId_i.subdetId() > 1) {
194 if (cell ==
nullptr) {
198 hcal_tp_position = tmpVector;
209 hcalhits.push_back(hhit);
234 for (
const auto&
hit : ecalhits) {
236 if (
hit.isInCard(
cc)) {
239 int local_iEta =
hit.crystalLocaliEta(
cc);
240 int local_iPhi =
hit.crystalLocaliPhi(
cc);
255 int inRegion_crystal_iPhi = local_iPhi;
264 myLink.
addCrystalE(inLink_crystal_iEta, inLink_crystal_iPhi,
hit.et_uint());
271 for (
const auto&
hit : hcalhits) {
272 if (
hit.isInCard(
cc) &&
hit.pt() > 0) {
275 int local_iEta =
hit.crystalLocaliEta(
cc);
276 int local_iPhi =
hit.crystalLocaliPhi(
cc);
341 cluster_list[
cc].push_back(newCluster);
346 ap_uint<12> towerEtECAL[12];
350 for (
int i = 0;
i < 12;
i++) {
360 towerHCALCard[
iEta][iPhi][
cc] =
371 int towerEtaBoundaries[nRegionBoundariesEta][2] = {{15, 14}, {12, 11}, {9, 8}, {6, 5}, {3, 2}};
373 for (
int iBound = 0; iBound < nRegionBoundariesEta; iBound++) {
375 cluster_list[
cc], towerEtaBoundaries[iBound][0], towerEtaBoundaries[iBound][1],
cc);
381 if (!cluster_list[
cc].
empty()) {
391 int whichTowerPhiInCard = cExtra.
towerPhi();
392 ap_uint<12> oldTowerEt = towerECALCard[whichTowerEtaInCard][whichTowerPhiInCard][
cc].
et();
393 ap_uint<12> newTowerEt = (oldTowerEt + cExtra.
clusterEnergy());
394 ap_uint<4>
hoe = towerECALCard[whichTowerEtaInCard][whichTowerPhiInCard][
cc].
hoe();
395 towerECALCard[whichTowerEtaInCard][whichTowerPhiInCard][
cc] =
p2eg::tower_t(newTowerEt,
hoe);
400 for (
unsigned int kk = 0;
kk < cluster_list[
cc].size(); ++
kk) {
403 if (cluster_list[
cc][
kk].clusterEnergy() > 0) {
404 cluster_list_merged[
cc].push_back(cluster_list[
cc][
kk]);
412 for (
auto&
c : cluster_list_merged[
cc]) {
413 float realEta =
c.realEta(
cc);
415 c.applyCalibration(
c.calib);
421 for (
auto&
c : cluster_list_merged[
cc]) {
443 ap_uint<12> ecalEt = towerECALCard[
ii][
jj][
cc].
et();
444 ap_uint<12> hcalEt = towerHCALCard[
ii][
jj][
cc].
et();
452 for (
auto&
c : cluster_list_merged[
cc]) {
475 std::map<std::string, float>
params;
476 params[
"standaloneWP_showerShape"] =
c.getIsSS();
477 params[
"trkMatchWP_showerShape"] =
c.getIsLooseTkss();
478 cluster.setExperimentalParams(
params);
480 L1EGXtalClusters->push_back(cluster);
496 L1CaloTowers->push_back(l1CaloTower);
528 t.et = t0_ecal.
et() + t0_hcal.
et();
529 t.hoe = t0_ecal.
hoe();
531 t.ecalEt = t0_ecal.
et();
532 t.hcalEt = t0_hcal.
et();
543 for (
size_t iCluster = 0; (iCluster < cluster_list_merged[rcc].size()) &&
548 c.et =
c0.clusterEnergy();
552 c.towPhi =
c0.towerPhi();
553 c.crEta =
c0.clusterEta();
554 c.crPhi =
c0.clusterPhi();
555 c.et5x5 =
c0.uint_et5x5();
556 c.et2x5 =
c0.uint_et2x5();
557 c.is_ss =
c0.getIsSS();
558 c.is_looseTkss =
c0.getIsLooseTkss();
559 c.is_iso =
c0.getIsIso();
560 c.is_looseTkiso =
c0.getIsLooseTkIso();
561 c.brems =
c0.getBrems();
574 for (
size_t iZeroCluster = cluster_list_merged[rcc].
size();
606 auto L1GCTClusters = std::make_unique<l1tp2::CaloCrystalClusterCollection>();
607 auto L1GCTTowers = std::make_unique<l1tp2::CaloTowerCollection>();
608 auto L1GCTFullTowers = std::make_unique<l1tp2::CaloTowerCollection>();
609 auto L1GCTEGammas = std::make_unique<l1t::EGammaBxCollection>();
610 auto L1DigitizedClusterCorrelator = std::make_unique<l1tp2::DigitizedClusterCorrelatorCollection>();
611 auto L1DigitizedTowerCorrelator = std::make_unique<l1tp2::DigitizedTowerCorrelatorCollection>();
612 auto L1DigitizedClusterGT = std::make_unique<l1tp2::DigitizedClusterGTCollection>();
626 L1DigitizedClusterCorrelator,
627 L1DigitizedTowerCorrelator,
628 L1DigitizedClusterGT,
636 iEvent.put(
std::move(L1DigitizedClusterCorrelator),
"GCTDigitizedClusterToCorrelator");
637 iEvent.put(
std::move(L1DigitizedTowerCorrelator),
"GCTDigitizedTowerToCorrelator");
638 iEvent.put(
std::move(L1DigitizedClusterGT),
"GCTDigitizedClusterToGT");
void applyCalibration(float factor)
bool validHT(const HcalTrigTowerDetId &id) const
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecord > decoderTag_
void getECALTowersEt(crystal tempX[CRYSTAL_IN_ETA][CRYSTAL_IN_PHI], ap_uint< 12 > towerEt[12])
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
RCTcluster_t RCTclusters[N_RCTCLUSTERS_FIBER]
void setEcalTowerEt(float et)
uint32_t cc[maxCellsPerHit]
linkECAL & getLinkECAL(int iEta, int iPhi)
void setTowerIPhi(int iPhi)
T const * product() const
void setIdHcal(const HcalDetId &idhcal)
static constexpr int n_clusters_4link
void setPosition(const GlobalVector &pos)
void addCrystalE(int iEta, int iPhi, ap_uint< 10 > energy)
void setRegionIdx(int regIdx)
static constexpr int N_GCTTOWERS_FIBER
int getAbsID_iPhi_fromFirmwareCardTowerLink(int nCard, int nTower, int nLink)
const CaloSubdetectorGeometry * hbGeometry
Log< level::Error, false > LogError
l1tp2::ParametricCalibration calib_
static constexpr int N_REGIONS_PER_CARD
static constexpr int N_CLUSTERS_PER_REGION
RCTtower_t RCTtowers[N_RCTTOWERS_FIBER]
edm::EDGetTokenT< edm::SortedCollection< HcalTriggerPrimitiveDigi > > hcalTPToken_
void setHcalTowerEt(float et)
static constexpr int CRYSTAL_IN_ETA
void setTowerIEta(int iEta)
float getTowerPhi_fromAbsID(int id)
bool passes_looseTkss(float pt, float eta, float ss)
bool passes_ss(float pt, float eta, float ss)
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > hbTopologyTag_
Cluster getClusterFromRegion3x4(crystal temp[CRYSTAL_IN_ETA][CRYSTAL_IN_PHI])
void setTowerPhi(float phi)
edm::EDGetTokenT< EcalEBTrigPrimDigiCollection > ecalTPEBToken_
ap_uint< 5 > towerEta() const
static constexpr float HCAL_LSB
RCTcard_t RCTcardEtaNeg[N_RCTCARDS_PHI]
float getTowerEta_fromAbsID(int id)
static constexpr int N_RCTCARDS_PHI
towerHCAL & getTowerHCAL(int iEta, int iPhi)
static constexpr float ECAL_LSB
const CaloSubdetectorGeometry * ebGeometry
Abs< T >::type abs(const T &t)
static constexpr int n_towers_cardPhi
static constexpr int N_RCTGCT_FIBERS
static constexpr int N_RCTCLUSTERS_FIBER
void stitchClusterOverRegionBoundary(std::vector< Cluster > &cluster_list, int towerEtaUpper, int towerEtaLower, int cc)
int getRegionNumber(const int local_iEta)
static constexpr float cut_500_MeV
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
void setTowerEta(float eta)
void addEt(ap_uint< 10 > newEt)
static constexpr int TOWER_IN_PHI
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryTag_
ap_uint< 10 > getCrystalE(int iEta, int iPhi)
static constexpr int TOWER_IN_ETA
static constexpr int N_GCTCARDS
ap_uint< 2 > towerPhi() const
region3x4 & getRegion3x4(int idx)
void setEt_uint(ap_uint< 10 > et_uint)
RCTtoGCTfiber_t RCTtoGCTfiber[N_RCTGCT_FIBERS]
void setId(const EBDetId &id)
RCTcard_t RCTcardEtaPos[N_RCTCARDS_PHI]
ap_uint< 12 > clusterEnergy() const
towers3x4 & getTowers3x4(int idx)
static constexpr int CRYSTALS_IN_TOWER_ETA
static constexpr int n_towers_halfPhi
static constexpr int n_towers_cardEta
void addHoverEToTower(ap_uint< 12 > ECAL, ap_uint< 12 > HCAL)
static constexpr int n_links_card
void algo_top(const GCTcard_t &GCTcard, GCTtoCorr_t &GCTtoCorr, unsigned int nGCTCard, std::unique_ptr< l1tp2::CaloCrystalClusterCollection > const &gctClusters, std::unique_ptr< l1tp2::CaloTowerCollection > const &gctTowers, std::unique_ptr< l1tp2::CaloTowerCollection > const &gctFullTowers, std::unique_ptr< l1t::EGammaBxCollection > const &gctEGammas, std::unique_ptr< l1tp2::DigitizedClusterCorrelatorCollection > const &gctDigitizedClustersCorrelator, std::unique_ptr< l1tp2::DigitizedTowerCorrelatorCollection > const &gctDigitizedTowersCorrelator, std::unique_ptr< l1tp2::DigitizedClusterGTCollection > const &gctDigitizedClustersGT, l1tp2::ParametricCalibration calib_)
const HcalTopology * hcTopology_
static constexpr int CRYSTAL_IN_PHI
static constexpr int CRYSTALS_IN_TOWER_PHI
Global3DVector GlobalVector
int getAbsID_iEta_fromFirmwareCardTowerLink(int nCard, int nTower, int nLink)
bool compareClusterET(const Cluster &lhs, const Cluster &rhs)
static const unsigned int GCTcardtoRCTcardnumber[N_GCTCARDS][N_RCTCARDS_PHI *2]
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.