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 ( 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(), and TCMET_cfi::radius.

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

Member Function Documentation

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

Definition at line 107 of file MagneticFieldMap.cc.

References inKGauss().

107  {
108 
109  return inKGauss(gp) * 2.99792458e-4;
110 
111 }
const GlobalVector inKGauss(const GlobalPoint &) const
double MagneticFieldMap::inInverseGeVZ ( const GlobalPoint gp) const

Definition at line 168 of file MagneticFieldMap.cc.

References inKGaussZ().

168  {
169 
170  return inKGaussZ(gp) * 2.99792458e-4;
171 
172 }
double inKGaussZ(const GlobalPoint &) const
void MagneticFieldMap::initialize ( )
private

Referenced by magneticField().

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

Definition at line 100 of file MagneticFieldMap.cc.

References inTesla().

Referenced by inInverseGeV().

100  {
101 
102  return inTesla(gp) * 10.;
103 
104 }
const GlobalVector inTesla(const GlobalPoint &) const
double MagneticFieldMap::inKGaussZ ( const GlobalPoint gp) const

Definition at line 161 of file MagneticFieldMap.cc.

References inTeslaZ().

Referenced by inInverseGeVZ().

161  {
162 
163  return inTeslaZ(gp)/10.;
164 
165 }
double inTeslaZ(const GlobalPoint &) const
const GlobalVector MagneticFieldMap::inTesla ( const GlobalPoint gp) const

Definition at line 78 of file MagneticFieldMap.cc.

References MagneticField::inTesla(), and pMF_.

Referenced by inKGauss().

78  {
79 
80  if (!pMF_) {
81  return GlobalVector( 0., 0., 4.);
82  } else {
83  return pMF_->inTesla(gp);
84  }
85 
86 }
const MagneticField * pMF_
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Global3DVector GlobalVector
Definition: GlobalVector.h:10
const GlobalVector MagneticFieldMap::inTesla ( const TrackerLayer aLayer,
double  coord,
int  success 
) const

Definition at line 89 of file MagneticFieldMap.cc.

References inTeslaZ(), and pMF_.

89  {
90 
91  if (!pMF_) {
92  return GlobalVector( 0., 0., 4.);
93  } else {
94  return GlobalVector(0.,0.,inTeslaZ(aLayer,coord,success));
95  }
96 
97 }
double inTeslaZ(const GlobalPoint &) const
const MagneticField * pMF_
Global3DVector GlobalVector
Definition: GlobalVector.h:10
double MagneticFieldMap::inTeslaZ ( const GlobalPoint gp) const

Definition at line 114 of file MagneticFieldMap.cc.

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

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

114  {
115 
116  return pMF_ ? pMF_->inTesla(gp).z() : 4.0;
117 
118 }
const MagneticField * pMF_
T z() const
Definition: PV3DBase.h:64
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
double MagneticFieldMap::inTeslaZ ( const TrackerLayer aLayer,
double  coord,
int  success 
) const

Definition at line 121 of file MagneticFieldMap.cc.

References stringResolutionProvider_cfi::bin, bins, fieldBarrelBinWidth, fieldBarrelZMin, fieldEndcapBinWidth, fieldEndcapRMin, TrackerLayer::layerNumber(), pMF_, theFieldBarrelHisto(), theFieldEndcapHisto(), and x.

122 {
123 
124  if (!pMF_) {
125  return 4.;
126  } else {
127  // Find the relevant histo
128  double theBinWidth;
129  double theXMin;
130  unsigned layer = aLayer.layerNumber();
131  const std::vector<double>* theHisto;
132 
133  if ( success == 1 ) {
134  theHisto = theFieldBarrelHisto(layer);
135  theBinWidth = fieldBarrelBinWidth[layer];
136  theXMin = fieldBarrelZMin[layer];
137  } else {
138  theHisto = theFieldEndcapHisto(layer);
139  theBinWidth = fieldEndcapBinWidth[layer];
140  theXMin = fieldEndcapRMin[layer];
141  }
142 
143  // Find the relevant bin
144  double x = fabs(coord);
145  unsigned bin = (unsigned) ((x-theXMin)/theBinWidth);
146  if ( bin+1 == (unsigned)bins ) bin -= 1; // Add a protection against coordinates near the layer edge
147  double x1 = theXMin + (bin-0.5)*theBinWidth;
148  double x2 = x1+theBinWidth;
149 
150  // Determine the field
151  double field1 = (*theHisto)[bin];
152  double field2 = (*theHisto)[bin+1];
153 
154  return field1 + (field2-field1) * (x-x1)/(x2-x1);
155 
156  }
157 
158 }
std::vector< double > fieldEndcapBinWidth
unsigned int layerNumber() const
Returns the layer number.
Definition: TrackerLayer.h:82
const MagneticField * pMF_
std::vector< double > fieldEndcapRMin
std::vector< double > fieldBarrelBinWidth
bin
set the eta bin as selection string.
const std::vector< double > * theFieldEndcapHisto(unsigned layer) const
std::vector< double > fieldBarrelZMin
const std::vector< double > * theFieldBarrelHisto(unsigned layer) const
const MagneticField& MagneticFieldMap::magneticField ( ) const
inline

Definition at line 35 of file MagneticFieldMap.h.

References initialize(), and pMF_.

35 {return *pMF_;}
const MagneticField * pMF_
const std::vector<double>* MagneticFieldMap::theFieldBarrelHisto ( unsigned  layer) const
inlineprivate

Definition at line 44 of file MagneticFieldMap.h.

References fieldBarrelHistos.

Referenced by inTeslaZ().

45  { return &(fieldBarrelHistos[layer]); }
std::vector< std::vector< double > > fieldBarrelHistos
const std::vector<double>* MagneticFieldMap::theFieldEndcapHisto ( unsigned  layer) const
inlineprivate

Definition at line 41 of file MagneticFieldMap.h.

References fieldEndcapHistos.

Referenced by inTeslaZ().

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

Member Data Documentation

unsigned MagneticFieldMap::bins
private

Definition at line 49 of file MagneticFieldMap.h.

Referenced by inTeslaZ(), and MagneticFieldMap().

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

Definition at line 52 of file MagneticFieldMap.h.

Referenced by inTeslaZ(), and MagneticFieldMap().

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

Definition at line 50 of file MagneticFieldMap.h.

Referenced by MagneticFieldMap(), and theFieldBarrelHisto().

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

Definition at line 53 of file MagneticFieldMap.h.

Referenced by inTeslaZ(), and MagneticFieldMap().

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

Definition at line 54 of file MagneticFieldMap.h.

Referenced by inTeslaZ(), and MagneticFieldMap().

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

Definition at line 51 of file MagneticFieldMap.h.

Referenced by MagneticFieldMap(), and theFieldEndcapHisto().

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

Definition at line 55 of file MagneticFieldMap.h.

Referenced by inTeslaZ(), and MagneticFieldMap().

const TrackerInteractionGeometry* MagneticFieldMap::geometry_
private

Definition at line 48 of file MagneticFieldMap.h.

Referenced by MagneticFieldMap().

const MagneticField* MagneticFieldMap::pMF_
private

Definition at line 47 of file MagneticFieldMap.h.

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