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

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

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.

Author
N. Amapane - INFN Torino

Definition at line 25 of file volumeHandle.h.

Member Typedef Documentation

Definition at line 27 of file volumeHandle.h.

Definition at line 28 of file volumeHandle.h.

Definition at line 29 of file volumeHandle.h.

Definition at line 30 of file volumeHandle.h.

Constructor & Destructor Documentation

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

Definition at line 39 of file volumeHandle.cc.

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

40  : name(fv.logicalPart().name().name()),
41  copyno(fv.copyno()),
42  magVolume(0),
43  masterSector(1),
44  theRN(0.),
45  theRMin(0.),
46  theRMax(0.),
47  refPlane(0),
48  solid(fv.logicalPart().solid()),
49  center_(GlobalPoint(fv.translation().x()/cm,
50  fv.translation().y()/cm,
51  fv.translation().z()/cm)),
52  expand(expand2Pi),
53  isIronFlag(false)
54 {
55  // ASSUMPTION: volume names ends with "_NUM" where NUM is the volume number
56  string volName = name;
57  volName.erase(0,volName.rfind('_')+1);
58  volumeno =boost::lexical_cast<unsigned short>(volName);
59 
60  for (int i=0; i<6; ++i) {
61  isAssigned[i] = false;
62  }
63 
64 
66  cout.precision(7);
67  }
68 
69 
70  referencePlane(fv);
71 
72  if (solid.shape() == ddbox) {
73  buildBox(fv);
74  } else if (solid.shape() == ddtrap) {
75  buildTrap(fv);
76  } else if (solid.shape() == ddcons) {
77  buildCons(fv);
78  } else if (solid.shape() == ddtubs) {
79  buildTubs(fv);
80  } else if (solid.shape() == ddpseudotrap) {
81  buildPseudoTrap(fv);
82  } else if (solid.shape() == ddtrunctubs) {
83  buildTruncTubs(fv);
84  } else {
85  cout << "volumeHandle ctor: Unexpected solid: " << (int) solid.shape() << endl;
86  }
87 
88 
89  // NOTE: Table name and master sector are no longer taken from xml!
90 // DDsvalues_type sv(fv.mergedSpecifics());
91 
92 // { // Extract the name of associated field file.
93 // std::vector<std::string> temp;
94 // std::string pname = "table";
95 // DDValue val(pname);
96 // DDsvalues_type sv(fv.mergedSpecifics());
97 // if (DDfetch(&sv,val)) {
98 // temp = val.strings();
99 // if (temp.size() != 1) {
100 // cout << "*** WARNING: volume has > 1 SpecPar " << pname << endl;
101 // }
102 // magFile = temp[0];
103 
104 // string find="[copyNo]";
105 // std::size_t j;
106 // for ( ; (j = magFile.find(find)) != string::npos ; ) {
107 // stringstream conv;
108 // conv << setfill('0') << setw(2) << copyno;
109 // string repl;
110 // conv >> repl;
111 // magFile.replace(j, find.length(), repl);
112 // }
113 
114 // } else {
115 // cout << "*** WARNING: volume does not have a SpecPar " << pname << endl;
116 // cout << " DDsvalues_type: " << fv.mergedSpecifics() << endl;
117 // }
118 // }
119 
120 // { // Extract the number of the master sector.
121 // std::vector<double> temp;
122 // const std::string pname = "masterSector";
123 // DDValue val(pname);
124 // if (DDfetch(&sv,val)) {
125 // temp = val.doubles();
126 // if (temp.size() != 1) {
127 // cout << "*** WARNING: volume has > 1 SpecPar " << pname << endl;
128 // }
129 // masterSector = int(temp[0]+.5);
130 // } else {
131 // if (MagGeoBuilderFromDDD::debug) {
132 // cout << "Volume does not have a SpecPar " << pname
133 // << " using: " << copyno << endl;
134 // cout << " DDsvalues_type: " << fv.mergedSpecifics() << endl;
135 // }
136 // masterSector = copyno;
137 // }
138 // }
139 
140  // Get material for this volume
141  if (fv.logicalPart().material().name().name() == "Iron") isIronFlag=true;
142 
143 
145  cout << " RMin = " << theRMin <<endl;
146  cout << " RMax = " << theRMax <<endl;
147 
148  if (theRMin < 0 || theRN < theRMin || theRMax < theRN)
149  cout << "*** WARNING: wrong RMin/RN/RMax , shape: " << (int) shape() << endl;
150 
151  cout << "Summary: " << name << " " << copyno
152  << " Shape= " << (int) shape()
153  << " trasl " << center()
154  << " R " << center().perp()
155  << " phi " << center().phi()
156  << " magFile " << magFile
157  << " Material= " << fv.logicalPart().material().name()
158  << " isIron= " << isIronFlag
159  << " masterSector= " << masterSector << std::endl;
160 
161  cout << " Orientation of surfaces:";
162  std::string sideName[3] = {"positiveSide", "negativeSide", "onSurface"};
163  for (int i=0; i<6; ++i) {
164  cout << " " << i << ":" << sideName[surfaces[i]->side(center_,0.3)];
165  }
166  cout << endl;
167  }
168 }
unsigned short copyno
copy number
Definition: volumeHandle.h:62
int i
Definition: DBlmapReader.cc:9
void buildBox(const DDExpandedView &fv)
const N & name() const
Definition: DDBase.h:82
T perp() const
Definition: PV3DBase.h:72
GloballyPositioned< float > * refPlane
Definition: volumeHandle.h:155
void buildTubs(const DDExpandedView &fv)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
void buildPseudoTrap(const DDExpandedView &fv)
const GlobalPoint & center() const
Return the center of the volume.
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
std::string name
Name of the volume.
Definition: volumeHandle.h:56
DDSolidShape shape() const
Shape of the solid.
Definition: volumeHandle.h:97
Surface::GlobalPoint GlobalPoint
Definition: volumeHandle.h:27
std::string magFile
Name of magnetic field table file.
Definition: volumeHandle.h:58
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
void buildCons(const DDExpandedView &fv)
void referencePlane(const DDExpandedView &fv)
const DDTranslation & translation() const
The absolute translation of the current node.
unsigned short volumeno
volume number
Definition: volumeHandle.h:60
int copyno() const
Copy number associated with the current node.
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:121
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
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
void buildTruncTubs(const DDExpandedView &fv)
MagGeoBuilderFromDDD::volumeHandle::~volumeHandle ( )

