CMS 3D CMS Logo

RectangularCartesianMFGrid.cc
Go to the documentation of this file.
2 #include "binary_ifstream.h"
4 
5 #include <iostream>
6 
7 using namespace std;
8 
10  : MFGrid3D(vol) {
11  // The parameters read from the data files are given in global coordinates.
12  // In version 85l, local frame has the same orientation of global frame for the reference
13  // volume, i.e. the r.f. transformation is only a translation.
14  // There is therefore no need to convert the field values to local coordinates.
15  // Check this assumption:
16  GlobalVector localXDir(frame().toGlobal(LocalVector(1, 0, 0)));
17  GlobalVector localYDir(frame().toGlobal(LocalVector(0, 1, 0)));
18 
19  if (localXDir.dot(GlobalVector(1, 0, 0)) > 0.999999 && localYDir.dot(GlobalVector(0, 1, 0)) > 0.999999) {
20  // "null" rotation - requires no conversion...
21  } else {
22  cout << "ERROR: RectangularCartesianMFGrid: unexpected orientation: x: " << localXDir << " y: " << localYDir
23  << endl;
24  }
25 
26  int n1, n2, n3;
27  inFile >> n1 >> n2 >> n3;
28  double xref, yref, zref;
29  inFile >> xref >> yref >> zref;
30  double stepx, stepy, stepz;
31  inFile >> stepx >> stepy >> stepz;
32 
33  vector<BVector> fieldValues;
34  float Bx, By, Bz;
35  int nLines = n1 * n2 * n3;
36  fieldValues.reserve(nLines);
37  for (int iLine = 0; iLine < nLines; ++iLine) {
38  inFile >> Bx >> By >> Bz;
39  fieldValues.push_back(BVector(Bx, By, Bz));
40  }
41  // check completeness
42  string lastEntry;
43  inFile >> lastEntry;
44  if (lastEntry != "complete") {
45  cout << "ERROR during file reading: file is not complete" << endl;
46  }
47 
48  GlobalPoint grefp(xref, yref, zref);
49  LocalPoint lrefp = frame().toLocal(grefp);
50 
51  Grid1D gridX(lrefp.x(), lrefp.x() + stepx * (n1 - 1), n1);
52  Grid1D gridY(lrefp.y(), lrefp.y() + stepy * (n2 - 1), n2);
53  Grid1D gridZ(lrefp.z(), lrefp.z() + stepz * (n3 - 1), n3);
54  grid_ = GridType(gridX, gridY, gridZ, fieldValues);
55 
56  // Activate/deactivate timers
57  // static SimpleConfigurable<bool> timerOn(false,"MFGrid:timing");
58  // (*TimingReport::current()).switchOn("MagneticFieldProvider::valueInTesla(RectangularCartesianMFGrid)",timerOn);
59 }
60 
62  cout << endl << "Dump of RectangularCartesianMFGrid" << endl;
63  // cout << "Number of points from file "
64  // << n1 << " " << n2 << " " << n3 << endl;
65  cout << "Number of points from Grid1D " << grid_.grida().nodes() << " " << grid_.gridb().nodes() << " "
66  << grid_.gridc().nodes() << endl;
67 
68  // cout << "Reference Point from file "
69  // << xref << " " << yref << " " << zref << endl;
70  cout << "Reference Point from Grid1D " << grid_.grida().lower() << " " << grid_.gridb().lower() << " "
71  << grid_.gridc().lower() << endl;
72 
73  // cout << "Basic Distance from file "
74  // << stepx << " " << stepy << " " << stepz << endl;
75  cout << "Basic Distance from Grid1D " << grid_.grida().step() << " " << grid_.gridb().step() << " "
76  << grid_.gridc().step() << endl;
77 
78  cout << "Dumping " << grid_.data().size() << " field values " << endl;
79  // grid_.dump();
80 }
81 
83  // static TimingReport::Item & timer= (*TimingReport::current())["MagneticFieldProvider::valueInTesla(RectangularCartesianMFGrid)"];
84  // TimeMe t(timer,false);
85 
87  GridType::ReturnType value = interpol.interpolate(p.x(), p.y(), p.z());
88  return LocalVector(value);
89 }
90 
91 void RectangularCartesianMFGrid::toGridFrame(const LocalPoint& p, double& a, double& b, double& c) const {
92  a = p.x();
93  b = p.y();
94  c = p.z();
95 }
96 
98  return LocalPoint(a, b, c);
99 }
GloballyPositioned< float >
LinearGridInterpolator3D
Definition: LinearGridInterpolator3D.h:22
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MFGrid::LocalVector
GloballyPositioned< float >::LocalVector LocalVector
Definition: MFGrid.h:32
Grid1D::nodes
int nodes() const
Definition: Grid1D.h:21
RectangularCartesianMFGrid::RectangularCartesianMFGrid
RectangularCartesianMFGrid(binary_ifstream &istr, const GloballyPositioned< float > &vol)
Definition: RectangularCartesianMFGrid.cc:9
RectangularCartesianMFGrid::dump
void dump() const override
Definition: RectangularCartesianMFGrid.cc:61
submitDQMOfflineCAF.nLines
nLines
Definition: submitDQMOfflineCAF.py:676
MFGrid::frame
const GloballyPositioned< float > & frame() const
Local reference frame.
Definition: MFGrid.h:60
MFGrid3D::GridType
Grid3D GridType
Definition: MFGrid3D.h:56
MFGrid3D::grid_
GridType grid_
Definition: MFGrid3D.h:59
Grid1D
Definition: Grid1D.h:7
binary_ifstream
Definition: binary_ifstream.h:8
MFGrid3D::BVector
Grid3D::BVector BVector
Definition: MFGrid3D.h:57
Grid1D::step
Scalar step() const
Definition: Grid1D.h:18
MFGrid::LocalPoint
GloballyPositioned< float >::LocalPoint LocalPoint
Definition: MFGrid.h:31
Grid3D::data
const Container & data() const
Definition: Grid3D.h:63
b
double b
Definition: hdecay.h:118
RectangularCartesianMFGrid::uncheckedValueInTesla
LocalVector uncheckedValueInTesla(const LocalPoint &p) const override
Interpolated field value at given point; does not check for exceptions.
Definition: RectangularCartesianMFGrid.cc:82
RectangularCartesianMFGrid.h
a
double a
Definition: hdecay.h:119
Grid3D::grida
const Grid1D & grida() const
Definition: Grid3D.h:59
binary_ifstream.h
value
Definition: value.py:1
RectangularCartesianMFGrid::fromGridFrame
LocalPoint fromGridFrame(double a, double b, double c) const override
find grid coordinates for point. For debugging and validation only.
Definition: RectangularCartesianMFGrid.cc:97
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
RectangularCartesianMFGrid::toGridFrame
void toGridFrame(const LocalPoint &p, double &a, double &b, double &c) const override
find grid coordinates for point. For debugging and validation only.
Definition: RectangularCartesianMFGrid.cc:91
std
Definition: JetResolutionObject.h:76
MFGrid::GlobalVector
GloballyPositioned< float >::GlobalVector GlobalVector
Definition: MFGrid.h:30
GloballyPositioned::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:98
LinearGridInterpolator3D::interpolate
ReturnType interpolate(Scalar a, Scalar b, Scalar c)
Definition: LinearGridInterpolator3D.cc:11
LinearGridInterpolator3D.h
MFGrid3D
Definition: MFGrid3D.h:17
Grid3D::gridb
const Grid1D & gridb() const
Definition: Grid3D.h:60
Basic3DVector< Scalar >
Grid3D::gridc
const Grid1D & gridc() const
Definition: Grid3D.h:61
MFGrid::GlobalPoint
GloballyPositioned< float >::GlobalPoint GlobalPoint
Definition: MFGrid.h:29
Grid1D::lower
Scalar lower() const
Definition: Grid1D.h:19