#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 |
int | geometryVersion |
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 |
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 26 of file MagGeometry.cc.
References cacheLastVolume, gather_cfg::cout, verbose::debugOut, geometryVersion, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), pi, theBarrelBinFinder, theBLayers, theEndcapBinFinder, and theESectors.
: lastVolume(0), theBLayers(tbl), theESectors(tes), theBVolumes(tbv), theEVolumes(tev), geometryVersion(0) { cacheLastVolume = config.getUntrackedParameter<bool>("cacheLastVolume", true); geometryVersion = config.getParameter<int>("geometryVersion"); 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 int nEBins = theESectors.size(); theEndcapBinFinder = new PeriodicBinFinderInPhi<float>(theESectors.front()->minPhi()+Geom::pi()/nEBins, nEBins); }
MagGeometry::~MagGeometry | ( | ) |
Destructor.
Definition at line 61 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 78 of file MagGeometry.cc.
References MagVolume::fieldInTesla(), findVolume(), edm::isNotFinite(), PV3DBase< T, PVType, FrameType >::mag(), and findQualityFiles::v.
Referenced by VolumeBasedMagneticField::inTesla(), and VolumeBasedMagneticField::inTeslaUnchecked().
{ MagVolume * v = 0; v = findVolume(gp); if (v!=0) { return v->fieldInTesla(gp); } // Fall-back case: no volume found if (edm::isNotFinite(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 137 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 101 of file MagGeometry.cc.
References gather_cfg::cout, newFWLiteAna::found, inBarrel(), theBVolumes, theEVolumes, and findQualityFiles::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 184 of file MagGeometry.cc.
References geometryVersion, PV3DBase< T, PVType, FrameType >::perp(), dttmaxenums::R, 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. if (geometryVersion>=120812) { return (Z<350. || (R>172.4 && Z<633.29) || (R>308.7345 && Z<662.01)); } else if (geometryVersion>=90812) { return (Z<350. || (R>172.4 && Z<633.89) || (R>308.755 && Z<662.01)); } else { // version 71212 return (Z<350. || (R>172.4 && Z<633.29) || (R>308.755 && Z<661.01)); } }
bool MagGeometry::isZSymmetric | ( | ) | const [inline] |
Definition at line 47 of file MagGeometry.h.
Referenced by VolumeBasedMagneticField::isZSymmetric().
{return false;}
friend class MagGeometryExerciser [friend] |
Definition at line 55 of file MagGeometry.h.
bool MagGeometry::cacheLastVolume [private] |
Definition at line 75 of file MagGeometry.h.
Referenced by findVolume(), and MagGeometry().
int MagGeometry::geometryVersion [private] |
Definition at line 76 of file MagGeometry.h.
Referenced by inBarrel(), and MagGeometry().
MagVolume* MagGeometry::lastVolume [mutable, private] |
Definition at line 63 of file MagGeometry.h.
Referenced by findVolume().
MagBinFinders::GeneralBinFinderInR<double>* MagGeometry::theBarrelBinFinder [private] |
Definition at line 72 of file MagGeometry.h.
Referenced by findVolume(), MagGeometry(), and ~MagGeometry().
std::vector<MagBLayer *> MagGeometry::theBLayers [private] |
Definition at line 65 of file MagGeometry.h.
Referenced by findVolume(), MagGeometry(), and ~MagGeometry().
std::vector<MagVolume6Faces*> MagGeometry::theBVolumes [private] |
Definition at line 69 of file MagGeometry.h.
Referenced by barrelVolumes(), and findVolume1().
PeriodicBinFinderInPhi<float>* MagGeometry::theEndcapBinFinder [private] |
Definition at line 73 of file MagGeometry.h.
Referenced by findVolume(), MagGeometry(), and ~MagGeometry().
std::vector<MagESector *> MagGeometry::theESectors [private] |
Definition at line 66 of file MagGeometry.h.
Referenced by findVolume(), MagGeometry(), and ~MagGeometry().
std::vector<MagVolume6Faces*> MagGeometry::theEVolumes [private] |
Definition at line 70 of file MagGeometry.h.
Referenced by endcapVolumes(), and findVolume1().