File indexing completed on 2024-04-06 12:22:33
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "MagneticField/Layers/interface/MagBLayer.h"
0010 #include "MagneticField/Layers/interface/MagBSector.h"
0011 #include "MagneticField/VolumeGeometry/interface/MagVolume.h"
0012 #include "Utilities/BinningTools/interface/PeriodicBinFinderInPhi.h"
0013 #include "DataFormats/GeometryVector/interface/Phi.h"
0014
0015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0016
0017 #include <iostream>
0018
0019 using namespace std;
0020
0021 MagBLayer::MagBLayer(vector<MagBSector*>& sectors, double rMin)
0022 : theSectors(sectors), theSingleVolume(nullptr), theRMin(rMin), theBinFinder(nullptr) {
0023
0024
0025
0026 theBinFinder = new PeriodicBinFinderInPhi<float>(theSectors.front()->minPhi() + Geom::pi() / 12., 12);
0027 }
0028
0029
0030 MagBLayer::MagBLayer(MagVolume* aVolume, double rMin) : theSingleVolume(nullptr), theRMin(rMin), theBinFinder(nullptr) {
0031
0032
0033 }
0034
0035 MagBLayer::~MagBLayer() {
0036 delete theBinFinder;
0037
0038 delete theSingleVolume;
0039
0040 for (vector<MagBSector*>::const_iterator isec = theSectors.begin(); isec != theSectors.end(); ++isec) {
0041 delete (*isec);
0042 }
0043 }
0044
0045 const MagVolume* MagBLayer::findVolume(const GlobalPoint& gp, double tolerance) const {
0046 const MagVolume* result = nullptr;
0047
0048
0049 if (theSingleVolume) {
0050
0051 if (theSingleVolume->inside(gp, tolerance)) {
0052 result = theSingleVolume;
0053
0054
0055 }
0056 return result;
0057 }
0058
0059
0060
0061 Geom::Phi<float> phi = gp.phi();
0062
0063
0064 int bin = theBinFinder->binIndex(phi);
0065 LogTrace("MagGeometry") << " Trying sector at phi " << theSectors[bin]->minPhi() << " " << phi << endl;
0066 result = theSectors[bin]->findVolume(gp, tolerance);
0067 LogTrace("MagGeometry") << "***In guessed bsector" << (result == nullptr ? " failed " : " OK ") << endl;
0068
0069 if (result == nullptr) {
0070 LogTrace("MagGeometry") << " Trying sector at phi " << theSectors[theBinFinder->binIndex(bin - 1)]->minPhi()
0071 << " " << phi << endl;
0072
0073 result = theSectors[theBinFinder->binIndex(bin - 1)]->findVolume(gp, tolerance);
0074 LogTrace("MagGeometry") << "***In previous bsector" << (result == nullptr ? " failed " : " OK ") << endl;
0075 }
0076 return result;
0077 }