CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CondFormats/L1TObjects/src/L1CaloHcalScale.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     L1TObjects
00004 // Class  :     L1CaloHcalScale
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Author:      
00010 // Created:     Wed Sep 27 17:18:27 CEST 2006
00011 // $Id: 
00012 
00013 #include "CondFormats/L1TObjects/interface/L1CaloHcalScale.h"
00014 
00015 using std::vector;
00016 using std::ostream;
00017 using std::endl;
00018 
00020 L1CaloHcalScale::L1CaloHcalScale(double lsb)
00021 {
00022   for (unsigned i=0; i<nBinRank; i++) {
00023     for (unsigned eta=0; eta<nBinEta; eta++) {
00024       m_scale[i][eta] = lsb * i;
00025       m_scale[i][eta+nBinEta] = lsb * i;
00026     }
00027   }
00028 }
00029 
00031 L1CaloHcalScale::~L1CaloHcalScale() {
00032 
00033 }
00034 
00036 void L1CaloHcalScale::setBin(unsigned short rank,
00037                              unsigned short eta,
00038                              short etaSign,
00039                              double et) {
00040   --eta ; // input eta index starts at 1
00041   if (rank < nBinRank && eta < nBinEta) {
00042     if( etaSign < 0 ) eta += nBinEta ;
00043     m_scale[rank][eta] = et;
00044   }
00045   else {
00046     // throw
00047   }
00048 }
00049 
00051 unsigned short L1CaloHcalScale::rank(double et,
00052                                      unsigned short eta,
00053                                      short etaSign) const {
00054   --eta ; // input eta index starts at 1
00055   if (eta < nBinEta) {
00056     unsigned short out = 0;
00057     if( etaSign < 0 ) eta += nBinEta ;
00058     for (unsigned i=0; i<nBinRank; i++) {
00059       if ( et >= m_scale[i][eta] ) { out = i; }
00060     }
00061     return out & (nBinRank-1);
00062   }
00063   else {
00064     // throw
00065   }
00066   return nBinRank ;
00067 }
00068 
00069 // convert from rank to Et/GeV
00070 double L1CaloHcalScale::et(unsigned short rank,
00071                            unsigned short eta,
00072                            short etaSign) const {
00073   --eta ; // input eta index starts at 1
00074   if (rank < nBinRank && eta < nBinEta) {
00075     if( etaSign < 0 ) eta += nBinEta ;
00076     return m_scale[rank][eta];
00077   }
00078   else return -1.;
00079 }
00080 
00081 // pretty print
00082 void L1CaloHcalScale::print(ostream& s) const {
00083   s << "L1CaloHcalScaleRcd" << endl;
00084   s << "Energy for HCAL inputs into the RCT" <<endl;
00085   s << "Each new row is for a given value of 8 bit output of HCAL.  Each column is for the respective eta value " << endl;
00086   for (unsigned rank=0; rank<nBinRank; rank++) {
00087     s << "rank " << rank << " ";
00088     for (unsigned eta=0; eta<2*nBinEta; eta++) {
00089       s << m_scale[rank][eta] << " " ;
00090     }
00091     s << endl;
00092   }
00093 }
00094 
00095