EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CommonGeometry.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CommonGeometry.cpp
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 
16 
17 #include <string>
18 
19 #include <boost/program_options.hpp>
20 
21 namespace ActsExamples {
22 namespace Geometry {
23 
33 std::pair<std::shared_ptr<const Acts::TrackingGeometry>,
34  std::vector<std::shared_ptr<ActsExamples::IContextDecorator>>>
35 build(const boost::program_options::variables_map& vm,
36  IBaseDetector& detector) {
37  // Material decoration
38  std::shared_ptr<const Acts::IMaterialDecorator> matDeco = nullptr;
39  auto matType = vm["mat-input-type"].template as<std::string>();
40  if (matType == "none") {
41  matDeco = std::make_shared<const Acts::MaterialWiper>();
42  } else if (matType == "file") {
43  // Retrieve the filename
44  auto fileName = vm["mat-input-file"].template as<std::string>();
45  // json or root based decorator
46  if (fileName.find(".json") != std::string::npos) {
47  // Set up the converter first
48  Acts::JsonGeometryConverter::Config jsonGeoConvConfig;
49  // Set up the json-based decorator
50  matDeco = std::make_shared<const Acts::JsonMaterialDecorator>(
51  jsonGeoConvConfig, fileName);
52  } else if (fileName.find(".root") != std::string::npos) {
53  // Set up the root-based decorator
55  rootMatDecConfig.fileName = fileName;
56  matDeco = std::make_shared<const ActsExamples::RootMaterialDecorator>(
57  rootMatDecConfig);
58  }
59  }
60 
62  return detector.finalize(vm, matDeco);
63 }
64 
65 } // namespace Geometry
66 } // namespace ActsExamples