Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:33

0001 #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/tdr_regionizer_ref.h"
0002 #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/tdr_regionizer_elements_ref.icc"
0003 
0004 #include <iostream>
0005 
0006 #ifdef CMSSW_GIT_HASH
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0009 
0010 l1ct::TDRRegionizerEmulator::TDRRegionizerEmulator(const edm::ParameterSet& iConfig)
0011     : TDRRegionizerEmulator(iConfig.getParameter<uint32_t>("nTrack"),
0012                             iConfig.getParameter<uint32_t>("nCalo"),
0013                             iConfig.getParameter<uint32_t>("nEmCalo"),
0014                             iConfig.getParameter<uint32_t>("nMu"),
0015                             iConfig.getParameter<uint32_t>("nClocks"),
0016                             iConfig.getParameter<std::vector<int32_t>>("bigRegionEdges"),
0017                             iConfig.getParameter<bool>("doSort")) {
0018   debug_ = iConfig.getUntrackedParameter<bool>("debug");
0019 }
0020 
0021 edm::ParameterSetDescription l1ct::TDRRegionizerEmulator::getParameterSetDescription() {
0022   edm::ParameterSetDescription description;
0023   description.add<uint32_t>("nClocks", 162);
0024   description.add<uint32_t>("nTrack", 22);
0025   description.add<uint32_t>("nCalo", 15);
0026   description.add<uint32_t>("nEmCalo", 12);
0027   description.add<uint32_t>("nMu", 2);
0028   description.add<bool>("doSort", false);
0029   description.add<std::vector<int32_t>>("bigRegionEdges", {-560, -80, 400, -560});
0030   description.addUntracked<bool>("debug", false);
0031   return description;
0032 }
0033 #endif
0034 
0035 l1ct::TDRRegionizerEmulator::TDRRegionizerEmulator(uint32_t ntk,
0036                                                    uint32_t ncalo,
0037                                                    uint32_t nem,
0038                                                    uint32_t nmu,
0039                                                    uint32_t nclocks,
0040                                                    std::vector<int32_t> bigRegionEdges,
0041                                                    bool dosort)
0042     : RegionizerEmulator(),
0043       ntk_(ntk),
0044       ncalo_(ncalo),
0045       nem_(nem),
0046       nmu_(nmu),
0047       nclocks_(nclocks),
0048       bigRegionEdges_(bigRegionEdges),
0049       dosort_(dosort),
0050       netaInBR_(6),
0051       nphiInBR_(3),
0052       init_(false) {
0053   nBigRegions_ = bigRegionEdges_.size() - 1;
0054 }
0055 
0056 l1ct::TDRRegionizerEmulator::~TDRRegionizerEmulator() {}
0057 
0058 void l1ct::TDRRegionizerEmulator::initSectorsAndRegions(const RegionizerDecodedInputs& in,
0059                                                         const std::vector<PFInputRegion>& out) {
0060   if (debug_) {
0061     dbgCout() << "doing init, out_size = " << out.size() << std::endl;
0062   }
0063   assert(!init_);
0064   init_ = true;
0065 
0066   for (unsigned int i = 0; i < nBigRegions_; i++) {
0067     tkRegionizers_.emplace_back(
0068         netaInBR_, nphiInBR_, ntk_, bigRegionEdges_[i], bigRegionEdges_[i + 1], nclocks_, 1, false);
0069     // duplicate input fibers to increase to increasee the throughput, since lots of data comes in per fiber
0070     hadCaloRegionizers_.emplace_back(
0071         netaInBR_, nphiInBR_, ncalo_, bigRegionEdges_[i], bigRegionEdges_[i + 1], nclocks_, 2, false);
0072     emCaloRegionizers_.emplace_back(
0073         netaInBR_, nphiInBR_, nem_, bigRegionEdges_[i], bigRegionEdges_[i + 1], nclocks_, 1, false);
0074     muRegionizers_.emplace_back(
0075         netaInBR_, nphiInBR_, nmu_, bigRegionEdges_[i], bigRegionEdges_[i + 1], nclocks_, 1, false);
0076   }
0077 
0078   if (debug_) {
0079     dbgCout() << "in.track.size() = " << in.track.size() << std::endl;
0080     dbgCout() << "in.hadcalo.size() = " << in.hadcalo.size() << std::endl;
0081     dbgCout() << "in.emcalo.size() = " << in.emcalo.size() << std::endl;
0082   }
0083 
0084   if (ntk_) {
0085     for (unsigned int i = 0; i < nBigRegions_; i++) {
0086       tkRegionizers_[i].initSectors(in.track);
0087       tkRegionizers_[i].initRegions(out);
0088     }
0089   }
0090   if (ncalo_) {
0091     for (unsigned int i = 0; i < nBigRegions_; i++) {
0092       hadCaloRegionizers_[i].initSectors(in.hadcalo);
0093       hadCaloRegionizers_[i].initRegions(out);
0094     }
0095   }
0096   if (nem_) {
0097     for (unsigned int i = 0; i < nBigRegions_; i++) {
0098       emCaloRegionizers_[i].initSectors(in.emcalo);
0099       emCaloRegionizers_[i].initRegions(out);
0100     }
0101   }
0102   if (nmu_) {
0103     for (unsigned int i = 0; i < nBigRegions_; i++) {
0104       muRegionizers_[i].initSectors(in.muon);
0105       muRegionizers_[i].initRegions(out);
0106     }
0107   }
0108 }
0109 
0110 void l1ct::TDRRegionizerEmulator::run(const RegionizerDecodedInputs& in, std::vector<PFInputRegion>& out) {
0111   if (debug_) {
0112     dbgCout() << "TDRRegionizerEmulator::run called, out.size =  " << out.size() << std::endl;
0113   }
0114 
0115   if (!init_) {
0116     initSectorsAndRegions(in, out);
0117   }
0118 
0119   for (unsigned int ie = 0; ie < nBigRegions_; ie++) {
0120     //add objects from link
0121     tkRegionizers_[ie].reset();
0122     tkRegionizers_[ie].fillBuffers(in.track);
0123     tkRegionizers_[ie].run();
0124 
0125     emCaloRegionizers_[ie].reset();
0126     emCaloRegionizers_[ie].fillBuffers(in.emcalo);
0127     emCaloRegionizers_[ie].run();
0128 
0129     hadCaloRegionizers_[ie].reset();
0130     hadCaloRegionizers_[ie].fillBuffers(in.hadcalo);
0131     hadCaloRegionizers_[ie].run();
0132 
0133     muRegionizers_[ie].reset();
0134     muRegionizers_[ie].fillBuffers(in.muon);
0135     muRegionizers_[ie].run();
0136   }
0137 
0138   for (unsigned int ie = 0; ie < nBigRegions_; ie++) {
0139     auto regionTrackMap = tkRegionizers_[ie].fillRegions(dosort_);
0140     for (auto& pr : regionTrackMap) {
0141       out[pr.first].track = pr.second;
0142     }
0143     auto regionEmCaloMap = emCaloRegionizers_[ie].fillRegions(dosort_);
0144     for (auto& pr : regionEmCaloMap) {
0145       out[pr.first].emcalo = pr.second;
0146     }
0147     auto regionHadCaloMap = hadCaloRegionizers_[ie].fillRegions(dosort_);
0148     for (auto& pr : regionHadCaloMap) {
0149       out[pr.first].hadcalo = pr.second;
0150     }
0151     auto regionMuMap = muRegionizers_[ie].fillRegions(dosort_);
0152     for (auto& pr : regionMuMap) {
0153       out[pr.first].muon = pr.second;
0154     }
0155   }
0156 }