CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

L1RCTLookupTables Class Reference

#include <L1RCTLookupTables.h>

List of all members.

Public Member Functions

bool activityBit (float ecal, float hcal) const
unsigned int eGammaETCode (float ecal, float hcal, int iAbsEta) const
unsigned int emRank (unsigned short energy) const
bool hOeFGVetoBit (float ecal, float hcal, bool fgbit) const
unsigned int jetMETETCode (float ecal, float hcal, int iAbsEta) const
 L1RCTLookupTables ()
unsigned int lookup (unsigned short hfInput, unsigned short crtNo, unsigned short crdNo, unsigned short twrNo) const
unsigned int lookup (unsigned short ecalInput, unsigned short hcalInput, unsigned short fgbit, unsigned short crtNo, unsigned short crdNo, unsigned short twrNo) const
const L1RCTParametersrctParameters () const
void setChannelMask (const L1RCTChannelMask *channelMask)
void setEcalScale (const L1CaloEcalScale *ecalScale)
void setHcalScale (const L1CaloHcalScale *hcalScale)
void setL1CaloEtScale (const L1CaloEtScale *etScale)
void setNoisyChannelMask (const L1RCTNoisyChannelMask *channelMask)
void setRCTParameters (const L1RCTParameters *rctParameters)

Private Member Functions

float convertEcal (unsigned short ecal, unsigned short iAbsEta, short sign) const
float convertHcal (unsigned short hcal, unsigned short iAbsEta, short sign) const
unsigned long convertToInteger (float et, float lsb, int precision) const

Private Attributes

const L1RCTChannelMaskchannelMask_
const L1CaloEcalScaleecalScale_
const L1CaloEtScaleetScale_
const L1CaloHcalScalehcalScale_
const L1RCTNoisyChannelMasknoisyChannelMask_
const L1RCTParametersrctParameters_

Detailed Description

Definition at line 11 of file L1RCTLookupTables.h.


Constructor & Destructor Documentation

L1RCTLookupTables::L1RCTLookupTables ( ) [inline]

Definition at line 17 of file L1RCTLookupTables.h.


Member Function Documentation

bool L1RCTLookupTables::activityBit ( float  ecal,
float  hcal 
) const

Definition at line 224 of file L1RCTLookupTables.cc.

References L1RCTParameters::eActivityCut(), Exception, L1RCTParameters::hActivityCut(), and rctParameters_.

Referenced by lookup().

{
  if(rctParameters_ == 0)
    throw cms::Exception("L1RCTParameters Invalid")
      << "L1RCTParameters should be set every event" << rctParameters_;
  return ((ecal > rctParameters_->eActivityCut()) || 
          (hcal > rctParameters_->hActivityCut()));
}
float L1RCTLookupTables::convertEcal ( unsigned short  ecal,
unsigned short  iAbsEta,
short  sign 
) const [private]

Definition at line 247 of file L1RCTLookupTables.cc.

References patCandidatesForDimuonsSequences_cff::ecal, ecalScale_, L1RCTParameters::eGammaLSB(), L1CaloEcalScale::et(), and rctParameters_.

Referenced by lookup().

{
  if(ecalScale_)
    {
      //std::cout << "[luts] energy " << ecal << " sign " << sign 
      //<< " iAbsEta " << iAbsEta << " iPhi "   << iPhi << std::endl;
      float dummy = 0;
      dummy = float (ecalScale_->et( ecal, iAbsEta, sign ));
      /*
      if (ecal > 0)
        {
          std::cout << "[luts] ecal converted from " << ecal << " to " 
                    << dummy << " with iAbsEta " << iAbsEta << std::endl;
        }
      */
      return dummy;
    }
  //else if(rctParameters_ == 0)
  //  {
  //    throw cms::Exception("L1RCTParameters Invalid")
  //    << "L1RCTParameters should be set every event" << rctParameters_;
  //  }
  else
    {
      return ((float) ecal) * rctParameters_->eGammaLSB();
    }
}
float L1RCTLookupTables::convertHcal ( unsigned short  hcal,
unsigned short  iAbsEta,
short  sign 
) const [private]

