Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:30

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  \author N. Amapane - INFN Torino
0005  */
0006 
0007 #include "eLayer.h"
0008 #include "MagneticField/VolumeGeometry/interface/MagVolume6Faces.h"
0009 #include "MagneticField/Layers/interface/MagELayer.h"
0010 
0011 #include "Utilities/General/interface/precomputed_value_sort.h"
0012 
0013 using namespace SurfaceOrientation;
0014 using namespace std;
0015 using namespace magneticfield;
0016 
0017 //The ctor is in charge of finding sectors inside the layer.
0018 eLayer::eLayer(handles::const_iterator begin, handles::const_iterator end) : theVolumes(begin, end), mlayer(nullptr) {
0019   //  bool debug=MagGeoBuilderFromDDD::debug;
0020 
0021   // Sort in R
0022   precomputed_value_sort(theVolumes.begin(), theVolumes.end(), ExtractR());
0023 
0024   //   if (debug) {
0025   //     cout << " elements: " << theVolumes.size() << " unique volumes: ";
0026   //     volumeHandle::printUniqueNames(theVolumes.begin(), theVolumes.end());
0027   //   }
0028 }
0029 
0030 // double MagGeoBuilderFromDDD::eLayer::minR() const {
0031 //   // ASSUMPTION: a layer is only 1 volume thick (by construction).
0032 //   return theVolumes.front()->minR();
0033 // }
0034 
0035 // double MagGeoBuilderFromDDD::eLayer::maxR() const {
0036 //   // ASSUMPTION: a layer is only 1 volume thick (by construction).
0037 //   return theVolumes.front()->maxR();
0038 // }
0039 
0040 MagELayer* eLayer::buildMagELayer() const {
0041   if (mlayer == nullptr) {
0042     //FIXME not guaranteed that all volumes in layer have the same zmin
0043     // and zmax!
0044     double zmin = 1e19;
0045     double zmax = -1e19;
0046     vector<MagVolume*> mVols;
0047     for (handles::const_iterator vol = theVolumes.begin(); vol != theVolumes.end(); ++vol) {
0048       mVols.push_back((*vol)->magVolume);
0049       zmin = min(zmin, (*vol)->minZ());
0050       zmax = max(zmax, (*vol)->maxZ());
0051     }
0052     mlayer = new MagELayer(mVols, zmin, zmax);
0053   }
0054   return mlayer;
0055 }