Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:45

0001 ///
0002 /// \class l1t::Stage2TowerCompressAlgorithmFirmwareImp1
0003 ///
0004 /// \author: Jim Brooke
0005 ///
0006 /// Description: first iteration of stage 2 jet algo
0007 
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include "L1Trigger/L1TCalorimeter/interface/Stage2TowerCompressAlgorithmFirmware.h"
0010 //#include "DataFormats/Math/interface/LorentzVector.h "
0011 
0012 l1t::Stage2TowerCompressAlgorithmFirmwareImp1::Stage2TowerCompressAlgorithmFirmwareImp1(CaloParamsHelper const* params)
0013     : params_(params) {}
0014 
0015 l1t::Stage2TowerCompressAlgorithmFirmwareImp1::~Stage2TowerCompressAlgorithmFirmwareImp1() {}
0016 
0017 void l1t::Stage2TowerCompressAlgorithmFirmwareImp1::processEvent(const std::vector<l1t::CaloTower>& inTowers,
0018                                                                  std::vector<l1t::CaloTower>& outTowers) {
0019   outTowers.reserve(outTowers.size() + inTowers.size());
0020   for (auto tow = inTowers.begin(); tow != inTowers.end(); ++tow) {
0021     if (!params_->doTowerEncoding()) {
0022       outTowers.push_back(*tow);
0023 
0024     }
0025 
0026     else {
0027       int etEm = tow->hwEtEm();
0028       int etHad = tow->hwEtHad();
0029 
0030       int ratio = 0;
0031       if (etEm > 0 && etHad > 0) {
0032         if (etEm >= etHad)
0033           ratio = (int)std::round(log(float(etEm) / float(etHad)) / log(2.));
0034         else
0035           ratio = (int)std::round(log(float(etHad) / float(etEm)) / log(2.));
0036       }
0037 
0038       if (ratio >= params_->towerMaskRatio())
0039         ratio = params_->towerMaskRatio();
0040 
0041       int sum = etEm + etHad;
0042 
0043       // apply
0044       if (sum >= params_->towerMaskSum())
0045         sum = params_->towerMaskSum();
0046 
0047       int qual = 0;
0048       qual |= (etEm == 0 || etHad == 0 ? 0x1 : 0x0);                    // denominator ==0 flag
0049       qual |= ((etHad == 0 && etEm > 0) || etEm >= etHad ? 0x2 : 0x0);  // E/H flag
0050       qual |= (tow->hwQual() & 0xc);                                    // get feature bits from existing tower
0051 
0052       l1t::CaloTower newTow;
0053       newTow.setHwEtEm(etEm);
0054       newTow.setHwEtHad(etHad);
0055       newTow.setHwEta(tow->hwEta());
0056       newTow.setHwPhi(tow->hwPhi());
0057       newTow.setHwPt(sum);
0058       newTow.setHwEtRatio(ratio);
0059       newTow.setHwQual(qual);
0060 
0061       outTowers.push_back(newTow);
0062     }
0063   }
0064 }