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.

Date:
2013/04/15 16:02:44
Revision:
1.10
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 41 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.

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

37  {
38  delete refPlane;
39 }
GloballyPositioned< float > * refPlane
Definition: volumeHandle.h:157
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 248 of file volumeHandle.cc.

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

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

References thePhiMin.

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

Minimum R for any point within the volume.

Definition at line 90 of file volumeHandle.h.

References theRMin.

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

Z limits.

Definition at line 86 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 96 of file volumeHandle.h.

References refPlane.

Referenced by MagGeoBuilderFromDDD::buildInterpolator().

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

Just for debugging...

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

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

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

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

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

321 {
322  //Check for null comparison
323  if (&s1==(surfaces[which_side]).get()){
324  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: OK (same ptr)" << endl;
325  return true;
326  }
327 
328  const float maxtilt = 0.999;
329 
330  const Surface & s2 = *(surfaces[which_side]);
331  // Try with a plane.
332  const Plane * p1 = dynamic_cast<const Plane*>(&s1);
333  if (p1!=0) {
334  const Plane * p2 = dynamic_cast<const Plane*>(&s2);
335  if (p2==0) {
336  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: different types" << endl;
337  return false;
338  }
339 
340  if ( (fabs(p1->normalVector().dot(p2->normalVector())) > maxtilt)
341  && (fabs((p1->toLocal(p2->position())).z()) < tolerance) ) {
342  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: OK "
343  << fabs(p1->normalVector().dot(p2->normalVector()))
344  << " " << fabs((p1->toLocal(p2->position())).z()) << endl;
345  return true;
346  } else{
347  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: not the same: "
348  << p1->normalVector() << p1->position() << endl
349  << " "
350  << p2->normalVector() << p2->position() << endl
351  << fabs(p1->normalVector().dot(p2->normalVector()))
352  << " " << (p1->toLocal(p2->position())).z()<< endl;
353  return false;
354  }
355  }
356 
357  // Try with a cylinder.
358  const Cylinder * cy1 = dynamic_cast<const Cylinder*>(&s1);
359  if (cy1!=0) {
360  const Cylinder * cy2 = dynamic_cast<const Cylinder*>(&s2);
361  if (cy2==0) {
362  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: different types" << endl;
363  return false;
364  }
365  // Assume axis is the same!
366  if (fabs(cy1->radius() - cy2->radius()) < tolerance) {
367  return true;
368  } else {
369  return false;
370  }
371  }
372 
373  // Try with a cone.
374  const Cone * co1 = dynamic_cast<const Cone*>(&s1);
375  if (co1!=0) {
376  const Cone * co2 = dynamic_cast<const Cone*>(&s2);
377  if (co2==0) {
378  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: different types" << endl;
379  return false;
380  }
381  // FIXME
382  if (fabs(co1->openingAngle()-co2->openingAngle()) < maxtilt
383  && (co1->vertex()-co2->vertex()).mag() < tolerance) {
384  return true;
385  } else {
386  return false;
387  }
388  }
389 
390  if (MagGeoBuilderFromDDD::debug) cout << " sameSurface: unknown surfaces..." << endl;
391  return false;
392 }
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
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
bool MagGeoBuilderFromDDD::volumeHandle::setSurface ( const Surface s1,
Sides  which_side 
)

Assign a shared surface perorming sanity checks.

Definition at line 396 of file volumeHandle.cc.

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

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

References DDSolid::shape(), and solid.

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

99 {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 449 of file volumeHandle.cc.

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

Referenced by MagGeoBuilderFromDDD::buildInterpolator().

449  {
450  std::vector<VolumeSide> result;
451  for (int i=0; i<6; ++i){
452  // If this is just a master volume out of wich a 2pi volume
453  // should be built (e.g. central cylinder), skip the phi boundaries.
454  if (expand && (i==phiplus || i==phiminus)) continue;
455 
456  // FIXME: Skip null inner degenerate cylindrical surface
457  if (solid.shape() == ddtubs && i == SurfaceOrientation::inner && theRMin < 0.001) continue;
458 
459  ReferenceCountingPointer<Surface> s = const_cast<Surface*> (surfaces[i].get());
460  result.push_back(VolumeSide(s, GlobalFace(i),
461  surfaces[i]->side(center_,0.3)));
462  }
463  return result;
464 }
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 442 of file volumeHandle.cc.

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

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

Definition at line 435 of file volumeHandle.cc.

435  {
436  return *(surfaces[which_side]);
437 }
bool MagGeoBuilderFromDDD::volumeHandle::toExpand ( ) const
inline

Definition at line 107 of file volumeHandle.h.

References expand.

Referenced by MagGeoBuilderFromDDD::buildInterpolator().

Member Data Documentation

GlobalPoint MagGeoBuilderFromDDD::volumeHandle::center_
private

Definition at line 163 of file volumeHandle.h.

Referenced by volumeHandle().

unsigned short MagGeoBuilderFromDDD::volumeHandle::copyno

copy number

Definition at line 64 of file volumeHandle.h.

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

bool MagGeoBuilderFromDDD::volumeHandle::expand
private

Definition at line 167 of file volumeHandle.h.

Referenced by toExpand().

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

Definition at line 124 of file volumeHandle.h.

Referenced by isPlaneMatched(), and volumeHandle().

bool MagGeoBuilderFromDDD::volumeHandle::isIronFlag
private

Definition at line 170 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 105 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 113 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 157 of file volumeHandle.h.

Referenced by placement().

DDSolid MagGeoBuilderFromDDD::volumeHandle::solid
private

Definition at line 160 of file volumeHandle.h.

Referenced by shape(), and volumeHandle().

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

Definition at line 122 of file volumeHandle.h.

Referenced by volumeHandle().

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

Definition at line 152 of file volumeHandle.h.

Referenced by minPhi().

double MagGeoBuilderFromDDD::volumeHandle::theRMax
private

Definition at line 151 of file volumeHandle.h.

Referenced by volumeHandle().

double MagGeoBuilderFromDDD::volumeHandle::theRMin
private

Definition at line 150 of file volumeHandle.h.

Referenced by minR(), and volumeHandle().

double MagGeoBuilderFromDDD::volumeHandle::theRN
private

Definition at line 146 of file volumeHandle.h.

Referenced by RN(), and volumeHandle().

unsigned short MagGeoBuilderFromDDD::volumeHandle::volumeno

volume number

Definition at line 62 of file volumeHandle.h.

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