File indexing completed on 2024-04-06 12:22:33
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "MagneticField/Layers/interface/MagBRod.h"
0010 #include "MagneticField/Layers/interface/MagBSlab.h"
0011
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013
0014 #include <iostream>
0015
0016 using namespace std;
0017
0018 MagBRod::MagBRod(vector<MagBSlab *> &slabs, Geom::Phi<float> phiMin)
0019 : theSlabs(slabs), thePhiMin(phiMin), theBinFinder(nullptr) {
0020
0021
0022
0023 if (theSlabs.size() > 1) {
0024 vector<double> zBorders;
0025 for (vector<MagBSlab *>::const_iterator islab = theSlabs.begin(); islab != theSlabs.end(); ++islab) {
0026 LogTrace("MagGeoBuilder") << " MagBSlab minZ=" << (*islab)->minZ() << endl;
0027
0028 zBorders.push_back((*islab)->minZ());
0029 }
0030 theBinFinder = new MagBinFinders::GeneralBinFinderInZ<double>(zBorders);
0031 }
0032 }
0033
0034 MagBRod::~MagBRod() {
0035 delete theBinFinder;
0036
0037 for (vector<MagBSlab *>::const_iterator islab = theSlabs.begin(); islab != theSlabs.end(); ++islab) {
0038 delete (*islab);
0039 }
0040 }
0041
0042 const MagVolume *MagBRod::findVolume(const GlobalPoint &gp, double tolerance) const {
0043 const MagVolume *result = nullptr;
0044 float Z = gp.z();
0045
0046 int bin = 0;
0047 if (theBinFinder != nullptr) {
0048 bin = theBinFinder->binIndex(Z);
0049 }
0050
0051 LogTrace("MagGeometry") << " Trying slab at Z " << theSlabs[bin]->minZ() << " " << Z << endl;
0052 result = theSlabs[bin]->findVolume(gp, tolerance);
0053 LogTrace("MagGeometry") << "***In guessed bslab" << (result == nullptr ? " failed " : " OK ") << endl;
0054
0055 return result;
0056 }