CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
magneticfield::volumeHandle Class Reference

#include <DD4hep_volumeHandle.h>

Inheritance diagram for magneticfield::volumeHandle:
magneticfield::BaseVolumeHandle

Public Member Functions

volumeHandle operator= (const volumeHandle &v)=delete
 
DDSolidShape shape () const override
 Shape of the solid. More...
 
std::vector< VolumeSidesides () const override
 The surfaces and they orientation, as required to build a MagVolume. More...
 
 volumeHandle (const cms::DDFilteredView &fv, bool expand2Pi=false, bool debugVal=false)
 
 volumeHandle (const volumeHandle &v)=delete
 
- Public Member Functions inherited from magneticfield::BaseVolumeHandle
 BaseVolumeHandle (bool expand2Pi=false, bool debugVal=false)
 
 BaseVolumeHandle (const BaseVolumeHandle &v)=delete
 
const GlobalPointcenter () const
 Return the center of the volume. More...
 
bool isIron () const
 Temporary hack to pass information on material. Will eventually be replaced! More...
 
bool isPlaneMatched (int which_side) const
 if the specified surface has been matched. More...
 
Geom::Phi< float > maxPhi () const
 Maximum value of phi covered by the volume. More...
 
double maxZ () const
 
Geom::Phi< float > minPhi () const
 Minimum value of phi covered by the volume. More...
 
double minR () const
 Minimum R for any point within the volume. More...
 
double minZ () const
 Z limits. More...
 
const GloballyPositioned< float > * placement () const
 Position and rotation. More...
 
int references (int which_side) const
 
const double RN () const
 Distance of (x,y) plane from origin. More...
 
bool sameSurface (const Surface &s1, Sides which_side, float tolerance=0.01)
 Find out if two surfaces are the same physical surface. More...
 
bool setSurface (const Surface &s1, Sides which_side)
 Assign a shared surface perorming sanity checks. More...
 
const Surfacesurface (int which_side) const
 Get the current surface on specified side. More...
 
const Surfacesurface (Sides which_side) const
 
bool toExpand () const
 
virtual ~BaseVolumeHandle ()
 

Private Member Functions

void buildBox ()
 
void buildCons ()
 
void buildPseudoTrap (double x1, double x2, double y1, double y2, double halfZ, double radius, bool atMinusZ)
 
void buildTrap ()
 
void buildTruncTubs ()
 
void buildTubs ()
 
void referencePlane (const cms::DDFilteredView &fv)
 

Private Attributes

const cms::DDFilteredViewsolid
 
const DDSolidShape theShape
 

Additional Inherited Members

- Public Types inherited from magneticfield::BaseVolumeHandle
typedef Surface::GlobalPoint GlobalPoint
 
typedef Surface::LocalPoint LocalPoint
 
typedef Surface::LocalVector LocalVector
 
typedef SurfaceOrientation::GlobalFace Sides
 
- Public Attributes inherited from magneticfield::BaseVolumeHandle
unsigned short copyno
 copy number More...
 
std::string magFile
 Name of magnetic field table file. More...
 
MagVolume6FacesmagVolume
 Pointer to the final MagVolume (must be set from outside) More...
 
int masterSector
 The sector for which an interpolator for this class of volumes should be built. More...
 
std::string name
 Name of the volume. More...
 
unsigned short volumeno
 volume number More...
 
- Protected Types inherited from magneticfield::BaseVolumeHandle
typedef ConstReferenceCountingPointer< SurfaceRCPS
 
- Protected Member Functions inherited from magneticfield::BaseVolumeHandle
void buildPhiZSurf (double startPhi, double deltaPhi, double zhalf, double rCentr)
 
- Protected Attributes inherited from magneticfield::BaseVolumeHandle
GlobalPoint center_
 
const bool debug
 
bool expand
 
bool isAssigned [6]
 
bool isIronFlag
 
GloballyPositioned< float > * refPlane
 
RCPS surfaces [6]
 
Geom::Phi< float > thePhiMin
 
double theRMax
 
double theRMin
 
double theRN
 

Detailed Description

Definition at line 23 of file DD4hep_volumeHandle.h.

Constructor & Destructor Documentation

◆ volumeHandle() [1/2]

