CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MagneticFieldMap Class Reference

#include <MagneticFieldMap.h>

Public Member Functions

const GlobalVector inInverseGeV (const GlobalPoint &) const
 
double inInverseGeVZ (const GlobalPoint &) const
 
const GlobalVector inKGauss (const GlobalPoint &) const
 
double inKGaussZ (const GlobalPoint &) const
 
const GlobalVector inTesla (const GlobalPoint &) const
 
const GlobalVector inTesla (const TrackerLayer &aLayer, double coord, int success) const
 
double inTeslaZ (const GlobalPoint &) const
 
double inTeslaZ (const TrackerLayer &aLayer, double coord, int success) const
 
const MagneticFieldmagneticField () const
 
 MagneticFieldMap (const MagneticField *pmF, const TrackerInteractionGeometry *myGeo)
 

Private Member Functions

void initialize ()
 
const std::vector< double > * theFieldBarrelHisto (unsigned layer) const
 
const std::vector< double > * theFieldEndcapHisto (unsigned layer) const
 

Private Attributes

unsigned bins
 
std::vector< double > fieldBarrelBinWidth
 
std::vector< std::vector< double > > fieldBarrelHistos
 
std::vector< double > fieldBarrelZMin
 
std::vector< double > fieldEndcapBinWidth
 
std::vector< std::vector< double > > fieldEndcapHistos
 
std::vector< double > fieldEndcapRMin
 
const TrackerInteractionGeometrygeometry_
 
const MagneticFieldpMF_
 

Detailed Description

Definition at line 18 of file MagneticFieldMap.h.

Constructor & Destructor Documentation

◆ MagneticFieldMap()

MagneticFieldMap::MagneticFieldMap ( const MagneticField pmF,
const TrackerInteractionGeometry myGeo 
)

Definition at line 7 of file MagneticFieldMap.cc.

References bins, TrackerInteractionGeometry::cylinderBegin(), TrackerInteractionGeometry::cylinderEnd(), fieldBarrelBinWidth, fieldBarrelHistos, fieldBarrelZMin, fieldEndcapBinWidth, fieldEndcapHistos, fieldEndcapRMin, geometry_, inTeslaZ(), nano_mu_digi_cff::layer, CosmicsPD_Skims::radius, SiStripMonitorCluster_cfi::zmax, and SiStripMonitorCluster_cfi::zmin.

8  : pMF_(pMF),
9  geometry_(myGeo),
10  bins(101),
11  fieldBarrelHistos(200, static_cast<std::vector<double> >(std::vector<double>(bins, static_cast<double>(0.)))),
12  fieldEndcapHistos(200, static_cast<std::vector<double> >(std::vector<double>(bins, static_cast<double>(0.)))),
13  fieldBarrelBinWidth(200, static_cast<double>(0.)),
14  fieldBarrelZMin(200, static_cast<double>(0.)),
15  fieldEndcapBinWidth(200, static_cast<double>(0.)),
16  fieldEndcapRMin(200, static_cast<double>(0.))
17 
18 {
19  std::list<TrackerLayer>::const_iterator cyliter;
20  std::list<TrackerLayer>::const_iterator cylitBeg = geometry_->cylinderBegin();
21  std::list<TrackerLayer>::const_iterator cylitEnd = geometry_->cylinderEnd();
22 
23  // Prepare the histograms
24  // std::cout << "Prepare magnetic field local database for FAMOS speed-up" << std::endl;
25  for (cyliter = cylitBeg; cyliter != cylitEnd; ++cyliter) {
26  int layer = cyliter->layerNumber();
27  // cout << " Fill Histogram " << hist << endl;
28 
29  // Cylinder bounds
30  double zmin = 0.;
31  double zmax;
32  double rmin = 0.;
33  double rmax;
34  if (cyliter->forward()) {
35  zmax = cyliter->disk()->position().z();
36  rmax = cyliter->disk()->outerRadius();
37  } else {
38  zmax = cyliter->cylinder()->bounds().length() / 2.;
39  rmax = cyliter->cylinder()->bounds().width() / 2. - cyliter->cylinder()->bounds().thickness() / 2.;
40  }
41 
42  // Histograms
43  double step;
44 
45  // Disk histogram characteristics
46  step = (rmax - rmin) / (bins - 1);
48  fieldEndcapRMin[layer] = rmin;
49 
50  // Fill the histo
51  int endcapBin = 0;
52  for (double radius = rmin + step / 2.; radius < rmax + step; radius += step) {
53  double field = inTeslaZ(GlobalPoint(radius, 0., zmax));
54  fieldEndcapHistos[layer][endcapBin++] = field;
55  }
56 
57  // Barrel Histogram characteritics
58  step = (zmax - zmin) / (bins - 1);
61 
62  // Fill the histo
63  int barrelBin = 0;
64  for (double zed = zmin + step / 2.; zed < zmax + step; zed += step) {
65  double field = inTeslaZ(GlobalPoint(rmax, 0., zed));
66  fieldBarrelHistos[layer][barrelBin++] = field;
67  }
68  }
69 }
std::vector< double > fieldEndcapBinWidth
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const MagneticField * pMF_
std::vector< double > fieldEndcapRMin
std::list< TrackerLayer >::const_iterator cylinderEnd() const
Returns the last pointer in the cylinder list.
const TrackerInteractionGeometry * geometry_
std::vector< std::vector< double > > fieldBarrelHistos
std::vector< double > fieldBarrelBinWidth
std::list< TrackerLayer >::const_iterator cylinderBegin() const
Returns the first pointer in the cylinder list.
std::vector< double > fieldBarrelZMin
std::vector< std::vector< double > > fieldEndcapHistos
step
Definition: StallMonitor.cc:98
double inTeslaZ(const GlobalPoint &) const

