CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
MagGeoBuilderFromDDD::volumeHandle Class Reference

#include <volumeHandle.h>

Public Types

typedef Surface::GlobalPoint GlobalPoint
 
typedef Surface::LocalPoint LocalPoint
 
typedef Surface::LocalVector LocalVector
 
typedef
SurfaceOrientation::GlobalFace 
Sides
 

Public Member Functions

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
 FIXME: currently returns max RN (to be fixed?). Used by: bLayer::maxR() 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...
 
DDSolidShape shape () const
 Shape of the solid. More...
 
std::vector< VolumeSidesides () const
 The surfaces and they orientation, as required to build a MagVolume. More...
 
const Surfacesurface (int which_side) const
 Get the current surface on specified side. More...
 
const Surfacesurface (Sides which_side) const
 
bool toExpand () const
 
 volumeHandle (const DDExpandedView &fv, bool expand2Pi=false)
 
 ~volumeHandle ()
 

Static Public Member Functions

static void printUniqueNames (handles::const_iterator begin, handles::const_iterator end)
 Just for debugging... More...
 

Public Attributes

int 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...
 

Private Member Functions

void buildBox (const DDExpandedView &fv)
 
void buildCons (const DDExpandedView &fv)
 
void buildPhiZSurf (double startPhi, double deltaPhi, double zhalf, double rCentr)
 
void buildPseudoTrap (const DDExpandedView &fv)
 
void buildTrap (const DDExpandedView &fv)
 
void buildTruncTubs (const DDExpandedView &fv)
 
void buildTubs (const DDExpandedView &fv)
 
volumeHandle operator= (const volumeHandle &v)
 
void referencePlane (const DDExpandedView &fv)
 
 volumeHandle (const volumeHandle &v)
 

Private Attributes

GlobalPoint center_
 
bool expand
 
bool isAssigned [6]
 
bool isIronFlag
 
GloballyPositioned< float > * refPlane
 
DDSolid solid
 
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.

Date:
2009/03/25 16:20:08
Revision:
1.8
Author
N. Amapane - INFN Torino

Definition at line 27 of file volumeHandle.h.

Member Typedef Documentation

Definition at line 29 of file volumeHandle.h.

Definition at line 30 of file volumeHandle.h.

Definition at line 31 of file volumeHandle.h.

Definition at line 32 of file volumeHandle.h.

Constructor & Destructor Documentation

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

Definition at line 40 of file volumeHandle.cc.

References buildBox(), buildCons(), buildPseudoTrap(), buildTrap(), buildTruncTubs(), buildTubs(), center(), center_, copyno, gather_cfg::cout, ddbox, ddcons, DDfetch(), ddpseudotrap, ddtrap, ddtrunctubs, ddtubs, MagGeoBuilderFromDDD::debug, DDValue::doubles(), i, isAssigned, isIronFlag, DDExpandedView::logicalPart(), magFile, masterSector, DDLogicalPart::material(), DDExpandedView::mergedSpecifics(), DDName::name(), name, DDBase< N, C >::name(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), referencePlane(), DDSolid::shape(), shape(), solid, DDValue::strings(), surfaces, cond::rpcobtemp::temp, theRMax, theRMin, and theRN.

