CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalPreshowerGeometry.cc
Go to the documentation of this file.
6 #include <iostream>
7 
9  m_xWidWaf ( 6.3 ) ,
10  m_xInterLadGap ( 0.05 ) , // additional gap between wafers in adj ladders
11  m_xIntraLadGap ( 0.04 ) , // gap between wafers in same ladder
12  m_yWidAct ( 6.1 ) ,
13  m_yCtrOff ( 0.05 ) // gap at center
14 {
15 }
16 
17 
19 
20 unsigned int
22 {
23  const CaloGenericDetId gid ( id ) ;
24 
25  assert( gid.isES() ) ;
26 
27 // plane 2 is split into 2 dees along x=0 for both signs of z
28 
29 // plane 1 at zsign=-1 is split into 2 dees between six=19 and six=20 for siy<=20,
30 // and six=21 and 22 for siy>=21
31 
32 // plane 1 at zsign=+1 is split into 2 dees between six=20 and six=21 for siy<=20,
33 // and six=19 and 20 for siy>=21
34 
35 
36 // Desired numbering
37 // LEFT RIGHT (as one faces the Dee from the IP)
38 // ES- pl=2 0 1
39 // pl=1 2 3 the reversal of pl=2 and pl=1 is intentional here (CM Kuo)
40 // ES+ pl=1 4 5
41 // pl=2 6 7
42 
43  const ESDetId esid ( id ) ;
44  const int jx ( esid.six() - 1 ) ;
45  const int jy ( esid.siy() - 1 ) ;
46  const int jz ( esid.zside() + 1 ) ;
47  const int pl ( esid.plane() - 1 ) ;
48  const bool second ( 1 == pl ) ;
49  const bool top ( 19 < jy ) ;
50  const bool negz ( 0 == jz ) ;
51  const int lrl ( 20>jx ? 0 : 1 ) ;
52  const int lrr ( 22>jx ? 0 : 1 ) ;
53 
54  return ( second ? jx/20 + 3*jz : // 2nd plane split along middle
55  ( negz && !top ? lrl + 2 : // 1st plane at neg z and bottom half split at six=19&20
56  ( negz && top ? lrr + 2 : // 1st plane at neg z and top half split at six=21&22
57  ( !negz && !top ? lrr + 4 : lrl + 4 ) ) ) ) ; // opposite at positive z
58 }
59 
60 DetId
62 {
63  return ESDetId( 1, 10 + 20*( iLoc%2 ), 10, 2>iLoc || 5<iLoc ? 2 : 1, 2*( iLoc/4 ) - 1 ) ;
64 }
65 
66 unsigned int
68 {
69  return (unsigned int)DetId::Ecal - 1 ;
70 }
71 
72 
73 void
75 {
77  unsigned int n1minus ( 0 ) ;
78  unsigned int n2minus ( 0 ) ;
79  unsigned int n1plus ( 0 ) ;
80  unsigned int n2plus ( 0 ) ;
81  double z1minus ( 0 ) ;
82  double z2minus ( 0 ) ;
83  double z1plus ( 0 ) ;
84  double z2plus ( 0 ) ;
85  const Cont& con ( cellGeometries() ) ;
86  for( unsigned int i ( 0 ) ; i != con.size() ; ++i )
87  {
88  const ESDetId esid ( getValidDetIds()[i] ) ;
89  if( 1 == esid.plane() )
90  {
91  if( 0 > esid.zside() )
92  {
93  z1minus += con[i]->getPosition().z() ;
94  ++n1minus ;
95  }
96  else
97  {
98  z1plus += con[i]->getPosition().z() ;
99  ++n1plus ;
100  }
101  }
102  if( 2 == esid.plane() )
103  {
104  if( 0 > esid.zside() )
105  {
106  z2minus += con[i]->getPosition().z() ;
107  ++n2minus ;
108  }
109  else
110  {
111  z2plus += con[i]->getPosition().z() ;
112  ++n2plus ;
113  }
114  }
115 // if( 0 == z1 && 1 == esid.plane() ) z1 = fabs( i->second->getPosition().z() ) ;
116 // if( 0 == z2 && 2 == esid.plane() ) z2 = fabs( i->second->getPosition().z() ) ;
117 // if( 0 != z1 && 0 != z2 ) break ;
118  }
119  assert( 0 != n1minus &&
120  0 != n2minus &&
121  0 != n1plus &&
122  0 != n2plus ) ;
123  z1minus /= (1.*n1minus) ;
124  z2minus /= (1.*n2minus) ;
125  z1plus /= (1.*n1plus) ;
126  z2plus /= (1.*n2plus) ;
127  assert( 0 != z1minus &&
128  0 != z2minus &&
129  0 != z1plus &&
130  0 != z2plus ) ;
131  setzPlanes( z1minus, z2minus, z1plus, z2plus ) ;
132 }
133 
134 
135 void
137  float z2minus,
138  float z1plus,
139  float z2plus )
140 {
141  assert( 0 > z1minus &&
142  0 > z2minus &&
143  0 < z1plus &&
144  0 < z2plus ) ;
145 
146  m_zplane[0] = z1minus ;
147  m_zplane[1] = z2minus ;
148  m_zplane[2] = z1plus ;
149  m_zplane[3] = z2plus ;
150 }
151 
152 
153 // Get closest cell, etc...
154 DetId
156 {
157  return getClosestCellInPlane( point, 2 );
158 }
159 
160 DetId
162  int plane ) const
163 {
164  const double x ( point.x() ) ;
165  const double y ( point.y() ) ;
166  const double z ( point.z() ) ;
167 
168  if( 0 == z ||
169  1 > plane ||
170  2 < plane ) return DetId( 0 ) ;
171 
172  const unsigned int iz ( ( 0>z ? 0 : 2 ) + plane - 1 ) ;
173 
174  const double ze ( m_zplane[iz] ) ;
175  const double xe ( x * ze/z ) ;
176  const double ye ( y * ze/z ) ;
177 
178  const double x0 ( 1 == plane ? xe : ye ) ;
179  const double y0 ( 1 == plane ? ye : xe ) ;
180 
181  static const double xWid ( m_xWidWaf + m_xIntraLadGap + m_xInterLadGap ) ;
182 
183  const int row ( 1 + int( y0 + 20.*m_yWidAct - m_yCtrOff )/m_yWidAct ) ;
184  const int col ( 1 + int( ( x0 + 20.*xWid )/xWid ) ) ;
185 
186  double closest ( 1e9 ) ;
187 
188  DetId detId ( 0 ) ;
189 
190  const int jz ( 0 > ze ? -1 : 1 ) ;
191 
192 
193 // std::cout<<"** p="<<point<<", ("<<xe<<", "<<ye<<", "<<ze<<"), row="<<row<<", col="<<col<<std::endl;
194 
195  for( int ix ( -1 ); ix != 2 ; ++ix ) // search within +-1 in row and col
196  {
197  for( int iy ( -1 ); iy != 2 ; ++iy )
198  {
199  for( int jstrip ( ESDetId::ISTRIP_MIN ) ; jstrip <= ESDetId::ISTRIP_MAX ; ++jstrip )
200  {
201  const int jx ( 1 == plane ? col + ix : row + iy ) ;
202  const int jy ( 1 == plane ? row + iy : col + ix ) ;
203  if( ESDetId::validDetId( jstrip, jx, jy, plane, jz ) )
204  {
205  const ESDetId esId ( jstrip, jx, jy, plane, jz ) ;
206  const unsigned int index ( esId.denseIndex() ) ;
207  const GlobalPoint& p ( cellGeometries()[ index ]->getPosition() ) ;
208  const double dist2 ( (p.x()-xe)*(p.x()-xe) + (p.y()-ye)*(p.y()-ye) ) ;
209  if( dist2 < closest && present( esId ) )
210  {
211  closest = dist2 ;
212  detId = esId ;
213  }
214  }
215  }
216  }
217  }
218  return detId ;
219 }
220 
221 std::vector<HepGeom::Point3D<double> >
223  unsigned int i,
224  HepGeom::Point3D<double> & ref )
225 {
226  return ( PreshowerStrip::localCorners( pv, ref ) ) ;
227 }
228 
231  const GlobalPoint& f2 ,
232  const GlobalPoint& f3 ,
234  const double* parm ,
235  const DetId& detId )
236 {
237  return ( new PreshowerStrip( f1, mgr , parm ) ) ;
238 }
int i
Definition: DBlmapReader.cc:9
std::vector< const CaloCellGeometry * > CellCont
T y() const
Definition: PV3DBase.h:57
void setzPlanes(float z1minus, float z2minus, float z1plus, float z2plus)
virtual DetId getClosestCell(const GlobalPoint &r) const
static const int ISTRIP_MAX
Definition: ESDetId.h:62
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
A base class to handle the shape of preshower strips.
U second(std::pair< T, U > const &p)
virtual bool present(const DetId &id) const
is this detid present in the geometry?
Definition: DDAxes.h:10
const CellCont & cellGeometries() const
the cells
static std::vector< HepGeom::Point3D< double > > localCorners(const double *pv, unsigned int i, HepGeom::Point3D< double > &ref)
static DetId detIdFromLocalAlignmentIndex(unsigned int iLoc)
T z() const
Definition: PV3DBase.h:58
virtual DetId getClosestCellInPlane(const GlobalPoint &r, int plane) const
static unsigned int alignmentTransformIndexLocal(const DetId &id)
int zside() const
Definition: ESDetId.h:33
bool isES() const
virtual ~EcalPreshowerGeometry()
The EcalPreshowerGeometry will delete all its cell geometries at destruction time.
uint32_t denseIndex() const
Definition: ESDetId.h:45
Definition: DetId.h:20
static bool validDetId(int istrip, int ixs, int iys, int iplane, int iz)
check if a valid index combination
Definition: ESDetId.cc:50
Definition: EZMgrFL.h:8
static CaloCellGeometry * newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, CaloCellGeometry::CornersMgr *mgr, const double *parm, const DetId &detId)
static std::vector< HepGeom::Point3D< double > > localCorners(const double *pv, HepGeom::Point3D< double > &ref)
int plane() const
Definition: ESDetId.h:35
T x() const
Definition: PV3DBase.h:56
static unsigned int alignmentTransformIndexGlobal(const DetId &id)
static const int ISTRIP_MIN
Definition: ESDetId.h:61
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5