CMS 3D CMS Logo

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

#include <volumeHandle.h>

Inheritance diagram for MagGeoBuilderFromDDD::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 DDExpandedView &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 DDExpandedView &fv)
 

Private Attributes

DDSolid solid
 

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

A temporary container to cache info on a six-surface volume during the processing. Used to sort, organise, and build shared planes. One instance is created for each DDVolume. The parameters of the boundary surfaces are calculated during construction.

Author
N. Amapane - INFN Torino (original developer)

Definition at line 23 of file volumeHandle.h.

Constructor & Destructor Documentation

◆ volumeHandle() [1/2]

MagGeoBuilderFromDDD::volumeHandle::volumeHandle ( const DDExpandedView fv,
bool  expand2Pi = false,
bool  debugVal = false 
)

Definition at line 30 of file volumeHandle.cc.

31  : magneticfield::BaseVolumeHandle(expand2Pi, debugVal) {
32  name = fv.logicalPart().name().name();
33  copyno = fv.copyno();
34  solid = fv.logicalPart().solid();
35  center_ = GlobalPoint(fv.translation().x() / cm, fv.translation().y() / cm, fv.translation().z() / cm);
36 
37  // ASSUMPTION: volume names ends with "_NUM" where NUM is the volume number
38  string volName = name;
39  volName.erase(0, volName.rfind('_') + 1);
40  volumeno = boost::lexical_cast<unsigned short>(volName);
41 
42  for (int i = 0; i < 6; ++i) {
43  isAssigned[i] = false;
44  }
45 
46  if (debug) {
47  cout.precision(7);
48  }
49 
50  referencePlane(fv);
51 
52  if (solid.shape() == DDSolidShape::ddbox) {
53  buildBox();
54  } else if (solid.shape() == DDSolidShape::ddtrap) {
55  buildTrap();
56  } else if (solid.shape() == DDSolidShape::ddcons) {
57  buildCons();
58  } else if (solid.shape() == DDSolidShape::ddtubs) {
59  buildTubs();
60  } else if (solid.shape() == DDSolidShape::ddpseudotrap) {
61  DDPseudoTrap ptrap(solid);
62  buildPseudoTrap(ptrap.x1(), ptrap.x2(), ptrap.y1(), ptrap.y2(), ptrap.halfZ(), ptrap.radius(), ptrap.atMinusZ());
63  } else if (solid.shape() == DDSolidShape::ddtrunctubs) {
65  } else {
66  cout << "volumeHandle ctor: Unexpected solid: " << DDSolidShapesName::name(solid.shape()) << endl;
67  }
68 
69  // NOTE: Table name and master sector are no longer taken from xml!
70  // DDsvalues_type sv(fv.mergedSpecifics());
71 
72  // { // Extract the name of associated field file.
73  // std::vector<std::string> temp;
74  // std::string pname = "table";
75  // DDValue val(pname);
76  // DDsvalues_type sv(fv.mergedSpecifics());
77  // if (DDfetch(&sv,val)) {
78  // temp = val.strings();
79  // if (temp.size() != 1) {
80  // cout << "*** WARNING: volume has > 1 SpecPar " << pname << endl;
81  // }
82  // magFile = temp[0];
83 
84  // string find="[copyNo]";
85  // std::size_t j;
86  // for ( ; (j = magFile.find(find)) != string::npos ; ) {
87  // stringstream conv;
88  // conv << setfill('0') << setw(2) << copyno;
89  // string repl;
90  // conv >> repl;
91  // magFile.replace(j, find.length(), repl);
92  // }
93 
94  // } else {
95  // cout << "*** WARNING: volume does not have a SpecPar " << pname << endl;
96  // cout << " DDsvalues_type: " << fv.mergedSpecifics() << endl;
97  // }
98  // }
99 
100  // { // Extract the number of the master sector.
101  // std::vector<double> temp;
102  // const std::string pname = "masterSector";
103  // DDValue val(pname);
104  // if (DDfetch(&sv,val)) {
105  // temp = val.doubles();
106  // if (temp.size() != 1) {
107  // cout << "*** WARNING: volume has > 1 SpecPar " << pname << endl;
108  // }
109  // masterSector = int(temp[0]+.5);
110  // } else {
111  // if (MagGeoBuilderFromDDD::debug) {
112  // cout << "Volume does not have a SpecPar " << pname
113  // << " using: " << copyno << endl;
114  // cout << " DDsvalues_type: " << fv.mergedSpecifics() << endl;
115  // }
116  // masterSector = copyno;
117  // }
118  // }
119 
120  // Get material for this volume
121  if (fv.logicalPart().material().name().name() == "Iron")
122  isIronFlag = true;
123 
124  if (debug) {
125  cout << " RMin = " << theRMin << endl;
126  cout << " RMax = " << theRMax << endl;
127 
128  if (theRMin < 0 || theRN < theRMin || theRMax < theRN)
129  cout << "*** WARNING: wrong RMin/RN/RMax , shape: " << DDSolidShapesName::name(shape()) << endl;
130 
131  cout << "Summary: " << name << " " << copyno << " Shape= " << DDSolidShapesName::name(shape()) << " trasl "
132  << center() << " R " << center().perp() << " phi " << center().phi() << " magFile " << magFile
133  << " Material= " << fv.logicalPart().material().name() << " isIron= " << isIronFlag
134  << " masterSector= " << masterSector << std::endl;
135 
136  cout << " Orientation of surfaces:";
137  std::string sideName[3] = {"positiveSide", "negativeSide", "onSurface"};
138  for (int i = 0; i < 6; ++i) {
139  cout << " " << i << ":" << sideName[surfaces[i]->side(center_, 0.3)];
140  }
141  cout << endl;
142  }
143 }