41  : name(fv.logicalPart().name().name()),
42  copyno(fv.copyno()),
43  magVolume(0),
44  masterSector(1),
45  theRN(0.),
46  theRMin(0.),
47  theRMax(0.),
48  refPlane(0),
49  solid(fv.logicalPart().solid()),
50  center_(GlobalPoint(fv.translation().x()/cm,
51  fv.translation().y()/cm,
52  fv.translation().z()/cm)),
53  expand(expand2Pi),
54  isIronFlag(false)
55 {
56  for (int i=0; i<6; ++i) {
57  isAssigned[i] = false;
58  }
59 
60 
62  cout.precision(7);
63  }
64 
65 
66  referencePlane(fv);
67 
68  if (solid.shape() == ddbox) {
69  buildBox(fv);
70  } else if (solid.shape() == ddtrap) {
71  buildTrap(fv);
72  } else if (solid.shape() == ddcons) {
73  buildCons(fv);
74  } else if (solid.shape() == ddtubs) {
75  buildTubs(fv);
76  } else if (solid.shape() == ddpseudotrap) {
77  buildPseudoTrap(fv);
78  } else if (solid.shape() == ddtrunctubs) {
79  buildTruncTubs(fv);
80  } else {
81  cout << "volumeHandle ctor: Unexpected solid: " << (int) solid.shape() << endl;
82  }
83 
84 
86 
87  { // Extract the name of associated field file.
88  std::vector<std::string> temp;
89  std::string pname = "table";
90  DDValue val(pname);
92  if (DDfetch(&sv,val)) {
93  temp = val.strings();
94  if (temp.size() != 1) {
95  cout << "*** WARNING: volume has > 1 SpecPar " << pname << endl;
96  }
97  magFile = temp[0];
98  } else {
99  cout << "*** WARNING: volume does not have a SpecPar " << pname << endl;
100  cout << " DDsvalues_type: " << fv.mergedSpecifics() << endl;
101  }
102  }
103 
104  { // Extract the number of the master sector.
105  std::vector<double> temp;
106  const std::string pname = "masterSector";
107  DDValue val(pname);
108  if (DDfetch(&sv,val)) {
109  temp = val.doubles();
110  if (temp.size() != 1) {
111  cout << "*** WARNING: volume has > 1 SpecPar " << pname << endl;
112  }
113  masterSector = int(temp[0]+.5);
114  } else {
115  cout << "*** WARNING: volume does not have a SpecPar " << pname << endl;
116  cout << " DDsvalues_type: " << fv.mergedSpecifics() << endl;
117  }
118  }
119 
120  // Get material for this volume
121  if (fv.logicalPart().material().name().name() == "Iron") isIronFlag=true;
122 
123 
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: " << (int) shape() << endl;
130 
131  cout << "Summary: " << name << " " << copyno
132  << " Shape= " << (int) shape()
133  << " trasl " << center()
134  << " R " << center().perp()
135  << " phi " << center().phi()
136  << " magFile " << magFile
137  << " Material= " << fv.logicalPart().material().name()
138  << " isIron= " << isIronFlag
139  << " masterSector= " << masterSector << std::endl;
140 
141  cout << " Orientation of surfaces:";
142  std::string sideName[3] = {"positiveSide", "negativeSide", "onSurface"};
143  for (int i=0; i<6; ++i) {
144  cout << " " << i << ":" << sideName[surfaces[i]->side(center_,0.3)];
145  }
146  cout << endl;
147  }
148 }
int i
Definition: DBlmapReader.cc:9
void buildBox(const DDExpandedView &fv)
DDsvalues_type mergedSpecifics() const
const N & name() const
Definition: DDBase.h:88
T perp() const
Definition: PV3DBase.h:66
GloballyPositioned< float > * refPlane
Definition: volumeHandle.h:155
DDSolidShape shape() const
The type of the solid.
Definition: DDSolid.cc:147
void buildTubs(const DDExpandedView &fv)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
void buildPseudoTrap(const DDExpandedView &fv)
const GlobalPoint & center() const
Return the center of the volume.
std::string name
Name of the volume.
Definition: volumeHandle.h:58
DDSolidShape shape() const
Shape of the solid.
Definition: volumeHandle.h:97
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:102
const DDMaterial & material() const
Returns a reference object of the material this LogicalPart is made of.
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Definition: DDsvalues.h:19
Surface::GlobalPoint GlobalPoint
Definition: volumeHandle.h:29
std::string magFile
Name of magnetic field table file.
Definition: volumeHandle.h:60
void buildCons(const DDExpandedView &fv)
void referencePlane(const DDExpandedView &fv)
const DDTranslation & translation() const
The absolute translation of the current node.
int copyno() const
Copy number associated with the current node.
const DDSolid & solid() const
Returns a reference object of the solid being the shape of this LogicalPart.
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
tuple cout
Definition: gather_cfg.py:41
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the expanded-view.
MagVolume6Faces * magVolume
Pointer to the final MagVolume (must be set from outside)
Definition: volumeHandle.h:103
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
void buildTruncTubs(const DDExpandedView &fv)
MagGeoBuilderFromDDD::volumeHandle::~volumeHandle ( )

Definition at line 36 of file volumeHandle.cc.