Definition at line 276 of file L1RCTLookupTables.cc.

References L1CaloHcalScale::et(), patCandidatesForDimuonsSequences_cff::hcal, hcalScale_, L1RCTParameters::jetMETLSB(), and rctParameters_.

Referenced by lookup().

{
  if (hcalScale_ != 0)
    {
      return (hcalScale_->et( hcal, iAbsEta, sign ));
    }
  else
    {
      //      edm::LogInfo("L1RegionalCaloTrigger") 
      //        << "CaloTPGTranscoder was not used" << std::endl;
      return ((float) hcal) * rctParameters_->jetMETLSB();
    }
}
unsigned long L1RCTLookupTables::convertToInteger ( float  et,
float  lsb,
int  precision 
) const [private]

Definition at line 291 of file L1RCTLookupTables.cc.

Referenced by eGammaETCode(), jetMETETCode(), and lookup().

{
  unsigned long etBits = (unsigned long)(et/lsb);
  unsigned long maxValue = (1 << precision) - 1;
  if(etBits > maxValue)
    return maxValue;
  else
    return etBits;
}
unsigned int L1RCTLookupTables::eGammaETCode ( float  ecal,
float  hcal,
int  iAbsEta 
) const

Definition at line 303 of file L1RCTLookupTables.cc.

References convertToInteger(), L1RCTParameters::eGammaLSB(), L1RCTParameters::EGammaTPGSum(), Exception, and rctParameters_.

Referenced by lookup().

{
  if(rctParameters_ == 0)
    throw cms::Exception("L1RCTParameters Invalid")
      << "L1RCTParameters should be set every event" << rctParameters_;
  float etLinear = rctParameters_->EGammaTPGSum(ecal,hcal,iAbsEta);
  return convertToInteger(etLinear, rctParameters_->eGammaLSB(), 7);
}
unsigned int L1RCTLookupTables::emRank ( unsigned short  energy) const

Definition at line 234 of file L1RCTLookupTables.cc.

References relval_parameters_module::energy, etScale_, and L1CaloEtScale::rank().

Referenced by L1RCTJetSummaryCard::asicCompare(), L1RCT::getIsolatedEGObjects(), L1RCT::getNonisolatedEGObjects(), and L1RCTLutWriter::writeEicLutFile().

{
  if(etScale_)
    {
      return etScale_->rank(energy);
    }
  else
    //    edm::LogInfo("L1RegionalCaloTrigger") 
    //      << "CaloEtScale was not used - energy instead of rank" << std::endl;
  return energy;
}
bool L1RCTLookupTables::hOeFGVetoBit ( float  ecal,
float  hcal,
bool  fgbit 
) const

Definition at line 200 of file L1RCTLookupTables.cc.

References L1RCTParameters::eMaxForFGCut(), L1RCTParameters::eMaxForHoECut(), L1RCTParameters::eMinForFGCut(), L1RCTParameters::eMinForHoECut(), Exception, L1RCTParameters::hMinForHoECut(), L1RCTParameters::hOeCut(), and rctParameters_.

Referenced by lookup().

{
  if(rctParameters_ == 0)
    throw cms::Exception("L1RCTParameters Invalid")
      << "L1RCTParameters should be set every event" << rctParameters_;
  bool veto = false;
  if(ecal > rctParameters_->eMinForFGCut() && 
     ecal < rctParameters_->eMaxForFGCut())
    {
      if(fgbit) veto = true;
    }
  if(ecal > rctParameters_->eMinForHoECut() && 
     ecal < rctParameters_->eMaxForHoECut())
    {
      if((hcal / ecal) > rctParameters_->hOeCut()) veto = true;
    }
  //  else
  if (ecal < rctParameters_->eMinForHoECut())
    {
      if(hcal > rctParameters_->hMinForHoECut()) veto = true;  // Changed from eMinForHoECut() - JLL 2008-Feb-13
    }
  return veto;
}
unsigned int L1RCTLookupTables::jetMETETCode ( float  ecal,
float  hcal,
int  iAbsEta 
) const

