Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:24

0001 ///
0002 /// \class l1t::Stage2Layer2JetAlgorithmFirmwareImp1
0003 ///
0004 /// \author:
0005 ///
0006 /// Description:
0007 
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include "L1Trigger/L1TCalorimeter/interface/Stage2Layer2DemuxJetAlgoFirmware.h"
0010 
0011 #include "L1Trigger/L1TCalorimeter/interface/CaloParamsHelper.h"
0012 #include "L1Trigger/L1TCalorimeter/interface/CaloTools.h"
0013 
0014 #include <vector>
0015 #include <algorithm>
0016 
0017 inline bool operator>(l1t::Jet& a, l1t::Jet& b) {
0018   if (a.hwPt() > b.hwPt()) {
0019     return true;
0020   } else {
0021     return false;
0022   }
0023 }
0024 
0025 #include "L1Trigger/L1TCalorimeter/interface/BitonicSort.h"
0026 
0027 l1t::Stage2Layer2DemuxJetAlgoFirmwareImp1::Stage2Layer2DemuxJetAlgoFirmwareImp1(CaloParamsHelper const*) {}
0028 
0029 void l1t::Stage2Layer2DemuxJetAlgoFirmwareImp1::processEvent(const std::vector<l1t::Jet>& inputJets,
0030                                                              std::vector<l1t::Jet>& outputJets) {
0031   outputJets = inputJets;
0032 
0033   // Sort the jets by pT
0034   std::vector<l1t::Jet>::iterator start(outputJets.begin());
0035   std::vector<l1t::Jet>::iterator end(outputJets.end());
0036 
0037   //  for (auto& jet: outputJets){
0038   //    std::cout << "MP : " << jet.hwPt() << ", " << jet.hwEta() << ", " << jet.hwPhi() << ", " << CaloTools::towerEta(jet.hwEta()) << ", " << CaloTools::towerPhi(jet.hwEta(),jet.hwPhi()) << std::endl;
0039   //  }
0040 
0041   BitonicSort<l1t::Jet>(down, start, end);
0042 
0043   // convert eta to GT coordinates
0044   for (auto& jet : outputJets) {
0045     int gtEt = jet.hwPt() > 0x7FF ? 0x7FF : jet.hwPt();
0046     int gtEta = CaloTools::gtEta(CaloTools::mpEta(jet.hwEta()));
0047     int gtPhi = CaloTools::gtPhi(CaloTools::mpEta(jet.hwEta()), jet.hwPhi());
0048 
0049     jet.setHwPt(gtEt);
0050     jet.setHwEta(gtEta);
0051     jet.setHwPhi(gtPhi);
0052   }
0053 }