36  {
37  delete refPlane;
38 }
GloballyPositioned< float > * refPlane
Definition: volumeHandle.h:155
MagGeoBuilderFromDDD::volumeHandle::volumeHandle ( const volumeHandle v)
private

Member Function Documentation

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

Referenced by volumeHandle().

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

Referenced by volumeHandle().

void MagGeoBuilderFromDDD::volumeHandle::buildPhiZSurf ( double  startPhi,
double  deltaPhi,
double  zhalf,
double  rCentr 
)
private

Definition at line 226 of file volumeHandle.cc.

References funct::cos(), gather_cfg::cout, MagGeoBuilderFromDDD::debug, SurfaceOrientation::phiminus, SurfaceOrientation::phiplus, funct::sin(), SurfaceOrientation::zminus, and SurfaceOrientation::zplus.

229  {
230  // This is 100% equal for cons and tubs!!!
231 
232  GlobalVector planeXAxis = refPlane->toGlobal(LocalVector( 1, 0, 0));
233  GlobalVector planeYAxis = refPlane->toGlobal(LocalVector( 0, 1, 0));
234  GlobalVector planeZAxis = refPlane->toGlobal(LocalVector( 0, 0, 1));
235 
236  // Local Y axis of the faces at +-phi.
237  GlobalVector y_phiplus = refPlane->toGlobal(LocalVector(cos(startPhi+deltaPhi),
238  sin(startPhi+deltaPhi),0.));
239  GlobalVector y_phiminus = refPlane->toGlobal(LocalVector(cos(startPhi),
240  sin(startPhi),0.));
241 
242  Surface::RotationType rot_Z(planeXAxis,planeYAxis);
243  Surface::RotationType rot_phiplus(planeZAxis, y_phiplus);
244  Surface::RotationType rot_phiminus(planeZAxis, y_phiminus);
245 
246  GlobalPoint pos_zplus(center_.x(),center_.y(),center_.z()+zhalf);
247  GlobalPoint pos_zminus(center_.x(),center_.y(),center_.z()-zhalf);
248  // BEWARE: in this case, the origin for phiplus,phiminus surfaces is
249  // at radius R and not on a plane passing by center_ orthogonal to the radius.
250  GlobalPoint pos_phiplus(refPlane->toGlobal(LocalPoint(rCentr*cos(startPhi+deltaPhi),rCentr*sin(startPhi+deltaPhi),0.)));
251  GlobalPoint pos_phiminus(refPlane->toGlobal(LocalPoint(rCentr*cos(startPhi),
252  rCentr*sin(startPhi),
253  0.)));
254  surfaces[zplus] = new Plane(pos_zplus, rot_Z);
255  surfaces[zminus] = new Plane(pos_zminus, rot_Z);
256  surfaces[phiplus] = new Plane(pos_phiplus, rot_phiplus);
257  surfaces[phiminus] = new Plane(pos_phiminus, rot_phiminus);
258 
260  cout << "Actual Center at: " << center_ << " R " << center_.perp()
261  << " phi " << center_.phi() << endl;
262  cout << "RN " << theRN << endl;
263 
264  cout << "pos_zplus " << pos_zplus << " "
265  << pos_zplus.perp() << " " << pos_zplus.phi() << endl
266  << "pos_zminus " << pos_zminus << " "
267  << pos_zminus.perp() << " " << pos_zminus.phi() << endl
268  << "pos_phiplus " << pos_phiplus << " "
269  << pos_phiplus.perp() << " " << pos_phiplus.phi() <<endl
270  << "pos_phiminus " << pos_phiminus << " "
271  << pos_phiminus.perp() << " " << pos_phiminus.phi() <<endl;
272 
273  cout << "y_phiplus " << y_phiplus << endl;
274  cout << "y_phiminus " << y_phiminus << endl;
275 
276  cout << "rot_Z " << surfaces[zplus]->toGlobal(LocalVector(0.,0.,1.)) << endl
277  << "rot_phi+ " << surfaces[phiplus]->toGlobal(LocalVector(0.,0.,1.))
278  << " phi " << surfaces[phiplus]->toGlobal(LocalVector(0.,0.,1.)).phi()
279  << endl
280  << "rot_phi- " << surfaces[phiminus]->toGlobal(LocalVector(0.,0.,1.))
281  << " phi " << surfaces[phiminus]->toGlobal(LocalVector(0.,0.,1.)).phi()
282  << endl;
283  }
284 
285 // // Check ordering.
287  if (pos_zplus.z() < pos_zminus.z()) {
288  cout << "*** WARNING: pos_zplus < pos_zminus " << endl;
289  }
290  if (Geom::Phi<float>(pos_phiplus.phi()-pos_phiminus.phi()) < 0. ) {
291  cout << "*** WARNING: pos_phiplus < pos_phiminus " << endl;
292  }
293  }
294 }
T perp() const
Definition: PV3DBase.h:66
GloballyPositioned< float > * refPlane
Definition: volumeHandle.h:155
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
T y() const
Definition: PV3DBase.h:57
Definition: Plane.h:17
T z() const
Definition: PV3DBase.h:58
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Surface::LocalVector LocalVector
Definition: volumeHandle.h:31
GlobalPoint toGlobal(const LocalPoint &lp) const
tuple cout
Definition: gather_cfg.py:41
T x() const
Definition: PV3DBase.h:56
void MagGeoBuilderFromDDD::volumeHandle::buildPseudoTrap ( const DDExpandedView fv)
private

