CMS 3D CMS Logo

MagGeoBuilderFromDDD::volumeHandle Class Reference

A temporary container to cache info on a six-surface volume during the processing. More...

#include <MagneticField/GeomBuilder/src/volumeHandle.h>

List of all members.

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.
bool isIron () const
 Temporary hack to pass information on material. Will eventually be replaced!
bool isPlaneMatched (int which_side) const
 if the specified surface has been matched.
Geom::Phi< float > maxPhi () const
 Maximum value of phi covered by the volume.
double maxZ () const
Geom::Phi< float > minPhi () const
 Minimum value of phi covered by the volume.
double minR () const
 Minimum R for any point within the volume.
double minZ () const
 Z limits.
const GloballyPositioned< float > * placement () const
 FIXME: currently returns max RN (to be fixed?). Used by: bLayer::maxR().
int references (int which_side) const
const double RN () const
 Distance of (x,y) plane from origin.
bool sameSurface (const Surface &s1, Sides which_side, float tolerance=0.01)
 Find out if two surfaces are the same physical surface.
bool setSurface (const Surface &s1, Sides which_side)
 Assign a shared surface perorming sanity checks.
DDSolidShape shape () const
 Shape of the solid.
std::vector< VolumeSidesides () const
 The surfaces and they orientation, as required to build a MagVolume.
const Surfacesurface (Sides which_side) const
const Surfacesurface (int which_side) const
 Get the current surface on specified side.
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...

Public Attributes

int copyno
 copy number
std::string magFile
 Name of magnetic field table file.
MagVolume6FacesmagVolume
 Pointer to the final MagVolume (must be set from outside).
int masterSector
 The sector for which an interpolator for this class of volumes should be built.
std::string name
 Name of the volume.

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

typedef Surface::GlobalPoint MagGeoBuilderFromDDD::volumeHandle::GlobalPoint

Definition at line 29 of file volumeHandle.h.

typedef Surface::LocalPoint MagGeoBuilderFromDDD::volumeHandle::LocalPoint

Definition at line 30 of file volumeHandle.h.

typedef Surface::LocalVector MagGeoBuilderFromDDD::volumeHandle::LocalVector

Definition at line 31 of file volumeHandle.h.

typedef SurfaceOrientation::GlobalFace MagGeoBuilderFromDDD::volumeHandle::Sides

Definition at line 32 of file volumeHandle.h.


Constructor & Destructor Documentation

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

Definition at line 43 of file volumeHandle.cc.

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

