00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <cmath>
00016
00017
00018 #include "CondFormats/L1TObjects/interface/L1CaloGeometry.h"
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
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
00086
00087
00088
00089
00090 L1CaloGeometry::~L1CaloGeometry()
00091 {
00092 }
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
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
00179
00180 double etaSign = 1. ;
00181
00182
00183 if( etaIndex >= m_etaSignBitOffset )
00184 {
00185 etaSign = -1. ;
00186 etaIndex -= m_etaSignBitOffset ;
00187 }
00188
00189
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
00205
00206 double etaSign = 1. ;
00207
00208
00209 if( etaIndex >= m_etaSignBitOffset )
00210 {
00211 etaSign = -1. ;
00212 etaIndex -= m_etaSignBitOffset ;
00213 }
00214
00215
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
00231
00232 double etaSign = 1. ;
00233
00234
00235 if( etaIndex >= m_etaSignBitOffset )
00236 {
00237 etaSign = -1. ;
00238 etaIndex -= m_etaSignBitOffset ;
00239 }
00240
00241
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
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
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
00407