Definition at line 35 of file volumeHandle.cc.

35  {
36  delete refPlane;
37 }
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 246 of file volumeHandle.cc.

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

249  {
250  // This is 100% equal for cons and tubs!!!
251 
252  GlobalVector planeXAxis = refPlane->toGlobal(LocalVector( 1, 0, 0));
253  GlobalVector planeYAxis = refPlane->toGlobal(LocalVector( 0, 1, 0));
254  GlobalVector planeZAxis = refPlane->toGlobal(LocalVector( 0, 0, 1));
255 
256  // Local Y axis of the faces at +-phi.
257  GlobalVector y_phiplus = refPlane->toGlobal(LocalVector(cos(startPhi+deltaPhi),
258  sin(startPhi+deltaPhi),0.));
259  GlobalVector y_phiminus = refPlane->toGlobal(LocalVector(cos(startPhi),
260  sin(startPhi),0.));
261 
262  Surface::RotationType rot_Z(planeXAxis,planeYAxis);
263  Surface::RotationType rot_phiplus(planeZAxis, y_phiplus);
264  Surface::RotationType rot_phiminus(planeZAxis, y_phiminus);
265 
266  GlobalPoint pos_zplus(center_.x(),center_.y(),center_.z()+zhalf);
267  GlobalPoint pos_zminus(center_.x(),center_.y(),center_.z()-zhalf);
268  // BEWARE: in this case, the origin for phiplus,phiminus surfaces is
269  // at radius R and not on a plane passing by center_ orthogonal to the radius.
270  GlobalPoint pos_phiplus(refPlane->toGlobal(LocalPoint(rCentr*cos(startPhi+deltaPhi),rCentr*sin(startPhi+deltaPhi),0.)));
271  GlobalPoint pos_phiminus(refPlane->toGlobal(LocalPoint(rCentr*cos(startPhi),
272  rCentr*sin(startPhi),
273  0.)));
274  surfaces[zplus] = new Plane(pos_zplus, rot_Z);
275  surfaces[zminus] = new Plane(pos_zminus, rot_Z);
276  surfaces[phiplus] = new Plane(pos_phiplus, rot_phiplus);
277  surfaces[phiminus] = new Plane(pos_phiminus, rot_phiminus);
278 
280  cout << "Actual Center at: " << center_ << " R " << center_.perp()
281  << " phi " << center_.phi() << endl;
282  cout << "RN " << theRN << endl;
283 
284  cout << "pos_zplus " << pos_zplus << " "
285  << pos_zplus.perp() << " " << pos_zplus.phi() << endl
286  << "pos_zminus " << pos_zminus << " "
287  << pos_zminus.perp() << " " << pos_zminus.phi() << endl
288  << "pos_phiplus " << pos_phiplus << " "
289  << pos_phiplus.perp() << " " << pos_phiplus.phi() <<endl
290  << "pos_phiminus " << pos_phiminus << " "
291  << pos_phiminus.perp() << " " << pos_phiminus.phi() <<endl;
292 
293  cout << "y_phiplus " << y_phiplus << endl;
294  cout << "y_phiminus " << y_phiminus << endl;
295 
296  cout << "rot_Z " << surfaces[zplus]->toGlobal(LocalVector(0.,0.,1.)) << endl
297  << "rot_phi+ " << surfaces[phiplus]->toGlobal(LocalVector(0.,0.,1.))
298  << " phi " << surfaces[phiplus]->toGlobal(LocalVector(0.,0.,1.)).phi()
299  << endl
300  << "rot_phi- " << surfaces[phiminus]->toGlobal(LocalVector(0.,0.,1.))
301  << " phi " << surfaces[phiminus]->toGlobal(LocalVector(0.,0.,1.)).phi()
302  << endl;
303  }
304 
305 // // Check ordering.
307  if (pos_zplus.z() < pos_zminus.z()) {
308  cout << "*** WARNING: pos_zplus < pos_zminus " << endl;
309  }
310  if (Geom::Phi<float>(pos_phiplus.phi()-pos_phiminus.phi()) < 0. ) {
311  cout << "*** WARNING: pos_phiplus < pos_phiminus " << endl;
312  }
313  }
314 }
T perp() const
Definition: PV3DBase.h:72
GloballyPositioned< float > * refPlane
Definition: volumeHandle.h:155
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
Definition: Plane.h:17
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Surface::LocalVector LocalVector
Definition: volumeHandle.h:29
GlobalPoint toGlobal(const LocalPoint &lp) const
tuple cout
Definition: gather_cfg.py:121
T x() const
Definition: PV3DBase.h:62
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 46 of file volumeHandle.h.