00044   : name(fv.logicalPart().name().name()),
00045     copyno(fv.copyno()),
00046     magVolume(0),
00047     masterSector(1),
00048     theRN(0.),
00049     theRMin(0.),
00050     theRMax(0.),
00051     refPlane(0),
00052     solid(fv.logicalPart().solid()),
00053     center_(GlobalPoint(fv.translation().x()/cm,
00054                         fv.translation().y()/cm,
00055                         fv.translation().z()/cm)),
00056     expand(expand2Pi),
00057     isIronFlag(false)
00058 {
00059   for (int i=0; i<6; ++i) {
00060     isAssigned[i] = false;
00061   }
00062 
00063   
00064   if (MagGeoBuilderFromDDD::debug) {  
00065     cout.precision(7);
00066   }
00067   
00068 
00069   referencePlane(fv);
00070 
00071   if (solid.shape() == ddbox) {
00072     buildBox(fv);
00073   } else if (solid.shape() == ddtrap) {
00074     buildTrap(fv);
00075   } else if (solid.shape() == ddcons) {
00076     buildCons(fv);
00077   } else if (solid.shape() == ddtubs) {   
00078     buildTubs(fv);
00079   } else if (solid.shape() == ddpseudotrap) {   
00080     buildPseudoTrap(fv);
00081   } else if (solid.shape() == ddtrunctubs) {   
00082     buildTruncTubs(fv);
00083   } else {
00084     cout << "volumeHandle ctor: Unexpected solid: " << (int) solid.shape() << endl;
00085   }
00086 
00087 
00088   DDsvalues_type sv(fv.mergedSpecifics());
00089     
00090   { // Extract the name of associated field file.
00091     std::vector<std::string> temp;
00092     std::string pname = "table";
00093     DDValue val(pname);
00094     DDsvalues_type sv(fv.mergedSpecifics());
00095     if (DDfetch(&sv,val)) {
00096       temp = val.strings();
00097       if (temp.size() != 1) {
00098         cout << "*** WARNING: volume has > 1 SpecPar " << pname << endl;
00099       }
00100       magFile = temp[0];
00101     } else {
00102       cout << "*** WARNING: volume does not have a SpecPar " << pname << endl;
00103       cout << " DDsvalues_type:  " << fv.mergedSpecifics() << endl;
00104     }
00105   }
00106 
00107   { // Extract the number of the master sector.
00108     std::vector<double> temp;
00109     const std::string pname = "masterSector";
00110     DDValue val(pname);
00111     if (DDfetch(&sv,val)) {
00112       temp = val.doubles();
00113       if (temp.size() != 1) {
00114         cout << "*** WARNING: volume has > 1 SpecPar " << pname << endl;
00115       }
00116       masterSector = int(temp[0]+.5);
00117     } else {
00118       cout << "*** WARNING: volume does not have a SpecPar " << pname << endl;
00119       cout << " DDsvalues_type:  " << fv.mergedSpecifics() << endl;
00120     }  
00121   }
00122   
00123   // Get material for this volume
00124   if (fv.logicalPart().material().name().name() == "Iron") isIronFlag=true;  
00125 
00126 
00127   if (MagGeoBuilderFromDDD::debug) {  
00128     cout << " RMin =  " << theRMin <<endl;
00129     cout << " RMax =  " << theRMax <<endl;
00130       
00131     if (theRMin < 0 || theRN < theRMin || theRMax < theRN) 
00132       cout << "*** WARNING: wrong RMin/RN/RMax , shape: " << (int) shape() << endl;
00133 
00134     cout << "Summary: " << name << " " << copyno
00135          << " Shape= " << (int) shape()
00136          << " trasl " << center()
00137          << " R " << center().perp()
00138          << " phi " << center().phi()
00139          << " magFile " << magFile
00140          << " Material= " << fv.logicalPart().material().name()
00141          << " isIron= " << isIronFlag
00142          << " masterSector= " << masterSector << std::endl;
00143 
00144     cout << " Orientation of surfaces:";
00145     std::string sideName[3] =  {"positiveSide", "negativeSide", "onSurface"};
00146     for (int i=0; i<6; ++i) {    
00147       cout << "  " << i << ":" << sideName[surfaces[i]->side(center_,0.3)];
00148     }
00149     cout << endl;
00150   }
00151 }

MagGeoBuilderFromDDD::volumeHandle::~volumeHandle (  ) 

Definition at line 39 of file volumeHandle.cc.

References refPlane.

00039                                                {
00040   delete refPlane;
00041 }

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 229 of file volumeHandle.cc.

References center_, funct::cos(), GenMuonPlsPt100GeV_cfg::cout, MagGeoBuilderFromDDD::debug, lat::endl(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), SurfaceOrientation::phiminus, SurfaceOrientation::phiplus, refPlane, funct::sin(), surfaces, theRN, GloballyPositioned< T >::toGlobal(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), SurfaceOrientation::zminus, and SurfaceOrientation::zplus.

