Skip to content

Commit c398e45

Browse files
committed
ALICE3: avoid code duplication to get the b field in different devices
1 parent bf51222 commit c398e45

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
12+
#ifndef O2_ALICE3_GLOBALRECONSTRUCTION_MAGNETICFIELD_HELPER_H
13+
#define O2_ALICE3_GLOBALRECONSTRUCTION_MAGNETICFIELD_HELPER_H
14+
15+
namespace o2::trk
16+
{
17+
18+
void ensureAlice3Field(float bz);
19+
20+
} // namespace o2::trk
21+
22+
#endif
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
12+
#include "ALICE3GlobalReconstructionWorkflow/MagneticFieldHelper.h"
13+
14+
#include "DetectorsBase/Propagator.h"
15+
#include "Field/MagFieldParam.h"
16+
#include "Field/MagneticField.h"
17+
#include "Framework/Logger.h"
18+
19+
#include <TGeoGlobalMagField.h>
20+
21+
namespace o2::trk
22+
{
23+
24+
void ensureAlice3Field(float bz)
25+
{
26+
auto* globalField = TGeoGlobalMagField::Instance();
27+
if (globalField->GetField() == nullptr) {
28+
auto* field = new o2::field::MagneticField("ALICE3Mag", "ALICE 3 Magnetic Field", bz / 5.f, 0.0, o2::field::MagFieldParam::k5kGUniform);
29+
globalField->SetField(field);
30+
globalField->Lock();
31+
LOGP(info, "Installed ALICE3 magnetic field with Bz={} kG", bz);
32+
}
33+
auto* propagator = o2::base::Propagator::Instance(false);
34+
propagator->updateField();
35+
propagator->setNominalBz(bz);
36+
}
37+
38+
} // namespace o2::trk

0 commit comments

Comments
 (0)