Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /* \file
0002  *  See header file for a description of this class.
0003  *
0004  *  \author N. Amapane - INFN Torino
0005  */
0006 
0007 #include "bSlab.h"
0008 #include "MagneticField/VolumeGeometry/interface/MagVolume6Faces.h"
0009 #include "MagneticField/Layers/interface/MagBSlab.h"
0010 
0011 #include "Utilities/General/interface/precomputed_value_sort.h"
0012 
0013 #include <iostream>
0014 
0015 using namespace SurfaceOrientation;
0016 using namespace std;
0017 using namespace magneticfield;
0018 
0019 bSlab::bSlab(handles::const_iterator begin, handles::const_iterator end, bool debugVal)
0020     : volumes(begin, end), mslab(nullptr), debug(debugVal) {
0021   if (volumes.size() > 1) {
0022     // Sort volumes by dphi i.e. phi(j)-phi(i) > 0 if j>1.
0023     precomputed_value_sort(volumes.begin(), volumes.end(), ExtractPhiMax(), LessDPhi());
0024 
0025     if (debug)
0026       cout << "        Slab has " << volumes.size() << " volumes" << endl;
0027 
0028     // Check that all volumes have the same dZ
0029     handles::const_iterator i = volumes.begin();
0030     float Zmax = (*i)->surface(zplus).position().z();
0031     float Zmin = (*i)->surface(zminus).position().z();
0032     for (++i; i != volumes.end(); ++i) {
0033       const float epsilon = 0.001;
0034       if (fabs(Zmax - (*i)->surface(zplus).position().z()) > epsilon ||
0035           fabs(Zmin - (*i)->surface(zminus).position().z()) > epsilon) {
0036         if (debug)
0037           cout << "*** WARNING: slabs Z coords not matching: D_Zmax = "
0038                << fabs(Zmax - (*i)->surface(zplus).position().z())
0039                << " D_Zmin = " << fabs(Zmin - (*i)->surface(zminus).position().z()) << endl;
0040       }
0041     }
0042   }
0043 }
0044 
0045 Geom::Phi<float> bSlab::minPhi() const { return volumes.front()->minPhi(); }
0046 
0047 Geom::Phi<float> bSlab::maxPhi() const { return volumes.back()->maxPhi(); }
0048 
0049 MagBSlab* bSlab::buildMagBSlab() const {
0050   if (mslab == nullptr) {
0051     vector<MagVolume*> mVols;
0052     for (handles::const_iterator vol = volumes.begin(); vol != volumes.end(); ++vol) {
0053       mVols.push_back((*vol)->magVolume);
0054     }
0055     mslab = new MagBSlab(mVols, volumes.front()->surface(zminus).position().z());  //FIXME
0056   }
0057   return mslab;
0058 }