References isAssigned.

46  {
47  return isAssigned[which_side];
48  }
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:69
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:64
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:64
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 464 of file volumeHandle.cc.

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

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

464  {
465  std::vector<std::string> names;
466  for (handles::const_iterator i = begin;
467  i != end; ++i){
468  names.push_back((*i)->name);
469  }
470 
471  sort(names.begin(),names.end());
472  std::vector<std::string>::iterator i = unique(names.begin(),names.end());
473  int nvols = int(i - names.begin());
474  cout << nvols << " ";
475  copy(names.begin(), i, ostream_iterator<std::string>(cout, " "));
476 
477  cout << endl;
478 }
int i
Definition: DBlmapReader.cc:9
static const HistoName names[]
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
tuple cout
Definition: gather_cfg.py:121
void MagGeoBuilderFromDDD::volumeHandle::referencePlane ( const DDExpandedView fv)
private

Definition at line 175 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().

175  {
176  // The refPlane is the "main plane" for the solid. It corresponds to the
177  // x,y plane in the DDD local frame, and defines a frame where the local
178  // coordinates are the same as in DDD.
179  // In the geometry version 85l_030919, this plane is normal to the
180  // beam line for all volumes but pseudotraps, so that global R is along Y,
181  // global phi is along -X and global Z along Z:
182  //
183  // Global(for vol at pi/2) Local
184  // +R (+Y) +Y
185  // +phi(-X) -X
186  // +Z +Z
187  //
188  // For pseudotraps the refPlane is parallel to beam line and global R is
189  // along Z, global phi is along +-X and and global Z along Y:
190  //
191  // Global(for vol at pi/2) Local
192  // +R (+Y) +Z
193  // +phi(-X) +X
194  // +Z +Y
195  //
196  // Note that the frame is centered in the DDD volume center, which is
197  // inside the volume for DDD boxes and (pesudo)trapezoids, on the beam line
198  // for tubs, cons and trunctubs.
199 
200  // In geometry version 1103l, trapezoids have X and Z in the opposite direction
201  // than the above. Boxes are either oriented as described above or in some case
202  // have opposite direction for Y and X.
203 
204  // The global position
205  Surface::PositionType & posResult = center_;
206 
207  // The reference plane rotation
208  DD3Vector x, y, z;
209  fv.rotation().GetComponents(x,y,z);
211  if (x.Cross(y).Dot(z) < 0.5) {
212  cout << "*** WARNING: Rotation is not RH "<< endl;
213  }
214  }
215 
216  // The global rotation
218  rotResult(float(x.X()),float(x.Y()),float(x.Z()),
219  float(y.X()),float(y.Y()),float(y.Z()),
220  float(z.X()),float(z.Y()),float(z.Z()));
221 
222  refPlane = new GloballyPositioned<float>(posResult, rotResult);
223 
224  // Check correct orientation
226 
227  cout << "Refplane pos " << refPlane->position() << endl;
228 
229  // See comments above for the conventions for orientation.
230  LocalVector globalZdir(0.,0.,1.); // Local direction of the axis along global Z
231  if (solid.shape() == ddpseudotrap) {
232  globalZdir = LocalVector(0.,1.,0.);
233  }
234  if (refPlane->toGlobal(globalZdir).z()<0.) {
235  globalZdir=-globalZdir;
236  }
237 
238  float chk = refPlane->toGlobal(globalZdir).dot(GlobalVector(0,0,1));
239  if (chk < .999) cout << "*** WARNING RefPlane check failed!***"
240  << chk << endl;
241  }
242 }
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
GloballyPositioned< float > * refPlane
Definition: volumeHandle.h:155
float float float 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:64
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
Surface::LocalVector LocalVector
Definition: volumeHandle.h:29
GlobalPoint toGlobal(const LocalPoint &lp) const
tuple cout
Definition: gather_cfg.py:121
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 50 of file volumeHandle.h.

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

