Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:36:52

0001 // Stage1TauIsolationLUT.cc
0002 // Author: Leonard Apanasevich
0003 //
0004 
0005 #include "L1Trigger/L1TCalorimeter/interface/Stage1TauIsolationLUT.h"
0006 #include <vector>
0007 
0008 using namespace l1t;
0009 
0010 const unsigned int Stage1TauIsolationLUT::nbitsJet = NBITS_JET_ET_LUT;
0011 const unsigned int Stage1TauIsolationLUT::nbitsTau = NBITS_TAU_ET_LUT;
0012 const unsigned int Stage1TauIsolationLUT::nbits_data = NBITS_DATA;
0013 const unsigned int Stage1TauIsolationLUT::lut_version = LUT_VERSION;
0014 
0015 Stage1TauIsolationLUT::Stage1TauIsolationLUT(CaloParamsHelper const* params) : params_(params) {}
0016 
0017 unsigned Stage1TauIsolationLUT::lutAddress(unsigned int tauPt, unsigned int jetPt) const {
0018   const unsigned int maxJet = pow(2, nbitsJet) - 1;
0019   const unsigned int maxTau = pow(2, nbitsTau) - 1;
0020 
0021   // lut only defined for 8 bit Jet ET
0022   if ((nbitsJet != 8) || (nbitsTau != 8))
0023     return 0;
0024 
0025   double jetLsb = params_->jetLsb();
0026   if (std::abs(jetLsb - 0.5) > 0.0001) {
0027     std::cout << "%Stage1TauIsolationLUT-E-Unexpected jetLsb " << jetLsb << " IsoTau calculation will be broken"
0028               << std::endl;
0029     return 0;
0030   }
0031 
0032   tauPt = tauPt >> 1;
0033   jetPt = jetPt >> 1;
0034 
0035   if (jetPt > maxJet)
0036     jetPt = maxJet;
0037   if (tauPt > maxTau)
0038     tauPt = maxTau;
0039 
0040   unsigned int address = (jetPt << nbitsTau) + tauPt;
0041   return address;
0042 }
0043 
0044 int Stage1TauIsolationLUT::lutPayload(unsigned int address) const {
0045   const unsigned int maxJet = pow(2, nbitsJet) - 1;
0046   const unsigned int maxTau = pow(2, nbitsTau) - 1;
0047 
0048   const double tauMaxJetIsolationA = params_->tauMaxJetIsolationA();
0049   const double tauMaxJetIsolationB = params_->tauMaxJetIsolationB();
0050   const double tauMinPtJetIsolationB = params_->tauMinPtJetIsolationB();
0051 
0052   unsigned int maxAddress = pow(2, nbitsJet + nbitsTau) - 1;
0053   if (address > maxAddress) {  // check that address is right length
0054     std::cout << "%Stage1TauIsolationLUT-E-Address: " << address
0055               << " exceeds maximum value allowed. Setting value to maximum (" << maxAddress << ")" << std::endl;
0056     address = maxAddress;
0057   }
0058   // extract the jet and tau et from the address
0059   int ijetet = address >> nbitsTau;
0060   int itauet = address & 0xff;
0061 
0062   double jet_pt = static_cast<float>(ijetet);  // no need convert to physical eT, as right shift (>>1) operation
0063   double tau_pt = static_cast<float>(itauet);  // in lutAddress automatically converts to physical eT, assuming lsb=0.5
0064 
0065   //std::cout << "ijetet: " << ijetet << "\titauet: " << itauet << std::endl;
0066   //std::cout << "jetet: " << jet_pt << "\ttauet: " << tau_pt << std::endl;
0067 
0068   int isol = 0;
0069   if (maxTau == (unsigned)itauet) {
0070     isol = 1;
0071   } else if (maxJet == (unsigned)ijetet) {
0072     isol = 1;
0073   } else {
0074     double relativeJetIsolationTau = (jet_pt / tau_pt) - 1;
0075 
0076     double isolCut = tauMaxJetIsolationA;
0077     if (tau_pt >= tauMinPtJetIsolationB)
0078       isolCut = tauMaxJetIsolationB;
0079     if (relativeJetIsolationTau < isolCut)
0080       isol = 1;
0081   }
0082   return isol;
0083 }
0084 
0085 Stage1TauIsolationLUT::~Stage1TauIsolationLUT() {}