Definition at line 312 of file L1RCTLookupTables.cc.

References convertToInteger(), Exception, L1RCTParameters::jetMETLSB(), L1RCTParameters::JetMETTPGSum(), and rctParameters_.

Referenced by lookup().

{
  if(rctParameters_ == 0)
    throw cms::Exception("L1RCTParameters Invalid")
      << "L1RCTParameters should be set every event" << rctParameters_;
  float etLinear = rctParameters_->JetMETTPGSum(ecal,hcal,iAbsEta);
  return convertToInteger(etLinear, rctParameters_->jetMETLSB(), 9);
}
unsigned int L1RCTLookupTables::lookup ( unsigned short  ecalInput,
unsigned short  hcalInput,
unsigned short  fgbit,
unsigned short  crtNo,
unsigned short  crdNo,
unsigned short  twrNo 
) const

Definition at line 20 of file L1RCTLookupTables.cc.

References abs, activityBit(), L1RCTParameters::calcIEta(), L1RCTParameters::calcIPhi(), channelMask_, convertEcal(), convertHcal(), patCandidatesForDimuonsSequences_cff::ecal, L1RCTNoisyChannelMask::ecalMask, L1RCTChannelMask::ecalMask, L1RCTParameters::eGammaECalScaleFactors(), eGammaETCode(), L1RCTParameters::eGammaHCalScaleFactors(), Exception, patCandidatesForDimuonsSequences_cff::hcal, L1RCTNoisyChannelMask::hcalMask, L1RCTChannelMask::hcalMask, L1RCTNoisyChannelMask::hcalThreshold, hOeFGVetoBit(), L1RCTParameters::jetMETECalScaleFactors(), jetMETETCode(), L1RCTParameters::jetMETHCalScaleFactors(), L1RCTParameters::noiseVetoHB(), L1RCTParameters::noiseVetoHEminus(), L1RCTParameters::noiseVetoHEplus(), noisyChannelMask_, convertSQLitetoXML_cfg::output, and rctParameters_.

Referenced by L1RCTSaveInput::analyze(), L1RCTJetSummaryCard::fillHFRegionSums(), L1RCTReceiverCard::fillInput(), L1RCTInputProducer::produce(), and L1RCTLutWriter::writeJscLutFile().

