CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions
ForwardDiskSectorBuilderFromDet Class Reference

#include <ForwardDiskSectorBuilderFromDet.h>

Public Member Functions

std::pair< DiskSectorBounds,
GlobalVector
computeBounds (const std::vector< const GeomDet * > &dets) const
 
BoundDiskSectoroperator() (const std::vector< const GeomDet * > &dets) const
 

Private Member Functions

Surface::RotationType computeRotation (const std::vector< const GeomDet * > &dets, Surface::PositionType pos) const
 
std::vector< GlobalPointcomputeTrapezoidalCorners (const GeomDet *detu) const
 

Detailed Description

As it's name indicates, it's a builder of a BoundDiskSector from a collection of Dets. The disk sector has the minimal size fully containing all Dets.

Definition at line 18 of file ForwardDiskSectorBuilderFromDet.h.

Member Function Documentation

pair< DiskSectorBounds, GlobalVector > ForwardDiskSectorBuilderFromDet::computeBounds ( const std::vector< const GeomDet * > &  dets) const

Definition at line 38 of file ForwardDiskSectorBuilderFromDet.cc.

References funct::cos(), Vector3DBase< T, FrameTag >::dot(), F(), i, max(), min, phi, phimax, phimin, Geom::pi(), pos, alignCSCRings::r, funct::sin(), Vector3DBase< T, FrameTag >::unit(), tablePrinter::width, detailsBasic3DVector::z, and zPos.

