Project
Loading...
Searching...
No Matches
ALICE3MagneticField.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
17#include <fairlogger/Logger.h> // for FairLogger
18#include <CommonUtils/ConfigurationMacroHelper.h> // for just-in-time compilation of macros
19#include <filesystem>
20
21using namespace o2::field;
22// ClassImp(ALICE3MagneticField)
23
24// initializes the just-in-time implementation of the field function
25void ALICE3MagneticField::initJITFieldFunction()
26{
27 // for now we check if there is an env variable, pointing to a macro file
28 auto filename = getenv("ALICE3_MAGFIELD_MACRO");
29 if (filename) {
30 LOG(info) << "Taking ALICE3 magnetic field implementation from macro (just in time)";
31 if (std::filesystem::exists(filename)) {
32 // if this file exists we will compile the hook on the fly
33 mJITFieldFunction = o2::conf::GetFromMacro<FieldEvalFcn>(filename, "field()", "function<void(const double*,double*)>", "o2mc_alice3_field_hook");
34 LOG(info) << "Hook initialized from file " << filename;
35 } else {
36 LOG(error) << "Did not find file " << filename;
37 }
38 }
39}
40
41void ALICE3MagneticField::init()
42{
43 LOG(info) << "Initializing ALICE3 magnetic field";
44 initJITFieldFunction();
45}
46
47void ALICE3MagneticField::Field(const Double_t* __restrict__ xyz, Double_t* __restrict__ b)
48{
49 if (mJITFieldFunction) {
50 mJITFieldFunction(xyz, b);
51 } else {
52 // TODO: These values are just toy; Real implementation should go here
53 b[0] = 0.;
54 b[1] = 0.;
55 b[2] = -10.; // -10 kGauss
56 }
57}
A simple magnetic field class for ALICE3 R&D.
void Field(const Double_t *__restrict__ point, Double_t *__restrict__ bField) override
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
std::string filename()
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"