Member Function Documentation

◆ inInverseGeV()

const GlobalVector MagneticFieldMap::inInverseGeV ( const GlobalPoint gp) const

Definition at line 89 of file MagneticFieldMap.cc.

References runTauDisplay::gp, and inKGauss().

89 { return inKGauss(gp) * 2.99792458e-4; }
const GlobalVector inKGauss(const GlobalPoint &) const

◆ inInverseGeVZ()

double MagneticFieldMap::inInverseGeVZ ( const GlobalPoint gp) const

Definition at line 131 of file MagneticFieldMap.cc.

References runTauDisplay::gp, and inKGaussZ().

131 { return inKGaussZ(gp) * 2.99792458e-4; }
double inKGaussZ(const GlobalPoint &) const

◆ initialize()

void MagneticFieldMap::initialize ( )
private

◆ inKGauss()

const GlobalVector MagneticFieldMap::inKGauss ( const GlobalPoint gp) const

Definition at line 87 of file MagneticFieldMap.cc.

References runTauDisplay::gp, and inTesla().

Referenced by inInverseGeV().

87 { return inTesla(gp) * 10.; }
const GlobalVector inTesla(const GlobalPoint &) const

◆ inKGaussZ()

double MagneticFieldMap::inKGaussZ ( const GlobalPoint gp) const

Definition at line 129 of file MagneticFieldMap.cc.

References runTauDisplay::gp, and inTeslaZ().

Referenced by inInverseGeVZ().

129 { return inTeslaZ(gp) / 10.; }
double inTeslaZ(const GlobalPoint &) const

◆ inTesla() [1/2]

const GlobalVector MagneticFieldMap::inTesla ( const GlobalPoint gp) const

Definition at line 71 of file MagneticFieldMap.cc.

References runTauDisplay::gp, MagneticField::inTesla(), and pMF_.

Referenced by inKGauss().

71  {
72  if (!pMF_) {
73  return GlobalVector(0., 0., 4.);
74  } else {
75  return pMF_->inTesla(gp);
76  }
77 }
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const MagneticField * pMF_
Global3DVector GlobalVector
Definition: GlobalVector.h:10

◆ inTesla() [2/2]

const GlobalVector MagneticFieldMap::inTesla ( const TrackerLayer aLayer,
double  coord,
int  success 
) const

Definition at line 79 of file MagneticFieldMap.cc.

References inTeslaZ(), pMF_, and summarizeEdmComparisonLogfiles::success.

79  {
80  if (!pMF_) {
81  return GlobalVector(0., 0., 4.);
82  } else {
83  return GlobalVector(0., 0., inTeslaZ(aLayer, coord, success));
84  }
85 }
const MagneticField * pMF_
double inTeslaZ(const GlobalPoint &) const
Global3DVector GlobalVector
Definition: GlobalVector.h:10

◆ inTeslaZ() [1/2]

double MagneticFieldMap::inTeslaZ ( const GlobalPoint gp) const

Definition at line 91 of file MagneticFieldMap.cc.

References runTauDisplay::gp, MagneticField::inTesla(), pMF_, and PV3DBase< T, PVType, FrameType >::z().

Referenced by ParticlePropagator::fieldMap(), inKGaussZ(), inTesla(), and MagneticFieldMap().

91 { return pMF_ ? pMF_->inTesla(gp).z() : 4.0; }
T z() const
Definition: PV3DBase.h:61
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const MagneticField * pMF_

◆ inTeslaZ() [2/2]

double MagneticFieldMap::inTeslaZ ( const TrackerLayer aLayer,
double  coord,
int  success 
) const

Definition at line 93 of file MagneticFieldMap.cc.

References newFWLiteAna::bin, bins, fieldBarrelBinWidth, fieldBarrelZMin, fieldEndcapBinWidth, fieldEndcapRMin, nano_mu_digi_cff::layer, TrackerLayer::layerNumber(), pMF_, summarizeEdmComparisonLogfiles::success, theFieldBarrelHisto(), theFieldEndcapHisto(), x, testProducerWithPsetDescEmpty_cfi::x1, and testProducerWithPsetDescEmpty_cfi::x2.

