CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
MagGeometry Class Reference

#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. More...
 
MagVolumefindVolume (const GlobalPoint &gp, double tolerance=0.) const
 Find a volume. More...
 
bool isZSymmetric () const
 
 MagGeometry (const edm::ParameterSet &config, std::vector< MagBLayer * >, std::vector< MagESector * >, std::vector< MagVolume6Faces * >, std::vector< MagVolume6Faces * >)
 Constructor. More...
 
 ~MagGeometry ()
 Destructor. More...
 

Private Member Functions

MagVolumefindVolume1 (const GlobalPoint &gp, double tolerance=0.) const
 
bool inBarrel (const GlobalPoint &gp) const
 

Private Attributes

bool cacheLastVolume
 
MagVolumelastVolume
 
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
 

Detailed Description

Entry point to the geometry of magnetic volumes.

Date:
2008/04/20 23:22:04
Revision:
1.9
Author
N. Amapane - INFN Torino

Definition at line 25 of file MagGeometry.h.

Member Typedef Documentation

Definition at line 29 of file MagGeometry.h.

Definition at line 28 of file MagGeometry.h.

Constructor & Destructor Documentation

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(), Geom::pi(), theBarrelBinFinder, theBLayers, theEndcapBinFinder, theESectors, and v_85l.

28  :
29  lastVolume(0), theBLayers(tbl), theESectors(tes), theBVolumes(tbv), theEVolumes(tev)
30 {
31 
32  cacheLastVolume = config.getUntrackedParameter<bool>("cacheLastVolume", true);
33  v_85l = (config.getParameter<std::string>("version")=="grid_85l_030919");
34 
35  vector<double> rBorders;
36 
37  for (vector<MagBLayer *>::const_iterator ilay = theBLayers.begin();
38  ilay != theBLayers.end(); ++ilay) {
39  if (verbose::debugOut) cout << " Barrel layer at " << (*ilay)->minR() <<endl;
40  //FIXME assume layers are already sorted in minR
41  rBorders.push_back((*ilay)->minR());
42  }
43 
45 
46  if (verbose::debugOut) {
47  for (vector<MagESector *>::const_iterator isec = theESectors.begin();
48  isec != theESectors.end(); ++isec) {
49  cout << " Endcap sector at " << (*isec)->minPhi() << endl;
50  }
51  }
52 
53  //FIXME assume sectors are already sorted in phi
54  //FIXME: PeriodicBinFinderInPhi gets *center* of first bin
55  theEndcapBinFinder = new PeriodicBinFinderInPhi<float>(theESectors.front()->minPhi()+Geom::pi()/12., 12);
56 
57 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MagVolume * lastVolume
Definition: MagGeometry.h:62
PeriodicBinFinderInPhi< float > * theEndcapBinFinder
Definition: MagGeometry.h:72
static bool debugOut
Definition: MagVerbosity.h:14
MagBinFinders::GeneralBinFinderInR< double > * theBarrelBinFinder
Definition: MagGeometry.h:71
std::vector< MagVolume6Faces * > theEVolumes
Definition: MagGeometry.h:69
std::vector< MagVolume6Faces * > theBVolumes
Definition: MagGeometry.h:68
std::vector< MagESector * > theESectors
Definition: MagGeometry.h:65
double pi()
Definition: Pi.h:31
tuple cout
Definition: gather_cfg.py:41
bool cacheLastVolume
Definition: MagGeometry.h:74
std::vector< MagBLayer * > theBLayers
Definition: MagGeometry.h:64
MagGeometry::~MagGeometry ( )

Destructor.

Definition at line 59 of file MagGeometry.cc.

References theBarrelBinFinder, theBLayers, theEndcapBinFinder, and theESectors.

59  {
60  delete theBarrelBinFinder;
61  delete theEndcapBinFinder;
62 
63  for (vector<MagBLayer *>::const_iterator ilay = theBLayers.begin();
64  ilay != theBLayers.end(); ++ilay) {
65  delete (*ilay);
66  }
67 
68  for (vector<MagESector *>::const_iterator ilay = theESectors.begin();
69  ilay != theESectors.end(); ++ilay) {
70  delete (*ilay);
71  }
72 }
PeriodicBinFinderInPhi< float > * theEndcapBinFinder
Definition: MagGeometry.h:72
MagBinFinders::GeneralBinFinderInR< double > * theBarrelBinFinder
Definition: MagGeometry.h:71
std::vector< MagESector * > theESectors
Definition: MagGeometry.h:65
std::vector< MagBLayer * > theBLayers
Definition: MagGeometry.h:64

Member Function Documentation

const std::vector<MagVolume6Faces*>& MagGeometry::barrelVolumes ( ) const
inline

Definition at line 49 of file MagGeometry.h.

References theBVolumes.

49 {return theBVolumes;}
std::vector< MagVolume6Faces * > theBVolumes
Definition: MagGeometry.h:68
const std::vector<MagVolume6Faces*>& MagGeometry::endcapVolumes ( ) const
inline

Definition at line 50 of file MagGeometry.h.

References theEVolumes.

50 {return theEVolumes;}
std::vector< MagVolume6Faces * > theEVolumes
Definition: MagGeometry.h:69
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().

76  {
77  MagVolume * v = 0;
78 
79  // Map version 85l is Z-symmetric; -> implement Z reflection
80  if (v_85l && gp.z()>0) {
81  GlobalPoint gpSym(gp.x(), gp.y(), -gp.z());
82  // Check volume cache
83  v = findVolume(gpSym);
84 
85  if (v!=0) {
86  GlobalVector bresult = v->fieldInTesla(gpSym);
87  return GlobalVector(-bresult.x(), -bresult.y(), bresult.z());
88  }
89 
90  } else { // No reflection
91  v = findVolume(gp);
92  if (v!=0) {
93  return v->fieldInTesla(gp);
94  }
95  }
96 
97  // Fall-back case: no volume found
98 
99  if (isnan(gp.mag())) {
100  LogWarning("InvalidInput") << "Input value invalid (not a number): " << gp << endl;
101 
102  } else {
103  LogWarning("MagneticField") << "MagGeometry::fieldInTesla: failed to find volume for " << gp << endl;
104  }
105  return GlobalVector();
106 }
Surface::GlobalVector GlobalVector
Definition: MagGeometry.h:28
T y() const
Definition: PV3DBase.h:57
T mag() const
Definition: PV3DBase.h:61
bool isnan(float x)
Definition: math.h:13
T z() const
Definition: PV3DBase.h:58
MagVolume * findVolume(const GlobalPoint &gp, double tolerance=0.) const
Find a volume.
Definition: MagGeometry.cc:147
T x() const
Definition: PV3DBase.h:56
mathSSE::Vec4< T > v
MagVolume * MagGeometry::findVolume ( const GlobalPoint gp,
double  tolerance = 0. 
) const

Find a volume.

Definition at line 147 of file MagGeometry.cc.

References newFWLiteAna::bin, PeriodicBinFinderInPhi< T >::binIndex(), MagBinFinders::GeneralBinFinderInR< T >::binIndex(), cacheLastVolume, gather_cfg::cout, verbose::debugOut, inBarrel(), MagVolume::inside(), lastVolume, max(), PV3DBase< T, PVType, FrameType >::perp(), phi, PV3DBase< T, PVType, FrameType >::phi(), dttmaxenums::R, query::result, theBarrelBinFinder, theBLayers, theEndcapBinFinder, and theESectors.

Referenced by fieldInTesla(), and VolumeBasedMagneticField::findVolume().

147  {
148  // Check volume cache
149  if (lastVolume!=0 && lastVolume->inside(gp)){
150  return lastVolume;
151  }
152 
153  MagVolume * result=0;
154  if (inBarrel(gp)) { // Barrel
155  double R = gp.perp();
156  int bin = theBarrelBinFinder->binIndex(R);
157 
158  for (int bin1 = bin; bin1 >= max(0,bin-2); --bin1) {
159  if (verbose::debugOut) cout << "Trying layer at R " << theBLayers[bin1]->minR()
160  << " " << R << endl ;
161  result = theBLayers[bin1]->findVolume(gp, tolerance);
162  if (verbose::debugOut) cout << "***In blayer " << bin1-bin << " "
163  << (result==0? " failed " : " OK ") <<endl;
164  if (result != 0) break;
165  }
166 
167  } else { // Endcaps
168  Geom::Phi<float> phi = gp.phi();
169  int bin = theEndcapBinFinder->binIndex(phi);
170  if (verbose::debugOut) cout << "Trying endcap sector at phi "
171  << theESectors[bin]->minPhi() << " " << phi << endl ;
172  result = theESectors[bin]->findVolume(gp, tolerance);
173  if (verbose::debugOut) cout << "***In guessed esector "
174  << (result==0? " failed " : " OK ") <<endl;
175  }
176 
177 
178  if (result==0 && tolerance < 0.0001) {
179  // If search fails, retry with a 300 micron tolerance.
180  // This is a hack for thin gaps on air-iron boundaries,
181  // which will not be present anymore once surfaces are matched.
182  if (verbose::debugOut) cout << "Increasing the tolerance to 0.03" <<endl;
183  result = findVolume(gp, 0.03);
184  }
185 
187 
188  return result;
189 }
T perp() const
Definition: PV3DBase.h:66
virtual int binIndex(T R) const
Definition: MagBinFinders.h:68
MagVolume * lastVolume
Definition: MagGeometry.h:62
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
PeriodicBinFinderInPhi< float > * theEndcapBinFinder
Definition: MagGeometry.h:72
static bool debugOut
Definition: MagVerbosity.h:14
bool inBarrel(const GlobalPoint &gp) const
Definition: MagGeometry.cc:194
virtual int binIndex(T phi) const
returns an index in the valid range for the bin that contains phi
virtual bool inside(const GlobalPoint &gp, double tolerance=0.) const =0
MagBinFinders::GeneralBinFinderInR< double > * theBarrelBinFinder
Definition: MagGeometry.h:71
const T & max(const T &a, const T &b)
tuple result
Definition: query.py:137
std::vector< MagESector * > theESectors
Definition: MagGeometry.h:65
tuple cout
Definition: gather_cfg.py:41
MagVolume * findVolume(const GlobalPoint &gp, double tolerance=0.) const
Find a volume.
Definition: MagGeometry.cc:147
bool cacheLastVolume
Definition: MagGeometry.h:74
std::vector< MagBLayer * > theBLayers
Definition: MagGeometry.h:64
Definition: DDAxes.h:10
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.

111  {
112 
113  MagVolume6Faces * found = 0;
114 
115  if (inBarrel(gp)) { // Barrel
116  for (vector<MagVolume6Faces*>::const_iterator v = theBVolumes.begin();
117  v!=theBVolumes.end(); ++v){
118  if ((*v)==0) { //FIXME: remove this check
119  cout << endl << "***ERROR: MagGeometry::findVolume: MagVolume not set" << endl;
120  continue;
121  }
122  if ((*v)->inside(gp,tolerance)) {
123  found = (*v);
124  break;
125  }
126  }
127 
128  } else { // Endcaps
129  for (vector<MagVolume6Faces*>::const_iterator v = theEVolumes.begin();
130  v!=theEVolumes.end(); ++v){
131  if ((*v)==0) { //FIXME: remove this check
132  cout << endl << "***ERROR: MagGeometry::findVolume: MagVolume not set" << endl;
133  continue;
134  }
135  if ((*v)->inside(gp,tolerance)) {
136  found = (*v);
137  break;
138  }
139  }
140  }
141 
142  return found;
143 }
bool inBarrel(const GlobalPoint &gp) const
Definition: MagGeometry.cc:194
std::vector< MagVolume6Faces * > theEVolumes
Definition: MagGeometry.h:69
std::vector< MagVolume6Faces * > theBVolumes
Definition: MagGeometry.h:68
tuple cout
Definition: gather_cfg.py:41
mathSSE::Vec4< T > v
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, Gflash::Z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by findVolume(), and findVolume1().

194  {
195  float Z = fabs(gp.z());
196  float R = gp.perp();
197 
198  // FIXME: Get these dimensions from the builder.
199  // For this we can wait the next generation of tables, when the picture
200  // may be more complicated
201  if (v_85l){
202  return (Z<634.49 || (R>308.755 && Z<661.01));
203  } else {
204  return (Z<350. ||
205  (R>172.4 && Z<633.29) ||
206  (R>308.755 && Z<661.01));
207  }
208 }
const double Z[kNumberCalorimeter]
T perp() const
Definition: PV3DBase.h:66
T z() const
Definition: PV3DBase.h:58
bool MagGeometry::isZSymmetric ( ) const

Definition at line 211 of file MagGeometry.cc.

References v_85l.

Referenced by VolumeBasedMagneticField::isZSymmetric().

211  {
212  return v_85l;
213 }

Friends And Related Function Documentation

friend class MagGeometryExerciser
friend

Definition at line 54 of file MagGeometry.h.

Member Data Documentation

bool MagGeometry::cacheLastVolume
private

Definition at line 74 of file MagGeometry.h.

Referenced by findVolume(), and MagGeometry().

MagVolume* MagGeometry::lastVolume
mutableprivate

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().