00232                                                                       {
00233   // This is 100% equal for cons and tubs!!!
00234 
00235   GlobalVector planeXAxis = refPlane->toGlobal(LocalVector( 1, 0, 0));
00236   GlobalVector planeYAxis = refPlane->toGlobal(LocalVector( 0, 1, 0));
00237   GlobalVector planeZAxis = refPlane->toGlobal(LocalVector( 0, 0, 1));
00238 
00239   // Local Y axis of the faces at +-phi.
00240   GlobalVector y_phiplus = refPlane->toGlobal(LocalVector(cos(startPhi+deltaPhi),
00241                                                           sin(startPhi+deltaPhi),0.));
00242   GlobalVector y_phiminus = refPlane->toGlobal(LocalVector(cos(startPhi),
00243                                                            sin(startPhi),0.));
00244 
00245   Surface::RotationType rot_Z(planeXAxis,planeYAxis);
00246   Surface::RotationType rot_phiplus(planeZAxis, y_phiplus); 
00247   Surface::RotationType rot_phiminus(planeZAxis, y_phiminus);
00248 
00249   GlobalPoint pos_zplus(center_.x(),center_.y(),center_.z()+zhalf);
00250   GlobalPoint pos_zminus(center_.x(),center_.y(),center_.z()-zhalf);
00251   // BEWARE: in this case, the origin for phiplus,phiminus surfaces is 
00252   // at radius R and not on a plane passing by center_ orthogonal to the radius.
00253   GlobalPoint pos_phiplus(refPlane->toGlobal(LocalPoint(rCentr*cos(startPhi+deltaPhi),rCentr*sin(startPhi+deltaPhi),0.)));
00254   GlobalPoint pos_phiminus(refPlane->toGlobal(LocalPoint(rCentr*cos(startPhi),
00255                                                          rCentr*sin(startPhi),
00256                                                          0.)));
00257   surfaces[zplus]    = new Plane(pos_zplus, rot_Z);
00258   surfaces[zminus]   = new Plane(pos_zminus, rot_Z);
00259   surfaces[phiplus]  = new Plane(pos_phiplus, rot_phiplus);
00260   surfaces[phiminus] = new Plane(pos_phiminus, rot_phiminus);  
00261   
00262   if (MagGeoBuilderFromDDD::debug) {
00263     cout << "Actual Center at: " << center_ << " R " << center_.perp()
00264          << " phi " << center_.phi() << endl;
00265     cout << "RN            " << theRN << endl;
00266 
00267     cout << "pos_zplus    " << pos_zplus << " "
00268          << pos_zplus.perp() << " " << pos_zplus.phi() << endl
00269          << "pos_zminus   " << pos_zminus << " "
00270          << pos_zminus.perp() << " " << pos_zminus.phi() << endl
00271          << "pos_phiplus  " << pos_phiplus << " "
00272          << pos_phiplus.perp() << " " << pos_phiplus.phi() <<endl
00273          << "pos_phiminus " << pos_phiminus << " "
00274          << pos_phiminus.perp() << " " << pos_phiminus.phi() <<endl;
00275 
00276     cout << "y_phiplus " << y_phiplus << endl;
00277     cout << "y_phiminus " << y_phiminus << endl;
00278 
00279     cout << "rot_Z " << surfaces[zplus]->toGlobal(LocalVector(0.,0.,1.)) << endl
00280          << "rot_phi+ " << surfaces[phiplus]->toGlobal(LocalVector(0.,0.,1.))
00281          << " phi " << surfaces[phiplus]->toGlobal(LocalVector(0.,0.,1.)).phi()
00282          << endl
00283          << "rot_phi- " << surfaces[phiminus]->toGlobal(LocalVector(0.,0.,1.))
00284          << " phi " << surfaces[phiminus]->toGlobal(LocalVector(0.,0.,1.)).phi()
00285          << endl;
00286   }
00287   
00288 //   // Check ordering.
00289   if (MagGeoBuilderFromDDD::debug) {
00290     if (pos_zplus.z() < pos_zminus.z()) {
00291       cout << "*** WARNING: pos_zplus < pos_zminus " << endl;
00292     }
00293     if (Geom::Phi<float>(pos_phiplus.phi()-pos_phiminus.phi()) < 0. ) {
00294       cout << "*** WARNING: pos_phiplus < pos_phiminus " << endl;
00295     }
00296   }
00297 }

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

