CMS 3D CMS Logo

volumeHandle.h
Go to the documentation of this file.
1 #ifndef volumeHandle_H
2 #define volumeHandle_H
3 
14 
15 /* #include "DDD/DDCore/interface/DDSolid.h" */
18 //#include "ClassReuse/SurfaceGeometry/interface/BoundPlane.h"
20 
21 class DDExpandedView;
22 class MagVolume6Faces;
23 
24 
26 public:
31  volumeHandle(const DDExpandedView & fv, bool expand2Pi=false);
32  ~volumeHandle();
33 
35  const GlobalPoint & center() const;
37  const double RN() const {return theRN;}
39  const Surface & surface(int which_side) const;
40  const Surface & surface(Sides which_side) const;
42  bool sameSurface(const Surface & s1, Sides which_side, float tolerance = 0.01);
44  bool setSurface(const Surface & s1, Sides which_side);
46  bool isPlaneMatched(int which_side) const {
47  return isAssigned[which_side];
48  }
49 
50  int references(int which_side) const { // FIXME!
51 /* return surfaces[which_side]->references(); */
52  return 0;
53  }
54 
60  unsigned short volumeno;
62  unsigned short copyno;
63 
65  static void printUniqueNames(handles::const_iterator begin,
66  handles::const_iterator end, bool uniq=true);
67 
68 
69  // Phi ranges: Used by: LessDPhiMax; bSector; bSlab::[min|max]Phi();
70  // MagBSector, MagBRod
71 
73  // FIXME: actually returns phi of the point on median plane of the -phi
74  // surface, except for trapezoids where the absoulte min has been implemented
75  Geom::Phi<float> minPhi() const {return thePhiMin;}
77  // FIXME: actually returns phi of the point on median plane of the +phi
78  // surface
80 
82  // ASSUMPTION: Computed on median Z plane, but this is not a problem since
83  // all Z planes are orthogonal to the beam line in the current geometry.
84  double minZ() const {return surface(SurfaceOrientation::zminus).position().z();}
85  double maxZ() const {return surface(SurfaceOrientation::zplus).position().z();}
86 
88  double minR() const {return theRMin;}
89 
91  // double maxR() const {return theRMax;}
92 
94  const GloballyPositioned<float> * placement() const {return refPlane;}
95 
97  DDSolidShape shape() const {return solid.shape();}
98 
100  std::vector<VolumeSide> sides() const;
101 
104 
105  bool toExpand() const {return expand;}
106 
108  bool isIron() const{return isIronFlag;}
109 
112 
113 private:
114  // Disallow Default/copy ctor & assignment op.
115  // (we want to handle only pointers!!!)
116  volumeHandle(const volumeHandle& v) = delete;
117  volumeHandle operator=(const volumeHandle &v) = delete;
118 
119  // The volume's six surfaces.
121  // If the corresponding surface has been assigned to a shared surface.
122  bool isAssigned[6];
123 
124  // initialise the refPlane
125  void referencePlane(const DDExpandedView &fv);
126  // Build the surfaces for a box
127  void buildBox(const DDExpandedView & fv);
128  // Build the surfaces for a trapezoid
129  void buildTrap(const DDExpandedView & fv);
130  // Build the surfaces for a ddtubs shape
131  void buildTubs(const DDExpandedView & fv);
132  // Build the surfaces for a ddcons shape
133  void buildCons(const DDExpandedView & fv);
134  // Build the surfaces for a ddpseudotrap shape
135  void buildPseudoTrap(const DDExpandedView & fv);
136  // Build the surfaces for a ddtrunctubs shape
137  void buildTruncTubs(const DDExpandedView & fv);
138 
139  // Build phi, z surfaces (common for ddtubs and ddcons)
140  void buildPhiZSurf(double startPhi, double deltaPhi, double zhalf,
141  double rCentr);
142 
143  // Distance from the origin along the normal to the volume's zphi plane.
144  double theRN;
145 
146  // Max and min radius for _any_ point within the volume
147  // FIXME!
148  double theRMin;
149  double theRMax;
151 
152  // The refPlane is the "main plane" for the solid. It corresponds to the
153  // x,y plane in the DDD local frame, and defines a frame where the local
154  // coordinates are the same as in DDD.
156 
157  // the DDSolid.
159 
160  // the center of the volume
161  GlobalPoint center_;
162 
163  // Flag this as a master volume out of wich a 2pi volume should be built
164  // (e.g. central cylinder); this is taken into account by sides().
165  bool expand;
166 
167  // Temporary hack to keep information on material. Will eventually be replaced!
169 
170 };
171 
172 
173 // Extractors for precomputed_value_sort() (safe sorting)
174 
175 // To sort volumes in Z
177  double operator()(const volumeHandle* v) const {
178  return v->center().z();
179  }
180 };
181 
182 // To sort volumes in abs(Z)
184  double operator()(const volumeHandle* v) const {
185  return fabs(v->center().z());
186  }
187 };
188 
189 
190 // To sort volumes in phi (from -pi to pi).
192  double operator()(const volumeHandle* v) const {
193  // note that Geom::Phi is implicitly converted to double.
194  // Periodicity is guaranteed.
195  return v->center().phi();
196  }
197 };
198 
199 // To sort volumes based on max phi(from -pi to pi).
201  double operator()(const volumeHandle* v) const {
202  // note that Geom::Phi is implicitly converted to double.
203  // Periodicity is guaranteed.
204  return v->maxPhi();
205  }
206 };
207 
208 // To sort volumes in R
210  double operator()(const volumeHandle* v) const {
211  return v->center().perp();
212  }
213 };
214 
215 // To sort volumes in RN (distance of (x,y) plane from origin)
217  double operator()(const volumeHandle* v) const {
218  return v->RN();
219  }
220 };
221 
222 
223 // To sort angles within any range SMALLER THAN PI "counter-clockwise",
224 // even if the angles cross the pi boundary.
225 // CAVEAT: // The result is undefined if the input values cover a
226 // range larger than pi!!!
228  bool operator()(double phi1, double phi2) const {
229  // handle periodicity
230  return ((Geom::Phi<float>(phi2)-Geom::Phi<float>(phi1))>0.);
231  }
232 };
233 
234 // Compare the Z of volumes.
235 // Should be used ONLY for std::max_element and std::min_element
236 // and NEVER for sorting (use precomputed_value_sort with ExtractZ instead)
238  bool operator()(const volumeHandle * v1, const volumeHandle * v2) const
239  {
240  if (v1->center().z() < v2->center().z()) return true;
241  return false;
242  }
243 };
244 
245 #endif
246 
unsigned short copyno
copy number
Definition: volumeHandle.h:62
const GloballyPositioned< float > * placement() const
FIXME: currently returns max RN (to be fixed?). Used by: bLayer::maxR()
Definition: volumeHandle.h:94
void buildBox(const DDExpandedView &fv)
void buildPhiZSurf(double startPhi, double deltaPhi, double zhalf, double rCentr)
T perp() const
Definition: PV3DBase.h:72
bool operator()(const volumeHandle *v1, const volumeHandle *v2) const
Definition: volumeHandle.h:238
bool isPlaneMatched(int which_side) const
if the specified surface has been matched.
Definition: volumeHandle.h:46
GloballyPositioned< float > * refPlane
Definition: volumeHandle.h:155
double operator()(const volumeHandle *v) const
Definition: volumeHandle.h:210
double operator()(const volumeHandle *v) const
Definition: volumeHandle.h:184
const double tolerance
void buildTubs(const DDExpandedView &fv)
std::vector< VolumeSide > sides() const
The surfaces and they orientation, as required to build a MagVolume.
double operator()(const volumeHandle *v) const
Definition: volumeHandle.h:192
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
DDSolidShape
Definition: DDSolidShapes.h:4
void buildPseudoTrap(const DDExpandedView &fv)
const GlobalPoint & center() const
Return the center of the volume.
double operator()(const volumeHandle *v) const
Definition: volumeHandle.h:177
Geom::Phi< float > maxPhi() const
Maximum value of phi covered by the volume.
Definition: volumeHandle.h:79
Geom::Phi< float > minPhi() const
Minimum value of phi covered by the volume.
Definition: volumeHandle.h:75
std::string name
Name of the volume.
Definition: volumeHandle.h:56
DDSolidShape shape() const
Shape of the solid.
Definition: volumeHandle.h:97
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
bool isIron() const
Temporary hack to pass information on material. Will eventually be replaced!
Definition: volumeHandle.h:108
const double RN() const
Distance of (x,y) plane from origin.
Definition: volumeHandle.h:37
T z() const
Definition: PV3DBase.h:64
Surface::LocalPoint LocalPoint
Definition: volumeHandle.h:28
Surface::GlobalPoint GlobalPoint
Definition: volumeHandle.h:27
std::string magFile
Name of magnetic field table file.
Definition: volumeHandle.h:58
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
void buildCons(const DDExpandedView &fv)
#define end
Definition: vmac.h:39
void referencePlane(const DDExpandedView &fv)
Point3DBase< float, GlobalTag > GlobalPoint
volumeHandle(const DDExpandedView &fv, bool expand2Pi=false)
Definition: volumeHandle.cc:39
Surface::LocalVector LocalVector
Definition: volumeHandle.h:29
double minZ() const
Z limits.
Definition: volumeHandle.h:84
double operator()(const volumeHandle *v) const
Definition: volumeHandle.h:217
unsigned short volumeno
volume number
Definition: volumeHandle.h:60
static void printUniqueNames(handles::const_iterator begin, handles::const_iterator end, bool uniq=true)
Just for debugging...
volumeHandle operator=(const volumeHandle &v)=delete
SurfaceOrientation::GlobalFace Sides
Definition: volumeHandle.h:30
double operator()(const volumeHandle *v) const
Definition: volumeHandle.h:201
const Surface & surface(int which_side) const
Get the current surface on specified side.
#define begin
Definition: vmac.h:32
double minR() const
Minimum R for any point within the volume.
Definition: volumeHandle.h:88
bool operator()(double phi1, double phi2) const
Definition: volumeHandle.h:228
void buildTrap(const DDExpandedView &fv)
int masterSector
The sector for which an interpolator for this class of volumes should be built.
Definition: volumeHandle.h:111
int references(int which_side) const
Definition: volumeHandle.h:50
MagVolume6Faces * magVolume
Pointer to the final MagVolume (must be set from outside)
Definition: volumeHandle.h:103
const PositionType & position() const
Provides an exploded view of the detector (tree-view)
bool setSurface(const Surface &s1, Sides which_side)
Assign a shared surface perorming sanity checks.
bool sameSurface(const Surface &s1, Sides which_side, float tolerance=0.01)
Find out if two surfaces are the same physical surface.
void buildTruncTubs(const DDExpandedView &fv)