CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Stage1TauIsolationLUT.cc
Go to the documentation of this file.
1 // Stage1TauIsolationLUT.cc
2 // Author: Leonard Apanasevich
3 //
4 
6 #include <vector>
7 
8 using namespace l1t;
9 
14 
16 {};
17 
18 unsigned Stage1TauIsolationLUT::lutAddress(unsigned int tauPt, unsigned int jetPt) const
19 {
20  const unsigned int maxJet = pow(2,nbitsJet)-1;
21  const unsigned int maxTau = pow(2,nbitsTau)-1;
22 
23  // lut only defined for 8 bit Jet ET
24  if ( (nbitsJet != 8) || (nbitsTau != 8) ) return 0;
25 
26  double jetLsb=params_->jetLsb();
27  if (std::abs(jetLsb-0.5) > 0.0001){
28  std::cout << "%Stage1TauIsolationLUT-E-Unexpected jetLsb " << jetLsb << " IsoTau calculation will be broken"<< std::endl;
29  return 0;
30  }
31 
32  tauPt=tauPt>>1;
33  jetPt=jetPt>>1;
34 
35  if (jetPt>maxJet) jetPt=maxJet;
36  if (tauPt>maxTau) tauPt=maxTau;
37 
38  unsigned int address= (jetPt << nbitsTau) + tauPt;
39  return address;
40 }
41 
42 int Stage1TauIsolationLUT::lutPayload(unsigned int address) const
43 {
44 
45  const unsigned int maxJet = pow(2,nbitsJet)-1;
46  const unsigned int maxTau = pow(2,nbitsTau)-1;
47 
48  const double tauMaxJetIsolationA = params_->tauMaxJetIsolationA();
49  const double tauMaxJetIsolationB = params_->tauMaxJetIsolationB();
50  const double tauMinPtJetIsolationB = params_->tauMinPtJetIsolationB();
51 
52  unsigned int maxAddress = pow(2,nbitsJet+nbitsTau)-1;
53  if (address > maxAddress){ // check that address is right length
54  std::cout << "%Stage1TauIsolationLUT-E-Address: " << address
55  << " exceeds maximum value allowed. Setting value to maximum (" << maxAddress << ")" << std::endl;
56  address = maxAddress;
57  }
58  // extract the jet and tau et from the address
59  int ijetet = address >> nbitsTau;
60  int itauet = address & 0xff;
61 
62 
63  double jet_pt = static_cast <float> (ijetet); // no need convert to physical eT, as right shift (>>1) operation
64  double tau_pt = static_cast <float> (itauet); // in lutAddress automatically converts to physical eT, assuming lsb=0.5
65 
66  //std::cout << "ijetet: " << ijetet << "\titauet: " << itauet << std::endl;
67  //std::cout << "jetet: " << jet_pt << "\ttauet: " << tau_pt << std::endl;
68 
69  int isol=0;
70  if (maxTau == (unsigned) itauet){
71  isol=1;
72  } else if (maxJet == (unsigned) ijetet){
73  isol=1;
74  } else {
75  double relativeJetIsolationTau = (jet_pt / tau_pt) -1;
76 
77  double isolCut=tauMaxJetIsolationA;
78  if (tau_pt >= tauMinPtJetIsolationB)isolCut=tauMaxJetIsolationB;
79  if (relativeJetIsolationTau < isolCut) isol=1;
80  }
81  return isol;
82 }
83 
static const unsigned int nbits_data
double tauMaxJetIsolationB() const
double tauMinPtJetIsolationB() const
#define NBITS_JET_ET_LUT
double jetLsb() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define NBITS_TAU_ET_LUT
Stage1TauIsolationLUT(CaloParamsHelper *params)
static const unsigned int nbitsTau
static const unsigned int nbitsJet
unsigned lutAddress(unsigned int, unsigned int) const
static const unsigned int lut_version
#define NBITS_DATA
int lutPayload(unsigned int) const
#define LUT_VERSION
tuple cout
Definition: gather_cfg.py:121
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
CaloParamsHelper *const params_
double tauMaxJetIsolationA() const