References DDPseudoTrap::atMinusZ(), buildBox(), buildCons(), buildPseudoTrap(), buildTrap(), buildTruncTubs(), buildTubs(), magneticfield::BaseVolumeHandle::center(), magneticfield::BaseVolumeHandle::center_, magneticfield::BaseVolumeHandle::copyno, DDExpandedView::copyno(), gather_cfg::cout, ddbox, ddcons, ddpseudotrap, ddtrap, ddtrunctubs, ddtubs, magneticfield::BaseVolumeHandle::debug, DDPseudoTrap::halfZ(), mps_fire::i, magneticfield::BaseVolumeHandle::isAssigned, magneticfield::BaseVolumeHandle::isIronFlag, DDExpandedView::logicalPart(), magneticfield::BaseVolumeHandle::magFile, magneticfield::BaseVolumeHandle::masterSector, DDLogicalPart::material(), DDSolidShapesName::name(), DDName::name(), DDBase< N, C >::name(), magneticfield::BaseVolumeHandle::name, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), DDPseudoTrap::radius(), referencePlane(), shape(), DDSolid::shape(), solid, DDLogicalPart::solid(), AlCaHLTBitMon_QueryRunRegistry::string, magneticfield::BaseVolumeHandle::surfaces, magneticfield::BaseVolumeHandle::theRMax, magneticfield::BaseVolumeHandle::theRMin, magneticfield::BaseVolumeHandle::theRN, DDExpandedView::translation(), magneticfield::BaseVolumeHandle::volumeno, DDPseudoTrap::x1(), DDPseudoTrap::x2(), DDPseudoTrap::y1(), and DDPseudoTrap::y2().

◆ volumeHandle() [2/2]

MagGeoBuilderFromDDD::volumeHandle::volumeHandle ( const volumeHandle v)
delete

Member Function Documentation

◆ buildBox()

void MagGeoBuilderFromDDD::volumeHandle::buildBox ( )
private

Referenced by volumeHandle().

◆ buildCons()

void MagGeoBuilderFromDDD::volumeHandle::buildCons ( )
private

Referenced by volumeHandle().

◆ buildPseudoTrap()

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

Referenced by volumeHandle().

◆ buildTrap()

void MagGeoBuilderFromDDD::volumeHandle::buildTrap ( )
private

Referenced by volumeHandle().

◆ buildTruncTubs()

void MagGeoBuilderFromDDD::volumeHandle::buildTruncTubs ( )
private

Referenced by volumeHandle().

◆ buildTubs()

void MagGeoBuilderFromDDD::volumeHandle::buildTubs ( )
private

Referenced by volumeHandle().

◆ operator=()

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

◆ referencePlane()

void MagGeoBuilderFromDDD::volumeHandle::referencePlane ( const DDExpandedView fv)
private

