CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/CondFormats/L1TObjects/src/L1CaloEcalScale.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     L1TObjects
00004 // Class  :     L1CaloEcalScale
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/L1CaloEcalScale.h"
00014 
00015 using std::vector;
00016 using std::ostream;
00017 using std::endl;
00018 
00020 L1CaloEcalScale::L1CaloEcalScale(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 L1CaloEcalScale::~L1CaloEcalScale() {
00032 
00033 }
00034 
00036 void L1CaloEcalScale::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 L1CaloEcalScale::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 L1CaloEcalScale::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 L1CaloEcalScale::print(ostream& s) const {
00083  s << "L1CaloEcalScaleRcd" << endl;
00084   s << "Energy for ECAL inputs into the RCT" <<endl;
00085   s << "Each new row is for a given value of 8 bit output of ECAL.  Each column is for the respective eta value " << endl;
00086 
00087   for (unsigned rank=0; rank<nBinRank; rank++) {
00088     s << "rank = " <<rank << " ";
00089     for (unsigned eta=0; eta<2*nBinEta; eta++) {
00090       s << m_scale[rank][eta] << " " ;
00091     }
00092     s << endl;
00093   }
00094 }
00095 
00096