{
  if(rctParameters_ == 0)
    throw cms::Exception("L1RCTParameters Invalid")
      << "L1RCTParameters should be set every event" << rctParameters_;
  if(channelMask_ == 0)
    throw cms::Exception("L1RCTChannelMask Invalid")
      << "L1RCTChannelMask should be set every event" << channelMask_;
  if(noisyChannelMask_ == 0)
    throw cms::Exception("L1RCTNoisyChannelMask Invalid")
      << "L1RCTNoisyChannelMask should be set every event" << noisyChannelMask_;
  if(ecalInput > 0xFF) 
    throw cms::Exception("Invalid Data") 
      << "ECAL compressedET should be less than 0xFF, is " << ecalInput;
  if(hcalInput > 0xFF) 
    throw cms::Exception("Invalid Data") 
      << "HCAL compressedET should be less than 0xFF, is " << hcalInput;
  if(fgbit > 1) 
    throw cms::Exception("Invalid Data") 
      << "ECAL finegrain should be a single bit, is " << fgbit;
  short iEta = (short) rctParameters_->calcIEta(crtNo, crdNo, twrNo);
  unsigned short iAbsEta = (unsigned short) abs(iEta);
  short sign = iEta/iAbsEta;
  unsigned short iPhi = rctParameters_->calcIPhi(crtNo, crdNo, twrNo);
  unsigned short phiSide = (iPhi/4)%2;
  if(iAbsEta < 1 || iAbsEta > 28) 
    throw cms::Exception("Invalid Data") 
      << "1 <= |IEta| <= 28, is " << iAbsEta;


  //Pre Input bits
  unsigned short ecalAfterMask=0;
  unsigned short hcalAfterMask=0;


  // using channel mask to mask off ecal channels
  //Mike: Introducing the hot channel mask 
  //If the Et is above the threshold then mask it as well


  
  float ecalBeforeMask = convertEcal(ecalInput, iAbsEta, sign);


  bool resetECAL = (channelMask_->ecalMask[crtNo][phiSide][iAbsEta-1]) || //channel mask
    (noisyChannelMask_->ecalMask[crtNo][phiSide][iAbsEta-1] &&
     ecalBeforeMask<noisyChannelMask_->ecalThreshold)||//hot mask
      (rctParameters_->eGammaECalScaleFactors()[iAbsEta-1] == 0.&&
       rctParameters_->jetMETECalScaleFactors()[iAbsEta-1] == 0.);       
    


  if (resetECAL)    {
      ecalAfterMask=0;
    }
  else    {
      ecalAfterMask=ecalInput;
    }

  float ecal =  convertEcal(ecalAfterMask, iAbsEta, sign);


  // masking off hcal for channels in channel mask
  float hcalBeforeMask = convertHcal(hcalInput, iAbsEta, sign);

  bool resetHCAL = channelMask_->hcalMask[crtNo][phiSide][iAbsEta-1]||
    (noisyChannelMask_->hcalMask[crtNo][phiSide][iAbsEta-1] &&
     hcalBeforeMask<noisyChannelMask_->hcalThreshold)||//hot mask
      (rctParameters_->eGammaHCalScaleFactors()[iAbsEta-1] == 0.&&
       rctParameters_->jetMETHCalScaleFactors()[iAbsEta-1] == 0.);

  if (resetHCAL)    {
      hcalAfterMask=0;
    }
  else    {
      hcalAfterMask=hcalInput;
    }

  float hcal = convertHcal(hcalAfterMask, iAbsEta, sign);

  unsigned long etIn7Bits;
  unsigned long etIn9Bits;

  if((ecalAfterMask == 0 && hcalAfterMask > 0) &&
     ((rctParameters_->noiseVetoHB() && iAbsEta > 0 && iAbsEta < 18)
      || (rctParameters_->noiseVetoHEplus() && iAbsEta>17 && crtNo>8)
      || (rctParameters_->noiseVetoHEminus() && iAbsEta>17 && crtNo<9)))
    {
      etIn7Bits = 0;
      etIn9Bits = 0;
    }
  else
    {
      etIn7Bits = eGammaETCode(ecal, hcal, iAbsEta);
      etIn9Bits = jetMETETCode(ecal, hcal, iAbsEta);
    }
  // Saturated input towers cause tower ET pegging at the highest value
  if((ecalAfterMask == 0xFF && 
      rctParameters_->eGammaECalScaleFactors()[iAbsEta-1] != 0. ) 
     || (hcalAfterMask == 0xFF &&
         rctParameters_->eGammaHCalScaleFactors()[iAbsEta-1] != 0. )
     )
    {
      etIn7Bits = 0x7F; // egamma path
    }
  if((ecalAfterMask == 0xFF &&
      rctParameters_->jetMETECalScaleFactors()[iAbsEta-1] != 0. )
     || (hcalAfterMask == 0xFF &&
         rctParameters_->jetMETHCalScaleFactors()[iAbsEta-1] != 0. ))
    {
      etIn9Bits = 0x1FF; // sums path
    }

  unsigned long shiftEtIn9Bits = etIn9Bits<<8;
  unsigned long shiftHE_FGBit = hOeFGVetoBit(ecal, hcal, fgbit)<<7;
  unsigned long shiftActivityBit = 0;
  if ( rctParameters_->jetMETECalScaleFactors()[iAbsEta-1] == 0.
       && rctParameters_->jetMETHCalScaleFactors()[iAbsEta-1] == 0. )
    {
      // do nothing, it's already zero
    }
  else if (rctParameters_->jetMETECalScaleFactors()[iAbsEta-1] == 0. )
    {
      shiftActivityBit = activityBit(0., hcal)<<17;
    }
  else if (rctParameters_->jetMETHCalScaleFactors()[iAbsEta-1] == 0. )
    {
      shiftActivityBit = activityBit(ecal, 0.)<<17;
    }
  else
    {
      shiftActivityBit = activityBit(ecal, hcal)<<17;
    }
  unsigned long output=etIn7Bits+shiftHE_FGBit+shiftEtIn9Bits+shiftActivityBit;
  return output;
}
unsigned int L1RCTLookupTables::lookup ( unsigned short  hfInput,
unsigned short  crtNo,
unsigned short  crdNo,
unsigned short  twrNo 
) const

