CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/MagneticField/Layers/src/MagESector.cc

Go to the documentation of this file.
00001 // #include "Utilities/Configuration/interface/Architecture.h"
00002 
00003 /*
00004  *  See header file for a description of this class.
00005  *
00006  *  $Date: 2007/02/03 16:15:59 $
00007  *  $Revision: 1.2 $
00008  *  \author N. Amapane - INFN Torino
00009  */
00010 
00011 #include "MagneticField/Layers/interface/MagESector.h"
00012 #include "MagneticField/Layers/interface/MagELayer.h"
00013 
00014 // #include "MagneticField/MagLayers/interface/MagVerbosity.h"
00015 
00016 #include <iostream>
00017 
00018 using namespace std;
00019 
00020 MagESector::MagESector(vector<MagELayer*>& layers, Geom::Phi<float> phiMin):
00021   theLayers(layers),
00022   thePhiMin(phiMin) 
00023 {}
00024 
00025 
00026 MagESector::~MagESector(){
00027   for (vector<MagELayer *>::const_iterator ilay = theLayers.begin();
00028        ilay != theLayers.end(); ++ilay) {
00029     delete (*ilay);
00030   }
00031 }
00032 
00033 
00034 MagVolume * MagESector::findVolume(const GlobalPoint & gp, double tolerance) const {
00035   MagVolume * result = 0;
00036   float Z = gp.z();
00037 
00038   //  int count = 0;
00039 
00040   // FIXME : use a binfinder
00041   for(vector<MagELayer*>::const_reverse_iterator ilay = theLayers.rbegin();
00042         ilay != theLayers.rend(); ++ilay) {
00043 
00044     if (Z+tolerance>(*ilay)->minZ()) {
00045       if (Z-tolerance<(*ilay)->maxZ()) {
00046 //      if (verbose.debugOut) cout << "  Trying layer at Z " << (*ilay)->minZ()
00047 //                      << " " << Z << endl ;
00048         result = (*ilay)->findVolume(gp, tolerance);
00049 //      if (verbose.debugOut) {
00050 //        cout << "***In elayer " << count << " " 
00051 //             << (result==0? " failed " : " OK ") <<endl;
00052 //        ++count;
00053 //      }
00054       } else {
00055         // break;  // FIXME: OK if sorted by maxZ
00056       }
00057     }
00058     if (result!=0) return result;
00059   }
00060 
00061   return 0;
00062 }