93  {
94  if (!pMF_) {
95  return 4.;
96  } else {
97  // Find the relevant histo
98  double theBinWidth;
99  double theXMin;
100  unsigned layer = aLayer.layerNumber();
101  const std::vector<double>* theHisto;
102 
103  if (success == 1) {
104  theHisto = theFieldBarrelHisto(layer);
105  theBinWidth = fieldBarrelBinWidth[layer];
106  theXMin = fieldBarrelZMin[layer];
107  } else {
108  theHisto = theFieldEndcapHisto(layer);
109  theBinWidth = fieldEndcapBinWidth[layer];
110  theXMin = fieldEndcapRMin[layer];
111  }
112 
113  // Find the relevant bin
114  double x = fabs(coord);
115  unsigned bin = (unsigned)((x - theXMin) / theBinWidth);
116  if (bin + 1 == (unsigned)bins)
117  bin -= 1; // Add a protection against coordinates near the layer edge
118  double x1 = theXMin + (bin - 0.5) * theBinWidth;
119  double x2 = x1 + theBinWidth;
120 
121  // Determine the field
122  double field1 = (*theHisto)[bin];
123  double field2 = (*theHisto)[bin + 1];
124 
125  return field1 + (field2 - field1) * (x - x1) / (x2 - x1);
126  }
127 }
std::vector< double > fieldEndcapBinWidth
const std::vector< double > * theFieldEndcapHisto(unsigned layer) const
const MagneticField * pMF_
std::vector< double > fieldEndcapRMin
const std::vector< double > * theFieldBarrelHisto(unsigned layer) const
std::vector< double > fieldBarrelBinWidth
unsigned int layerNumber() const
Returns the layer number.
Definition: TrackerLayer.h:78
std::vector< double > fieldBarrelZMin

◆ magneticField()

const MagneticField& MagneticFieldMap::magneticField ( ) const
inline

Definition at line 32 of file MagneticFieldMap.h.

References pMF_.

32 { return *pMF_; }
const MagneticField * pMF_

◆ theFieldBarrelHisto()

const std::vector<double>* MagneticFieldMap::theFieldBarrelHisto ( unsigned  layer) const
inlineprivate

Definition at line 39 of file MagneticFieldMap.h.

References fieldBarrelHistos, and nano_mu_digi_cff::layer.

Referenced by inTeslaZ().

39 { return &(fieldBarrelHistos[layer]); }
std::vector< std::vector< double > > fieldBarrelHistos

◆ theFieldEndcapHisto()

const std::vector<double>* MagneticFieldMap::theFieldEndcapHisto ( unsigned  layer) const
inlineprivate

Definition at line 37 of file MagneticFieldMap.h.

References fieldEndcapHistos, and nano_mu_digi_cff::layer.

Referenced by inTeslaZ().

37 { return &(fieldEndcapHistos[layer]); }
std::vector< std::vector< double > > fieldEndcapHistos

Member Data Documentation

◆ bins

unsigned MagneticFieldMap::bins
private

Definition at line 43 of file MagneticFieldMap.h.

Referenced by inTeslaZ(), and MagneticFieldMap().

◆ fieldBarrelBinWidth

std::vector<double> MagneticFieldMap::fieldBarrelBinWidth
private

Definition at line 46 of file MagneticFieldMap.h.

Referenced by inTeslaZ(), and MagneticFieldMap().

◆ fieldBarrelHistos

std::vector<std::vector<double> > MagneticFieldMap::fieldBarrelHistos
private

Definition at line 44 of file MagneticFieldMap.h.

Referenced by MagneticFieldMap(), and theFieldBarrelHisto().

◆ fieldBarrelZMin

std::vector<double> MagneticFieldMap::fieldBarrelZMin
private

Definition at line 47 of file MagneticFieldMap.h.

Referenced by inTeslaZ(), and MagneticFieldMap().

◆ fieldEndcapBinWidth

std::vector<double> MagneticFieldMap::fieldEndcapBinWidth
private

Definition at line 48 of file MagneticFieldMap.h.

Referenced by inTeslaZ(), and MagneticFieldMap().

◆ fieldEndcapHistos

std::vector<std::vector<double> > MagneticFieldMap::fieldEndcapHistos
private

Definition at line 45 of file MagneticFieldMap.h.

Referenced by MagneticFieldMap(), and theFieldEndcapHisto().

◆ fieldEndcapRMin

std::vector<double> MagneticFieldMap::fieldEndcapRMin
private

Definition at line 49 of file MagneticFieldMap.h.

Referenced by inTeslaZ(), and MagneticFieldMap().

◆ geometry_

const TrackerInteractionGeometry* MagneticFieldMap::geometry_
private

Definition at line 42 of file MagneticFieldMap.h.

Referenced by MagneticFieldMap().

◆ pMF_

const MagneticField* MagneticFieldMap::pMF_
private

Definition at line 41 of file MagneticFieldMap.h.

Referenced by inTesla(), inTeslaZ(), and magneticField().