volumeHandle::volumeHandle ( const cms::DDFilteredView fv,
bool  expand2Pi = false,
bool  debugVal = false 
)

Definition at line 27 of file DD4hep_volumeHandle.cc.

28  : BaseVolumeHandle(expand2Pi, debugVal), theShape(fv.legacyShape(cms::dd::getCurrentShape(fv))), solid(fv) {
29  name = fv.name();
30  copyno = fv.copyNum();
31  const auto *const transArray = fv.trans();
32  center_ = GlobalPoint(transArray[0], transArray[1], transArray[2]);
33 
34  // ASSUMPTION: volume names ends with "_NUM" where NUM is the volume number
35  string volName = name;
36  volName.erase(0, volName.rfind('_') + 1);
37  volumeno = static_cast<unsigned short>(std::atoi(volName.c_str()));
38 
39  for (int i = 0; i < 6; ++i) {
40  isAssigned[i] = false;
41  }
42  referencePlane(fv);
43  switch (theShape) {
45  buildBox();
46  break;
48  buildTrap();
49  break;
51  buildCons();
52  break;
54  buildTubs();
55  break;
57  vector<double> d = solid.volume().volume().solid().dimensions();
58  buildPseudoTrap(d[0], d[1], d[2], d[3], d[4], d[5], d[6]);
59  } break;
62  break;
63  default:
64  LogError("magneticfield::volumeHandle")
65  << "ctor: Unexpected shape # " << static_cast<int>(theShape) << " for vol " << name;
66  }
67 
68  // Get material for this volume
69  if (fv.materialName() == "Iron")
70  isIronFlag = true;
71 
72  if (debug) {
73  LogTrace("MagGeoBuilder") << " RMin = " << theRMin << newln << " RMax = " << theRMax;
74 
75  if (theRMin < 0 || theRN < theRMin || theRMax < theRN)
76  LogTrace("MagGeoBuilder") << "*** WARNING: wrong RMin/RN/RMax";
77 
78  LogTrace("MagGeoBuilder") << "Summary: " << name << " " << copyno << " shape = " << theShape << " trasl "
79  << center() << " R " << center().perp() << " phi " << center().phi() << " magFile "
80  << magFile << " Material= " << fv.materialName() << " isIron= " << isIronFlag
81  << " masterSector= " << masterSector;
82 
83  LogTrace("MagGeoBuilder") << " Orientation of surfaces:";
84  std::string sideName[3] = {"positiveSide", "negativeSide", "onSurface"};
85  for (int i = 0; i < 6; ++i) {
86  if (surfaces[i] != nullptr)
87  LogTrace("MagGeoBuilder") << " " << i << ":" << sideName[surfaces[i]->side(center_, 0.3)];
88  }
89  }
90 }

References buildBox(), buildCons(), buildPseudoTrap(), buildTrap(), buildTruncTubs(), buildTubs(), magneticfield::BaseVolumeHandle::center(), magneticfield::BaseVolumeHandle::center_, magneticfield::BaseVolumeHandle::copyno, cms::DDFilteredView::copyNum(), ztail::d, ddbox, ddcons, ddpseudotrap, ddtrap, ddtrunctubs, ddtubs, magneticfield::BaseVolumeHandle::debug, mps_fire::i, magneticfield::BaseVolumeHandle::isAssigned, magneticfield::BaseVolumeHandle::isIronFlag, LogTrace, magneticfield::BaseVolumeHandle::magFile, magneticfield::BaseVolumeHandle::masterSector, cms::DDFilteredView::materialName(), magneticfield::BaseVolumeHandle::name, cms::DDFilteredView::name(), magneticfield::newln, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), referencePlane(), solid, AlCaHLTBitMon_QueryRunRegistry::string, magneticfield::BaseVolumeHandle::surfaces, magneticfield::BaseVolumeHandle::theRMax, magneticfield::BaseVolumeHandle::theRMin, magneticfield::BaseVolumeHandle::theRN, theShape, cms::DDFilteredView::trans(), cms::DDFilteredView::volume(), and magneticfield::BaseVolumeHandle::volumeno.

◆ volumeHandle() [2/2]

magneticfield::volumeHandle::volumeHandle ( const volumeHandle v)
delete

