CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/MagneticField/Layers/src/MagBLayer.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:33 $
00007  *  $Revision: 1.4 $
00008  *  \author N. Amapane - INFN Torino
00009  */
00010 
00011 #include "MagneticField/Layers/interface/MagBLayer.h"
00012 #include "MagneticField/Layers/interface/MagBSector.h"
00013 #include "MagneticField/VolumeGeometry/interface/MagVolume.h"
00014 #include "Utilities/BinningTools/interface/PeriodicBinFinderInPhi.h"
00015 #include "DataFormats/GeometryVector/interface/Phi.h"
00016 
00017 #include "MagneticField/Layers/interface/MagVerbosity.h"
00018 
00019 #include <iostream>
00020 
00021 using namespace std;
00022 
00023 MagBLayer::MagBLayer(vector<MagBSector*>& sectors, double rMin) :
00024   theSectors(sectors),
00025   theSingleVolume(0),
00026   theRMin(rMin),
00027   theBinFinder(0)
00028 {
00029   // TOFIX
00030 //   if (verbose.debugOut) cout << "Building MagBLayer with " << theSectors.size()
00031 //                << " sectors, minR " << theRMin << endl;
00032   //FIXME: PeriodicBinFinderInPhi gets *center* of first bin
00033   theBinFinder = new PeriodicBinFinderInPhi<float>(theSectors.front()->minPhi()+Geom::pi()/12.,12);
00034 
00035 }
00036 
00038 MagBLayer::MagBLayer(MagVolume* aVolume, double rMin) :
00039   theSingleVolume(0),
00040   theRMin(rMin),
00041   theBinFinder(0) 
00042 {
00043   // TOFIX
00044 //   if (verbose.debugOut) cout << "Building MagBLayer with " << 0
00045 //                << " sectors, minR " << theRMin << endl;    
00046 }
00047 
00048 
00049 
00050 MagBLayer::~MagBLayer() {
00051   delete theBinFinder;
00052   
00053   delete theSingleVolume;
00054 
00055   for (vector<MagBSector *>::const_iterator isec = theSectors.begin();
00056        isec != theSectors.end(); ++isec) {
00057     delete (*isec);
00058   }
00059 }
00060 
00061 
00062 MagVolume* MagBLayer::findVolume(const GlobalPoint & gp, double tolerance) const {
00063   MagVolume * result = 0;
00064 
00065   //In case the layer is composed of a single volume...
00066   if (theSingleVolume) {
00067     // TOFIX
00068 //     if (verbose.debugOut) cout << "   Trying the unique volume " << endl;
00069     if (theSingleVolume->inside(gp, tolerance)) {
00070       result = theSingleVolume;
00071     // TOFIX
00072 //       if (verbose.debugOut) cout << "***In unique bsector"
00073 //                << (result==0? " failed " : " OK ") <<endl;
00074     }
00075     return result;
00076   }
00077 
00078   // Normal cases - query the sectors.
00079   
00080   Geom::Phi<float> phi = gp.phi();
00081 
00082   // FIXME assume sectors are sorted in phi!
00083   int bin= theBinFinder->binIndex(phi);
00084     // TOFIX
00085   if (verbose::debugOut) cout << "   Trying sector at phi " << theSectors[bin]->minPhi()
00086                               << " " << phi << endl ;
00087   result = theSectors[bin]->findVolume(gp, tolerance);
00088     // TOFIX
00089   if (verbose::debugOut) cout << "***In guessed bsector"
00090                              << (result==0? " failed " : " OK ") <<endl;
00091 
00092   if (result==0) { // If fails, can be in previous bin.
00093     // TOFIX
00094     if (verbose::debugOut) cout << "   Trying sector at phi "
00095                                << theSectors[theBinFinder->binIndex(bin-1)]->minPhi()
00096                                << " " << phi << endl ;
00097     
00098     result = theSectors[theBinFinder->binIndex(bin-1)]->findVolume(gp, tolerance);
00099     // TOFIX
00100     if (verbose::debugOut) cout << "***In previous bsector"
00101                                << (result==0? " failed " : " OK ") <<endl;
00102 
00103   }
00104   return result;
00105 
00106 }
00107 
00108 
00109