CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/MagneticField/GeomBuilder/src/bSlab.cc

Go to the documentation of this file.
00001 /* \file
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2008/03/29 14:29:11 $
00005  *  $Revision: 1.6 $
00006  *  \author N. Amapane - INFN Torino
00007  */
00008 
00009 #include "MagneticField/GeomBuilder/src/bSlab.h"
00010 #include "MagneticField/VolumeGeometry/interface/MagVolume6Faces.h"
00011 #include "MagneticField/Layers/interface/MagBSlab.h"
00012 #include "MagneticField/Layers/interface/MagVerbosity.h"
00013 
00014 #include "Utilities/General/interface/precomputed_value_sort.h"
00015 
00016 using namespace SurfaceOrientation;
00017 using namespace std;
00018 
00019 MagGeoBuilderFromDDD::bSlab::~bSlab(){}
00020 
00021 MagGeoBuilderFromDDD::bSlab::bSlab(handles::const_iterator begin, handles::const_iterator end) :
00022   volumes(begin, end),
00023   mslab(0)
00024 {
00025   if (volumes.size() > 1) {
00026     // Sort volumes by dphi i.e. phi(j)-phi(i) > 0 if j>1.
00027     precomputed_value_sort(volumes.begin(), volumes.end(),
00028                            ExtractPhiMax(), LessDPhi());
00029 
00030   if (MagGeoBuilderFromDDD::debug) cout << "        Slab has " << volumes.size()
00031                   << " volumes" << endl;
00032 
00033     // Check that all volumes have the same dZ
00034     handles::const_iterator i = volumes.begin();
00035     float Zmax = (*i)->surface(zplus).position().z();
00036     float Zmin= (*i)->surface(zminus).position().z();
00037     for (++i; i != volumes.end(); ++i){
00038       const float epsilon = 0.001;      
00039       if (fabs(Zmax - (*i)->surface(zplus).position().z()) > epsilon ||
00040           fabs(Zmin - (*i)->surface(zminus).position().z()) > epsilon) {
00041         if (MagGeoBuilderFromDDD::debug) cout << "*** WARNING: slabs Z coords not matching: D_Zmax = "
00042                         << fabs(Zmax - (*i)->surface(zplus).position().z())
00043                         << " D_Zmin = " 
00044                         << fabs(Zmin - (*i)->surface(zminus).position().z())
00045                         << endl;
00046       }
00047     }
00048   }
00049 }
00050 
00051 Geom::Phi<float> MagGeoBuilderFromDDD::bSlab::minPhi() const {
00052   return volumes.front()->minPhi();
00053 }
00054 
00055 Geom::Phi<float>  MagGeoBuilderFromDDD::bSlab::maxPhi() const {
00056   return volumes.back()->maxPhi();
00057 }
00058 
00059 
00060 MagBSlab * MagGeoBuilderFromDDD::bSlab::buildMagBSlab() const {
00061   if (mslab==0) {
00062     vector<MagVolume*> mVols;
00063     for (handles::const_iterator vol = volumes.begin();
00064          vol!=volumes.end(); ++vol) {
00065       mVols.push_back((*vol)->magVolume);
00066     }
00067     mslab = new MagBSlab(mVols, volumes.front()->surface(zminus).position().z()); //FIXME
00068   }
00069   return mslab;
00070 }