Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-24 02:11:09

0001 /*
0002  *  Compute parameters for a box 
0003  *
0004  *  \author N. Amapane - INFN Torino
0005  */
0006 
0007 inline void volumeHandle::buildBox(double halfX, double halfY, double halfZ) {
0008   LogTrace("MagGeoBuilder") << "Building box surfaces...: ";
0009 
0010   // Global vectors of the normals to X, Y, Z axes
0011   GlobalVector planeXAxis = refPlane->toGlobal(LocalVector(1, 0, 0));
0012   GlobalVector planeYAxis = refPlane->toGlobal(LocalVector(0, 1, 0));
0013   GlobalVector planeZAxis = refPlane->toGlobal(LocalVector(0, 0, 1));
0014 
0015   // FIXME Assumption: it is assumed that in the following that
0016   // local Z is always along global Z
0017   // (true for version 1103l, not necessarily in the future)
0018 
0019   // To determine the orientation of other local axes,
0020   // find local axis closest to global R
0021   GlobalVector Rvol(refPlane->position().x(), refPlane->position().y(), refPlane->position().z());
0022   double rnX = planeXAxis.dot(Rvol);
0023   double rnY = planeYAxis.dot(Rvol);
0024 
0025   GlobalPoint pos_outer;
0026   GlobalPoint pos_inner;
0027   GlobalPoint pos_phiplus;
0028   GlobalPoint pos_phiminus;
0029   GlobalPoint pos_zplus(refPlane->toGlobal(LocalPoint(0., 0., halfZ)));
0030   GlobalPoint pos_zminus(refPlane->toGlobal(LocalPoint(0., 0., -halfZ)));
0031 
0032   Surface::RotationType rot_R;
0033   Surface::RotationType rot_phi;
0034   Surface::RotationType rot_Z = Surface::RotationType(planeXAxis, planeYAxis);
0035 
0036   if (std::abs(rnX) > std::abs(rnY)) {
0037     // X is ~parallel to global R dir, Y is along +/- phi
0038     theRN = std::abs(rnX);
0039     if (rnX < 0) {
0040       halfX = -halfX;
0041       halfY = -halfY;
0042     }
0043     pos_outer = GlobalPoint(refPlane->toGlobal(LocalPoint(halfX, 0., 0.)));
0044     pos_inner = GlobalPoint(refPlane->toGlobal(LocalPoint(-halfX, 0., 0.)));
0045     pos_phiplus = GlobalPoint(refPlane->toGlobal(LocalPoint(0., halfY, 0.)));
0046     pos_phiminus = GlobalPoint(refPlane->toGlobal(LocalPoint(0., -halfY, 0.)));
0047 
0048     rot_R = Surface::RotationType(planeZAxis, planeYAxis);
0049     rot_phi = Surface::RotationType(planeZAxis, planeXAxis);  // opposite to y axis
0050   } else {
0051     // Y is ~parallel to global R dir, X is along +/- phi
0052     theRN = std::abs(rnY);
0053     if (rnY < 0) {
0054       halfX = -halfX;
0055       halfY = -halfY;
0056     }
0057     pos_outer = GlobalPoint(refPlane->toGlobal(LocalPoint(0., halfY, 0.)));
0058     pos_inner = GlobalPoint(refPlane->toGlobal(LocalPoint(0., -halfY, 0.)));
0059     pos_phiplus = GlobalPoint(refPlane->toGlobal(LocalPoint(-halfX, 0., 0.)));
0060     pos_phiminus = GlobalPoint(refPlane->toGlobal(LocalPoint(halfX, 0., 0.)));
0061 
0062     rot_R = Surface::RotationType(planeZAxis, planeXAxis);
0063     rot_phi = Surface::RotationType(planeZAxis, planeYAxis);  // opposite to x axis
0064   }
0065 
0066   LogTrace("MagGeoBuilder") << " halfX: " << halfX << "  halfY: " << halfY << "  halfZ: " << halfZ << "  RN: " << theRN;
0067 
0068   LogTrace("MagGeoBuilder") << "pos_outer    " << pos_outer << " " << pos_outer.perp() << " " << pos_outer.phi()
0069                             << newln << "pos_inner    " << pos_inner << " " << pos_inner.perp() << " "
0070                             << pos_inner.phi() << newln << "pos_zplus    " << pos_zplus << " " << pos_zplus.perp()
0071                             << " " << pos_zplus.phi() << newln << "pos_zminus   " << pos_zminus << " "
0072                             << pos_zminus.perp() << " " << pos_zminus.phi() << newln << "pos_phiplus  " << pos_phiplus
0073                             << " " << pos_phiplus.perp() << " " << pos_phiplus.phi() << newln << "pos_phiminus "
0074                             << pos_phiminus << " " << pos_phiminus.perp() << " " << pos_phiminus.phi();
0075 
0076   // Check ordering.
0077   if (debug) {
0078     if (pos_outer.perp() < pos_inner.perp()) {
0079       LogTrace("MagGeoBuilder") << "*** WARNING: pos_outer < pos_inner for box";
0080     }
0081     if (pos_zplus.z() < pos_zminus.z()) {
0082       LogTrace("MagGeoBuilder") << "*** WARNING: pos_zplus < pos_zminus for box";
0083     }
0084     if (Geom::Phi<float>(pos_phiplus.phi() - pos_phiminus.phi()) < 0.) {
0085       LogTrace("MagGeoBuilder") << "*** WARNING: pos_phiplus < pos_phiminus for box";
0086     }
0087   }
0088 
0089   // FIXME: use builder
0090   surfaces[outer] = new Plane(pos_outer, rot_R);
0091   surfaces[inner] = new Plane(pos_inner, rot_R);
0092   surfaces[zplus] = new Plane(pos_zplus, rot_Z);
0093   surfaces[zminus] = new Plane(pos_zminus, rot_Z);
0094   surfaces[phiplus] = new Plane(pos_phiplus, rot_phi);
0095   surfaces[phiminus] = new Plane(pos_phiminus, rot_phi);
0096 
0097   LogTrace("MagGeoBuilder") << "rot_R   " << surfaces[outer]->toGlobal(LocalVector(0., 0., 1.)) << newln << "rot_Z   "
0098                             << surfaces[zplus]->toGlobal(LocalVector(0., 0., 1.)) << newln << "rot_phi "
0099                             << surfaces[phiplus]->toGlobal(LocalVector(0., 0., 1.));
0100 
0101   // Save volume boundaries
0102   theRMin = std::abs(surfaces[inner]->toLocal(GlobalPoint(0, 0, 0)).z());
0103   theRMax = std::abs(surfaces[outer]->toLocal(GlobalPoint(0, 0, 0)).z());
0104   // FIXME: use phi of middle plane of phiminus surface. Is not the absolute phimin!
0105   thePhiMin = surfaces[phiminus]->position().phi();
0106 }