Referenced by volumeHandle().

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

Referenced by volumeHandle().

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

Referenced by volumeHandle().

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

Referenced by volumeHandle().

const Surface::GlobalPoint & MagGeoBuilderFromDDD::volumeHandle::center ( ) const
bool MagGeoBuilderFromDDD::volumeHandle::isIron ( ) const
inline

Temporary hack to pass information on material. Will eventually be replaced!

Definition at line 108 of file volumeHandle.h.

References isIronFlag.

bool MagGeoBuilderFromDDD::volumeHandle::isPlaneMatched ( int  which_side) const
inline

if the specified surface has been matched.

Definition at line 48 of file volumeHandle.h.

References isAssigned.

48  {
49  return isAssigned[which_side];
50  }
Geom::Phi<float> MagGeoBuilderFromDDD::volumeHandle::maxPhi ( ) const
inline

Maximum value of phi covered by the volume.

Definition at line 79 of file volumeHandle.h.

References PV3DBase< T, PVType, FrameType >::phi(), SurfaceOrientation::phiplus, GloballyPositioned< T >::position(), and surface().

Referenced by MagGeoBuilderFromDDD::ExtractPhiMax::operator()().

Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
const Surface & surface(int which_side) const
Get the current surface on specified side.
const PositionType & position() const
double MagGeoBuilderFromDDD::volumeHandle::maxZ ( ) const
inline

Definition at line 85 of file volumeHandle.h.

References GloballyPositioned< T >::position(), surface(), PV3DBase< T, PVType, FrameType >::z(), and SurfaceOrientation::zplus.

T z() const
Definition: PV3DBase.h:58
const Surface & surface(int which_side) const
Get the current surface on specified side.
const PositionType & position() const
Geom::Phi<float> MagGeoBuilderFromDDD::volumeHandle::minPhi ( ) const
inline

Minimum value of phi covered by the volume.

Definition at line 75 of file volumeHandle.h.

References thePhiMin.

75 {return thePhiMin;}
double MagGeoBuilderFromDDD::volumeHandle::minR ( ) const
inline

Minimum R for any point within the volume.

Definition at line 88 of file volumeHandle.h.

References theRMin.

double MagGeoBuilderFromDDD::volumeHandle::minZ ( ) const
inline

Z limits.

Definition at line 84 of file volumeHandle.h.

References GloballyPositioned< T >::position(), surface(), PV3DBase< T, PVType, FrameType >::z(), and SurfaceOrientation::zminus.

T z() const
Definition: PV3DBase.h:58
const Surface & surface(int which_side) const
Get the current surface on specified side.
const PositionType & position() const
volumeHandle MagGeoBuilderFromDDD::volumeHandle::operator= ( const volumeHandle v)
private
const GloballyPositioned<float>* MagGeoBuilderFromDDD::volumeHandle::placement ( ) const
inline

FIXME: currently returns max RN (to be fixed?). Used by: bLayer::maxR()

Position and rotation

Definition at line 94 of file volumeHandle.h.

References refPlane.

Referenced by MagGeoBuilderFromDDD::buildInterpolator().