Return the center of the volume.

Definition at line 154 of file volumeHandle.cc.

References center_.

Referenced by MagGeoBuilderFromDDD::build(), MagGeoBuilderFromDDD::LessZ::operator()(), MagGeoBuilderFromDDD::ExtractPhi::operator()(), MagGeoBuilderFromDDD::ExtractR::operator()(), MagGeoBuilderFromDDD::ExtractAbsZ::operator()(), MagGeoBuilderFromDDD::ExtractZ::operator()(), and volumeHandle().

00154                                                                           {
00155   return center_;
00156 }

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.

00108 {return 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.

00048                                             {
00049     return isAssigned[which_side];
00050   }

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 SurfaceOrientation::phiplus, GloballyPositioned< T >::position(), and surface().

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

00079 {return surface(SurfaceOrientation::phiplus).position().phi();}

double MagGeoBuilderFromDDD::volumeHandle::maxZ (  )  const [inline]

Definition at line 85 of file volumeHandle.h.

References GloballyPositioned< T >::position(), surface(), and SurfaceOrientation::zplus.

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.

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

00088 {return theRMin;}

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

Z limits.

Definition at line 84 of file volumeHandle.h.

References GloballyPositioned< T >::position(), surface(), and SurfaceOrientation::zminus.

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.

00094 {return refPlane;}

void MagGeoBuilderFromDDD::volumeHandle::printUniqueNames ( handles::const_iterator  begin,
handles::const_iterator  end 
) [static]

Just for debugging...

Definition at line 450 of file volumeHandle.cc.

References edmNew::copy(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), i, int, names, and python::multivaluedict::sort().

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

00450                                                                                                                {
00451     std::vector<std::string> names;
00452     for (handles::const_iterator i = begin; 
00453          i != end; ++i){
00454       names.push_back((*i)->name);
00455     }
00456      
00457     sort(names.begin(),names.end());
00458     std::vector<std::string>::iterator i = unique(names.begin(),names.end());
00459     int nvols = int(i - names.begin());
00460     cout << nvols << " ";
00461     copy(names.begin(), i, ostream_iterator<std::string>(cout, " "));
00462      
00463     cout << endl;
00464 }

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

Definition at line 158 of file volumeHandle.cc.

References center_, GenMuonPlsPt100GeV_cfg::cout, ddpseudotrap, MagGeoBuilderFromDDD::debug, lat::endl(), GloballyPositioned< T >::position(), refPlane, DDExpandedView::rotation(), DDSolid::shape(), solid, GloballyPositioned< T >::toGlobal(), x, y, PV3DBase< T, PVType, FrameType >::z(), and z.

Referenced by volumeHandle().

00158                                                                              {
00159   // The refPlane is the "main plane" for the solid. It corresponds to the 
00160   // x,y plane in the DDD local frame, and defines a frame where the local
00161   // coordinates are the same as in DDD. 
00162   // In the geometry version 85l_030919, this plane is normal to the 
00163   // beam line for all volumes but pseudotraps, so that global R is along Y,
00164   // global phi is along -X and global Z along Z:
00165   //
00166   //   Global(for vol at pi/2)    Local 
00167   //   +R (+Y)                    +Y
00168   //   +phi(-X)                   -X
00169   //   +Z                         +Z
00170   //
00171   // For pseudotraps the refPlane is parallel to beam line and global R is
00172   // along Z, global phi is along +-X and and global Z along Y:
00173   // 
00174   //   Global(for vol at pi/2)    Local 
00175   //   +R (+Y)                    +Z
00176   //   +phi(-X)                   +X
00177   //   +Z                         +Y
00178   //
00179   // Note that the frame is centered in the DDD volume center, which is
00180   // inside the volume for DDD boxes and (pesudo)trapezoids, on the beam line
00181   // for tubs, cons and trunctubs. 
00182 
00183   // In geometry version 1103l, trapezoids have X and Z in the opposite direction
00184   // than the above.  Boxes are either oriented as described above or in some case 
00185   // have opposite direction for Y and X.
00186 
00187   // The global position
00188   Surface::PositionType & posResult = center_;
00189 
00190   // The reference plane rotation
00191   DD3Vector x, y, z;
00192   fv.rotation().GetComponents(x,y,z);
00193   if (MagGeoBuilderFromDDD::debug) {
00194     if (x.Cross(y).Dot(z) < 0.5) {
00195       cout << "*** WARNING: Rotation is not RH "<< endl;
00196     }
00197   }
00198   
00199   // The global rotation
00200   Surface::RotationType
00201     rotResult(float(x.X()),float(x.Y()),float(x.Z()),
00202               float(y.X()),float(y.Y()),float(y.Z()),
00203               float(z.X()),float(z.Y()),float(z.Z()));
00204 
00205   refPlane = new GloballyPositioned<float>(posResult, rotResult);
00206 
00207   // Check correct orientation
00208   if (MagGeoBuilderFromDDD::debug) {
00209 
00210     cout << "Refplane pos  " << refPlane->position() << endl;
00211 
00212     // See comments above for the conventions for orientation.
00213     LocalVector globalZdir(0.,0.,1.); // Local direction of the axis along global Z 
00214     if (solid.shape() == ddpseudotrap) {
00215       globalZdir = LocalVector(0.,1.,0.);    
00216     }
00217     if (refPlane->toGlobal(globalZdir).z()<0.) {
00218       globalZdir=-globalZdir;
00219     }
00220 
00221     float chk = refPlane->toGlobal(globalZdir).dot(GlobalVector(0,0,1));
00222     if (chk < .999) cout << "*** WARNING RefPlane check failed!***"
00223                          << chk << endl; 
00224   }
00225 }

int MagGeoBuilderFromDDD::volumeHandle::references ( int  which_side  )  const [inline]

Definition at line 52 of file volumeHandle.h.

00052                                        { // FIXME!
00053 /*     return surfaces[which_side]->references(); */
00054     return 0;
00055   }

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

00039 {return theRN;}

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 301 of file volumeHandle.cc.

References GenMuonPlsPt100GeV_cfg::cout, MagGeoBuilderFromDDD::debug, Vector3DBase< T, FrameTag >::dot(), lat::endl(), muonGeometry::mag(), Plane::normalVector(), Cone::openingAngle(), p1, p2, GloballyPositioned< T >::position(), Cylinder::radius(), s2, surfaces, GloballyPositioned< T >::toLocal(), and Cone::vertex().

Referenced by setSurface().

00302 {
00303   //Check for null comparison
00304   if (&s1==(surfaces[which_side]).get()){
00305     if (MagGeoBuilderFromDDD::debug) cout << "      sameSurface: OK (same ptr)" << endl;
00306     return true;
00307   }
00308 
00309 //   static TimingReport::Item & timer = (*TimingReport::current())["volumeHandle::sameSurface"];
00310 //   TimeMe time(timer,false);
00311 
00312   const float maxtilt  = 0.999;
00313 
00314   const Surface & s2 = *(surfaces[which_side]);
00315   // Try with a plane.
00316   const Plane * p1 = dynamic_cast<const Plane*>(&s1);
00317   if (p1!=0) {
00318     const Plane * p2 = dynamic_cast<const Plane*>(&s2);
00319     if (p2==0) {
00320       if (MagGeoBuilderFromDDD::debug) cout << "      sameSurface: different types" << endl;
00321       return false;
00322     }
00323     
00324     if ( (fabs(p1->normalVector().dot(p2->normalVector())) > maxtilt)
00325          && (fabs((p1->toLocal(p2->position())).z()) < tolerance) ) {
00326       if (MagGeoBuilderFromDDD::debug) cout << "      sameSurface: OK "
00327                       << fabs(p1->normalVector().dot(p2->normalVector()))
00328                       << " " << fabs((p1->toLocal(p2->position())).z()) << endl;
00329       return true;
00330     } else{
00331       if (MagGeoBuilderFromDDD::debug) cout << "      sameSurface: not the same: "
00332                       << p1->normalVector() << p1->position() << endl
00333                       << "                                 "
00334                       << p2->normalVector() << p2->position() << endl
00335                       << fabs(p1->normalVector().dot(p2->normalVector()))
00336                       << " " << (p1->toLocal(p2->position())).z()<< endl;
00337       return false;
00338     }
00339   }
00340 
00341   // Try with a cylinder.  
00342   const Cylinder * cy1 = dynamic_cast<const Cylinder*>(&s1);
00343   if (cy1!=0) {
00344     const Cylinder * cy2 = dynamic_cast<const Cylinder*>(&s2);
00345     if (cy2==0) {
00346       if (MagGeoBuilderFromDDD::debug) cout << "      sameSurface: different types" << endl;
00347       return false;
00348     }
00349     // Assume axis is the same!
00350     if (fabs(cy1->radius() - cy2->radius()) < tolerance) {
00351       return true;
00352     } else {
00353       return false;
00354     }
00355   }
00356 
00357   // Try with a cone.  
00358   const Cone * co1 = dynamic_cast<const Cone*>(&s1);
00359   if (co1!=0) {
00360     const Cone * co2 = dynamic_cast<const Cone*>(&s2);
00361     if (co2==0) {
00362       if (MagGeoBuilderFromDDD::debug) cout << "      sameSurface: different types" << endl;
00363       return false;
00364     }
00365     // FIXME
00366     if (fabs(co1->openingAngle()-co2->openingAngle()) < maxtilt 
00367         && (co1->vertex()-co2->vertex()).mag() < tolerance) {
00368       return true;
00369     } else {
00370       return false;
00371     }
00372   }
00373 
00374   if (MagGeoBuilderFromDDD::debug) cout << "      sameSurface: unknown surfaces..." << endl;
00375   return false;
00376 }

bool MagGeoBuilderFromDDD::volumeHandle::setSurface ( const Surface s1,
Sides  which_side 
)

Assign a shared surface perorming sanity checks.

Definition at line 380 of file volumeHandle.cc.

References copyno, GenMuonPlsPt100GeV_cfg::cout, MagGeoBuilderFromDDD::debug, lat::endl(), int, isAssigned, name, Plane::normalVector(), p1, p2, GloballyPositioned< T >::position(), s2, sameSurface(), and surfaces.

00381 {
00382  //Check for null assignment
00383   if (&s1==(surfaces[which_side]).get()){
00384     isAssigned[which_side] = true;
00385     return true;
00386   }
00387 
00388   if (!sameSurface(s1,which_side)){
00389     cout << "***ERROR: setSurface: trying to assign a surface that does not match destination surface. Skipping." << endl;    
00390     const Surface & s2 = *(surfaces[which_side]);
00391     //FIXME: Just planes for the time being!!!
00392     const Plane * p1 = dynamic_cast<const Plane*>(&s1);
00393     const Plane * p2 = dynamic_cast<const Plane*>(&s2);
00394     if (p1!=0 && p2 !=0) 
00395       cout << p1->normalVector() << p1->position() << endl
00396            << p2->normalVector() << p2->position() << endl;
00397     return false;
00398   }
00399   
00400 
00401   if (isAssigned[which_side]) {
00402     if (&s1!=(surfaces[which_side]).get()){
00403       cout << "*** WARNING volumeHandle::setSurface: trying to reassign a surface to a different surface instance" << endl;
00404       return false;
00405     }
00406   } else {
00407     surfaces[which_side] = &s1;
00408     isAssigned[which_side] = true;
00409     if (MagGeoBuilderFromDDD::debug) cout << "     Volume " << name << " # " << copyno << " Assigned: " << (int) which_side << endl;
00410     return true;
00411   }
00412 
00413   return false; // let the compiler be happy
00414 }

DDSolidShape MagGeoBuilderFromDDD::volumeHandle::shape (  )  const [inline]

Shape of the solid.

Definition at line 97 of file volumeHandle.h.

References DDSolid::shape(), and solid.

Referenced by volumeHandle().

00097 {return solid.shape();}

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

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

Definition at line 433 of file volumeHandle.cc.

References center_, ddtubs, expand, i, SurfaceOrientation::inner, SurfaceOrientation::phiminus, SurfaceOrientation::phiplus, HLT_VtxMuL3::result, s, DDSolid::shape(), solid, surfaces, and theRMin.

00433                                              {
00434   std::vector<VolumeSide> result;
00435   for (int i=0; i<6; ++i){
00436     // If this is just a master volume out of wich a 2pi volume
00437     // should be built (e.g. central cylinder), skip the phi boundaries.
00438     if (expand && (i==phiplus || i==phiminus)) continue;
00439 
00440     // FIXME: Skip null inner degenerate cylindrical surface
00441     if (solid.shape() == ddtubs && i == SurfaceOrientation::inner && theRMin < 0.001) continue;
00442 
00443     ReferenceCountingPointer<Surface> s = const_cast<Surface*> (surfaces[i].get());
00444     result.push_back(VolumeSide(s, GlobalFace(i),
00445                                 surfaces[i]->side(center_,0.3)));
00446   }
00447   return result;
00448 }

const Surface & MagGeoBuilderFromDDD::volumeHandle::surface ( Sides  which_side  )  const

Definition at line 419 of file volumeHandle.cc.

References surfaces.

00419                                                                 {
00420   return *(surfaces[which_side]);
00421 }

const Surface & MagGeoBuilderFromDDD::volumeHandle::surface ( int  which_side  )  const

Get the current surface on specified side.

Definition at line 426 of file volumeHandle.cc.

References surfaces.

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

00426                                                               {
00427   assert(which_side >=0 && which_side <6);
00428   return *(surfaces[which_side]);
00429 }

bool MagGeoBuilderFromDDD::volumeHandle::toExpand (  )  const [inline]

Definition at line 105 of file volumeHandle.h.

References expand.

00105 {return expand;}


Member Data Documentation

GlobalPoint MagGeoBuilderFromDDD::volumeHandle::center_ [private]

Definition at line 161 of file volumeHandle.h.

Referenced by buildPhiZSurf(), center(), referencePlane(), sides(), and volumeHandle().

int MagGeoBuilderFromDDD::volumeHandle::copyno

copy number

Definition at line 62 of file volumeHandle.h.

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

bool MagGeoBuilderFromDDD::volumeHandle::expand [private]

Definition at line 165 of file volumeHandle.h.

Referenced by sides(), and toExpand().

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

Definition at line 122 of file volumeHandle.h.

Referenced by isPlaneMatched(), setSurface(), 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(), 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(), and volumeHandle().

std::string MagGeoBuilderFromDDD::volumeHandle::name

Name of the volume.

Definition at line 58 of file volumeHandle.h.

Referenced by setSurface(), and volumeHandle().

GloballyPositioned<float>* MagGeoBuilderFromDDD::volumeHandle::refPlane [private]

Definition at line 155 of file volumeHandle.h.

Referenced by buildPhiZSurf(), placement(), referencePlane(), and ~volumeHandle().

DDSolid MagGeoBuilderFromDDD::volumeHandle::solid [private]

Definition at line 158 of file volumeHandle.h.

Referenced by referencePlane(), shape(), sides(), and volumeHandle().

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

Definition at line 120 of file volumeHandle.h.

Referenced by buildPhiZSurf(), sameSurface(), setSurface(), sides(), surface(), and 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(), sides(), and volumeHandle().

double MagGeoBuilderFromDDD::volumeHandle::theRN [private]

Definition at line 144 of file volumeHandle.h.

Referenced by buildPhiZSurf(), RN(), and volumeHandle().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:27:57 2009 for CMSSW by  doxygen 1.5.4