CbmRoot
CbmLitFieldGridCreator.cxx
Go to the documentation of this file.
1 
9 #include "../../parallel/LitFieldGrid.h"
10 
11 #include "FairField.h"
12 #include "FairRunAna.h"
13 
15  : fField(FairRunAna::Instance()->GetField())
16  , fXangle(35.)
17  , fYangle(35.)
18  , fCellSizeX(2.)
19  , fCellSizeY(2.) {}
20 
22 
25  float tanXangle = std::tan(fXangle * 3.14159265 / 180.); //
26  float tanYangle = std::tan(fYangle * 3.14159265 / 180.); //
27  float Xmax = Z * tanXangle;
28  float Ymax = Z * tanYangle;
29  int nofCellsX = int(Xmax / fCellSizeX);
30  int nofCellsY = int(Ymax / fCellSizeY);
31  Xmax = nofCellsX * fCellSizeX;
32  Ymax = nofCellsY * fCellSizeY;
33  nofCellsX += nofCellsX;
34  nofCellsY += nofCellsY;
35 
36  std::vector<std::vector<lit::parallel::LitFieldValue<fscal>>> field;
37  field.resize(nofCellsX + 1);
38  for (unsigned int i = 0; i < nofCellsX + 1; i++) {
39  field[i].resize(nofCellsY + 1);
40  }
41 
42  for (int j = 0; j < nofCellsX + 1; j++) { // loop over x position
43  double X = -Xmax + j * fCellSizeX;
44  for (int k = 0; k < nofCellsY + 1; k++) { // loop over y position
45  double Y = -Ymax + k * fCellSizeY;
46 
47  // get field value
48  double pos[3] = {X, Y, Z};
49  double B[3];
50  fField->GetFieldValue(pos, B);
51 
53  v.Bx = B[0];
54  v.By = B[1];
55  v.Bz = B[2];
56  field[j][k] = v;
57  }
58  }
59  grid.SetZ(Z);
60  grid.SetField(field, -Xmax, Xmax, -Ymax, Ymax, nofCellsX, nofCellsY);
61  std::cout << "Grid created: " << grid << "\n";
62 }
CbmLitFieldGridCreator::~CbmLitFieldGridCreator
virtual ~CbmLitFieldGridCreator()
Destructor.
Definition: CbmLitFieldGridCreator.cxx:21
fscal
float fscal
Definition: L1/vectors/P4_F32vec4.h:250
CbmLitFieldGridCreator::fXangle
float fXangle
Definition: CbmLitFieldGridCreator.h:64
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmLitFieldGridCreator::CbmLitFieldGridCreator
CbmLitFieldGridCreator()
Constructor.
Definition: CbmLitFieldGridCreator.cxx:14
lit::parallel::LitFieldGrid
Class stores a grid of magnetic field values in XY slice at Z position.
Definition: LitFieldGrid.h:44
CbmLitFieldGridCreator::fYangle
float fYangle
Definition: CbmLitFieldGridCreator.h:65
lit::parallel::LitFieldValue
Magnetic field value at a certain point in the space.
Definition: LitFieldValue.h:29
CbmLitFieldGridCreator::fCellSizeX
float fCellSizeX
Definition: CbmLitFieldGridCreator.h:67
lit::parallel::LitFieldGrid::SetZ
void SetZ(fscal Z)
Sets Z position of the grid.
Definition: LitFieldGrid.h:71
CbmLitFieldGridCreator::fCellSizeY
float fCellSizeY
Definition: CbmLitFieldGridCreator.h:68
lit::parallel::LitFieldGrid::SetField
void SetField(const vector< vector< LitFieldValue< fscal >>> &field, fscal xmin, fscal xmax, fscal ymin, fscal ymax, int nofBinsX, int nofBinsY)
Set field values for the grid.
Definition: LitFieldGrid.h:89
CbmLitFieldGridCreator.h
Class creates grid with magnetic field values at a certain Z position.
v
__m128 v
Definition: L1/vectors/P4_F32vec4.h:1
pos
TVector3 pos
Definition: CbmMvdSensorDigiToHitTask.cxx:60
CbmLitFieldGridCreator::fField
FairField * fField
Definition: CbmLitFieldGridCreator.h:62
CbmLitFieldGridCreator::CreateGrid
void CreateGrid(fscal Z, lit::parallel::LitFieldGrid &grid)
Main function which creates grid with magnetic field values in (X, Y) slice.
Definition: CbmLitFieldGridCreator.cxx:23