94 {return refPlane;}
GloballyPositioned< float > * refPlane
Definition: volumeHandle.h:155
void MagGeoBuilderFromDDD::volumeHandle::printUniqueNames ( handles::const_iterator  begin,
handles::const_iterator  end 
)
static

Just for debugging...

Definition at line 444 of file volumeHandle.cc.

References filterCSVwithJSON::copy, gather_cfg::cout, end, i, h::names, and python.multivaluedict::sort().

Referenced by MagGeoBuilderFromDDD::bLayer::bLayer(), MagGeoBuilderFromDDD::bRod::bRod(), MagGeoBuilderFromDDD::bSector::bSector(), and MagGeoBuilderFromDDD::eSector::eSector().

444  {
445  std::vector<std::string> names;
446  for (handles::const_iterator i = begin;
447  i != end; ++i){
448  names.push_back((*i)->name);
449  }
450 
451  sort(names.begin(),names.end());
452  std::vector<std::string>::iterator i = unique(names.begin(),names.end());
453  int nvols = int(i - names.begin());
454  cout << nvols << " ";
455  copy(names.begin(), i, ostream_iterator<std::string>(cout, " "));
456 
457  cout << endl;
458 }
int i
Definition: DBlmapReader.cc:9
#define end
Definition: vmac.h:38
#define begin
Definition: vmac.h:31
tuple cout
Definition: gather_cfg.py:41
static const HistoName names[]
void MagGeoBuilderFromDDD::volumeHandle::referencePlane ( const DDExpandedView fv)
private

Definition at line 155 of file volumeHandle.cc.

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

Referenced by volumeHandle().

155  {
156  // The refPlane is the "main plane" for the solid. It corresponds to the
157  // x,y plane in the DDD local frame, and defines a frame where the local
158  // coordinates are the same as in DDD.
159  // In the geometry version 85l_030919, this plane is normal to the
160  // beam line for all volumes but pseudotraps, so that global R is along Y,
161  // global phi is along -X and global Z along Z:
162  //
163  // Global(for vol at pi/2) Local
164  // +R (+Y) +Y
165  // +phi(-X) -X
166  // +Z +Z
167  //
168  // For pseudotraps the refPlane is parallel to beam line and global R is
169  // along Z, global phi is along +-X and and global Z along Y:
170  //
171  // Global(for vol at pi/2) Local
172  // +R (+Y) +Z
173  // +phi(-X) +X
174  // +Z +Y
175  //
176  // Note that the frame is centered in the DDD volume center, which is
177  // inside the volume for DDD boxes and (pesudo)trapezoids, on the beam line
178  // for tubs, cons and trunctubs.
179 
180  // In geometry version 1103l, trapezoids have X and Z in the opposite direction
181  // than the above. Boxes are either oriented as described above or in some case
182  // have opposite direction for Y and X.
183 
184  // The global position
185  Surface::PositionType & posResult = center_;
186 
187  // The reference plane rotation
188  DD3Vector x, y, z;
189  fv.rotation().GetComponents(x,y,z);
191  if (x.Cross(y).Dot(z) < 0.5) {
192  cout << "*** WARNING: Rotation is not RH "<< endl;
193  }
194  }
195 
196  // The global rotation
198  rotResult(float(x.X()),float(x.Y()),float(x.Z()),
199  float(y.X()),float(y.Y()),float(y.Z()),
200  float(z.X()),float(z.Y()),float(z.Z()));
201 
202  refPlane = new GloballyPositioned<float>(posResult, rotResult);
203 
204  // Check correct orientation
206 
207  cout << "Refplane pos " << refPlane->position() << endl;
208 
209  // See comments above for the conventions for orientation.
210  LocalVector globalZdir(0.,0.,1.); // Local direction of the axis along global Z
211  if (solid.shape() == ddpseudotrap) {
212  globalZdir = LocalVector(0.,1.,0.);
213  }
214  if (refPlane->toGlobal(globalZdir).z()<0.) {
215  globalZdir=-globalZdir;
216  }
217 
218  float chk = refPlane->toGlobal(globalZdir).dot(GlobalVector(0,0,1));
219  if (chk < .999) cout << "*** WARNING RefPlane check failed!***"
220  << chk << endl;
221  }
222 }
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
GloballyPositioned< float > * refPlane
Definition: volumeHandle.h:155
DDSolidShape shape() const
The type of the solid.
Definition: DDSolid.cc:147
double double double z
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
T z() const
Definition: PV3DBase.h:58
Surface::LocalVector LocalVector
Definition: volumeHandle.h:31
GlobalPoint toGlobal(const LocalPoint &lp) const
tuple cout
Definition: gather_cfg.py:41
Definition: DDAxes.h:10
const PositionType & position() const
Global3DVector GlobalVector
Definition: GlobalVector.h:10
int MagGeoBuilderFromDDD::volumeHandle::references ( int  which_side) const
inline

