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 const * > & 
barrelVolumes () const
 
const std::vector
< MagVolume6Faces const * > & 
endcapVolumes () const
 
GlobalVector fieldInTesla (const GlobalPoint &gp) const
 Return field vector at the specified global point. More...
 
MagVolume const * findVolume (const GlobalPoint &gp, double tolerance=0.) const
 Find a volume. More...
 
bool isZSymmetric () const
 
 MagGeometry (const edm::ParameterSet &config, const std::vector< MagBLayer * > &, const std::vector< MagESector * > &, const std::vector< MagVolume6Faces * > &, const std::vector< MagVolume6Faces * > &)
 Constructor. More...
 
 MagGeometry (const edm::ParameterSet &config, const std::vector< MagBLayer const * > &, const std::vector< MagESector const * > &, const std::vector< MagVolume6Faces const * > &, const std::vector< MagVolume6Faces const * > &)
 
 ~MagGeometry ()
 Destructor. More...
 

Private Member Functions

MagVolume const * findVolume1 (const GlobalPoint &gp, double tolerance=0.) const
 
bool inBarrel (const GlobalPoint &gp) const
 

Private Attributes

bool cacheLastVolume
 
int geometryVersion
 
std::atomic< MagVolume const * > lastVolume
 
MagBinFinders::GeneralBinFinderInR
< double > const * 
theBarrelBinFinder
 
std::vector< MagBLayer const * > theBLayers
 
std::vector< MagVolume6Faces
const * > 
theBVolumes
 
PeriodicBinFinderInPhi< float >
const * 
theEndcapBinFinder
 
std::vector< MagESector const * > theESectors
 
std::vector< MagVolume6Faces
const * > 
theEVolumes
 

Friends

class MagGeometryExerciser
 

Detailed Description

Entry point to the geometry of magnetic volumes.

Author
N. Amapane - INFN Torino

Definition at line 24 of file MagGeometry.h.

Member Typedef Documentation

Definition at line 28 of file MagGeometry.h.

Definition at line 27 of file MagGeometry.h.

Constructor & Destructor Documentation

MagGeometry::MagGeometry ( const edm::ParameterSet config,
const std::vector< MagBLayer * > &  tbl,
const std::vector< MagESector * > &  tes,
const std::vector< MagVolume6Faces * > &  tbv,
const std::vector< MagVolume6Faces * > &  tev 
)

Constructor.

Definition at line 24 of file MagGeometry.cc.

27  :
28  MagGeometry(config, reinterpret_cast<std::vector<MagBLayer const*> const&>(tbl), reinterpret_cast<std::vector<MagESector const*> const&>(tes),
29  reinterpret_cast<std::vector<MagVolume6Faces const*> const&>(tbv), reinterpret_cast<std::vector<MagVolume6Faces const*> const&>(tev)) {}
MagGeometry(const edm::ParameterSet &config, const std::vector< MagBLayer * > &, const std::vector< MagESector * > &, const std::vector< MagVolume6Faces * > &, const std::vector< MagVolume6Faces * > &)
Constructor.
Definition: MagGeometry.cc:24
string const
Definition: compareJSON.py:14
MagGeometry::MagGeometry ( const edm::ParameterSet config,
const std::vector< MagBLayer const * > &  tbl,
const std::vector< MagESector const * > &  tes,
const std::vector< MagVolume6Faces const * > &  tbv,
const std::vector< MagVolume6Faces const * > &  tev 
)

Definition at line 31 of file MagGeometry.cc.

References cacheLastVolume, gather_cfg::cout, verbose::debugOut, geometryVersion, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), Geom::pi(), theBarrelBinFinder, theBLayers, theEndcapBinFinder, and theESectors.

