Project
Loading...
Searching...
No Matches
GRPMagField.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
16#include <Framework/Logger.h>
19#include <cstdint>
20
21using namespace o2::parameters;
22
23//_______________________________________________
24GRPMagField* GRPMagField::loadFrom(const std::string& grpMagFieldFileName)
25{
26 // load object from file
27 auto fname = o2::base::NameConf::getGRPMagFieldFileName(grpMagFieldFileName);
28 TFile flGRPMagField(fname.c_str());
29 if (flGRPMagField.IsZombie()) {
30 LOG(error) << "Failed to open " << fname;
31 throw std::runtime_error("Failed to open GRP Mag Field file");
32 }
33 auto grpMagField = reinterpret_cast<o2::parameters::GRPMagField*>(flGRPMagField.GetObjectChecked(o2::base::NameConf::CCDBOBJECT.data(), Class()));
34 if (!grpMagField) {
35 throw std::runtime_error(fmt::format("Failed to load GRP Mag Field object from {}", fname));
36 }
37 return grpMagField;
38}
39
41{
42 printf("magnet currents (A) L3 = %.3f, Dipole = %.f; uniformity = %s\n", getL3Current(), getDipoleCurrent(), mUniformField ? "true" : "false");
43}
44
45o2::units::Current_t GRPMagField::checkDipoleOverride()
46{
47 static float v = getenv("O2_OVERRIDE_DIPOLE_CURRENT") ? atof(getenv("O2_OVERRIDE_DIPOLE_CURRENT")) : NOOVERRIDEVAL;
48 static bool alarmShown = false;
49 if (v != NOOVERRIDEVAL && !alarmShown) {
50 LOGP(error, "Overriding DIPOLE current to {}", v);
51 alarmShown = true;
52 }
53 return v;
54}
55
56o2::units::Current_t GRPMagField::checkL3Override()
57{
58 static float v = getenv("O2_OVERRIDE_L3_CURRENT") ? atof(getenv("O2_OVERRIDE_L3_CURRENT")) : NOOVERRIDEVAL;
59 static bool alarmShown = false;
60 if (v != NOOVERRIDEVAL && !alarmShown) {
61 LOGP(error, "Overriding L3 current to {}", v);
62 alarmShown = true;
63 }
64 return v;
65}
Header of the General Run Parameters object for B field values.
Definition of the Names Generator class.
static constexpr std::string_view CCDBOBJECT
Definition NameConf.h:66
static std::string getGRPMagFieldFileName(const std::string_view prefix=STANDARDSIMPREFIX)
Definition NameConf.cxx:76
o2::units::Current_t getDipoleCurrent() const
Definition GRPMagField.h:43
o2::units::Current_t getL3Current() const
getters/setters for magnets currents
Definition GRPMagField.h:37
static GRPMagField * loadFrom(const std::string &grpMagFieldFileName="")
void print() const
print itself
const GLdouble * v
Definition glcorearb.h:832
GLboolean * data
Definition glcorearb.h:298
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"