CbmRoot
Loading...
Searching...
No Matches
CbmLitFieldGridCreator.cxx
Go to the documentation of this file.
1/* Copyright (C) 2011-2013 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
13
15#include "FairField.h"
16#include "FairRunAna.h"
17
19 : fField(FairRunAna::Instance()->GetField())
20 , fXangle(35.)
21 , fYangle(35.)
22 , fCellSizeX(2.)
23 , fCellSizeY(2.)
24{
25}
26
28
30{
31 float tanXangle = std::tan(fXangle * 3.14159265 / 180.); //
32 float tanYangle = std::tan(fYangle * 3.14159265 / 180.); //
33 float Xmax = Z * tanXangle;
34 float Ymax = Z * tanYangle;
35 int nofCellsX = int(Xmax / fCellSizeX);
36 int nofCellsY = int(Ymax / fCellSizeY);
37 Xmax = nofCellsX * fCellSizeX;
38 Ymax = nofCellsY * fCellSizeY;
39 nofCellsX += nofCellsX;
40 nofCellsY += nofCellsY;
41
42 std::vector<std::vector<lit::parallel::LitFieldValue<fscal>>> field;
43 field.resize(nofCellsX + 1);
44 for (unsigned int i = 0; i < nofCellsX + 1; i++) {
45 field[i].resize(nofCellsY + 1);
46 }
47
48 for (int j = 0; j < nofCellsX + 1; j++) { // loop over x position
49 double X = -Xmax + j * fCellSizeX;
50 for (int k = 0; k < nofCellsY + 1; k++) { // loop over y position
51 double Y = -Ymax + k * fCellSizeY;
52
53 // get field value
54 double pos[3] = {X, Y, Z};
55 double B[3];
56 fField->GetFieldValue(pos, B);
57
59 v.Bx = B[0];
60 v.By = B[1];
61 v.Bz = B[2];
62 field[j][k] = v;
63 }
64 }
65 grid.SetZ(Z);
66 grid.SetField(field, -Xmax, Xmax, -Ymax, Ymax, nofCellsX, nofCellsY);
67 std::cout << "Grid created: " << grid << "\n";
68}
Class creates grid with magnetic field values at a certain Z position.
fscal v[fmask::Size]
Definition KfSimdPseudo.h:4
Class stores a grid of magnetic field values in XY slice at Z position.
virtual ~CbmLitFieldGridCreator()
Destructor.
void CreateGrid(fscal Z, lit::parallel::LitFieldGrid &grid)
Main function which creates grid with magnetic field values in (X, Y) slice.
Class stores a grid of magnetic field values in XY slice at Z position.
void SetZ(fscal Z)
Sets Z position of the grid.
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.
Magnetic field value at a certain point in the space.