CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
Phase2L1CaloPFClusterEmulator Class Reference

#include <L1Trigger/L1CaloTrigger/plugins/Phase2L1CaloPFClusterEmulator.cc>

Inheritance diagram for Phase2L1CaloPFClusterEmulator:
edm::stream::EDProducer<>

Public Member Functions

 Phase2L1CaloPFClusterEmulator (const edm::ParameterSet &)
 
 ~Phase2L1CaloPFClusterEmulator () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< l1tp2::CaloTowerCollectioncaloTowerToken_
 
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecorddecoderTag_
 
edm::EDGetTokenT< HcalTrigPrimDigiCollectionhfToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: Creates 3x3 PF clusters from GCTintTowers to be sent to correlator. Follows firmware logic, creates 8 clusters per (2+17+2)x(2+4+2).

Implementation: To be run together with Phase2L1CaloEGammaEmulator.

Definition at line 53 of file Phase2L1CaloPFClusterEmulator.cc.

Constructor & Destructor Documentation

◆ Phase2L1CaloPFClusterEmulator()

Phase2L1CaloPFClusterEmulator::Phase2L1CaloPFClusterEmulator ( const edm::ParameterSet iConfig)
explicit

Definition at line 72 of file Phase2L1CaloPFClusterEmulator.cc.