Distance of (x,y) plane from origin.

Definition at line 37 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 318 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().

319 {
320  //Check for null comparison
321  if (&s1==(surfaces[which_side]).get()){
322  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: OK (same ptr)" << endl;
323  return true;
324  }
325 
326  const float maxtilt = 0.999;
327 
328  const Surface & s2 = *(surfaces[which_side]);
329  // Try with a plane.
330  const Plane * p1 = dynamic_cast<const Plane*>(&s1);
331  if (p1!=0) {
332  const Plane * p2 = dynamic_cast<const Plane*>(&s2);
333  if (p2==0) {
334  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: different types" << endl;
335  return false;
336  }
337 
338  if ( (fabs(p1->normalVector().dot(p2->normalVector())) > maxtilt)
339  && (fabs((p1->toLocal(p2->position())).z()) < tolerance) ) {
340  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: OK "
341  << fabs(p1->normalVector().dot(p2->normalVector()))
342  << " " << fabs((p1->toLocal(p2->position())).z()) << endl;
343  return true;
344  } else{
345  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: not the same: "
346  << p1->normalVector() << p1->position() << endl
347  << " "
348  << p2->normalVector() << p2->position() << endl
349  << fabs(p1->normalVector().dot(p2->normalVector()))
350  << " " << (p1->toLocal(p2->position())).z()<< endl;
351  return false;
352  }
353  }
354 
355  // Try with a cylinder.
356  const Cylinder * cy1 = dynamic_cast<const Cylinder*>(&s1);
357  if (cy1!=0) {
358  const Cylinder * cy2 = dynamic_cast<const Cylinder*>(&s2);
359  if (cy2==0) {
360  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: different types" << endl;
361  return false;
362  }
363  // Assume axis is the same!
364  if (fabs(cy1->radius() - cy2->radius()) < tolerance) {
365  return true;
366  } else {
367  return false;
368  }
369  }
370 
371  // Try with a cone.
372  const Cone * co1 = dynamic_cast<const Cone*>(&s1);
373  if (co1!=0) {
374  const Cone * co2 = dynamic_cast<const Cone*>(&s2);
375  if (co2==0) {
376  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: different types" << endl;
377  return false;
378  }
379  // FIXME
380  if (fabs(co1->openingAngle()-co2->openingAngle()) < maxtilt
381  && (co1->vertex()-co2->vertex()).mag() < tolerance) {
382  return true;
383  } else {
384  return false;
385  }
386  }
387 
388  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: unknown surfaces..." << endl;
389  return false;
390 }
Definition: Cone.h:17
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GlobalVector normalVector() const
Definition: Plane.h:45
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:55
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:67
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:64
double p2[4]
Definition: TauolaWrapper.h:90
double p1[4]
Definition: TauolaWrapper.h:89
tuple cout
Definition: gather_cfg.py:121
const PositionType & position() const
Geom::Theta< float > openingAngle() const
Angle of the cone.
Definition: Cone.h:58
bool MagGeoBuilderFromDDD::volumeHandle::setSurface ( const Surface s1,
Sides  which_side 
)

