EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BFieldWritingBase.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file BFieldWritingBase.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
13 
14 #include <boost/program_options.hpp>
15 
16 namespace ActsExamples {
17 namespace BField {
18 
19 template <typename bfield_t>
20 void writeField(boost::program_options::variables_map vm,
21  std::shared_ptr<const bfield_t> bField) {
23  using Config = typename Writer::Config;
24  using GridType = typename Writer::GridType;
25 
26  // Write the interpolated magnetic field
27  Config writerConfig;
28  if (vm["bf-out-rz"].template as<bool>()) {
29  writerConfig.gridType = GridType::rz;
30  } else {
31  writerConfig.gridType = GridType::xyz;
32  }
33  writerConfig.treeName = vm["bf-map-out"].template as<std::string>();
34  writerConfig.fileName = vm["bf-file-out"].template as<std::string>();
35  writerConfig.bField = bField;
36  std::cout << "setting rBounds" << std::endl;
37  if (vm.count("bf-rRange") && vm.count("bf-zRange")) {
38  auto rBounds = vm["bf-rRange"].template as<read_range>();
39  auto zBounds = vm["bf-zRange"].template as<read_range>();
40  writerConfig.rBounds = {{rBounds[0] * Acts::UnitConstants::mm,
41  rBounds[1] * Acts::UnitConstants::mm}};
42  writerConfig.zBounds = {{zBounds[0] * Acts::UnitConstants::mm,
43  zBounds[1] * Acts::UnitConstants::mm}};
44  }
45  writerConfig.rBins = vm["bf-rBins"].template as<size_t>();
46  writerConfig.zBins = vm["bf-ZBins"].template as<size_t>();
47  writerConfig.phiBins = vm["bf-PhiBins"].template as<size_t>();
48 
50 }
51 } // namespace BField
52 } // namespace ActsExamples