CMS 3D CMS Logo

L1CaloGeometry.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     L1Geometry
00004 // Class  :     L1CaloGeometry
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Werner Sun
00010 //         Created:  Mon Oct 23 21:52:36 EDT 2006
00011 // $Id: L1CaloGeometry.cc,v 1.1 2008/04/16 23:20:48 wsun Exp $
00012 //
00013 
00014 // system include files
00015 #include <cmath>
00016 
00017 // user include files
00018 #include "CondFormats/L1TObjects/interface/L1CaloGeometry.h"
00019 
00020 
00021 //
00022 // constants, enums and typedefs
00023 //
00024 
00025 //
00026 // static data member definitions
00027 //
00028 
00029 // double L1CaloGeometry::m_gctEmJetPhiOffset =
00030 //    -M_PI / L1CaloGeometry::kNumberGctEmJetPhiBins ;
00031 // double L1CaloGeometry::m_gctEtSumPhiOffset = 0. ;
00032 
00033 // double L1CaloGeometry::m_gctEmJetPhiBinWidth =
00034 //    2. * M_PI / L1CaloGeometry::kNumberGctEmJetPhiBins ;
00035 // double L1CaloGeometry::m_gctEtSumPhiBinWidth =
00036 //    2. * M_PI / L1CaloGeometry::kNumberGctEtSumPhiBins ;
00037 
00038 // double L1CaloGeometry::m_gctEtaBinBoundaries[
00039 //    kNumberGctCentralEtaBinsPerHalf + kNumberGctForwardEtaBinsPerHalf + 1 ] = {
00040 //       0.0000,
00041 //       0.3480,
00042 //       0.6950,
00043 //       1.0440,
00044 //       1.3920,
00045 //       1.7400,
00046 //       2.1720,
00047 //       3.0000,
00048 //       3.5000,
00049 //       4.0000,
00050 //       4.5000,
00051 //       5.0000 } ;
00052 
00053 //
00054 // constructors and destructor
00055 //
00056 L1CaloGeometry::L1CaloGeometry()
00057 {
00058 }
00059 
00060 L1CaloGeometry::L1CaloGeometry( unsigned int numberGctEmJetPhiBins,
00061                                 double gctEmJetPhiBinOffset,
00062                                 unsigned int numberGctEtSumPhiBins,
00063                                 double gctEtSumPhiBinOffset,
00064                                 unsigned int numberGctCentralEtaBinsPerHalf,
00065                                 unsigned int numberGctForwardEtaBinsPerHalf,
00066                                 unsigned int etaSignBitOffset,
00067                                 const std::vector<double>& gctEtaBinBoundaries)
00068   : m_numberGctEmJetPhiBins( numberGctEmJetPhiBins ),
00069     m_numberGctEtSumPhiBins( numberGctEtSumPhiBins ),
00070     m_numberGctCentralEtaBinsPerHalf( numberGctCentralEtaBinsPerHalf ),
00071     m_numberGctForwardEtaBinsPerHalf( numberGctForwardEtaBinsPerHalf ),
00072     m_etaSignBitOffset( etaSignBitOffset ),
00073     m_gctEtaBinBoundaries( gctEtaBinBoundaries )
00074 {
00075   m_etaBinsPerHalf =
00076     m_numberGctCentralEtaBinsPerHalf + m_numberGctForwardEtaBinsPerHalf ;
00077 
00078   m_gctEmJetPhiBinWidth = 2. * M_PI / m_numberGctEmJetPhiBins ;
00079   m_gctEtSumPhiBinWidth = 2. * M_PI / m_numberGctEtSumPhiBins ;
00080 
00081   m_gctEmJetPhiOffset = gctEmJetPhiBinOffset * m_gctEmJetPhiBinWidth ;
00082   m_gctEtSumPhiOffset = gctEtSumPhiBinOffset * m_gctEtSumPhiBinWidth ;
00083 }
00084 
00085 // L1CaloGeometry::L1CaloGeometry(const L1CaloGeometry& rhs)
00086 // {
00087 //    // do actual copying here;
00088 // }
00089 
00090 L1CaloGeometry::~L1CaloGeometry()
00091 {
00092 }
00093 
00094 //
00095 // assignment operators
00096 //
00097 // const L1CaloGeometry& L1CaloGeometry::operator=(const L1CaloGeometry& rhs)
00098 // {
00099 //   //An exception safe implementation is
00100 //   L1CaloGeometry temp(rhs);
00101 //   swap(rhs);
00102 //
00103 //   return *this;
00104 // }
00105 
00106 //
00107 // member functions
00108 //
00109 
00110 //
00111 // const member functions
00112 //
00113 
00114 double
00115 L1CaloGeometry::globalEtaBinCenter( unsigned int globalEtaIndex ) const
00116 {
00117    int etaIndex ;
00118    double etaSign = 1. ;
00119    if( globalEtaIndex < m_etaBinsPerHalf )
00120    {
00121       etaIndex = m_etaBinsPerHalf - globalEtaIndex - 1 ;
00122       etaSign = -1. ;
00123    }
00124    else
00125    {
00126       etaIndex = globalEtaIndex - m_etaBinsPerHalf ;
00127    }
00128 
00129    return 0.5 * etaSign *
00130       ( m_gctEtaBinBoundaries[ etaIndex ] +
00131         m_gctEtaBinBoundaries[ etaIndex + 1 ] ) ;
00132 }
00133 
00134 double
00135 L1CaloGeometry::globalEtaBinLowEdge( unsigned int globalEtaIndex ) const
00136 {
00137    int etaIndex ;
00138    double etaSign = 1. ;
00139    if( globalEtaIndex < m_etaBinsPerHalf )
00140    {
00141       etaIndex = m_etaBinsPerHalf - globalEtaIndex - 1 ;
00142       etaSign = -1. ;
00143    }
00144    else
00145    {
00146       etaIndex = globalEtaIndex - m_etaBinsPerHalf ;
00147    }
00148 
00149    return ( etaSign > 0. ? 
00150             m_gctEtaBinBoundaries[ etaIndex ] :
00151             -m_gctEtaBinBoundaries[ etaIndex + 1 ] ) ;
00152 }
00153 
00154 double
00155 L1CaloGeometry::globalEtaBinHighEdge( unsigned int globalEtaIndex ) const
00156 {
00157    int etaIndex ;
00158    double etaSign = 1. ;
00159    if( globalEtaIndex < m_etaBinsPerHalf )
00160    {
00161       etaIndex = m_etaBinsPerHalf - globalEtaIndex - 1 ;
00162       etaSign = -1. ;
00163    }
00164    else
00165    {
00166       etaIndex = globalEtaIndex - m_etaBinsPerHalf ;
00167    }
00168 
00169    return ( etaSign > 0. ? 
00170             m_gctEtaBinBoundaries[ etaIndex + 1 ] :
00171             -m_gctEtaBinBoundaries[ etaIndex ] ) ;
00172 }
00173 
00174 double
00175 L1CaloGeometry::etaBinCenter( unsigned int etaIndex,
00176                               bool central ) const
00177 {
00178    // Central/tau jets and EM have etaIndex = 0-6 for eta = 0-3.
00179    // Forward jets have etaIndex = 0-3 for eta = 3-5.
00180    double etaSign = 1. ;
00181 
00182    // Check sign BEFORE shifting forward jet bin index.
00183    if( etaIndex >= m_etaSignBitOffset )
00184    {
00185       etaSign = -1. ;
00186       etaIndex -= m_etaSignBitOffset ;
00187    }
00188 
00189    // Shift forward jet bin index AFTER checking sign bit.
00190    if( !central )
00191    {
00192       etaIndex += m_numberGctCentralEtaBinsPerHalf ;
00193    }
00194 
00195    return 0.5 * etaSign *
00196       ( m_gctEtaBinBoundaries[ etaIndex ] +
00197         m_gctEtaBinBoundaries[ etaIndex + 1 ] ) ;
00198 }
00199 
00200 double
00201 L1CaloGeometry::etaBinLowEdge( unsigned int etaIndex,
00202                                bool central ) const
00203 {
00204    // Central/tau jets and EM have etaIndex = 0-6 for eta = 0-3.
00205    // Forward jets have etaIndex = 0-3 for eta = 3-5.
00206    double etaSign = 1. ;
00207 
00208    // Check sign BEFORE shifting forward jet bin index.
00209    if( etaIndex >= m_etaSignBitOffset )
00210    {
00211       etaSign = -1. ;
00212       etaIndex -= m_etaSignBitOffset ;
00213    }
00214 
00215    // Shift forward jet bin index AFTER checking sign bit.
00216    if( !central )
00217    {
00218       etaIndex += m_numberGctCentralEtaBinsPerHalf ;
00219    }
00220 
00221    return ( etaSign > 0. ? 
00222             m_gctEtaBinBoundaries[ etaIndex ] :
00223             -m_gctEtaBinBoundaries[ etaIndex + 1 ] ) ;
00224 }
00225 
00226 double
00227 L1CaloGeometry::etaBinHighEdge( unsigned int etaIndex,
00228                                 bool central ) const
00229 {
00230    // Central/tau jets and EM have etaIndex = 0-6 for eta = 0-3.
00231    // Forward jets have etaIndex = 0-3 for eta = 3-5.
00232    double etaSign = 1. ;
00233 
00234    // Check sign BEFORE shifting forward jet bin index.
00235    if( etaIndex >= m_etaSignBitOffset )
00236    {
00237       etaSign = -1. ;
00238       etaIndex -= m_etaSignBitOffset ;
00239    }
00240 
00241    // Shift forward jet bin index AFTER checking sign bit.
00242    if( !central )
00243    {
00244       etaIndex += m_numberGctCentralEtaBinsPerHalf ;
00245    }
00246 
00247    return ( etaSign > 0. ? 
00248             m_gctEtaBinBoundaries[ etaIndex + 1 ] :
00249             -m_gctEtaBinBoundaries[ etaIndex ] ) ;
00250 }
00251 
00252 double
00253 L1CaloGeometry::emJetPhiBinCenter( unsigned int phiIndex ) const
00254 {
00255    return ( ( double ) phiIndex + 0.5 ) * m_gctEmJetPhiBinWidth +
00256       m_gctEmJetPhiOffset ;
00257 }
00258 
00259 double
00260 L1CaloGeometry::emJetPhiBinLowEdge( unsigned int phiIndex ) const
00261 {
00262    return ( ( double ) phiIndex ) * m_gctEmJetPhiBinWidth +
00263       m_gctEmJetPhiOffset ;
00264 }
00265 
00266 double
00267 L1CaloGeometry::emJetPhiBinHighEdge( unsigned int phiIndex ) const
00268 {
00269    return ( ( double ) phiIndex + 1. ) * m_gctEmJetPhiBinWidth +
00270       m_gctEmJetPhiOffset ;
00271 }
00272 
00273 double
00274 L1CaloGeometry::etSumPhiBinCenter( unsigned int phiIndex ) const
00275 {
00276    return ( ( double ) phiIndex + 0.5 ) * m_gctEtSumPhiBinWidth +
00277       m_gctEtSumPhiOffset ;
00278 }
00279 
00280 double
00281 L1CaloGeometry::etSumPhiBinLowEdge( unsigned int phiIndex ) const
00282 {
00283    return ( ( double ) phiIndex ) * m_gctEtSumPhiBinWidth +
00284       m_gctEtSumPhiOffset ;
00285 }
00286 
00287 double
00288 L1CaloGeometry::etSumPhiBinHighEdge( unsigned int phiIndex ) const
00289 {
00290    return ( ( double ) phiIndex + 1. ) * m_gctEtSumPhiBinWidth +
00291       m_gctEtSumPhiOffset ;
00292 }
00293 
00294 unsigned int
00295 L1CaloGeometry::etaIndex( const double& etaValue ) const
00296 {
00297    unsigned int etaIndex = 0 ;
00298 
00299    for( unsigned int i = 0 ; i < m_numberGctCentralEtaBinsPerHalf ; ++i )
00300    {
00301       if( fabs( etaValue ) >= m_gctEtaBinBoundaries[ i ] )
00302       {
00303          etaIndex = i ;
00304       }
00305    }
00306 
00307    for( unsigned int i = 0 ; i < m_numberGctForwardEtaBinsPerHalf ; ++i )
00308    {
00309       if( fabs( etaValue ) >=
00310           m_gctEtaBinBoundaries[ i + m_numberGctCentralEtaBinsPerHalf ] )
00311       {
00312          etaIndex = i ;
00313       }
00314    }
00315 
00316    if( etaValue < 0. )
00317    {
00318       etaIndex += m_etaSignBitOffset ;
00319    }
00320 
00321    return etaIndex ;
00322 }
00323 
00324 unsigned int
00325 L1CaloGeometry::globalEtaIndex( const double& etaValue ) const
00326 {
00327    unsigned int etaIndex = 0 ;
00328 
00329    if( etaValue < 0. )
00330    {
00331       for( unsigned int i = m_etaBinsPerHalf ; i > 0 ; --i )
00332       {
00333          if( fabs( etaValue ) < m_gctEtaBinBoundaries[ i ] )
00334          {
00335             etaIndex = m_etaBinsPerHalf - i ;
00336          }
00337       }
00338    }
00339    else
00340    {
00341       for( unsigned int i = 0 ; i < m_etaBinsPerHalf ; ++i )
00342       {
00343          if( etaValue >= m_gctEtaBinBoundaries[ i ] )
00344          {
00345             etaIndex = i + m_etaBinsPerHalf ;
00346          }
00347       }
00348    }
00349 
00350    return etaIndex ;
00351 }
00352 
00353 unsigned int
00354 L1CaloGeometry::emJetPhiIndex( const double& phiValue ) const
00355 {
00356    double phiAdjusted = phiValue - m_gctEmJetPhiOffset ;
00357 
00358    // Check phiValue is between m_gctEmJetPhiOffset and m_gctEmJetPhiOffset+2pi
00359    if( phiAdjusted < 0. )
00360    {
00361       do
00362       {
00363          phiAdjusted += 2. * M_PI ;
00364       }
00365       while( phiAdjusted < 0. ) ;
00366    }
00367    else if( phiAdjusted > 2. * M_PI )
00368    {
00369       do
00370       {
00371          phiAdjusted -= 2. * M_PI ;
00372       }
00373       while( phiAdjusted > 2. * M_PI ) ;
00374    }
00375 
00376    return ( ( int ) ( phiAdjusted / m_gctEmJetPhiBinWidth ) ) ;
00377 }
00378 
00379 unsigned int
00380 L1CaloGeometry::etSumPhiIndex( const double& phiValue ) const
00381 {
00382    double phiAdjusted = phiValue - m_gctEtSumPhiOffset ;
00383 
00384    // Check phiValue is between m_gctEtSumPhiOffset and m_gctEtSumPhiOffset+2pi
00385    if( phiAdjusted < 0. )
00386    {
00387       do
00388       {
00389          phiAdjusted += 2. * M_PI ;
00390       }
00391       while( phiAdjusted < 0. ) ;
00392    }
00393    else if( phiAdjusted > 2. * M_PI )
00394    {
00395       do
00396       {
00397          phiAdjusted -= 2. * M_PI ;
00398       }
00399       while( phiAdjusted > 2. * M_PI ) ;
00400    }
00401 
00402    return ( ( int ) ( phiAdjusted / m_gctEtSumPhiBinWidth ) ) ;
00403 }
00404 
00405 //
00406 // static member functions
00407 //

Generated on Tue Jun 9 17:26:38 2009 for CMSSW by  doxygen 1.5.4