39 {
40  // go over all corners and compute maximum deviations
41  float rmin = (**(dets.begin())).surface().position().perp();
42  float rmax(rmin);
43  float zmin((**(dets.begin())).surface().position().z());
44  float zmax(zmin);
45  float phimin((**(dets.begin())).surface().position().phi());
46  float phimax(phimin);
47 
48 
49  for (vector<const GeomDet*>::const_iterator idet=dets.begin();
50  idet != dets.end(); idet++) {
51  vector<const GeomDet*> detUnits = (**idet).components();
52  if( detUnits.size() ){
53  for (vector<const GeomDet*>::const_iterator detu=detUnits.begin();
54  detu!=detUnits.end(); detu++) {
55  // edm::LogInfo(TkDetLayers) << " Builder: Position of detUnit :"<< (**detu).position() ;
56  vector<GlobalPoint> corners = computeTrapezoidalCorners(*detu) ;
57  for (vector<GlobalPoint>::const_iterator i=corners.begin();
58  i!=corners.end(); i++) {
59  float r = i->perp();
60  float z = i->z();
61  float phi = i->phi();
62  rmin = min( rmin, r);
63  rmax = max( rmax, r);
64  zmin = min( zmin, z);
65  zmax = max( zmax, z);
66  if ( PhiLess()( phi, phimin)) phimin = phi;
67  if ( PhiLess()( phimax, phi)) phimax = phi;
68  }
69  // in addition to the corners we have to check the middle of the
70  // det +/- length/2, since the min (max) radius for typical fw
71  // dets is reached there
72  float rdet = (**detu).position().perp();
73  float len = (**detu).surface().bounds().length();
74  float width = (**detu).surface().bounds().width();
75 
76  GlobalVector xAxis = (**detu).toGlobal(LocalVector(1,0,0));
77  GlobalVector yAxis = (**detu).toGlobal(LocalVector(0,1,0));
78  GlobalVector perpDir = GlobalVector( (**detu).position() - GlobalPoint(0,0,(**detu).position().z()) );
79 
80  double xAxisCos = xAxis.unit().dot(perpDir.unit());
81  double yAxisCos = yAxis.unit().dot(perpDir.unit());
82 
83  if( fabs(xAxisCos) > fabs(yAxisCos) ) {
84  rmin = min( rmin, rdet-width/2.F);
85  rmax = max( rmax, rdet+width/2.F);
86  }else{
87  rmin = min( rmin, rdet-len/2.F);
88  rmax = max( rmax, rdet+len/2.F);
89  }
90  }
91  }else{
92  vector<GlobalPoint> corners = computeTrapezoidalCorners(*idet) ;
93  for (vector<GlobalPoint>::const_iterator i=corners.begin();
94  i!=corners.end(); i++) {
95  float r = i->perp();
96  float z = i->z();
97  float phi = i->phi();
98  rmin = min( rmin, r);
99  rmax = max( rmax, r);
100  zmin = min( zmin, z);
101  zmax = max( zmax, z);
102  if ( PhiLess()( phi, phimin)) phimin = phi;
103  if ( PhiLess()( phimax, phi)) phimax = phi;
104  }
105  // in addition to the corners we have to check the middle of the
106  // det +/- length/2, since the min (max) radius for typical fw
107  // dets is reached there
108 
109  float rdet = (**idet).position().perp();
110  float len = (**idet).surface().bounds().length();
111  float width = (**idet).surface().bounds().width();
112 
113  GlobalVector xAxis = (**idet).toGlobal(LocalVector(1,0,0));
114  GlobalVector yAxis = (**idet).toGlobal(LocalVector(0,1,0));
115  GlobalVector perpDir = GlobalVector( (**idet).position() - GlobalPoint(0,0,(**idet).position().z()) );
116 
117  double xAxisCos = xAxis.unit().dot(perpDir.unit());
118  double yAxisCos = yAxis.unit().dot(perpDir.unit());
119 
120  if( fabs(xAxisCos) > fabs(yAxisCos) ) {
121  rmin = min( rmin, rdet-width/2.F);
122  rmax = max( rmax, rdet+width/2.F);
123  }else{
124  rmin = min( rmin, rdet-len/2.F);
125  rmax = max( rmax, rdet+len/2.F);
126  }
127  }
128  }
129 
130 
131  if (!PhiLess()(phimin, phimax))
132  edm::LogError("TkDetLayers") << " ForwardDiskSectorBuilderFromDet : "
133  << "Something went wrong with Phi Sorting !" ;
134  float zPos = (zmax+zmin)/2.;
135  float phiWin = phimax - phimin;
136  float phiPos = (phimax+phimin)/2.;
137  float rmed = (rmin+rmax)/2.;
138  if ( phiWin < 0. ) {
139  if ( (phimin < Geom::pi() / 2.) || (phimax > -Geom::pi()/2.) ){
140  edm::LogError("TkDetLayers") << " Debug: something strange going on, please check " ;
141  }
142  // edm::LogInfo(TkDetLayers) << " Wedge at pi: phi " << phimin << " " << phimax << " " << phiWin
143  // << " " << 2.*Geom::pi()+phiWin << " " ;
144  phiWin += 2.*Geom::pi();
145  phiPos += Geom::pi();
146  }
147  GlobalVector pos( rmed*cos(phiPos), rmed*sin(phiPos), zPos);
148  return make_pair(DiskSectorBounds(rmin,rmax,zmin-zPos,zmax-zPos,phiWin), pos);
149 }
int i
Definition: DBlmapReader.cc:9
Local3DVector LocalVector
Definition: LocalVector.h:12
double zPos
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:107
#define min(a, b)
Definition: mlp_lapack.h:161
double double double z
const T & max(const T &a, const T &b)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Vector3DBase unit() const
Definition: Vector3DBase.h:57
std::vector< GlobalPoint > computeTrapezoidalCorners(const GeomDet *detu) const
double pi()
Definition: Pi.h:31
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
Global3DVector GlobalVector
Definition: GlobalVector.h:10
Definition: DDAxes.h:10
Surface::RotationType ForwardDiskSectorBuilderFromDet::computeRotation ( const std::vector< const GeomDet * > &  dets,
Surface::PositionType  pos 
) const
private

Definition at line 152 of file ForwardDiskSectorBuilderFromDet.cc.

References Vector3DBase< T, FrameTag >::cross(), csvLumiCalc::unit, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

153  {
154 
155  GlobalVector yAxis = ( GlobalVector( pos.x(), pos.y(), 0.)).unit();
156 
157  GlobalVector zAxis( 0., 0., 1.);
158  GlobalVector xAxis = yAxis.cross( zAxis);
159 
160  return Surface::RotationType( xAxis, yAxis);
161 }
T y() const
Definition: PV3DBase.h:62
string unit
Definition: csvLumiCalc.py:46
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:119
TkRotation< float > RotationType
T x() const
Definition: PV3DBase.h:61
Global3DVector GlobalVector
Definition: GlobalVector.h:10
vector< GlobalPoint > ForwardDiskSectorBuilderFromDet::computeTrapezoidalCorners ( const GeomDet detu) const
private

