#include <MagGeometry.h>
Public Types | |
typedef Surface::GlobalPoint | GlobalPoint |
typedef Surface::GlobalVector | GlobalVector |
Public Member Functions | |
const std::vector < MagVolume6Faces * > & | barrelVolumes () const |
const std::vector < MagVolume6Faces * > & | endcapVolumes () const |
GlobalVector | fieldInTesla (const GlobalPoint &gp) const |
Return field vector at the specified global point. | |
MagVolume * | findVolume (const GlobalPoint &gp, double tolerance=0.) const |
Find a volume. | |
bool | isZSymmetric () const |
MagGeometry (const edm::ParameterSet &config, std::vector< MagBLayer * >, std::vector< MagESector * >, std::vector< MagVolume6Faces * >, std::vector< MagVolume6Faces * >) | |
Constructor. | |
~MagGeometry () | |
Destructor. | |
Private Member Functions | |
MagVolume * | findVolume1 (const GlobalPoint &gp, double tolerance=0.) const |
bool | inBarrel (const GlobalPoint &gp) const |
Private Attributes | |
bool | cacheLastVolume |
MagVolume * | lastVolume |
MagBinFinders::GeneralBinFinderInR < double > * | theBarrelBinFinder |
std::vector< MagBLayer * > | theBLayers |
std::vector< MagVolume6Faces * > | theBVolumes |
PeriodicBinFinderInPhi< float > * | theEndcapBinFinder |
std::vector< MagESector * > | theESectors |
std::vector< MagVolume6Faces * > | theEVolumes |
bool | v_85l |
Friends | |
class | MagGeometryExerciser |
Entry point to the geometry of magnetic volumes.
Definition at line 25 of file MagGeometry.h.
Definition at line 29 of file MagGeometry.h.
Definition at line 28 of file MagGeometry.h.
MagGeometry::MagGeometry | ( | const edm::ParameterSet & | config, |
std::vector< MagBLayer * > | tbl, | ||
std::vector< MagESector * > | tes, | ||
std::vector< MagVolume6Faces * > | tbv, | ||
std::vector< MagVolume6Faces * > | tev | ||
) |
Constructor.
Definition at line 25 of file MagGeometry.cc.
References cacheLastVolume, gather_cfg::cout, verbose::debugOut, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), pi, theBarrelBinFinder, theBLayers, theEndcapBinFinder, theESectors, and v_85l.
: lastVolume(0), theBLayers(tbl), theESectors(tes), theBVolumes(tbv), theEVolumes(tev) { cacheLastVolume = config.getUntrackedParameter<bool>("cacheLastVolume", true); v_85l = (config.getParameter<std::string>("version")=="grid_85l_030919"); vector<double> rBorders; for (vector<MagBLayer *>::const_iterator ilay = theBLayers.begin(); ilay != theBLayers.end(); ++ilay) { if (verbose::debugOut) cout << " Barrel layer at " << (*ilay)->minR() <<endl; //FIXME assume layers are already sorted in minR rBorders.push_back((*ilay)->minR()); } theBarrelBinFinder = new MagBinFinders::GeneralBinFinderInR<double>(rBorders); if (verbose::debugOut) { for (vector<MagESector *>::const_iterator isec = theESectors.begin(); isec != theESectors.end(); ++isec) { cout << " Endcap sector at " << (*isec)->minPhi() << endl; } } //FIXME assume sectors are already sorted in phi //FIXME: PeriodicBinFinderInPhi gets *center* of first bin theEndcapBinFinder = new PeriodicBinFinderInPhi<float>(theESectors.front()->minPhi()+Geom::pi()/12., 12); }
MagGeometry::~MagGeometry | ( | ) |
Destructor.
Definition at line 59 of file MagGeometry.cc.
References theBarrelBinFinder, theBLayers, theEndcapBinFinder, and theESectors.
{ delete theBarrelBinFinder; delete theEndcapBinFinder; for (vector<MagBLayer *>::const_iterator ilay = theBLayers.begin(); ilay != theBLayers.end(); ++ilay) { delete (*ilay); } for (vector<MagESector *>::const_iterator ilay = theESectors.begin(); ilay != theESectors.end(); ++ilay) { delete (*ilay); } }
const std::vector<MagVolume6Faces*>& MagGeometry::barrelVolumes | ( | ) | const [inline] |
const std::vector<MagVolume6Faces*>& MagGeometry::endcapVolumes | ( | ) | const [inline] |
GlobalVector MagGeometry::fieldInTesla | ( | const GlobalPoint & | gp | ) | const |
Return field vector at the specified global point.
Definition at line 76 of file MagGeometry.cc.
References MagVolume::fieldInTesla(), findVolume(), edm::detail::isnan(), PV3DBase< T, PVType, FrameType >::mag(), v, v_85l, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
Referenced by VolumeBasedMagneticField::inTesla(), and VolumeBasedMagneticField::inTeslaUnchecked().
{ MagVolume * v = 0; // Map version 85l is Z-symmetric; -> implement Z reflection if (v_85l && gp.z()>0) { GlobalPoint gpSym(gp.x(), gp.y(), -gp.z()); // Check volume cache v = findVolume(gpSym); if (v!=0) { GlobalVector bresult = v->fieldInTesla(gpSym); return GlobalVector(-bresult.x(), -bresult.y(), bresult.z()); } } else { // No reflection v = findVolume(gp); if (v!=0) { return v->fieldInTesla(gp); } } // Fall-back case: no volume found if (isnan(gp.mag())) { LogWarning("InvalidInput") << "Input value invalid (not a number): " << gp << endl; } else { LogWarning("MagneticField") << "MagGeometry::fieldInTesla: failed to find volume for " << gp << endl; } return GlobalVector(); }
MagVolume * MagGeometry::findVolume | ( | const GlobalPoint & | gp, |
double | tolerance = 0. |
||
) | const |
Find a volume.
Definition at line 147 of file MagGeometry.cc.
References newFWLiteAna::bin, MagBinFinders::GeneralBinFinderInR< T >::binIndex(), PeriodicBinFinderInPhi< T >::binIndex(), cacheLastVolume, gather_cfg::cout, verbose::debugOut, inBarrel(), MagVolume::inside(), lastVolume, max(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), phi, dttmaxenums::R, query::result, theBarrelBinFinder, theBLayers, theEndcapBinFinder, and theESectors.
Referenced by fieldInTesla(), and VolumeBasedMagneticField::findVolume().
{ // Check volume cache if (lastVolume!=0 && lastVolume->inside(gp)){ return lastVolume; } MagVolume * result=0; if (inBarrel(gp)) { // Barrel double R = gp.perp(); int bin = theBarrelBinFinder->binIndex(R); for (int bin1 = bin; bin1 >= max(0,bin-2); --bin1) { if (verbose::debugOut) cout << "Trying layer at R " << theBLayers[bin1]->minR() << " " << R << endl ; result = theBLayers[bin1]->findVolume(gp, tolerance); if (verbose::debugOut) cout << "***In blayer " << bin1-bin << " " << (result==0? " failed " : " OK ") <<endl; if (result != 0) break; } } else { // Endcaps Geom::Phi<float> phi = gp.phi(); int bin = theEndcapBinFinder->binIndex(phi); if (verbose::debugOut) cout << "Trying endcap sector at phi " << theESectors[bin]->minPhi() << " " << phi << endl ; result = theESectors[bin]->findVolume(gp, tolerance); if (verbose::debugOut) cout << "***In guessed esector " << (result==0? " failed " : " OK ") <<endl; } if (result==0 && tolerance < 0.0001) { // If search fails, retry with a 300 micron tolerance. // This is a hack for thin gaps on air-iron boundaries, // which will not be present anymore once surfaces are matched. if (verbose::debugOut) cout << "Increasing the tolerance to 0.03" <<endl; result = findVolume(gp, 0.03); } if (cacheLastVolume) lastVolume = result; return result; }
MagVolume * MagGeometry::findVolume1 | ( | const GlobalPoint & | gp, |
double | tolerance = 0. |
||
) | const [private] |
Definition at line 111 of file MagGeometry.cc.
References gather_cfg::cout, newFWLiteAna::found, inBarrel(), theBVolumes, theEVolumes, and v.
{ MagVolume6Faces * found = 0; if (inBarrel(gp)) { // Barrel for (vector<MagVolume6Faces*>::const_iterator v = theBVolumes.begin(); v!=theBVolumes.end(); ++v){ if ((*v)==0) { //FIXME: remove this check cout << endl << "***ERROR: MagGeometry::findVolume: MagVolume not set" << endl; continue; } if ((*v)->inside(gp,tolerance)) { found = (*v); break; } } } else { // Endcaps for (vector<MagVolume6Faces*>::const_iterator v = theEVolumes.begin(); v!=theEVolumes.end(); ++v){ if ((*v)==0) { //FIXME: remove this check cout << endl << "***ERROR: MagGeometry::findVolume: MagVolume not set" << endl; continue; } if ((*v)->inside(gp,tolerance)) { found = (*v); break; } } } return found; }
bool MagGeometry::inBarrel | ( | const GlobalPoint & | gp | ) | const [private] |
Definition at line 194 of file MagGeometry.cc.
References PV3DBase< T, PVType, FrameType >::perp(), dttmaxenums::R, v_85l, PV3DBase< T, PVType, FrameType >::z(), and Gflash::Z.
Referenced by findVolume(), and findVolume1().
{ float Z = fabs(gp.z()); float R = gp.perp(); // FIXME: Get these dimensions from the builder. // For this we can wait the next generation of tables, when the picture // may be more complicated if (v_85l){ return (Z<634.49 || (R>308.755 && Z<661.01)); } else { return (Z<350. || (R>172.4 && Z<633.29) || (R>308.755 && Z<661.01)); } }
bool MagGeometry::isZSymmetric | ( | ) | const |
Definition at line 211 of file MagGeometry.cc.
References v_85l.
Referenced by VolumeBasedMagneticField::isZSymmetric().
{ return v_85l; }
friend class MagGeometryExerciser [friend] |
Definition at line 54 of file MagGeometry.h.
bool MagGeometry::cacheLastVolume [private] |
Definition at line 74 of file MagGeometry.h.
Referenced by findVolume(), and MagGeometry().
MagVolume* MagGeometry::lastVolume [mutable, private] |
Definition at line 62 of file MagGeometry.h.
Referenced by findVolume().
MagBinFinders::GeneralBinFinderInR<double>* MagGeometry::theBarrelBinFinder [private] |
Definition at line 71 of file MagGeometry.h.
Referenced by findVolume(), MagGeometry(), and ~MagGeometry().
std::vector<MagBLayer *> MagGeometry::theBLayers [private] |
Definition at line 64 of file MagGeometry.h.
Referenced by findVolume(), MagGeometry(), and ~MagGeometry().
std::vector<MagVolume6Faces*> MagGeometry::theBVolumes [private] |
Definition at line 68 of file MagGeometry.h.
Referenced by barrelVolumes(), and findVolume1().
PeriodicBinFinderInPhi<float>* MagGeometry::theEndcapBinFinder [private] |
Definition at line 72 of file MagGeometry.h.
Referenced by findVolume(), MagGeometry(), and ~MagGeometry().
std::vector<MagESector *> MagGeometry::theESectors [private] |
Definition at line 65 of file MagGeometry.h.
Referenced by findVolume(), MagGeometry(), and ~MagGeometry().
std::vector<MagVolume6Faces*> MagGeometry::theEVolumes [private] |
Definition at line 69 of file MagGeometry.h.
Referenced by endcapVolumes(), and findVolume1().
bool MagGeometry::v_85l [private] |
Definition at line 75 of file MagGeometry.h.
Referenced by fieldInTesla(), inBarrel(), isZSymmetric(), and MagGeometry().