Member Function Documentation

◆ buildBox()

void magneticfield::volumeHandle::buildBox ( )
private

Referenced by volumeHandle().

◆ buildCons()

void magneticfield::volumeHandle::buildCons ( )
private

Referenced by volumeHandle().

◆ buildPseudoTrap()

void magneticfield::volumeHandle::buildPseudoTrap ( double  x1,
double  x2,
double  y1,
double  y2,
double  halfZ,
double  radius,
bool  atMinusZ 
)
private

Referenced by volumeHandle().

◆ buildTrap()

void magneticfield::volumeHandle::buildTrap ( )
private

Referenced by volumeHandle().

◆ buildTruncTubs()

void magneticfield::volumeHandle::buildTruncTubs ( )
private

Referenced by volumeHandle().

◆ buildTubs()

void magneticfield::volumeHandle::buildTubs ( )
private

Referenced by volumeHandle().

◆ operator=()

volumeHandle magneticfield::volumeHandle::operator= ( const volumeHandle v)
delete

◆ referencePlane()

void volumeHandle::referencePlane ( const cms::DDFilteredView fv)
private

Definition at line 92 of file DD4hep_volumeHandle.cc.

92  {
93  // The refPlane is the "main plane" for the solid. It corresponds to the
94  // x,y plane in the DDD local frame, and defines a frame where the local
95  // coordinates are the same as in DDD.
96  // In the geometry version 85l_030919, this plane is normal to the
97  // beam line for all volumes but pseudotraps, so that global R is along Y,
98  // global phi is along -X and global Z along Z:
99  //
100  // Global(for vol at pi/2) Local
101  // +R (+Y) +Y
102  // +phi(-X) -X
103  // +Z +Z
104  //
105  // For pseudotraps the refPlane is parallel to beam line and global R is
106  // along Z, global phi is along +-X and and global Z along Y:
107  //
108  // Global(for vol at pi/2) Local
109  // +R (+Y) +Z
110  // +phi(-X) +X
111  // +Z +Y
112  //
113  // Note that the frame is centered in the DDD volume center, which is
114  // inside the volume for DDD boxes and (pesudo)trapezoids, on the beam line
115  // for tubs, cons and trunctubs.
116 
117  // In geometry version 1103l, trapezoids have X and Z in the opposite direction
118  // than the above. Boxes are either oriented as described above or in some case
119  // have opposite direction for Y and X.
120 
121  // The global position
122  Surface::PositionType &posResult = center_;
123 
124  // The reference plane rotation
125  math::XYZVector x, y, z;
126  dd4hep::Rotation3D refRot;
127  fv.rot(refRot);
128  refRot.GetComponents(x, y, z);
129  if (debug) {
130  if (x.Cross(y).Dot(z) < 0.5) {
131  LogTrace("MagGeoBuilder") << "*** WARNING: Rotation is not RH ";
132  }
133  }
134 
135  // The global rotation
136  Surface::RotationType rotResult(float(x.X()),
137  float(x.Y()),
138  float(x.Z()),
139  float(y.X()),
140  float(y.Y()),
141  float(y.Z()),
142  float(z.X()),
143  float(z.Y()),
144  float(z.Z()));
145 
146  refPlane = new GloballyPositioned<float>(posResult, rotResult);
147 
148  // Check correct orientation
149  if (debug) {
150  LogTrace("MagGeoBuilder") << "Refplane pos " << refPlane->position();
151 
152  // See comments above for the conventions for orientation.
153  LocalVector globalZdir(0., 0., 1.); // Local direction of the axis along global Z
154 
156  globalZdir = LocalVector(0., 1., 0.);
157  }
158 
159  if (refPlane->toGlobal(globalZdir).z() < 0.) {
160  globalZdir = -globalZdir;
161  }
162  float chk = refPlane->toGlobal(globalZdir).dot(GlobalVector(0, 0, 1));
163  if (chk < .999)
164  LogTrace("MagGeoBuilder") << "*** WARNING RefPlane check failed!***" << chk;
165  }
166 }