Definition at line 145 of file volumeHandle.cc.

145  {
146  // The refPlane is the "main plane" for the solid. It corresponds to the
147  // x,y plane in the DDD local frame, and defines a frame where the local
148  // coordinates are the same as in DDD.
149  // In the geometry version 85l_030919, this plane is normal to the
150  // beam line for all volumes but pseudotraps, so that global R is along Y,
151  // global phi is along -X and global Z along Z:
152  //
153  // Global(for vol at pi/2) Local
154  // +R (+Y) +Y
155  // +phi(-X) -X
156  // +Z +Z
157  //
158  // For pseudotraps the refPlane is parallel to beam line and global R is
159  // along Z, global phi is along +-X and and global Z along Y:
160  //
161  // Global(for vol at pi/2) Local
162  // +R (+Y) +Z
163  // +phi(-X) +X
164  // +Z +Y
165  //
166  // Note that the frame is centered in the DDD volume center, which is
167  // inside the volume for DDD boxes and (pesudo)trapezoids, on the beam line
168  // for tubs, cons and trunctubs.
169 
170  // In geometry version 1103l, trapezoids have X and Z in the opposite direction
171  // than the above. Boxes are either oriented as described above or in some case
172  // have opposite direction for Y and X.
173 
174  // The global position
175  Surface::PositionType &posResult = center_;
176 
177  // The reference plane rotation
178  DD3Vector x, y, z;
179  fv.rotation().GetComponents(x, y, z);
180  if (debug) {
181  if (x.Cross(y).Dot(z) < 0.5) {
182  cout << "*** WARNING: Rotation is not RH " << endl;
183  }
184  }
185 
186  // The global rotation
187  Surface::RotationType rotResult(float(x.X()),
188  float(x.Y()),
189  float(x.Z()),
190  float(y.X()),
191  float(y.Y()),
192  float(y.Z()),
193  float(z.X()),
194  float(z.Y()),
195  float(z.Z()));
196 
197  refPlane = new GloballyPositioned<float>(posResult, rotResult);
198 
199  // Check correct orientation
200  if (debug) {
201  cout << "Refplane pos " << refPlane->position() << endl;
202 
203  // See comments above for the conventions for orientation.
204  LocalVector globalZdir(0., 0., 1.); // Local direction of the axis along global Z
206  globalZdir = LocalVector(0., 1., 0.);
207  }
208  if (refPlane->toGlobal(globalZdir).z() < 0.) {
209  globalZdir = -globalZdir;
210  }
211 
212  float chk = refPlane->toGlobal(globalZdir).dot(GlobalVector(0, 0, 1));
213  if (chk < .999)
214  cout << "*** WARNING RefPlane check failed!***" << chk << endl;
215  }
216 }

References gather_cfg::cout, ddpseudotrap, MagGeoBuilderFromDDD::debug, Vector3DBase< T, FrameTag >::dot(), DDExpandedView::rotation(), x, y, and z.

Referenced by volumeHandle().

◆ shape()

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

Shape of the solid.

Implements magneticfield::BaseVolumeHandle.

Definition at line 32 of file volumeHandle.h.

32 { return solid.shape(); }

References DDSolid::shape(), and solid.

Referenced by volumeHandle().

◆ sides()

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

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

Implements magneticfield::BaseVolumeHandle.

Definition at line 218 of file volumeHandle.cc.

218  {
219  std::vector<VolumeSide> result;
220  for (int i = 0; i < 6; ++i) {
221  // If this is just a master volume out of wich a 2pi volume
222  // should be built (e.g. central cylinder), skip the phi boundaries.
223  if (expand && (i == phiplus || i == phiminus))
224  continue;
225 
226  // FIXME: Skip null inner degenerate cylindrical surface
228  continue;
229 
230  ReferenceCountingPointer<Surface> s = const_cast<Surface *>(surfaces[i].get());
231  result.push_back(VolumeSide(s, GlobalFace(i), surfaces[i]->side(center_, 0.3)));
232  }
233  return result;
234 }

References ddtubs, get, mps_fire::i, SurfaceOrientation::inner, SurfaceOrientation::phiminus, SurfaceOrientation::phiplus, mps_fire::result, and alignCSCRings::s.

Referenced by MagGeoBuilderFromDDD::buildInterpolator().