Definition at line 52 of file volumeHandle.h.

52  { // FIXME!
53 /* return surfaces[which_side]->references(); */
54  return 0;
55  }
const double MagGeoBuilderFromDDD::volumeHandle::RN ( ) const
inline

Distance of (x,y) plane from origin.

Definition at line 39 of file volumeHandle.h.

References theRN.

Referenced by MagGeoBuilderFromDDD::ExtractRN::operator()().

bool MagGeoBuilderFromDDD::volumeHandle::sameSurface ( const Surface s1,
Sides  which_side,
float  tolerance = 0.01 
)

Find out if two surfaces are the same physical surface.

Definition at line 298 of file volumeHandle.cc.

References gather_cfg::cout, MagGeoBuilderFromDDD::debug, Vector3DBase< T, FrameTag >::dot(), mag(), Plane::normalVector(), Cone::openingAngle(), p1, p2, GloballyPositioned< T >::position(), Cylinder::radius(), indexGen::s2, GloballyPositioned< T >::toLocal(), Cone::vertex(), and PV3DBase< T, PVType, FrameType >::z().

299 {
300  //Check for null comparison
301  if (&s1==(surfaces[which_side]).get()){
302  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: OK (same ptr)" << endl;
303  return true;
304  }
305 
306  const float maxtilt = 0.999;
307 
308  const Surface & s2 = *(surfaces[which_side]);
309  // Try with a plane.
310  const Plane * p1 = dynamic_cast<const Plane*>(&s1);
311  if (p1!=0) {
312  const Plane * p2 = dynamic_cast<const Plane*>(&s2);
313  if (p2==0) {
314  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: different types" << endl;
315  return false;
316  }
317 
318  if ( (fabs(p1->normalVector().dot(p2->normalVector())) > maxtilt)
319  && (fabs((p1->toLocal(p2->position())).z()) < tolerance) ) {
320  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: OK "
321  << fabs(p1->normalVector().dot(p2->normalVector()))
322  << " " << fabs((p1->toLocal(p2->position())).z()) << endl;
323  return true;
324  } else{
325  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: not the same: "
326  << p1->normalVector() << p1->position() << endl
327  << " "
328  << p2->normalVector() << p2->position() << endl
329  << fabs(p1->normalVector().dot(p2->normalVector()))
330  << " " << (p1->toLocal(p2->position())).z()<< endl;
331  return false;
332  }
333  }
334 
335  // Try with a cylinder.
336  const Cylinder * cy1 = dynamic_cast<const Cylinder*>(&s1);
337  if (cy1!=0) {
338  const Cylinder * cy2 = dynamic_cast<const Cylinder*>(&s2);
339  if (cy2==0) {
340  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: different types" << endl;
341  return false;
342  }
343  // Assume axis is the same!
344  if (fabs(cy1->radius() - cy2->radius()) < tolerance) {
345  return true;
346  } else {
347  return false;
348  }
349  }
350 
351  // Try with a cone.
352  const Cone * co1 = dynamic_cast<const Cone*>(&s1);
353  if (co1!=0) {
354  const Cone * co2 = dynamic_cast<const Cone*>(&s2);
355  if (co2==0) {
356  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: different types" << endl;
357  return false;
358  }
359  // FIXME
360  if (fabs(co1->openingAngle()-co2->openingAngle()) < maxtilt
361  && (co1->vertex()-co2->vertex()).mag() < tolerance) {
362  return true;
363  } else {
364  return false;
365  }
366  }
367 
368  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: unknown surfaces..." << endl;
369  return false;
370 }
Definition: Cone.h:20
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GlobalVector normalVector() const
Definition: Plane.h:47
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:107
Definition: Plane.h:17
tuple s2
Definition: indexGen.py:106
GlobalPoint vertex() const
Global position of the cone vertex.
Definition: Cone.h:50
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:55
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:58
double p2[4]
Definition: TauolaWrapper.h:90
double p1[4]
Definition: TauolaWrapper.h:89
tuple cout
Definition: gather_cfg.py:41
const PositionType & position() const
Geom::Theta< float > openingAngle() const
Angle of the cone.
Definition: Cone.h:53
bool MagGeoBuilderFromDDD::volumeHandle::setSurface ( const Surface s1,
Sides  which_side 
)

