Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:25

0001 // #include "Utilities/Configuration/interface/Architecture.h"
0002 
0003 /*
0004  *  See header file for a description of this class.
0005  *
0006  *  \author N. Amapane - INFN Torino
0007  */
0008 
0009 #include "MagneticField/Layers/interface/MagESector.h"
0010 #include "MagneticField/Layers/interface/MagELayer.h"
0011 
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013 
0014 #include <iostream>
0015 
0016 using namespace std;
0017 
0018 MagESector::MagESector(vector<MagELayer*>& layers, Geom::Phi<float> phiMin) : theLayers(layers), thePhiMin(phiMin) {}
0019 
0020 MagESector::~MagESector() {
0021   for (vector<MagELayer*>::const_iterator ilay = theLayers.begin(); ilay != theLayers.end(); ++ilay) {
0022     delete (*ilay);
0023   }
0024 }
0025 
0026 const MagVolume* MagESector::findVolume(const GlobalPoint& gp, double tolerance) const {
0027   const MagVolume* result = nullptr;
0028   float Z = gp.z();
0029 
0030   // FIXME : use a binfinder
0031   for (vector<MagELayer*>::const_reverse_iterator ilay = theLayers.rbegin(); ilay != theLayers.rend(); ++ilay) {
0032     if (Z + tolerance > (*ilay)->minZ()) {
0033       if (Z - tolerance < (*ilay)->maxZ()) {
0034         LogTrace("MagGeometry") << "  Trying elayer at Z " << (*ilay)->minZ() << " " << Z << endl;
0035         result = (*ilay)->findVolume(gp, tolerance);
0036         LogTrace("MagGeometry") << "***In elayer " << (result == nullptr ? " failed " : " OK ") << endl;
0037       } else {
0038         // break;  // FIXME: OK if sorted by maxZ
0039       }
0040     }
0041     if (result != nullptr)
0042       return result;
0043   }
0044 
0045   return nullptr;
0046 }