Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
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
00030
00031
00032
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
00044
00045
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
00066 if (theSingleVolume) {
00067
00068
00069 if (theSingleVolume->inside(gp, tolerance)) {
00070 result = theSingleVolume;
00071
00072
00073
00074 }
00075 return result;
00076 }
00077
00078
00079
00080 Geom::Phi<float> phi = gp.phi();
00081
00082
00083 int bin= theBinFinder->binIndex(phi);
00084
00085 if (verbose::debugOut) cout << " Trying sector at phi " << theSectors[bin]->minPhi()
00086 << " " << phi << endl ;
00087 result = theSectors[bin]->findVolume(gp, tolerance);
00088
00089 if (verbose::debugOut) cout << "***In guessed bsector"
00090 << (result==0? " failed " : " OK ") <<endl;
00091
00092 if (result==0) {
00093
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
00100 if (verbose::debugOut) cout << "***In previous bsector"
00101 << (result==0? " failed " : " OK ") <<endl;
00102
00103 }
00104 return result;
00105
00106 }
00107
00108
00109