References magneticfield::BaseVolumeHandle::center_, ddpseudotrap, magneticfield::BaseVolumeHandle::debug, LogTrace, GloballyPositioned< T >::position(), magneticfield::BaseVolumeHandle::refPlane, cms::DDFilteredView::rot(), theShape, GloballyPositioned< T >::toGlobal(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by volumeHandle().

◆ shape()

DDSolidShape magneticfield::volumeHandle::shape ( ) const
inlineoverridevirtual

Shape of the solid.

Implements magneticfield::BaseVolumeHandle.

Definition at line 33 of file DD4hep_volumeHandle.h.

33 { return (theShape); }

References theShape.

◆ sides()

std::vector< VolumeSide > volumeHandle::sides ( void  ) const
overridevirtual

The surfaces and they orientation, as required to build a MagVolume.

Implements magneticfield::BaseVolumeHandle.

Definition at line 168 of file DD4hep_volumeHandle.cc.

168  {
169  std::vector<VolumeSide> result;
170  for (int i = 0; i < 6; ++i) {
171  // If this is just a master volume out of wich a 2pi volume
172  // should be built (e.g. central cylinder), skip the phi boundaries.
173  if (expand && (i == phiplus || i == phiminus))
174  continue;
175 
176  // FIXME: Skip null inner degenerate cylindrical surface
178  continue;
179 
180  ReferenceCountingPointer<Surface> s = const_cast<Surface *>(surfaces[i].get());
181  result.push_back(VolumeSide(s, GlobalFace(i), surfaces[i]->side(center_, 0.3)));
182  }
183  return result;
184 }

References magneticfield::BaseVolumeHandle::center_, ddtubs, magneticfield::BaseVolumeHandle::expand, get, mps_fire::i, SurfaceOrientation::inner, SurfaceOrientation::phiminus, SurfaceOrientation::phiplus, mps_fire::result, alignCSCRings::s, magneticfield::BaseVolumeHandle::surfaces, magneticfield::BaseVolumeHandle::theRMin, and theShape.

Referenced by magneticfield::MagGeoBuilder::buildInterpolator().

Member Data Documentation

◆ solid

const cms::DDFilteredView& magneticfield::volumeHandle::solid
private

Definition at line 58 of file DD4hep_volumeHandle.h.

Referenced by volumeHandle().

◆ theShape

const DDSolidShape magneticfield::volumeHandle::theShape
private

Definition at line 57 of file DD4hep_volumeHandle.h.

Referenced by referencePlane(), shape(), sides(), and volumeHandle().

Vector3DBase< float, LocalTag >
GloballyPositioned< float >
magneticfield::BaseVolumeHandle::magFile
std::string magFile
Name of magnetic field table file.
Definition: BaseVolumeHandle.h:66
cms::DDFilteredView::rot
const Double_t * rot() const
The absolute rotation of the current node.
Definition: DDFilteredView.cc:120
cms::DDFilteredView::volume
const PlacedVolume volume() const
The physical volume of the current node.
Definition: DDFilteredView.cc:68
magneticfield::BaseVolumeHandle::BaseVolumeHandle
BaseVolumeHandle(bool expand2Pi=false, bool debugVal=false)
Definition: BaseVolumeHandle.cc:24
SurfaceOrientation::phiplus
Definition: Surface.h:19
TkRotation< float >
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:355
DDSolidShape::ddtrap
magneticfield::BaseVolumeHandle::debug
const bool debug
Definition: BaseVolumeHandle.h:151
magneticfield::volumeHandle::buildBox
void buildBox()
magneticfield::volumeHandle::theShape
const DDSolidShape theShape
Definition: DD4hep_volumeHandle.h:57
cms::DDFilteredView::copyNum
unsigned short copyNum() const
Definition: DDFilteredView.cc:610
DDSolidShape::ddpseudotrap
magneticfield::BaseVolumeHandle::center
const GlobalPoint & center() const
Return the center of the volume.
Definition: BaseVolumeHandle.cc:42
magneticfield::BaseVolumeHandle::isAssigned
bool isAssigned[6]
Definition: BaseVolumeHandle.h:122
ReferenceCountingPointer< Surface >
DDAxes::x
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
magneticfield::BaseVolumeHandle::volumeno
unsigned short volumeno
volume number
Definition: BaseVolumeHandle.h:69
magneticfield::BaseVolumeHandle::expand
bool expand
Definition: BaseVolumeHandle.h:146
magneticfield::volumeHandle::buildTruncTubs
void buildTruncTubs()
VolumeSide
Definition: VolumeSide.h:15
magneticfield::BaseVolumeHandle::theRMin
double theRMin
Definition: BaseVolumeHandle.h:132
magneticfield::newln
const char *const newln
Definition: BaseVolumeHandle.h:218
cms::DDFilteredView::name
std::string_view name() const
Definition: DDFilteredView.cc:606
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
cms::DDFilteredView::trans
const Double_t * trans() const
The absolute translation of the current node.
Definition: DDFilteredView.cc:101
alignCSCRings.s
s
Definition: alignCSCRings.py:92
magneticfield::BaseVolumeHandle::theRN
double theRN
Definition: BaseVolumeHandle.h:128
DDSolidShape::ddtubs
magneticfield::BaseVolumeHandle::isIronFlag
bool isIronFlag
Definition: BaseVolumeHandle.h:149
SurfaceOrientation::inner
Definition: Surface.h:19
DDSolidShape::ddtrunctubs
magneticfield::BaseVolumeHandle::theRMax
double theRMax
Definition: BaseVolumeHandle.h:133
DDAxes::z
magneticfield::BaseVolumeHandle::GlobalPoint
Surface::GlobalPoint GlobalPoint
Definition: BaseVolumeHandle.h:24
Point3DBase< float, GlobalTag >
magneticfield::BaseVolumeHandle::masterSector
int masterSector
The sector for which an interpolator for this class of volumes should be built.
Definition: BaseVolumeHandle.h:111
cms::dd::getCurrentShape
DDSolidShape getCurrentShape(const cms::DDFilteredView &fview)
Definition: DDShapes.cc:19
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
magneticfield::BaseVolumeHandle::center_
GlobalPoint center_
Definition: BaseVolumeHandle.h:142
edm::LogError
Definition: MessageLogger.h:183
DDSolidShape::ddcons
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
magneticfield::BaseVolumeHandle::LocalVector
Surface::LocalVector LocalVector
Definition: BaseVolumeHandle.h:26
magneticfield::volumeHandle::referencePlane
void referencePlane(const cms::DDFilteredView &fv)
Definition: DD4hep_volumeHandle.cc:92
get
#define get
magneticfield::BaseVolumeHandle::copyno
unsigned short copyno
copy number
Definition: BaseVolumeHandle.h:72
magneticfield::volumeHandle::buildCons
void buildCons()
GloballyPositioned::position
const PositionType & position() const
Definition: GloballyPositioned.h:36
DDSolidShape::ddbox
magneticfield::BaseVolumeHandle::name
std::string name
Name of the volume.
Definition: BaseVolumeHandle.h:63
cms::DDFilteredView::materialName
std::string_view materialName() const
Definition: DDFilteredView.cc:612
magneticfield::BaseVolumeHandle::surfaces
RCPS surfaces[6]
Definition: BaseVolumeHandle.h:120
magneticfield::volumeHandle::solid
const cms::DDFilteredView & solid
Definition: DD4hep_volumeHandle.h:58
SurfaceOrientation::GlobalFace
GlobalFace
Definition: Surface.h:19
SurfaceOrientation::phiminus
Definition: Surface.h:19
ztail.d
d
Definition: ztail.py:151
mps_fire.result
result
Definition: mps_fire.py:303
cms::DDFilteredView::legacyShape
LegacySolidShape legacyShape(const cms::DDSolidShape shape) const
Definition: DDFilteredView.cc:468
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
magneticfield::BaseVolumeHandle::refPlane
GloballyPositioned< float > * refPlane
Definition: BaseVolumeHandle.h:139
magneticfield::volumeHandle::buildTrap
void buildTrap()
magneticfield::volumeHandle::buildPseudoTrap
void buildPseudoTrap(double x1, double x2, double y1, double y2, double halfZ, double radius, bool atMinusZ)
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
GloballyPositioned::toGlobal
GlobalPoint toGlobal(const LocalPoint &lp) const
Definition: GloballyPositioned.h:66
magneticfield::volumeHandle::buildTubs
void buildTubs()