Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:19

0001 // -*- C++ -*-
0002 //
0003 // Package:     L1TObjects
0004 // Class  :     L1CaloEcalScale
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Author:
0010 // Created:     Wed Sep 27 17:18:27 CEST 2006
0011 // $Id:
0012 
0013 #include "CondFormats/L1TObjects/interface/L1CaloEcalScale.h"
0014 
0015 using std::endl;
0016 using std::ostream;
0017 using std::vector;
0018 
0019 /// construct a linear scale with a particular LSB
0020 L1CaloEcalScale::L1CaloEcalScale(double lsb) {
0021   for (unsigned i = 0; i < nBinRank; i++) {
0022     for (unsigned eta = 0; eta < nBinEta; eta++) {
0023       m_scale[i][eta] = lsb * i;
0024       m_scale[i][eta + nBinEta] = lsb * i;
0025     }
0026   }
0027 }
0028 
0029 /// dtor
0030 L1CaloEcalScale::~L1CaloEcalScale() {}
0031 
0032 /// set scale bin
0033 void L1CaloEcalScale::setBin(unsigned short rank, unsigned short eta, short etaSign, double et) {
0034   --eta;  // input eta index starts at 1
0035   if (rank < nBinRank && eta < nBinEta) {
0036     if (etaSign < 0)
0037       eta += nBinEta;
0038     m_scale[rank][eta] = et;
0039   } else {
0040     // throw
0041   }
0042 }
0043 
0044 /// convert from Et in GeV to rank
0045 unsigned short L1CaloEcalScale::rank(double et, unsigned short eta, short etaSign) const {
0046   --eta;  // input eta index starts at 1
0047   if (eta < nBinEta) {
0048     unsigned short out = 0;
0049     if (etaSign < 0)
0050       eta += nBinEta;
0051     for (unsigned i = 0; i < nBinRank; i++) {
0052       if (et >= m_scale[i][eta]) {
0053         out = i;
0054       }
0055     }
0056     return out & (nBinRank - 1);
0057   } else {
0058     // throw
0059   }
0060   return nBinRank;
0061 }
0062 
0063 // convert from rank to Et/GeV
0064 double L1CaloEcalScale::et(unsigned short rank, unsigned short eta, short etaSign) const {
0065   --eta;  // input eta index starts at 1
0066   if (rank < nBinRank && eta < nBinEta) {
0067     if (etaSign < 0)
0068       eta += nBinEta;
0069     return m_scale[rank][eta];
0070   } else
0071     return -1.;
0072 }
0073 
0074 // pretty print
0075 void L1CaloEcalScale::print(ostream& s) const {
0076   s << "L1CaloEcalScaleRcd" << endl;
0077   s << "Energy for ECAL inputs into the RCT" << endl;
0078   s << "Each new row is for a given value of 8 bit output of ECAL.  Each column is for the respective eta value "
0079     << endl;
0080 
0081   for (unsigned rank = 0; rank < nBinRank; rank++) {
0082     s << "rank = " << rank << " ";
0083     for (unsigned eta = 0; eta < 2 * nBinEta; eta++) {
0084       s << m_scale[rank][eta] << " ";
0085     }
0086     s << endl;
0087   }
0088 }