![]() |
![]() |
#include <MagneticField/VolumeBasedEngine/interface/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 |
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, GenMuonPlsPt100GeV_cfg::cout, verbose::debugOut, lat::endl(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), Geom::pi(), theBarrelBinFinder, theBLayers, theEndcapBinFinder, theESectors, and v_85l.
00029 : 00030 lastVolume(0), theBLayers(tbl), theESectors(tes), theBVolumes(tbv), theEVolumes(tev) 00031 { 00032 00033 cacheLastVolume = config.getUntrackedParameter<bool>("cacheLastVolume", true); 00034 v_85l = (config.getParameter<std::string>("version")=="grid_85l_030919"); 00035 00036 vector<double> rBorders; 00037 00038 for (vector<MagBLayer *>::const_iterator ilay = theBLayers.begin(); 00039 ilay != theBLayers.end(); ++ilay) { 00040 if (verbose::debugOut) cout << " Barrel layer at " << (*ilay)->minR() <<endl; 00041 //FIXME assume layers are already sorted in minR 00042 rBorders.push_back((*ilay)->minR()); 00043 } 00044 00045 theBarrelBinFinder = new MagBinFinders::GeneralBinFinderInR<double>(rBorders); 00046 00047 if (verbose::debugOut) { 00048 for (vector<MagESector *>::const_iterator isec = theESectors.begin(); 00049 isec != theESectors.end(); ++isec) { 00050 cout << " Endcap sector at " << (*isec)->minPhi() << endl; 00051 } 00052 } 00053 00054 //FIXME assume sectors are already sorted in phi 00055 //FIXME: PeriodicBinFinderInPhi gets *center* of first bin 00056 theEndcapBinFinder = new PeriodicBinFinderInPhi<float>(theESectors.front()->minPhi()+Geom::pi()/12., 12); 00057 00058 }
MagGeometry::~MagGeometry | ( | ) |
Destructor.
Definition at line 60 of file MagGeometry.cc.
References theBarrelBinFinder, theBLayers, theEndcapBinFinder, and theESectors.
00060 { 00061 delete theBarrelBinFinder; 00062 delete theEndcapBinFinder; 00063 00064 for (vector<MagBLayer *>::const_iterator ilay = theBLayers.begin(); 00065 ilay != theBLayers.end(); ++ilay) { 00066 delete (*ilay); 00067 } 00068 00069 for (vector<MagESector *>::const_iterator ilay = theESectors.begin(); 00070 ilay != theESectors.end(); ++ilay) { 00071 delete (*ilay); 00072 } 00073 }
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 77 of file MagGeometry.cc.
References lat::endl(), MagVolume::fieldInTesla(), findVolume(), edm::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().
00077 { 00078 MagVolume * v = 0; 00079 00080 // Map version 85l is Z-symmetric; -> implement Z reflection 00081 if (v_85l && gp.z()>0) { 00082 GlobalPoint gpSym(gp.x(), gp.y(), -gp.z()); 00083 // Check volume cache 00084 v = findVolume(gpSym); 00085 00086 if (v!=0) { 00087 GlobalVector bresult = v->fieldInTesla(gpSym); 00088 return GlobalVector(-bresult.x(), -bresult.y(), bresult.z()); 00089 } 00090 00091 } else { // No reflection 00092 v = findVolume(gp); 00093 if (v!=0) { 00094 return v->fieldInTesla(gp); 00095 } 00096 } 00097 00098 // Fall-back case: no volume found 00099 00100 if (isnan(gp.mag())) { 00101 LogWarning("InvalidInput") << "Input value invalid (not a number): " << gp << endl; 00102 00103 } else { 00104 LogWarning("MagneticField") << "MagGeometry::fieldInTesla: failed to find volume for " << gp << endl; 00105 } 00106 return GlobalVector(); 00107 }
MagVolume * MagGeometry::findVolume | ( | const GlobalPoint & | gp, | |
double | tolerance = 0. | |||
) | const |
Find a volume.
Definition at line 148 of file MagGeometry.cc.
References MagBinFinders::GeneralBinFinderInR< T >::binIndex(), PeriodicBinFinderInPhi< T >::binIndex(), cacheLastVolume, GenMuonPlsPt100GeV_cfg::cout, verbose::debugOut, lat::endl(), inBarrel(), MagVolume::inside(), lastVolume, max, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), phi, dttmaxenums::R, HLT_VtxMuL3::result, theBarrelBinFinder, theBLayers, theEndcapBinFinder, and theESectors.
Referenced by fieldInTesla(), and VolumeBasedMagneticField::findVolume().
00148 { 00149 // Check volume cache 00150 if (lastVolume!=0 && lastVolume->inside(gp)){ 00151 return lastVolume; 00152 } 00153 00154 MagVolume * result=0; 00155 if (inBarrel(gp)) { // Barrel 00156 double R = gp.perp(); 00157 int bin = theBarrelBinFinder->binIndex(R); 00158 00159 for (int bin1 = bin; bin1 >= max(0,bin-2); --bin1) { 00160 if (verbose::debugOut) cout << "Trying layer at R " << theBLayers[bin1]->minR() 00161 << " " << R << endl ; 00162 result = theBLayers[bin1]->findVolume(gp, tolerance); 00163 if (verbose::debugOut) cout << "***In blayer " << bin1-bin << " " 00164 << (result==0? " failed " : " OK ") <<endl; 00165 if (result != 0) break; 00166 } 00167 00168 } else { // Endcaps 00169 Geom::Phi<float> phi = gp.phi(); 00170 int bin = theEndcapBinFinder->binIndex(phi); 00171 if (verbose::debugOut) cout << "Trying endcap sector at phi " 00172 << theESectors[bin]->minPhi() << " " << phi << endl ; 00173 result = theESectors[bin]->findVolume(gp, tolerance); 00174 if (verbose::debugOut) cout << "***In guessed esector " 00175 << (result==0? " failed " : " OK ") <<endl; 00176 } 00177 00178 00179 if (result==0 && tolerance < 0.0001) { 00180 // If search fails, retry with a 300 micron tolerance. 00181 // This is a hack for thin gaps on air-iron boundaries, 00182 // which will not be present anymore once surfaces are matched. 00183 if (verbose::debugOut) cout << "Increasing the tolerance to 0.03" <<endl; 00184 result = findVolume(gp, 0.03); 00185 } 00186 00187 if (cacheLastVolume) lastVolume = result; 00188 00189 return result; 00190 }
MagVolume * MagGeometry::findVolume1 | ( | const GlobalPoint & | gp, | |
double | tolerance = 0. | |||
) | const [private] |
Definition at line 112 of file MagGeometry.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), inBarrel(), theBVolumes, theEVolumes, and v.
00112 { 00113 00114 MagVolume6Faces * found = 0; 00115 00116 if (inBarrel(gp)) { // Barrel 00117 for (vector<MagVolume6Faces*>::const_iterator v = theBVolumes.begin(); 00118 v!=theBVolumes.end(); ++v){ 00119 if ((*v)==0) { //FIXME: remove this check 00120 cout << endl << "***ERROR: MagGeometry::findVolume: MagVolume not set" << endl; 00121 continue; 00122 } 00123 if ((*v)->inside(gp,tolerance)) { 00124 found = (*v); 00125 break; 00126 } 00127 } 00128 00129 } else { // Endcaps 00130 for (vector<MagVolume6Faces*>::const_iterator v = theEVolumes.begin(); 00131 v!=theEVolumes.end(); ++v){ 00132 if ((*v)==0) { //FIXME: remove this check 00133 cout << endl << "***ERROR: MagGeometry::findVolume: MagVolume not set" << endl; 00134 continue; 00135 } 00136 if ((*v)->inside(gp,tolerance)) { 00137 found = (*v); 00138 break; 00139 } 00140 } 00141 } 00142 00143 return found; 00144 }
bool MagGeometry::inBarrel | ( | const GlobalPoint & | gp | ) | const [private] |
Definition at line 195 of file MagGeometry.cc.
References PV3DBase< T, PVType, FrameType >::perp(), dttmaxenums::R, v_85l, and PV3DBase< T, PVType, FrameType >::z().
Referenced by findVolume(), and findVolume1().
00195 { 00196 float Z = fabs(gp.z()); 00197 float R = gp.perp(); 00198 00199 // FIXME: Get these dimensions from the builder. 00200 // For this we can wait the next generation of tables, when the picture 00201 // may be more complicated 00202 if (v_85l){ 00203 return (Z<634.49 || (R>308.755 && Z<661.01)); 00204 } else { 00205 return (Z<350. || 00206 (R>172.4 && Z<633.29) || 00207 (R>308.755 && Z<661.01)); 00208 } 00209 }
bool MagGeometry::isZSymmetric | ( | ) | const |
Definition at line 212 of file MagGeometry.cc.
References v_85l.
Referenced by VolumeBasedMagneticField::isZSymmetric().
00212 { 00213 return v_85l; 00214 }
friend class MagGeometryExerciser [friend] |
Definition at line 54 of file MagGeometry.h.
bool MagGeometry::cacheLastVolume [private] |
MagVolume* MagGeometry::lastVolume [mutable, private] |
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] |
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] |
bool MagGeometry::v_85l [private] |
Definition at line 75 of file MagGeometry.h.
Referenced by fieldInTesla(), inBarrel(), isZSymmetric(), and MagGeometry().