Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/Phase2L1ParticleFlow/interface/egamma/l2egsorter_ref.h"
0002 
0003 #include <cmath>
0004 #include <cstdio>
0005 #include <algorithm>
0006 #include <memory>
0007 #include <iostream>
0008 
0009 using namespace l1ct;
0010 
0011 #ifdef CMSSW_GIT_HASH
0012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0013 
0014 l1ct::L2EgSorterEmulator::L2EgSorterEmulator(const edm::ParameterSet &pset)
0015     : L2EgSorterEmulator(pset.getParameter<uint32_t>("nREGIONS"),
0016                          pset.getParameter<uint32_t>("nEGPerRegion"),
0017                          pset.getParameter<uint32_t>("nEGOut"),
0018                          pset.getUntrackedParameter<uint32_t>("debug", 0)) {}
0019 #endif
0020 
0021 void L2EgSorterEmulator::toFirmware(const std::vector<EGIsoObjEmu> &out_photons,
0022                                     const std::vector<EGIsoEleObjEmu> &out_eles,
0023                                     EGIsoObj out_egphs[/*nObjOut*/],
0024                                     EGIsoEleObj out_egeles[/*nObjOut*/]) const {
0025   for (unsigned int io = 0; io < nEGOut; io++) {
0026     EGIsoObj pho;
0027     EGIsoEleObj ele;
0028     if (io < out_photons.size())
0029       pho = out_photons[io];
0030     else
0031       pho.clear();
0032     if (io < out_eles.size())
0033       ele = out_eles[io];
0034     else
0035       ele.clear();
0036 
0037     out_egphs[io] = pho;
0038     out_egeles[io] = ele;
0039   }
0040 }
0041 
0042 void L2EgSorterEmulator::run(const std::vector<l1ct::OutputBoard> &in,
0043                              std::vector<EGIsoObjEmu> &out_photons,
0044                              std::vector<EGIsoEleObjEmu> &out_eles) const {
0045   if (debug_) {
0046     unsigned int region_n = 0;
0047     for (const auto &region : in) {
0048       dbgCout() << "REGION " << region_n++ << std::endl;
0049       print_objects(region.egphoton, "photon_in");
0050       print_objects(region.egelectron, "electron_in");
0051     }
0052   }
0053 
0054   // we copy to be able to resize them
0055   std::vector<std::vector<EGIsoObjEmu>> photons_in;
0056   std::vector<std::vector<EGIsoEleObjEmu>> eles_in;
0057   photons_in.reserve(in.size());
0058   eles_in.reserve(in.size());
0059   for (const auto &region : in) {
0060     std::vector<EGIsoObjEmu> photons = region.egphoton;
0061     std::vector<EGIsoEleObjEmu> eles = region.egelectron;
0062     resize_input(photons);
0063     resize_input(eles);
0064 
0065     photons_in.push_back(photons);
0066     eles_in.push_back(eles);
0067   }
0068   merge(photons_in, out_photons);
0069   merge(eles_in, out_eles);
0070 
0071   if (debug_) {
0072     print_objects(out_photons, "photon_out");
0073     print_objects(out_eles, "electron_out");
0074   }
0075 }