CMS 3D CMS Logo

BaseVolumeHandle.h
Go to the documentation of this file.
1 #ifndef MagneticField_GeomBuilder_BaseVolumeHandle_H
2 #define MagneticField_GeomBuilder_BaseVolumeHandle_H
3 
17 
18 class MagVolume6Faces;
19 
20 namespace magneticfield {
21 
23  public:
28 
29  BaseVolumeHandle(bool expand2Pi = false, bool debugVal = false);
30 
31  // Disallow Default/copy ctor
32  // (we want to handle only pointers!!!)
33  BaseVolumeHandle(const BaseVolumeHandle& v) = delete;
34 
35  virtual ~BaseVolumeHandle();
36 
38  const GlobalPoint& center() const;
39 
41  const double RN() const { return theRN; }
42 
44  const Surface& surface(int which_side) const;
45 
46  const Surface& surface(Sides which_side) const;
47 
49  bool sameSurface(const Surface& s1, Sides which_side, float tolerance = 0.01);
50 
52  bool setSurface(const Surface& s1, Sides which_side);
53 
55  bool isPlaneMatched(int which_side) const { return isAssigned[which_side]; }
56 
57  int references(int which_side) const { // FIXME!
58  /* return surfaces[which_side]->references(); */
59  return 0;
60  }
61 
64 
67 
69  unsigned short volumeno;
70 
72  unsigned short copyno;
73 
74  // Phi ranges: Used by: LessDPhiMax; bSector; bSlab::[min|max]Phi();
75  // MagBSector, MagBRod
76 
78  // FIXME: actually returns phi of the point on median plane of the -phi
79  // surface, except for trapezoids where the absoulte min has been implemented
80  Geom::Phi<float> minPhi() const { return thePhiMin; }
81 
83  // FIXME: actually returns phi of the point on median plane of the +phi
84  // surface
86 
88  // ASSUMPTION: Computed on median Z plane, but this is not a problem since
89  // all Z planes are orthogonal to the beam line in the current geometry.
90  double minZ() const { return surface(SurfaceOrientation::zminus).position().z(); }
91  double maxZ() const { return surface(SurfaceOrientation::zplus).position().z(); }
92 
94  double minR() const { return theRMin; }
95 
97  const GloballyPositioned<float>* placement() const { return refPlane; }
98 
100  virtual std::vector<VolumeSide> sides() const = 0;
101 
104 
105  bool toExpand() const { return expand; }
106 
108  bool isIron() const { return isIronFlag; }
109 
112 
114  virtual DDSolidShape shape() const = 0;
115 
116  protected:
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  // Build phi, z surfaces (common for ddtubs and ddcons)
125  void buildPhiZSurf(double startPhi, double deltaPhi, double zhalf, double rCentr);
126 
127  // Distance from the origin along the normal to the volume's zphi plane.
128  double theRN;
129 
130  // Max and min radius for _any_ point within the volume
131  // FIXME!
132  double theRMin;
133  double theRMax;
135 
136  // The refPlane is the "main plane" for the solid. It corresponds to the
137  // x,y plane in the DDD local frame, and defines a frame where the local
138  // coordinates are the same as in DDD.
140 
141  // the center of the volume
143 
144  // Flag this as a master volume out of wich a 2pi volume should be built
145  // (e.g. central cylinder); this is taken into account by sides().
146  bool expand;
147 
148  // Temporary hack to keep information on material. Will eventually be replaced!
150 
151  const bool debug;
152  };
153 
154  typedef std::vector<BaseVolumeHandle*> handles;
155 
156  // Extractors for precomputed_value_sort() (safe sorting)
157 
158  // To sort volumes in Z
159  struct ExtractZ {
160  double operator()(const BaseVolumeHandle* v) const { return v->center().z(); }
161  };
162 
163  // To sort volumes in abs(Z)
164  struct ExtractAbsZ {
165  double operator()(const BaseVolumeHandle* v) const { return fabs(v->center().z()); }
166  };
167 
168  // To sort volumes in phi (from -pi to pi).
169  struct ExtractPhi {
170  double operator()(const BaseVolumeHandle* v) const {
171  // note that Geom::Phi is implicitly converted to double.
172  // Periodicity is guaranteed.
173  return v->center().phi();
174  }
175  };
176 
177  // To sort volumes based on max phi(from -pi to pi).
178  struct ExtractPhiMax {
179  double operator()(const BaseVolumeHandle* v) const {
180  // note that Geom::Phi is implicitly converted to double.
181  // Periodicity is guaranteed.
182  return v->maxPhi();
183  }
184  };
185 
186  // To sort volumes in R
187  struct ExtractR {
188  double operator()(const BaseVolumeHandle* v) const { return v->center().perp(); }
189  };
190 
191  // To sort volumes in RN (distance of (x,y) plane from origin)
192  struct ExtractRN {
193  double operator()(const BaseVolumeHandle* v) const { return v->RN(); }
194  };
195 
196  // To sort angles within any range SMALLER THAN PI "counter-clockwise",
197  // even if the angles cross the pi boundary.
198  // CAVEAT: // The result is undefined if the input values cover a
199  // range larger than pi!!!
200  struct LessDPhi {
201  bool operator()(double phi1, double phi2) const {
202  // handle periodicity
203  return ((Geom::Phi<float>(phi2) - Geom::Phi<float>(phi1)) > 0.);
204  }
205  };
206 
207  // Compare the Z of volumes.
208  // Should be used ONLY for std::max_element and std::min_element
209  // and NEVER for sorting (use precomputed_value_sort with ExtractZ instead)
210  struct LessZ {
211  bool operator()(const BaseVolumeHandle* v1, const BaseVolumeHandle* v2) const {
212  if (v1->center().z() < v2->center().z())
213  return true;
214  return false;
215  }
216  };
217 
218  inline const char* const newln = "\n";
219  // Newline for formatting debug messages
220  // Intended to be similar to "endl"
221 
222 } // namespace magneticfield
223 
224 #endif
Vector3DBase< float, LocalTag >
GloballyPositioned< float >
DDSolidShapes.h
magneticfield::BaseVolumeHandle::magFile
std::string magFile
Name of magnetic field table file.
Definition: BaseVolumeHandle.h:66
magneticfield::BaseVolumeHandle::BaseVolumeHandle
BaseVolumeHandle(bool expand2Pi=false, bool debugVal=false)
Definition: BaseVolumeHandle.cc:24
SurfaceOrientation::phiplus
Definition: Surface.h:19
GloballyPositioned< float >::GlobalPoint
Point3DBase< float, GlobalTag > GlobalPoint
Definition: GloballyPositioned.h:23
magneticfield::BaseVolumeHandle::references
int references(int which_side) const
Definition: BaseVolumeHandle.h:57
DDSolidShape
DDSolidShape
Definition: DDSolidShapes.h:6
magneticfield::BaseVolumeHandle::debug
const bool debug
Definition: BaseVolumeHandle.h:151
magneticfield::BaseVolumeHandle::maxZ
double maxZ() const
Definition: BaseVolumeHandle.h:91
magneticfield::BaseVolumeHandle::toExpand
bool toExpand() const
Definition: BaseVolumeHandle.h:105
magneticfield::BaseVolumeHandle::thePhiMin
Geom::Phi< float > thePhiMin
Definition: BaseVolumeHandle.h:134
magneticfield::BaseVolumeHandle::center
const GlobalPoint & center() const
Return the center of the volume.
Definition: BaseVolumeHandle.cc:42
magneticfield::BaseVolumeHandle::surface
const Surface & surface(int which_side) const
Get the current surface on specified side.
Definition: BaseVolumeHandle.cc:215
magneticfield::BaseVolumeHandle::isAssigned
bool isAssigned[6]
Definition: BaseVolumeHandle.h:122
magneticfield
Definition: MagFieldConfig.h:22
magneticfield::LessZ
Definition: BaseVolumeHandle.h:210
magneticfield::LessZ::operator()
bool operator()(const BaseVolumeHandle *v1, const BaseVolumeHandle *v2) const
Definition: BaseVolumeHandle.h:211
ConstReferenceCountingPointer< Surface >
Surface
Definition: Surface.h:36
magneticfield::BaseVolumeHandle::volumeno
unsigned short volumeno
volume number
Definition: BaseVolumeHandle.h:69
magneticfield::BaseVolumeHandle::minPhi
Geom::Phi< float > minPhi() const
Minimum value of phi covered by the volume.
Definition: BaseVolumeHandle.h:80
findQualityFiles.v
v
Definition: findQualityFiles.py:179
magneticfield::BaseVolumeHandle::expand
bool expand
Definition: BaseVolumeHandle.h:146
magneticfield::ExtractZ::operator()
double operator()(const BaseVolumeHandle *v) const
Definition: BaseVolumeHandle.h:160
magneticfield::ExtractR::operator()
double operator()(const BaseVolumeHandle *v) const
Definition: BaseVolumeHandle.h:188
magneticfield::ExtractZ
Definition: BaseVolumeHandle.h:159
magneticfield::BaseVolumeHandle::theRMin
double theRMin
Definition: BaseVolumeHandle.h:132
magneticfield::newln
const char *const newln
Definition: BaseVolumeHandle.h:218
magneticfield::BaseVolumeHandle::RCPS
ConstReferenceCountingPointer< Surface > RCPS
Definition: BaseVolumeHandle.h:117
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
magneticfield::BaseVolumeHandle::magVolume
MagVolume6Faces * magVolume
Pointer to the final MagVolume (must be set from outside)
Definition: BaseVolumeHandle.h:103
VolumeSide.h
magneticfield::BaseVolumeHandle::theRN
double theRN
Definition: BaseVolumeHandle.h:128
magneticfield::BaseVolumeHandle::Sides
SurfaceOrientation::GlobalFace Sides
Definition: BaseVolumeHandle.h:27
Surface.h
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
magneticfield::BaseVolumeHandle::isIronFlag
bool isIronFlag
Definition: BaseVolumeHandle.h:149
magneticfield::BaseVolumeHandle::isPlaneMatched
bool isPlaneMatched(int which_side) const
if the specified surface has been matched.
Definition: BaseVolumeHandle.h:55
magneticfield::BaseVolumeHandle::~BaseVolumeHandle
virtual ~BaseVolumeHandle()
Definition: BaseVolumeHandle.cc:35
magneticfield::BaseVolumeHandle::shape
virtual DDSolidShape shape() const =0
Shape of the solid.
magneticfield::BaseVolumeHandle::theRMax
double theRMax
Definition: BaseVolumeHandle.h:133
magneticfield::BaseVolumeHandle::GlobalPoint
Surface::GlobalPoint GlobalPoint
Definition: BaseVolumeHandle.h:24
magneticfield::BaseVolumeHandle::sameSurface
bool sameSurface(const Surface &s1, Sides which_side, float tolerance=0.01)
Find out if two surfaces are the same physical surface.
Definition: BaseVolumeHandle.cc:101
MagVolume6Faces
Definition: MagVolume6Faces.h:23
magneticfield::BaseVolumeHandle::placement
const GloballyPositioned< float > * placement() const
Position and rotation.
Definition: BaseVolumeHandle.h:97
Point3DBase< float, LocalTag >
magneticfield::BaseVolumeHandle::masterSector
int masterSector
The sector for which an interpolator for this class of volumes should be built.
Definition: BaseVolumeHandle.h:111
magneticfield::handles
std::vector< BaseVolumeHandle * > handles
Definition: BaseVolumeHandle.h:154
SurfaceOrientation::zminus
Definition: Surface.h:19
magneticfield::BaseVolumeHandle::minZ
double minZ() const
Z limits.
Definition: BaseVolumeHandle.h:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
magneticfield::BaseVolumeHandle::maxPhi
Geom::Phi< float > maxPhi() const
Maximum value of phi covered by the volume.
Definition: BaseVolumeHandle.h:85
magneticfield::BaseVolumeHandle::center_
GlobalPoint center_
Definition: BaseVolumeHandle.h:142
magneticfield::LessDPhi
Definition: BaseVolumeHandle.h:200
magneticfield::ExtractR
Definition: BaseVolumeHandle.h:187
magneticfield::BaseVolumeHandle::LocalPoint
Surface::LocalPoint LocalPoint
Definition: BaseVolumeHandle.h:25
magneticfield::ExtractAbsZ::operator()
double operator()(const BaseVolumeHandle *v) const
Definition: BaseVolumeHandle.h:165
magneticfield::BaseVolumeHandle::LocalVector
Surface::LocalVector LocalVector
Definition: BaseVolumeHandle.h:26
tolerance
const double tolerance
Definition: HGCalGeomParameters.cc:26
magneticfield::ExtractPhi::operator()
double operator()(const BaseVolumeHandle *v) const
Definition: BaseVolumeHandle.h:170
Geom::Phi< float >
magneticfield::ExtractPhi
Definition: BaseVolumeHandle.h:169
magneticfield::BaseVolumeHandle
Definition: BaseVolumeHandle.h:22
magneticfield::BaseVolumeHandle::copyno
unsigned short copyno
copy number
Definition: BaseVolumeHandle.h:72
magneticfield::ExtractPhiMax
Definition: BaseVolumeHandle.h:178
magneticfield::BaseVolumeHandle::sides
virtual std::vector< VolumeSide > sides() const =0
The surfaces and they orientation, as required to build a MagVolume.
GloballyPositioned::position
const PositionType & position() const
Definition: GloballyPositioned.h:36
ReferenceCounted.h
magneticfield::BaseVolumeHandle::name
std::string name
Name of the volume.
Definition: BaseVolumeHandle.h:63
magneticfield::ExtractRN
Definition: BaseVolumeHandle.h:192
magneticfield::ExtractRN::operator()
double operator()(const BaseVolumeHandle *v) const
Definition: BaseVolumeHandle.h:193
magneticfield::BaseVolumeHandle::buildPhiZSurf
void buildPhiZSurf(double startPhi, double deltaPhi, double zhalf, double rCentr)
Definition: BaseVolumeHandle.cc:44
magneticfield::BaseVolumeHandle::surfaces
RCPS surfaces[6]
Definition: BaseVolumeHandle.h:120
SurfaceOrientation::zplus
Definition: Surface.h:19
magneticfield::BaseVolumeHandle::isIron
bool isIron() const
Temporary hack to pass information on material. Will eventually be replaced!
Definition: BaseVolumeHandle.h:108
magneticfield::LessDPhi::operator()
bool operator()(double phi1, double phi2) const
Definition: BaseVolumeHandle.h:201
SurfaceOrientation::GlobalFace
GlobalFace
Definition: Surface.h:19
magneticfield::ExtractPhiMax::operator()
double operator()(const BaseVolumeHandle *v) const
Definition: BaseVolumeHandle.h:179
magneticfield::ExtractAbsZ
Definition: BaseVolumeHandle.h:164
magneticfield::BaseVolumeHandle::setSurface
bool setSurface(const Surface &s1, Sides which_side)
Assign a shared surface perorming sanity checks.
Definition: BaseVolumeHandle.cc:177
magneticfield::BaseVolumeHandle::refPlane
GloballyPositioned< float > * refPlane
Definition: BaseVolumeHandle.h:139
magneticfield::BaseVolumeHandle::RN
const double RN() const
Distance of (x,y) plane from origin.
Definition: BaseVolumeHandle.h:41
magneticfield::BaseVolumeHandle::minR
double minR() const
Minimum R for any point within the volume.
Definition: BaseVolumeHandle.h:94
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66