Definition at line 162 of file L1RCTLookupTables.cc.

References abs, L1RCTParameters::calcIEta(), channelMask_, convertHcal(), convertToInteger(), Exception, L1RCTChannelMask::hfMask, L1RCTNoisyChannelMask::hfMask, L1RCTParameters::jetMETLSB(), noisyChannelMask_, rctParameters_, and query::result.

{
  if(rctParameters_ == 0)
    throw cms::Exception("L1RCTParameters Invalid")
      << "L1RCTParameters should be set every event" << rctParameters_;
  if(channelMask_ == 0)
    throw cms::Exception("L1RCTChannelMask Invalid")
      << "L1RCTChannelMask should be set every event" << channelMask_;
  if(hfInput > 0xFF) 
    throw cms::Exception("Invalid Data") 
      << "HF compressedET should be less than 0xFF, is " << hfInput;
  short iEta = rctParameters_->calcIEta(crtNo, crdNo, twrNo);
  unsigned short iAbsEta = abs(iEta);
  short sign = (iEta/iAbsEta);
  unsigned short phiSide = twrNo/4;
  if(iAbsEta < 29 || iAbsEta > 32) 
    throw cms::Exception("Invalid Data") 
      << "29 <= |iEta| <= 32, is " << iAbsEta;

  float et = convertHcal(hfInput, iAbsEta, sign);;



  if (channelMask_->hfMask[crtNo][phiSide][iAbsEta-29]||
      (noisyChannelMask_->hfMask[crtNo][phiSide][iAbsEta-29]&&
       et<noisyChannelMask_->hfThreshold))
    {
      et = 0;
    }

  unsigned int result = convertToInteger(et, rctParameters_->jetMETLSB(), 8);
  return result;
}
const L1RCTParameters* L1RCTLookupTables::rctParameters ( ) const [inline]
void L1RCTLookupTables::setChannelMask ( const L1RCTChannelMask channelMask) [inline]
void L1RCTLookupTables::setEcalScale ( const L1CaloEcalScale ecalScale) [inline]
void L1RCTLookupTables::setHcalScale ( const L1CaloHcalScale hcalScale) [inline]
void L1RCTLookupTables::setL1CaloEtScale ( const L1CaloEtScale etScale) [inline]
void L1RCTLookupTables::setNoisyChannelMask ( const L1RCTNoisyChannelMask channelMask) [inline]

Definition at line 31 of file L1RCTLookupTables.h.

References noisyChannelMask_.

Referenced by L1RCTLutWriter::analyze(), and L1RCTProducer::updateConfiguration().

    {
      noisyChannelMask_ = channelMask;
    }
void L1RCTLookupTables::setRCTParameters ( const L1RCTParameters rctParameters) [inline]

Member Data Documentation

Definition at line 83 of file L1RCTLookupTables.h.

Referenced by lookup(), and setChannelMask().

Definition at line 85 of file L1RCTLookupTables.h.

Referenced by convertEcal(), and setEcalScale().

Definition at line 87 of file L1RCTLookupTables.h.

Referenced by emRank(), and setL1CaloEtScale().

Definition at line 86 of file L1RCTLookupTables.h.

Referenced by convertHcal(), and setHcalScale().

Definition at line 84 of file L1RCTLookupTables.h.

Referenced by lookup(), and setNoisyChannelMask().