Definition at line 165 of file ForwardDiskSectorBuilderFromDet.cc.

References i, Parameters::parameters, and GeomDet::specificSurface().

165  {
166 
167 
168  const BoundPlane& plane( det->specificSurface());
169 
170  const TrapezoidalPlaneBounds* myBounds( static_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
171 
172  /*
173  if (myBounds == 0) {
174  string errmsg="ForwardDiskSectorBuilderFromDet: problems with dynamic cast to trapezoidal bounds for DetUnits";
175  throw DetLayerException(errmsg);
176  edm::LogError("TkDetLayers") << errmsg ;
177  }
178  */
179 
180  vector<float> parameters = (*myBounds).parameters();
181 
182  if ( parameters[0] == 0 ) {
183  edm::LogError("TkDetLayers") << "ForwardDiskSectorBuilder: something weird going on !" ;
184  edm::LogError("TkDetLayers") << " Trapezoidal parameters of GeomDet (L2/L1/T/H): " ;
185  for (int i = 0; i < 4; i++ ) edm::LogError("TkDetLayers") << " "
186  << 2.*parameters[i]
187  << "\n";
188  }
189 
190 
191  float hbotedge = parameters[0];
192  float htopedge = parameters[1];
193  float hapothem = parameters[3];
194  float hthick = parameters[2];
195 
196  vector<GlobalPoint> corners;
197 
198  corners.push_back( plane.toGlobal( LocalPoint( -htopedge, hapothem, hthick)));
199  corners.push_back( plane.toGlobal( LocalPoint( -htopedge, hapothem, -hthick)));
200  corners.push_back( plane.toGlobal( LocalPoint( htopedge, hapothem, hthick)));
201  corners.push_back( plane.toGlobal( LocalPoint( htopedge, hapothem, -hthick)));
202  corners.push_back( plane.toGlobal( LocalPoint( hbotedge, -hapothem, hthick)));
203  corners.push_back( plane.toGlobal( LocalPoint( hbotedge, -hapothem, -hthick)));
204  corners.push_back( plane.toGlobal( LocalPoint( -hbotedge, -hapothem, hthick)));
205  corners.push_back( plane.toGlobal( LocalPoint( -hbotedge, -hapothem, -hthick)));
206 
207  return corners;
208 }
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
BoundDiskSector * ForwardDiskSectorBuilderFromDet::operator() ( const std::vector< const GeomDet * > &  dets) const

Warning, remember to assign this pointer to a ReferenceCountingPointer! Should be changed to return a ReferenceCountingPointer<BoundDisk>

Definition at line 13 of file ForwardDiskSectorBuilderFromDet.cc.

References i, PV3DBase< T, PVType, FrameType >::perp(), pos, GloballyPositioned< T >::position(), and makeMuonMisalignmentScenario::rot.

14 {
15  // check that the dets are all at about the same radius and z
16  float rcheck = dets.front()->surface().position().perp();
17  float zcheck = dets.front()->surface().position().z();
18  for ( vector<const GeomDet*>::const_iterator i = dets.begin(); i != dets.end(); i++){
19  float rdiff = (**i).surface().position().perp()-rcheck;
20  if ( fabs(rdiff) > 1.)
21  edm::LogError("TkDetLayers") << " ForwardDiskSectorBuilderFromDet: Trying to build Petal Wedge from "
22  << "Dets at different radii !! Delta_r = " << rdiff ;
23  float zdiff = zcheck - (**i).surface().position().z();
24  if ( fabs(zdiff) > 0.8)
25  edm::LogError("TkDetLayers") << " ForwardDiskSectorBuilderFromDet: Trying to build Petal Wedge from "
26  << "Dets at different z positions !! Delta_z = " << zdiff ;
27  }
28 
29  pair<DiskSectorBounds,GlobalVector> bo =
30  computeBounds( dets );
31 
32  Surface::PositionType pos( bo.second.x(), bo.second.y(), bo.second.z() );
34  return new BoundDiskSector( pos, rot, bo.first);
35 }
int i
Definition: DBlmapReader.cc:9
std::pair< DiskSectorBounds, GlobalVector > computeBounds(const std::vector< const GeomDet * > &dets) const
Surface::RotationType computeRotation(const std::vector< const GeomDet * > &dets, Surface::PositionType pos) const