Assign a shared surface perorming sanity checks.

Definition at line 374 of file volumeHandle.cc.

References gather_cfg::cout, MagGeoBuilderFromDDD::debug, mergeVDriftHistosByStation::name, Plane::normalVector(), p1, p2, GloballyPositioned< T >::position(), and indexGen::s2.

375 {
376  //Check for null assignment
377  if (&s1==(surfaces[which_side]).get()){
378  isAssigned[which_side] = true;
379  return true;
380  }
381 
382  if (!sameSurface(s1,which_side)){
383  cout << "***ERROR: setSurface: trying to assign a surface that does not match destination surface. Skipping." << endl;
384  const Surface & s2 = *(surfaces[which_side]);
385  //FIXME: Just planes for the time being!!!
386  const Plane * p1 = dynamic_cast<const Plane*>(&s1);
387  const Plane * p2 = dynamic_cast<const Plane*>(&s2);
388  if (p1!=0 && p2 !=0)
389  cout << p1->normalVector() << p1->position() << endl
390  << p2->normalVector() << p2->position() << endl;
391  return false;
392  }
393 
394 
395  if (isAssigned[which_side]) {
396  if (&s1!=(surfaces[which_side]).get()){
397  cout << "*** WARNING volumeHandle::setSurface: trying to reassign a surface to a different surface instance" << endl;
398  return false;
399  }
400  } else {
401  surfaces[which_side] = &s1;
402  isAssigned[which_side] = true;
403  if (MagGeoBuilderFromDDD::debug) cout << " Volume " << name << " # " << copyno << " Assigned: " << (int) which_side << endl;
404  return true;
405  }
406 
407  return false; // let the compiler be happy
408 }
GlobalVector normalVector() const
Definition: Plane.h:47
std::string name
Name of the volume.
Definition: volumeHandle.h:58
Definition: Plane.h:17
tuple s2
Definition: indexGen.py:106
double p2[4]
Definition: TauolaWrapper.h:90
double p1[4]
Definition: TauolaWrapper.h:89
tuple cout
Definition: gather_cfg.py:41
const PositionType & position() const
bool sameSurface(const Surface &s1, Sides which_side, float tolerance=0.01)
Find out if two surfaces are the same physical surface.
DDSolidShape MagGeoBuilderFromDDD::volumeHandle::shape ( ) const
inline

Shape of the solid.

Definition at line 97 of file volumeHandle.h.

References DDSolid::shape(), and solid.

Referenced by MagGeoBuilderFromDDD::buildInterpolator(), and volumeHandle().

97 {return solid.shape();}
DDSolidShape shape() const
The type of the solid.
Definition: DDSolid.cc:147
std::vector< VolumeSide > MagGeoBuilderFromDDD::volumeHandle::sides ( ) const

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

Definition at line 427 of file volumeHandle.cc.

References ddtubs, i, SurfaceOrientation::inner, SurfaceOrientation::phiminus, SurfaceOrientation::phiplus, query::result, and asciidump::s.

Referenced by MagGeoBuilderFromDDD::buildInterpolator().

427  {
428  std::vector<VolumeSide> result;
429  for (int i=0; i<6; ++i){
430  // If this is just a master volume out of wich a 2pi volume
431  // should be built (e.g. central cylinder), skip the phi boundaries.
432  if (expand && (i==phiplus || i==phiminus)) continue;
433 
434  // FIXME: Skip null inner degenerate cylindrical surface
435  if (solid.shape() == ddtubs && i == SurfaceOrientation::inner && theRMin < 0.001) continue;
436 
437  ReferenceCountingPointer<Surface> s = const_cast<Surface*> (surfaces[i].get());
438  result.push_back(VolumeSide(s, GlobalFace(i),
439  surfaces[i]->side(center_,0.3)));
440  }
441  return result;
442 }
int i
Definition: DBlmapReader.cc:9
DDSolidShape shape() const
The type of the solid.
Definition: DDSolid.cc:147
tuple result
Definition: query.py:137
string s
Definition: asciidump.py:422
const Surface & MagGeoBuilderFromDDD::volumeHandle::surface ( int  which_side) const