Assign a shared surface perorming sanity checks.

Definition at line 394 of file volumeHandle.cc.

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

395 {
396  //Check for null assignment
397  if (&s1==(surfaces[which_side]).get()){
398  isAssigned[which_side] = true;
399  return true;
400  }
401 
402  if (!sameSurface(s1,which_side)){
403  cout << "***ERROR: setSurface: trying to assign a surface that does not match destination surface. Skipping." << endl;
404  const Surface & s2 = *(surfaces[which_side]);
405  //FIXME: Just planes for the time being!!!
406  const Plane * p1 = dynamic_cast<const Plane*>(&s1);
407  const Plane * p2 = dynamic_cast<const Plane*>(&s2);
408  if (p1!=0 && p2 !=0)
409  cout << p1->normalVector() << p1->position() << endl
410  << p2->normalVector() << p2->position() << endl;
411  return false;
412  }
413 
414 
415  if (isAssigned[which_side]) {
416  if (&s1!=(surfaces[which_side]).get()){
417  cout << "*** WARNING volumeHandle::setSurface: trying to reassign a surface to a different surface instance" << endl;
418  return false;
419  }
420  } else {
421  surfaces[which_side] = &s1;
422  isAssigned[which_side] = true;
423  if (MagGeoBuilderFromDDD::debug) cout << " Volume " << name << " # " << copyno << " Assigned: " << (int) which_side << endl;
424  return true;
425  }
426 
427  return false; // let the compiler be happy
428 }
unsigned short copyno
copy number
Definition: volumeHandle.h:62
GlobalVector normalVector() const
Definition: Plane.h:45
std::string name
Name of the volume.
Definition: volumeHandle.h:56
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:121
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 ( void  ) 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(void) const
The type of the solid.
Definition: DDSolid.cc:144
std::vector< VolumeSide > MagGeoBuilderFromDDD::volumeHandle::sides ( void  ) const

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

Definition at line 447 of file volumeHandle.cc.

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

Referenced by MagGeoBuilderFromDDD::buildInterpolator().

447  {
448  std::vector<VolumeSide> result;
449  for (int i=0; i<6; ++i){
450  // If this is just a master volume out of wich a 2pi volume
451  // should be built (e.g. central cylinder), skip the phi boundaries.
452  if (expand && (i==phiplus || i==phiminus)) continue;
453 
454  // FIXME: Skip null inner degenerate cylindrical surface
455  if (solid.shape() == ddtubs && i == SurfaceOrientation::inner && theRMin < 0.001) continue;
456 
457  ReferenceCountingPointer<Surface> s = const_cast<Surface*> (surfaces[i].get());
458  result.push_back(VolumeSide(s, GlobalFace(i),
459  surfaces[i]->side(center_,0.3)));
460  }
461  return result;
462 }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: query.py:137
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
const Surface & MagGeoBuilderFromDDD::volumeHandle::surface ( int  which_side) const

Get the current surface on specified side.

Definition at line 440 of file volumeHandle.cc.

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

440  {
441  assert(which_side >=0 && which_side <6);
442  return *(surfaces[which_side]);
443 }
const Surface & MagGeoBuilderFromDDD::volumeHandle::surface ( Sides  which_side) const

Definition at line 433 of file volumeHandle.cc.

433  {
434  return *(surfaces[which_side]);
435 }
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().

unsigned short 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 58 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().

unsigned short MagGeoBuilderFromDDD::volumeHandle::volumeno

volume number

Definition at line 60 of file volumeHandle.h.

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