Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:33

0001 // #include "Utilities/Configuration/interface/Architecture.h"
0002 
0003 /*
0004  *  See header file for a description of this class.
0005  *
0006  *  \author N. Amapane - INFN Torino
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   //   LogTrace("MagGeometry") << "Building MagBRod with " << theSlabs.size()
0021   //          << " slabs, minPhi " << thePhiMin << endl;
0022 
0023   if (theSlabs.size() > 1) {  // Set the binfinder
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       //FIXME assume layers are already sorted in Z
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) {  // true if there is > 1 bin
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 }