CbmRoot
Loading...
Searching...
No Matches
CbmKfOriginalField.h
Go to the documentation of this file.
1/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov[committer] */
4
9
10#pragma once // include this header only once per compilation unit
11
12#include "FairField.h"
13#include "FairRunAna.h"
14
15#include <mutex>
16#include <tuple>
17
18namespace cbm::kf
19{
23 public:
29 std::tuple<double, double, double> operator()(double x, double y, double z) const
30 {
31 assert(FairRunAna::Instance());
32 assert(FairRunAna::Instance()->GetField());
33 double pos[3] = {x, y, z};
34 double B[3] = {0., 0., 0.};
35 // protect the field access
36 // TODO: make CbmField thread-safe
37 static std::mutex mymutex;
38 mymutex.lock();
39 FairRunAna::Instance()->GetField()->GetFieldValue(pos, B);
40 mymutex.unlock();
41 return std::tuple(B[0], B[1], B[2]);
42 }
43 };
44
46 class ZeroField {
47 public:
53 std::tuple<double, double, double> operator()(double, double, double) const { return std::tuple(0., 0., 0.); }
54 };
55} // namespace cbm::kf
Thread-safe representation of the magnetic field in CBM.
std::tuple< double, double, double > operator()(double x, double y, double z) const
Returns magnetic field flux density in a spatial point.
std::tuple< double, double, double > operator()(double, double, double) const
Returns magnetic field flux density in a spatial point.