ECCE @ 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 
13 #include <boost/program_options.hpp>
14 #include <string>
15 
19 
20 namespace FW {
21 namespace Geometry {
22 
32 std::pair<std::shared_ptr<const Acts::TrackingGeometry>,
33  std::vector<std::shared_ptr<FW::IContextDecorator>>>
34 build(const boost::program_options::variables_map& vm,
35  IBaseDetector& detector) {
36  // Material decoration
37  std::shared_ptr<const Acts::IMaterialDecorator> matDeco = nullptr;
38  auto matType = vm["mat-input-type"].template as<std::string>();
39  if (matType == "none") {
40  matDeco = std::make_shared<const Acts::MaterialWiper>();
41  } else if (matType == "file") {
42  // Retrieve the filename
43  auto fileName = vm["mat-input-file"].template as<std::string>();
44  // json or root based decorator
45  if (fileName.find(".json") != std::string::npos) {
46  // Set up the converter first
47  Acts::JsonGeometryConverter::Config jsonGeoConvConfig;
48  // Set up the json-based decorator
49  matDeco = std::make_shared<const Acts::JsonMaterialDecorator>(
50  jsonGeoConvConfig, fileName);
51  } else if (fileName.find(".root") != std::string::npos) {
52  // Set up the root-based decorator
53  FW::RootMaterialDecorator::Config rootMatDecConfig;
54  rootMatDecConfig.fileName = fileName;
55  matDeco =
56  std::make_shared<const FW::RootMaterialDecorator>(rootMatDecConfig);
57  }
58  }
59 
61  return detector.finalize(vm, matDeco);
62 }
63 
64 } // namespace Geometry
65 } // namespace FW