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/05/13 15:55:54
Revision:
1.9
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_, conv, copyno, gather_cfg::cout, ddbox, ddcons, DDfetch(), ddpseudotrap, ddtrap, ddtrunctubs, ddtubs, MagGeoBuilderFromDDD::debug, DDValue::doubles(), spr::find(), i, isAssigned, isIronFlag, j, 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, groupFilesInBlocks::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 
99  string find="[copyNo]";
100  std::size_t j;
101  for ( ; (j = magFile.find(find)) != string::npos ; ) {
102  stringstream conv;
103  conv << setfill('0') << setw(2) << copyno;
104  string repl;
105  conv >> repl;
106  magFile.replace(j, find.length(), repl);
107  }
108 
109  } else {
110  cout << "*** WARNING: volume does not have a SpecPar " << pname << endl;
111  cout << " DDsvalues_type: " << fv.mergedSpecifics() << endl;
112  }
113  }
114 
115  { // Extract the number of the master sector.
116  std::vector<double> temp;
117  const std::string pname = "masterSector";
118  DDValue val(pname);
119  if (DDfetch(&sv,val)) {
120  temp = val.doubles();
121  if (temp.size() != 1) {
122  cout << "*** WARNING: volume has > 1 SpecPar " << pname << endl;
123  }
124  masterSector = int(temp[0]+.5);
125  } else {
127  cout << "Volume does not have a SpecPar " << pname
128  << " using: " << copyno << endl;
129  cout << " DDsvalues_type: " << fv.mergedSpecifics() << endl;
130  }
132  }
133  }
134 
135  // Get material for this volume
136  if (fv.logicalPart().material().name().name() == "Iron") isIronFlag=true;
137 
138 
140  cout << " RMin = " << theRMin <<endl;
141  cout << " RMax = " << theRMax <<endl;
142 
143  if (theRMin < 0 || theRN < theRMin || theRMax < theRN)
144  cout << "*** WARNING: wrong RMin/RN/RMax , shape: " << (int) shape() << endl;
145 
146  cout << "Summary: " << name << " " << copyno
147  << " Shape= " << (int) shape()
148  << " trasl " << center()
149  << " R " << center().perp()
150  << " phi " << center().phi()
151  << " magFile " << magFile
152  << " Material= " << fv.logicalPart().material().name()
153  << " isIron= " << isIronFlag
154  << " masterSector= " << masterSector << std::endl;
155 
156  cout << " Orientation of surfaces:";
157  std::string sideName[3] = {"positiveSide", "negativeSide", "onSurface"};
158  for (int i=0; i<6; ++i) {
159  cout << " " << i << ":" << sideName[surfaces[i]->side(center_,0.3)];
160  }
161  cout << endl;
162  }
163 }
int i
Definition: DBlmapReader.cc:9
void buildBox(const DDExpandedView &fv)
DDsvalues_type mergedSpecifics() const
const N & name() const
Definition: DDBase.h:82
T perp() const
Definition: PV3DBase.h:71
GloballyPositioned< float > * refPlane
Definition: volumeHandle.h:155
static HepMC::IO_HEPEVT conv
void buildTubs(const DDExpandedView &fv)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
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.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
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
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
int j
Definition: DBlmapReader.cc:9
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.
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 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 241 of file volumeHandle.cc.

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

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

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

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

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

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

Assign a shared surface perorming sanity checks.

Definition at line 389 of file volumeHandle.cc.

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

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

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

Referenced by MagGeoBuilderFromDDD::buildInterpolator().

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

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

435  {
436  assert(which_side >=0 && which_side <6);
437  return *(surfaces[which_side]);
438 }
const Surface & MagGeoBuilderFromDDD::volumeHandle::surface ( Sides  which_side) const

Definition at line 428 of file volumeHandle.cc.

428  {
429  return *(surfaces[which_side]);
430 }
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().