Get the current surface on specified side.

Definition at line 420 of file volumeHandle.cc.

Referenced by maxPhi(), maxZ(), and minZ().

420  {
421  assert(which_side >=0 && which_side <6);
422  return *(surfaces[which_side]);
423 }
const Surface & MagGeoBuilderFromDDD::volumeHandle::surface ( Sides  which_side) const

Definition at line 413 of file volumeHandle.cc.

413  {
414  return *(surfaces[which_side]);
415 }
bool MagGeoBuilderFromDDD::volumeHandle::toExpand ( ) const
inline

Definition at line 105 of file volumeHandle.h.

References expand.

Referenced by MagGeoBuilderFromDDD::buildInterpolator().

Member Data Documentation

GlobalPoint MagGeoBuilderFromDDD::volumeHandle::center_
private

Definition at line 161 of file volumeHandle.h.

Referenced by volumeHandle().

int MagGeoBuilderFromDDD::volumeHandle::copyno

copy number

Definition at line 62 of file volumeHandle.h.

Referenced by MagGeoBuilderFromDDD::build(), MagGeoBuilderFromDDD::buildInterpolator(), and volumeHandle().

bool MagGeoBuilderFromDDD::volumeHandle::expand
private

Definition at line 165 of file volumeHandle.h.

Referenced by toExpand().

bool MagGeoBuilderFromDDD::volumeHandle::isAssigned[6]
private

Definition at line 122 of file volumeHandle.h.

Referenced by isPlaneMatched(), and volumeHandle().

bool MagGeoBuilderFromDDD::volumeHandle::isIronFlag
private

Definition at line 168 of file volumeHandle.h.

Referenced by isIron(), and volumeHandle().

std::string MagGeoBuilderFromDDD::volumeHandle::magFile

Name of magnetic field table file.

Definition at line 60 of file volumeHandle.h.

Referenced by MagGeoBuilderFromDDD::build(), MagGeoBuilderFromDDD::buildInterpolator(), and volumeHandle().

MagVolume6Faces* MagGeoBuilderFromDDD::volumeHandle::magVolume

Pointer to the final MagVolume (must be set from outside)

Definition at line 103 of file volumeHandle.h.

int MagGeoBuilderFromDDD::volumeHandle::masterSector

The sector for which an interpolator for this class of volumes should be built.

Definition at line 111 of file volumeHandle.h.

Referenced by MagGeoBuilderFromDDD::build(), MagGeoBuilderFromDDD::buildInterpolator(), and volumeHandle().

std::string MagGeoBuilderFromDDD::volumeHandle::name
GloballyPositioned<float>* MagGeoBuilderFromDDD::volumeHandle::refPlane
private

Definition at line 155 of file volumeHandle.h.

Referenced by placement().

DDSolid MagGeoBuilderFromDDD::volumeHandle::solid
private

Definition at line 158 of file volumeHandle.h.

Referenced by shape(), and volumeHandle().

RCPS MagGeoBuilderFromDDD::volumeHandle::surfaces[6]
private

Definition at line 120 of file volumeHandle.h.

Referenced by volumeHandle().

Geom::Phi<float> MagGeoBuilderFromDDD::volumeHandle::thePhiMin
private

Definition at line 150 of file volumeHandle.h.

Referenced by minPhi().

double MagGeoBuilderFromDDD::volumeHandle::theRMax
private

Definition at line 149 of file volumeHandle.h.

Referenced by volumeHandle().

double MagGeoBuilderFromDDD::volumeHandle::theRMin
private

Definition at line 148 of file volumeHandle.h.

Referenced by minR(), and volumeHandle().

double MagGeoBuilderFromDDD::volumeHandle::theRN
private

Definition at line 144 of file volumeHandle.h.

Referenced by RN(), and volumeHandle().