73  : caloTowerToken_(consumes<l1tp2::CaloTowerCollection>(iConfig.getParameter<edm::InputTag>("gctFullTowers"))),
74  hfToken_(consumes<HcalTrigPrimDigiCollection>(iConfig.getParameter<edm::InputTag>("hcalDigis"))),
75  decoderTag_(esConsumes<CaloTPGTranscoder, CaloTPGRecord>(edm::ESInputTag("", ""))) {
76  produces<l1tp2::CaloPFClusterCollection>("GCTPFCluster");
77 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecord > decoderTag_
edm::EDGetTokenT< HcalTrigPrimDigiCollection > hfToken_
edm::EDGetTokenT< l1tp2::CaloTowerCollection > caloTowerToken_

◆ ~Phase2L1CaloPFClusterEmulator()

Phase2L1CaloPFClusterEmulator::~Phase2L1CaloPFClusterEmulator ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

void Phase2L1CaloPFClusterEmulator::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 303 of file Phase2L1CaloPFClusterEmulator.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

303  {
305  desc.add<edm::InputTag>("gctFullTowers", edm::InputTag("l1tPhase2L1CaloEGammaEmulator", "GCTFullTowers"));
306  desc.add<edm::InputTag>("hcalDigis", edm::InputTag("simHcalTriggerPrimitiveDigis"));
307  descriptions.addWithDefaultLabel(desc);
308 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

void Phase2L1CaloPFClusterEmulator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 84 of file Phase2L1CaloPFClusterEmulator.cc.

References funct::abs(), caloTowerToken_, decoderTag_, l1tnanotables_cff::et, gctpf::GCTpfcluster_t::et, gctpf::GCTpfcluster_t::eta, gctpf::PFcluster_t::GCTpfclusters, edm::EventSetup::getData(), hfToken_, mps_fire::i, hit::id, hcalRecHitTable_cff::ieta, iEvent, hcalRecHitTable_cff::iphi, edm::HandleBase::isValid(), isotrackApplyRegressor::k, l1t::CaloTools::kHFBegin, l1t::CaloTools::kHFEnd, eostools::move(), nHfEta, nHfPhi, nHfRegions, nPFClusterSLR, nSLR, nTowerEta, nTowerEtaSLR, nTowerPhi, nTowerPhiSLR, gctpf::pfcluster(), gctpf::pfclusterHF(), gctpf::GCTpfcluster_t::phi, edm::Handle< T >::product(), l1tp2::CaloPFCluster::setClusterEt(), l1tp2::CaloPFCluster::setClusterEta(), l1tp2::CaloPFCluster::setClusterIEta(), l1tp2::CaloPFCluster::setClusterIPhi(), l1tp2::CaloPFCluster::setClusterPhi(), groupFilesInBlocks::temp, l1t::CaloTools::towerEta(), and l1t::CaloTools::towerPhi().

84  {
85  using namespace edm;
86  std::unique_ptr<l1tp2::CaloPFClusterCollection> pfclusterCands(make_unique<l1tp2::CaloPFClusterCollection>());
87 
88  edm::Handle<std::vector<l1tp2::CaloTower>> caloTowerCollection;
89  iEvent.getByToken(caloTowerToken_, caloTowerCollection);
90  if (!caloTowerCollection.isValid())
91  cms::Exception("Phase2L1CaloPFClusterEmulator") << "Failed to get towers from caloTowerCollection!";
92 
93  float GCTintTowers[nTowerEta][nTowerPhi];
94  float realEta[nTowerEta][nTowerPhi];
95  float realPhi[nTowerEta][nTowerPhi];
96  for (const l1tp2::CaloTower& i : *caloTowerCollection) {
97  int ieta = i.towerIEta();
98  int iphi = i.towerIPhi();
99  GCTintTowers[ieta][iphi] = i.ecalTowerEt();
100  realEta[ieta][iphi] = i.towerEta();
101  realPhi[ieta][iphi] = i.towerPhi();
102  }
103 
105 
106  for (int ieta = 0; ieta < nTowerEtaSLR; ieta++) {
107  for (int iphi = 0; iphi < nTowerPhiSLR; iphi++) {
108  for (int k = 0; k < nSLR; k++) {
109  regions[k][ieta][iphi] = 0.;
110  }
111  }
112  }
113 
114  //Assign ETs to 36 21x8 regions
115 
116  for (int ieta = 0; ieta < nTowerEtaSLR; ieta++) {
117  for (int iphi = 0; iphi < nTowerPhiSLR; iphi++) {
118  if (ieta > 1) {
119  if (iphi > 1)
120  regions[0][ieta][iphi] = GCTintTowers[ieta - 2][iphi - 2];
121  for (int k = 1; k < 17; k++) {
122  regions[k * 2][ieta][iphi] = GCTintTowers[ieta - 2][iphi + k * 4 - 2];
123  }
124  if (iphi < 6)
125  regions[34][ieta][iphi] = GCTintTowers[ieta - 2][iphi + 66];
126  }
127  if (ieta < 19) {
128  if (iphi > 1)
129  regions[1][ieta][iphi] = GCTintTowers[ieta + 15][iphi - 2];
130  for (int k = 1; k < 17; k++) {
131  regions[k * 2 + 1][ieta][iphi] = GCTintTowers[ieta + 15][iphi + k * 4 - 2];
132  }
133  if (iphi < 6)
134  regions[35][ieta][iphi] = GCTintTowers[ieta + 15][iphi + 66];
135  }
136  }
137  }
138 
139  float temporary[nTowerEtaSLR][nTowerPhiSLR];
140  int etaoffset = 0;
141  int phioffset = 0;
142 
143  //Use same code from firmware for finding clusters
144  for (int k = 0; k < nSLR; k++) {
145  for (int ieta = 0; ieta < nTowerEtaSLR; ieta++) {
146  for (int iphi = 0; iphi < nTowerPhiSLR; iphi++) {
147  temporary[ieta][iphi] = regions[k][ieta][iphi];
148  }
149  }
150  if (k % 2 == 0)
151  etaoffset = 0;
152  else
153  etaoffset = 17;
154  if (k > 1 && k % 2 == 0)
155  phioffset = phioffset + 4;
156 
157  gctpf::PFcluster_t tempPfclusters;
158  tempPfclusters = gctpf::pfcluster(temporary, etaoffset, phioffset);
159 
160  for (int i = 0; i < nPFClusterSLR; i++) {
161  int gcteta = tempPfclusters.GCTpfclusters[i].eta;
162  int gctphi = tempPfclusters.GCTpfclusters[i].phi;
163  float towereta = realEta[gcteta][gctphi];
164  float towerphi = realPhi[gcteta][gctphi];
165  l1tp2::CaloPFCluster l1CaloPFCluster;
166  l1CaloPFCluster.setClusterEt(tempPfclusters.GCTpfclusters[i].et);
167  l1CaloPFCluster.setClusterIEta(gcteta);
168  l1CaloPFCluster.setClusterIPhi(gctphi);
169  l1CaloPFCluster.setClusterEta(towereta);
170  l1CaloPFCluster.setClusterPhi(towerphi);
171  pfclusterCands->push_back(l1CaloPFCluster);
172  }
173  }
174 
176  if (!iEvent.getByToken(hfToken_, hfHandle))
177  edm::LogError("Phase2L1CaloJetEmulator") << "Failed to get HcalTrigPrimDigi for HF!";
178  iEvent.getByToken(hfToken_, hfHandle);
179 
180  float hfTowers[2 * nHfEta][nHfPhi]; // split 12 -> 24
181  float hfEta[nHfEta][nHfPhi];
182  float hfPhi[nHfEta][nHfPhi];
183  for (int iphi = 0; iphi < nHfPhi; iphi++) {
184  for (int ieta = 0; ieta < nHfEta; ieta++) {
185  hfTowers[2 * ieta][iphi] = 0;
186  hfTowers[2 * ieta + 1][iphi] = 0;
187  int temp;
188  if (ieta < nHfEta / 2)
190  else
193  hfPhi[ieta][iphi] = l1t::CaloTools::towerPhi(temp, iphi + 1);
194  }
195  }
196 
197  float regionsHF[nHfRegions][nHfEta]
198  [nHfPhi /
199  6]; // 6 regions each 3 sectors (1 sector = 20 deg in phi), 12x12->24x12 unique towers, no overlap in phi
200 
201  for (int ieta = 0; ieta < nHfEta; ieta++) {
202  for (int iphi = 0; iphi < nHfPhi / 6; iphi++) {
203  for (int k = 0; k < nHfRegions; k++) {
204  regionsHF[k][ieta][iphi] = 0.;
205  }
206  }
207  }
208 
209  // Assign ET to 12 24x12 regions
210  const auto& decoder = iSetup.getData(decoderTag_);
211  for (const auto& hit : *hfHandle.product()) {
212  double et = decoder.hcaletValue(hit.id(), hit.t0());
213  int ieta = 0;
214  if (abs(hit.id().ieta()) < l1t::CaloTools::kHFBegin)
215  continue;
216  if (abs(hit.id().ieta()) > l1t::CaloTools::kHFEnd)
217  continue;
218  if (hit.id().ieta() <= -(l1t::CaloTools::kHFBegin + 1)) {
219  ieta = hit.id().ieta() + l1t::CaloTools::kHFEnd;
220  } else if (hit.id().ieta() >= (l1t::CaloTools::kHFBegin + 1)) {
221  ieta = nHfEta / 2 + (hit.id().ieta() - (l1t::CaloTools::kHFBegin + 1));
222  }
223  int iphi = hit.id().iphi() - 1; // HF phi runs between 1-72
224  // split tower energy
225  hfTowers[2 * ieta][iphi] = et / 2;
226  hfTowers[2 * ieta + 1][iphi] = et / 2;
227  if ((ieta < 2 || ieta >= nHfEta - 2) && iphi % 4 == 2) {
228  hfTowers[2 * ieta][iphi] = et / 8;
229  hfTowers[2 * ieta + 1][iphi] = et / 8;
230  hfTowers[2 * ieta][iphi + 1] = et / 8;
231  hfTowers[2 * ieta + 1][iphi + 1] = et / 8;
232  hfTowers[2 * ieta][iphi + 2] = et / 8;
233  hfTowers[2 * ieta + 1][iphi + 2] = et / 8;
234  hfTowers[2 * ieta][iphi + 3] = et / 8;
235  hfTowers[2 * ieta + 1][iphi + 3] = et / 8;
236  } else if ((ieta >= 2 && ieta < nHfEta - 2) && iphi % 2 == 0) {
237  hfTowers[2 * ieta][iphi] = et / 4;
238  hfTowers[2 * ieta + 1][iphi] = et / 4;
239  hfTowers[2 * ieta][iphi + 1] = et / 4;
240  hfTowers[2 * ieta + 1][iphi + 1] = et / 4;
241  }
242  }
243 
244  for (int ieta = 0; ieta < 2 * nHfEta; ieta++) {
245  for (int iphi = 0; iphi < nHfPhi / 6; iphi++) {
246  if (ieta < nHfEta) {
247  regionsHF[0][ieta][0] = hfTowers[ieta][70];
248  regionsHF[0][ieta][1] = hfTowers[ieta][71];
249  for (int k = 0; k < nHfRegions; k += 2) {
250  if (k != 0 || iphi > 1)
251  regionsHF[k][ieta][iphi] = hfTowers[ieta][iphi + k * (nHfRegions / 2) - 2];
252  }
253  } else {
254  regionsHF[1][ieta - nHfEta][0] = hfTowers[ieta][70];
255  regionsHF[1][ieta - nHfEta][1] = hfTowers[ieta][71];
256  for (int k = 1; k < nHfRegions; k += 2) {
257  if (k != 1 || iphi > 1)
258  regionsHF[k][ieta - nHfEta][iphi] = hfTowers[ieta][iphi + (k - 1) * (nHfRegions / 2) - 2];
259  }
260  }
261  }
262  }
263 
264  float temporaryHF[nHfEta][nHfPhi / 6];
265  int etaoffsetHF = 0;
266  int phioffsetHF = -2;
267 
268  for (int k = 0; k < nHfRegions; k++) {
269  for (int ieta = 0; ieta < nHfEta; ieta++) {
270  for (int iphi = 0; iphi < nHfPhi / 6; iphi++) {
271  temporaryHF[ieta][iphi] = regionsHF[k][ieta][iphi];
272  }
273  }
274  if (k % 2 == 0)
275  etaoffsetHF = 0;
276  else
277  etaoffsetHF = nHfEta;
278  if (k > 1 && k % 2 == 0)
279  phioffsetHF = phioffsetHF + nHfPhi / 6;
280 
281  gctpf::PFcluster_t tempPfclustersHF;
282  tempPfclustersHF = gctpf::pfclusterHF(temporaryHF, etaoffsetHF, phioffsetHF);
283 
284  for (int i = 0; i < nPFClusterSLR; i++) {
285  int hfeta = tempPfclustersHF.GCTpfclusters[i].eta / 2; // turn back 24 -> 12
286  int hfphi = tempPfclustersHF.GCTpfclusters[i].phi;
287  float towereta = hfEta[hfeta][hfphi];
288  float towerphi = hfPhi[hfeta][hfphi];
289  l1tp2::CaloPFCluster l1CaloPFCluster;
290  l1CaloPFCluster.setClusterEt(tempPfclustersHF.GCTpfclusters[i].et);
291  l1CaloPFCluster.setClusterIEta(hfeta);
292  l1CaloPFCluster.setClusterIPhi(hfphi);
293  l1CaloPFCluster.setClusterEta(towereta);
294  l1CaloPFCluster.setClusterPhi(towerphi);
295  pfclusterCands->push_back(l1CaloPFCluster);
296  }
297  }
298 
299  iEvent.put(std::move(pfclusterCands), "GCTPFCluster");
300 }
void setClusterEta(float clusterEtaIn)
Definition: CaloPFCluster.h:43
static float towerEta(int ieta)
Definition: CaloTools.cc:201
static constexpr int nHfRegions
PFcluster_t pfclusterHF(float temporary[nHfEta][nHfPhi/6], int etaoffset, int phioffset)
static float towerPhi(int ieta, int iphi)
Definition: CaloTools.cc:208
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
static constexpr int nPFClusterSLR
void setClusterIPhi(int clusterIPhiIn)
Definition: CaloPFCluster.h:42
T const * product() const
Definition: Handle.h:70
static constexpr int nSLR
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecord > decoderTag_
static const int kHFBegin
Definition: CaloTools.h:39
static constexpr int nHfPhi
int iEvent
Definition: GenABIO.cc:224
GCTpfcluster_t GCTpfclusters[nPFClusterSLR]
static const int kHFEnd
Definition: CaloTools.h:40
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< HcalTrigPrimDigiCollection > hfToken_
static constexpr int nTowerEtaSLR
unsigned int id
static constexpr int nTowerEta
PFcluster_t pfcluster(float temporary[nTowerEtaSLR][nTowerPhiSLR], int etaoffset, int phioffset)
static constexpr int nTowerPhiSLR
static constexpr int nTowerPhi
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
static constexpr int nHfEta
void setClusterPhi(float clusterPhiIn)
Definition: CaloPFCluster.h:44
void setClusterIEta(int clusterIEtaIn)
Definition: CaloPFCluster.h:41
edm::EDGetTokenT< l1tp2::CaloTowerCollection > caloTowerToken_
def move(src, dest)
Definition: eostools.py:511
void setClusterEt(float clusterEtIn)
Definition: CaloPFCluster.h:40

Member Data Documentation

◆ caloTowerToken_

edm::EDGetTokenT<l1tp2::CaloTowerCollection> Phase2L1CaloPFClusterEmulator::caloTowerToken_
private

Definition at line 64 of file Phase2L1CaloPFClusterEmulator.cc.

Referenced by produce().

◆ decoderTag_

edm::ESGetToken<CaloTPGTranscoder, CaloTPGRecord> Phase2L1CaloPFClusterEmulator::decoderTag_
private

Definition at line 66 of file Phase2L1CaloPFClusterEmulator.cc.

Referenced by produce().

◆ hfToken_

edm::EDGetTokenT<HcalTrigPrimDigiCollection> Phase2L1CaloPFClusterEmulator::hfToken_
private

Definition at line 65 of file Phase2L1CaloPFClusterEmulator.cc.

Referenced by produce().