Member Data Documentation

◆ solid

DDSolid MagGeoBuilderFromDDD::volumeHandle::solid
private

Definition at line 55 of file volumeHandle.h.

Referenced by shape(), and volumeHandle().

Vector3DBase< float, LocalTag >
GloballyPositioned< float >
magneticfield::BaseVolumeHandle::magFile
std::string magFile
Name of magnetic field table file.
Definition: BaseVolumeHandle.h:66
MagGeoBuilderFromDDD::volumeHandle::shape
DDSolidShape shape() const override
Shape of the solid.
Definition: volumeHandle.h:32
SurfaceOrientation::phiplus
Definition: Surface.h:19
TkRotation< float >
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:355
DDExpandedView::rotation
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
Definition: DDExpandedView.cc:47
DDSolidShape::ddtrap
magneticfield::BaseVolumeHandle::debug
const bool debug
Definition: BaseVolumeHandle.h:151
DDSolidShape::ddpseudotrap
magneticfield::BaseVolumeHandle::center
const GlobalPoint & center() const
Return the center of the volume.
Definition: BaseVolumeHandle.cc:42
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DDLogicalPart::material
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
Definition: DDLogicalPart.cc:118
magneticfield::BaseVolumeHandle::isAssigned
bool isAssigned[6]
Definition: BaseVolumeHandle.h:122
MagGeoBuilderFromDDD::volumeHandle::buildBox
void buildBox()
ReferenceCountingPointer< Surface >
DDAxes::x
MagGeoBuilderFromDDD::volumeHandle::solid
DDSolid solid
Definition: volumeHandle.h:55
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
MagGeoBuilderFromDDD::volumeHandle::referencePlane
void referencePlane(const DDExpandedView &fv)
Definition: volumeHandle.cc:145
VolumeSide
Definition: VolumeSide.h:15
DDPseudoTrap
Definition: DDSolid.h:106
DD3Vector
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
magneticfield::BaseVolumeHandle::theRMin
double theRMin
Definition: BaseVolumeHandle.h:132
MagGeoBuilderFromDDD::volumeHandle::buildCons
void buildCons()
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DDExpandedView::copyno
int copyno() const
Copy number associated with the current node.
Definition: DDExpandedView.cc:53
DDSolid::shape
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:119
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
DDBase::name
const N & name() const
Definition: DDBase.h:59
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDSolidShapesName::name
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:32
magneticfield::BaseVolumeHandle::center_
GlobalPoint center_
Definition: BaseVolumeHandle.h:142
MagGeoBuilderFromDDD::volumeHandle::buildPseudoTrap
void buildPseudoTrap(double x1, double x2, double y1, double y2, double halfZ, double radius, bool atMinusZ)
MagGeoBuilderFromDDD::volumeHandle::buildTubs
void buildTubs()
DDSolidShape::ddcons
magneticfield::BaseVolumeHandle::LocalVector
Surface::LocalVector LocalVector
Definition: BaseVolumeHandle.h:26
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:40
magneticfield::BaseVolumeHandle
Definition: BaseVolumeHandle.h:22
MagGeoBuilderFromDDD::volumeHandle::buildTrap
void buildTrap()
get
#define get
magneticfield::BaseVolumeHandle::copyno
unsigned short copyno
copy number
Definition: BaseVolumeHandle.h:72
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
magneticfield::BaseVolumeHandle::surfaces
RCPS surfaces[6]
Definition: BaseVolumeHandle.h:120
SurfaceOrientation::GlobalFace
GlobalFace
Definition: Surface.h:19
DDExpandedView::logicalPart
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the expanded-view.
Definition: DDExpandedView.cc:41
SurfaceOrientation::phiminus
Definition: Surface.h:19
mps_fire.result
result
Definition: mps_fire.py:303
MagGeoBuilderFromDDD::volumeHandle::buildTruncTubs
void buildTruncTubs()
magneticfield::BaseVolumeHandle::refPlane
GloballyPositioned< float > * refPlane
Definition: BaseVolumeHandle.h:139
DDExpandedView::translation
const DDTranslation & translation() const
The absolute translation of the current node.
Definition: DDExpandedView.cc:45
DDLogicalPart::solid
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
Definition: DDLogicalPart.cc:120
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