Go to the documentation of this file.00001 #include "Geometry/CaloGeometry/interface/PreshowerStrip.h"
00002 #include "Geometry/CaloGeometry/interface/CaloGenericDetId.h"
00003 #include "Geometry/EcalAlgo/interface/EcalPreshowerGeometry.h"
00004 #include "DataFormats/EcalDetId/interface/ESDetId.h"
00005 #include "FWCore/Utilities/interface/Exception.h"
00006 #include <iostream>
00007
00008 typedef CaloCellGeometry::CCGFloat CCGFloat ;
00009 typedef CaloCellGeometry::Pt3D Pt3D ;
00010 typedef CaloCellGeometry::Pt3DVec Pt3DVec ;
00011 typedef HepGeom::Plane3D<CCGFloat> Pl3D ;
00012
00013 EcalPreshowerGeometry::EcalPreshowerGeometry() :
00014 m_xWidWaf ( 6.3 ) ,
00015 m_xInterLadGap ( 0.05 ) ,
00016 m_xIntraLadGap ( 0.04 ) ,
00017 m_yWidAct ( 6.1 ) ,
00018 m_yCtrOff ( 0.05 ) ,
00019 m_cellVec ( k_NumberOfCellsForCorners )
00020 {
00021 }
00022
00023
00024 EcalPreshowerGeometry::~EcalPreshowerGeometry() {}
00025
00026 unsigned int
00027 EcalPreshowerGeometry::alignmentTransformIndexLocal( const DetId& id )
00028 {
00029 const CaloGenericDetId gid ( id ) ;
00030
00031 assert( gid.isES() ) ;
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 const ESDetId esid ( id ) ;
00050 const int jx ( esid.six() - 1 ) ;
00051 const int jy ( esid.siy() - 1 ) ;
00052 const int jz ( esid.zside() + 1 ) ;
00053 const int pl ( esid.plane() - 1 ) ;
00054 const bool second ( 1 == pl ) ;
00055 const bool top ( 19 < jy ) ;
00056 const bool negz ( 0 == jz ) ;
00057 const int lrl ( 19>jx ? 0 : 1 ) ;
00058 const int lrr ( 21>jx ? 0 : 1 ) ;
00059
00060 return ( second ? jx/20 + 3*jz :
00061 ( negz && !top ? lrl + 2 :
00062 ( negz && top ? lrr + 2 :
00063 ( !negz && !top ? lrr + 4 : lrl + 4 ) ) ) ) ;
00064 }
00065
00066 DetId
00067 EcalPreshowerGeometry::detIdFromLocalAlignmentIndex( unsigned int iLoc )
00068 {
00069 return ESDetId( 1, 10 + 20*( iLoc%2 ), 10, 2>iLoc || 5<iLoc ? 2 : 1, 2*( iLoc/4 ) - 1 ) ;
00070 }
00071
00072 unsigned int
00073 EcalPreshowerGeometry::alignmentTransformIndexGlobal( const DetId& id )
00074 {
00075 return (unsigned int)DetId::Ecal - 1 ;
00076 }
00077
00078
00079 void
00080 EcalPreshowerGeometry::initializeParms()
00081 {
00082 unsigned int n1minus ( 0 ) ;
00083 unsigned int n2minus ( 0 ) ;
00084 unsigned int n1plus ( 0 ) ;
00085 unsigned int n2plus ( 0 ) ;
00086 CCGFloat z1minus ( 0 ) ;
00087 CCGFloat z2minus ( 0 ) ;
00088 CCGFloat z1plus ( 0 ) ;
00089 CCGFloat z2plus ( 0 ) ;
00090 const std::vector<DetId>& esDetIds ( getValidDetIds() ) ;
00091
00092 for( unsigned int i ( 0 ) ; i != esDetIds.size() ; ++i )
00093 {
00094 const ESDetId esid ( esDetIds[i] ) ;
00095 const CaloCellGeometry* cell ( getGeometry( esid ) ) ;
00096 if( 0 != cell )
00097 {
00098 const CCGFloat zz ( cell->getPosition().z() ) ;
00099 if( 1 == esid.plane() )
00100 {
00101 if( 0 > esid.zside() )
00102 {
00103 z1minus += zz ;
00104 ++n1minus ;
00105 }
00106 else
00107 {
00108 z1plus += zz ;
00109 ++n1plus ;
00110 }
00111 }
00112 if( 2 == esid.plane() )
00113 {
00114 if( 0 > esid.zside() )
00115 {
00116 z2minus += zz ;
00117 ++n2minus ;
00118 }
00119 else
00120 {
00121 z2plus += zz ;
00122 ++n2plus ;
00123 }
00124 }
00125 }
00126 }
00127 assert( 0 != n1minus &&
00128 0 != n2minus &&
00129 0 != n1plus &&
00130 0 != n2plus ) ;
00131 z1minus /= (1.*n1minus) ;
00132 z2minus /= (1.*n2minus) ;
00133 z1plus /= (1.*n1plus) ;
00134 z2plus /= (1.*n2plus) ;
00135 assert( 0 != z1minus &&
00136 0 != z2minus &&
00137 0 != z1plus &&
00138 0 != z2plus ) ;
00139 setzPlanes( z1minus, z2minus, z1plus, z2plus ) ;
00140 }
00141
00142
00143 void
00144 EcalPreshowerGeometry::setzPlanes( CCGFloat z1minus,
00145 CCGFloat z2minus,
00146 CCGFloat z1plus,
00147 CCGFloat z2plus )
00148 {
00149 assert( 0 > z1minus &&
00150 0 > z2minus &&
00151 0 < z1plus &&
00152 0 < z2plus ) ;
00153
00154 m_zplane[0] = z1minus ;
00155 m_zplane[1] = z2minus ;
00156 m_zplane[2] = z1plus ;
00157 m_zplane[3] = z2plus ;
00158 }
00159
00160
00161
00162 DetId
00163 EcalPreshowerGeometry::getClosestCell( const GlobalPoint& point ) const
00164 {
00165 return getClosestCellInPlane( point, 2 );
00166 }
00167
00168 DetId
00169 EcalPreshowerGeometry::getClosestCellInPlane( const GlobalPoint& point,
00170 int plane ) const
00171 {
00172 const CCGFloat x ( point.x() ) ;
00173 const CCGFloat y ( point.y() ) ;
00174 const CCGFloat z ( point.z() ) ;
00175
00176 if( 0 == z ||
00177 1 > plane ||
00178 2 < plane ) return DetId( 0 ) ;
00179
00180 const unsigned int iz ( ( 0>z ? 0 : 2 ) + plane - 1 ) ;
00181
00182 const CCGFloat ze ( m_zplane[iz] ) ;
00183 const CCGFloat xe ( x * ze/z ) ;
00184 const CCGFloat ye ( y * ze/z ) ;
00185
00186 const CCGFloat x0 ( 1 == plane ? xe : ye ) ;
00187 const CCGFloat y0 ( 1 == plane ? ye : xe ) ;
00188
00189 static const CCGFloat xWid ( m_xWidWaf + m_xIntraLadGap + m_xInterLadGap ) ;
00190
00191 const int row ( 1 + int( y0 + 20.*m_yWidAct - m_yCtrOff )/m_yWidAct ) ;
00192 const int col ( 1 + int( ( x0 + 20.*xWid )/xWid ) ) ;
00193
00194 CCGFloat closest ( 1e9 ) ;
00195
00196 DetId detId ( 0 ) ;
00197
00198 const int jz ( 0 > ze ? -1 : 1 ) ;
00199
00200
00201
00202
00203 for( int ix ( -1 ); ix != 2 ; ++ix )
00204 {
00205 for( int iy ( -1 ); iy != 2 ; ++iy )
00206 {
00207 for( int jstrip ( ESDetId::ISTRIP_MIN ) ; jstrip <= ESDetId::ISTRIP_MAX ; ++jstrip )
00208 {
00209 const int jx ( 1 == plane ? col + ix : row + iy ) ;
00210 const int jy ( 1 == plane ? row + iy : col + ix ) ;
00211 if( ESDetId::validDetId( jstrip, jx, jy, plane, jz ) )
00212 {
00213 const ESDetId esId ( jstrip, jx, jy, plane, jz ) ;
00214 const CaloCellGeometry* cell ( getGeometry( esId ) ) ;
00215 if( 0 != cell )
00216 {
00217 const GlobalPoint& p ( cell->getPosition() ) ;
00218 const CCGFloat dist2 ( (p.x()-xe)*(p.x()-xe) + (p.y()-ye)*(p.y()-ye) ) ;
00219 if( dist2 < closest && present( esId ) )
00220 {
00221 closest = dist2 ;
00222 detId = esId ;
00223 }
00224 }
00225 }
00226 }
00227 }
00228 }
00229 return detId ;
00230 }
00231
00232 void
00233 EcalPreshowerGeometry::localCorners( Pt3DVec& lc ,
00234 const CCGFloat* pv ,
00235 unsigned int i ,
00236 Pt3D& ref )
00237 {
00238 PreshowerStrip::localCorners( lc, pv, ref ) ;
00239 }
00240
00241 void
00242 EcalPreshowerGeometry::newCell( const GlobalPoint& f1 ,
00243 const GlobalPoint& f2 ,
00244 const GlobalPoint& f3 ,
00245 const CCGFloat* parm ,
00246 const DetId& detId )
00247 {
00248 const unsigned int cellIndex ( ESDetId( detId ).denseIndex() ) ;
00249 m_cellVec[ cellIndex ] = PreshowerStrip( f1, cornersMgr(), parm ) ;
00250 m_validIds.push_back( detId ) ;
00251 }
00252
00253 const CaloCellGeometry*
00254 EcalPreshowerGeometry::cellGeomPtr( uint32_t index ) const
00255 {
00256 const CaloCellGeometry* cell ( &m_cellVec[ index ] ) ;
00257 return ( m_cellVec.size() < index ||
00258 0 == cell->param() ? 0 : cell ) ;
00259 }