34  :
36 {
37 
38  cacheLastVolume = config.getUntrackedParameter<bool>("cacheLastVolume", true);
39  geometryVersion = config.getParameter<int>("geometryVersion");
40 
41  vector<double> rBorders;
42 
43  for (vector<MagBLayer const*>::const_iterator ilay = theBLayers.begin();
44  ilay != theBLayers.end(); ++ilay) {
45  if (verbose::debugOut) cout << " Barrel layer at " << (*ilay)->minR() <<endl;
46  //FIXME assume layers are already sorted in minR
47  rBorders.push_back((*ilay)->minR());
48  }
49 
51 
52  if (verbose::debugOut) {
53  for (vector<MagESector const*>::const_iterator isec = theESectors.begin();
54  isec != theESectors.end(); ++isec) {
55  cout << " Endcap sector at " << (*isec)->minPhi() << endl;
56  }
57  }
58 
59  //FIXME assume sectors are already sorted in phi
60  //FIXME: PeriodicBinFinderInPhi gets *center* of first bin
61  int nEBins = theESectors.size();
62  theEndcapBinFinder = new PeriodicBinFinderInPhi<float>(theESectors.front()->minPhi()+Geom::pi()/nEBins, nEBins);
63 
64 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::atomic< MagVolume const * > lastVolume
Definition: MagGeometry.h:66
std::vector< MagESector const * > theESectors
Definition: MagGeometry.h:69
PeriodicBinFinderInPhi< float > const * theEndcapBinFinder
Definition: MagGeometry.h:76
std::vector< MagBLayer const * > theBLayers
Definition: MagGeometry.h:68
std::vector< MagVolume6Faces const * > theBVolumes
Definition: MagGeometry.h:72
double pi()
Definition: Pi.h:31
tuple cout
Definition: gather_cfg.py:121
std::vector< MagVolume6Faces const * > theEVolumes
Definition: MagGeometry.h:73
static constexpr bool debugOut
Definition: MagVerbosity.h:12
MagBinFinders::GeneralBinFinderInR< double > const * theBarrelBinFinder
Definition: MagGeometry.h:75
bool cacheLastVolume
Definition: MagGeometry.h:78
int geometryVersion
Definition: MagGeometry.h:79
MagGeometry::~MagGeometry ( )

Destructor.

Definition at line 66 of file MagGeometry.cc.

References theBarrelBinFinder, theBLayers, theEndcapBinFinder, and theESectors.

66  {
67  delete theBarrelBinFinder;
68  delete theEndcapBinFinder;
69 
70  for (vector<MagBLayer const*>::const_iterator ilay = theBLayers.begin();
71  ilay != theBLayers.end(); ++ilay) {
72  delete (*ilay);
73  }
74 
75  for (vector<MagESector const*>::const_iterator ilay = theESectors.begin();
76  ilay != theESectors.end(); ++ilay) {
77  delete (*ilay);
78  }
79 }
std::vector< MagESector const * > theESectors
Definition: MagGeometry.h:69
PeriodicBinFinderInPhi< float > const * theEndcapBinFinder
Definition: MagGeometry.h:76
std::vector< MagBLayer const * > theBLayers
Definition: MagGeometry.h:68
MagBinFinders::GeneralBinFinderInR< double > const * theBarrelBinFinder
Definition: MagGeometry.h:75

Member Function Documentation

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

Definition at line 53 of file MagGeometry.h.

References theBVolumes.

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

Definition at line 54 of file MagGeometry.h.

References theEVolumes.

54 {return theEVolumes;}
std::vector< MagVolume6Faces const * > theEVolumes
Definition: MagGeometry.h:73
GlobalVector MagGeometry::fieldInTesla ( const GlobalPoint gp) const

Return field vector at the specified global point.

Definition at line 83 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().

83  {
84  MagVolume const * v = 0;
85 
86 
87  v = findVolume(gp);
88  if (v!=0) {
89  return v->fieldInTesla(gp);
90  }
91 
92  // Fall-back case: no volume found
93 
94  if (edm::isNotFinite(gp.mag())) {
95  LogWarning("InvalidInput") << "Input value invalid (not a number): " << gp << endl;
96 
97  } else {
98  LogWarning("MagneticField") << "MagGeometry::fieldInTesla: failed to find volume for " << gp << endl;
99  }
100  return GlobalVector();
101 }
Surface::GlobalVector GlobalVector
Definition: MagGeometry.h:27
MagVolume const * findVolume(const GlobalPoint &gp, double tolerance=0.) const
Find a volume.
Definition: MagGeometry.cc:142
T mag() const
Definition: PV3DBase.h:67
bool isNotFinite(T x)
Definition: isFinite.h:10
LocalVector fieldInTesla(const LocalPoint &lp) const
Definition: MagVolume.cc:11
MagVolume const * MagGeometry::findVolume ( const GlobalPoint gp,
double  tolerance = 0. 
) const

Find a volume.

Definition at line 142 of file MagGeometry.cc.

References newFWLiteAna::bin, PeriodicBinFinderInPhi< T >::binIndex(), MagBinFinders::GeneralBinFinderInR< T >::binIndex(), cacheLastVolume, gather_cfg::cout, verbose::debugOut, inBarrel(), 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().

142  {
143  // Check volume cache
144  auto lastVolumeCheck = lastVolume.load(std::memory_order_acquire);
145  if (lastVolumeCheck!=nullptr && lastVolumeCheck->inside(gp)){
146  return lastVolumeCheck;
147  }
148 
149  MagVolume const* result=0;
150  if (inBarrel(gp)) { // Barrel
151  double R = gp.perp();
152  int bin = theBarrelBinFinder->binIndex(R);
153 
154  // Search up to 3 layers inwards. This may happen for very thin layers.
155  for (int bin1 = bin; bin1 >= max(0,bin-3); --bin1) {
156  if (verbose::debugOut) cout << "Trying layer at R " << theBLayers[bin1]->minR()
157  << " " << R << endl ;
158  result = theBLayers[bin1]->findVolume(gp, tolerance);
159  if (verbose::debugOut) cout << "***In blayer " << bin1-bin << " "
160  << (result==0? " failed " : " OK ") <<endl;
161  if (result != 0) break;
162  }
163 
164  } else { // Endcaps
165  Geom::Phi<float> phi = gp.phi();
166  int bin = theEndcapBinFinder->binIndex(phi);
167  if (verbose::debugOut) cout << "Trying endcap sector at phi "
168  << theESectors[bin]->minPhi() << " " << phi << endl ;
169  result = theESectors[bin]->findVolume(gp, tolerance);
170  if (verbose::debugOut) cout << "***In guessed esector "
171  << (result==0? " failed " : " OK ") <<endl;
172  }
173 
174 
175  if (result==0 && tolerance < 0.0001) {
176  // If search fails, retry with a 300 micron tolerance.
177  // This is a hack for thin gaps on air-iron boundaries,
178  // which will not be present anymore once surfaces are matched.
179  if (verbose::debugOut) cout << "Increasing the tolerance to 0.03" <<endl;
180  result = findVolume(gp, 0.03);
181  }
182 
183  if (cacheLastVolume) lastVolume.store(result,std::memory_order_release);
184 
185  return result;
186 }
T perp() const
Definition: PV3DBase.h:72
virtual int binIndex(T R) const
Definition: MagBinFinders.h:66
std::atomic< MagVolume const * > lastVolume
Definition: MagGeometry.h:66
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
bool inBarrel(const GlobalPoint &gp) const
Definition: MagGeometry.cc:191
MagVolume const * findVolume(const GlobalPoint &gp, double tolerance=0.) const
Find a volume.
Definition: MagGeometry.cc:142
virtual int binIndex(T phi) const
returns an index in the valid range for the bin that contains phi
const T & max(const T &a, const T &b)
std::vector< MagESector const * > theESectors
Definition: MagGeometry.h:69
PeriodicBinFinderInPhi< float > const * theEndcapBinFinder
Definition: MagGeometry.h:76
tuple result
Definition: query.py:137
std::vector< MagBLayer const * > theBLayers
Definition: MagGeometry.h:68
tuple cout
Definition: gather_cfg.py:121
static constexpr bool debugOut
Definition: MagVerbosity.h:12
MagBinFinders::GeneralBinFinderInR< double > const * theBarrelBinFinder
Definition: MagGeometry.h:75
bool cacheLastVolume
Definition: MagGeometry.h:78
Definition: DDAxes.h:10
MagVolume const * MagGeometry::findVolume1 ( const GlobalPoint gp,
double  tolerance = 0. 
) const
private

Definition at line 106 of file MagGeometry.cc.

References gather_cfg::cout, newFWLiteAna::found, inBarrel(), theBVolumes, theEVolumes, and findQualityFiles::v.

106  {
107 
108  MagVolume6Faces const* found = 0;
109 
110  if (inBarrel(gp)) { // Barrel
111  for (vector<MagVolume6Faces const*>::const_iterator v = theBVolumes.begin();
112  v!=theBVolumes.end(); ++v){
113  if ((*v)==0) { //FIXME: remove this check
114  cout << endl << "***ERROR: MagGeometry::findVolume: MagVolume not set" << endl;
115  continue;
116  }
117  if ((*v)->inside(gp,tolerance)) {
118  found = (*v);
119  break;
120  }
121  }
122 
123  } else { // Endcaps
124  for (vector<MagVolume6Faces const*>::const_iterator v = theEVolumes.begin();
125  v!=theEVolumes.end(); ++v){
126  if ((*v)==0) { //FIXME: remove this check
127  cout << endl << "***ERROR: MagGeometry::findVolume: MagVolume not set" << endl;
128  continue;
129  }
130  if ((*v)->inside(gp,tolerance)) {
131  found = (*v);
132  break;
133  }
134  }
135  }
136 
137  return found;
138 }
bool inBarrel(const GlobalPoint &gp) const
Definition: MagGeometry.cc:191
std::vector< MagVolume6Faces const * > theBVolumes
Definition: MagGeometry.h:72
tuple cout
Definition: gather_cfg.py:121
std::vector< MagVolume6Faces const * > theEVolumes
Definition: MagGeometry.h:73
bool MagGeometry::inBarrel ( const GlobalPoint gp) const
private

Definition at line 191 of file MagGeometry.cc.

References geometryVersion, PV3DBase< T, PVType, FrameType >::perp(), dttmaxenums::R, Gflash::Z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by findVolume(), and findVolume1().

191  {
192  float Z = fabs(gp.z());
193  float R = gp.perp();
194 
195  // FIXME: Get these dimensions from the builder.
196  if (geometryVersion>=120812) {
197  return (Z<350. ||
198  (R>172.4 && Z<633.29) ||
199  (R>308.7345 && Z<662.01));
200  } else if (geometryVersion>=90812) {
201  return (Z<350. ||
202  (R>172.4 && Z<633.89) ||
203  (R>308.755 && Z<662.01));
204  } else { // version 71212
205  return (Z<350. ||
206  (R>172.4 && Z<633.29) ||
207  (R>308.755 && Z<661.01));
208  }
209 }
const double Z[kNumberCalorimeter]
T perp() const
Definition: PV3DBase.h:72
T z() const
Definition: PV3DBase.h:64
int geometryVersion
Definition: MagGeometry.h:79
bool MagGeometry::isZSymmetric ( ) const
inline

Definition at line 50 of file MagGeometry.h.

Referenced by VolumeBasedMagneticField::isZSymmetric().

50 {return false;}

Friends And Related Function Documentation

friend class MagGeometryExerciser
friend

Definition at line 58 of file MagGeometry.h.

Member Data Documentation

bool MagGeometry::cacheLastVolume
private

Definition at line 78 of file MagGeometry.h.

Referenced by findVolume(), and MagGeometry().

int MagGeometry::geometryVersion
private

Definition at line 79 of file MagGeometry.h.

Referenced by inBarrel(), and MagGeometry().

std::atomic<MagVolume const*> MagGeometry::lastVolume
mutableprivate

Definition at line 66 of file MagGeometry.h.

Referenced by findVolume().

MagBinFinders::GeneralBinFinderInR<double> const* MagGeometry::theBarrelBinFinder
private

Definition at line 75 of file MagGeometry.h.

Referenced by findVolume(), MagGeometry(), and ~MagGeometry().

std::vector<MagBLayer const*> MagGeometry::theBLayers
private

Definition at line 68 of file MagGeometry.h.

Referenced by findVolume(), MagGeometry(), and ~MagGeometry().

std::vector<MagVolume6Faces const*> MagGeometry::theBVolumes
private

Definition at line 72 of file MagGeometry.h.

Referenced by barrelVolumes(), and findVolume1().

PeriodicBinFinderInPhi<float> const* MagGeometry::theEndcapBinFinder
private

Definition at line 76 of file MagGeometry.h.

Referenced by findVolume(), MagGeometry(), and ~MagGeometry().

std::vector<MagESector const*> MagGeometry::theESectors
private

Definition at line 69 of file MagGeometry.h.

Referenced by findVolume(), MagGeometry(), and ~MagGeometry().

std::vector<MagVolume6Faces const*> MagGeometry::theEVolumes
private

Definition at line 73 of file MagGeometry.h.

Referenced by endcapVolumes(), and findVolume1().