CMS 3D CMS Logo

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