EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DD4hepDetectorOptions.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DD4hepDetectorOptions.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017 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 #include <Acts/Utilities/Units.hpp>
14 
15 #include <cstdlib>
16 #include <utility>
17 
18 #include <boost/program_options.hpp>
19 
20 namespace po = boost::program_options;
21 
22 namespace ActsExamples {
23 
24 namespace Options {
25 
26 void sortFCChhDetElements(std::vector<dd4hep::DetElement>& det) {
27  std::vector<dd4hep::DetElement> tracker;
28  std::vector<dd4hep::DetElement> eCal;
29  std::vector<dd4hep::DetElement> hCal;
30  std::vector<dd4hep::DetElement> muon;
31  for (auto& detElement : det) {
32  std::string detName = detElement.name();
33  if (detName.find("Muon") != std::string::npos)
34  muon.push_back(detElement);
35  else if (detName.find("ECal") != std::string::npos)
36  eCal.push_back(detElement);
37  else if (detName.find("HCal") != std::string::npos)
38  hCal.push_back(detElement);
39  else
40  tracker.push_back(detElement);
41  }
42  sort(muon.begin(), muon.end(),
43  [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) {
44  return (a.id() < b.id());
45  });
46  sort(eCal.begin(), eCal.end(),
47  [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) {
48  return (a.id() < b.id());
49  });
50  sort(hCal.begin(), hCal.end(),
51  [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) {
52  return (a.id() < b.id());
53  });
54  sort(tracker.begin(), tracker.end(),
55  [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) {
56  return (a.id() < b.id());
57  });
58  det.clear();
59  det = tracker;
60 
61  det.insert(det.end(), eCal.begin(), eCal.end());
62  det.insert(det.end(), hCal.begin(), hCal.end());
63  det.insert(det.end(), muon.begin(), muon.end());
64 }
65 
67 template <typename aopt_t>
68 void addDD4hepOptions(aopt_t& opt) {
69  opt.add_options()(
70  "dd4hep-input",
71  po::value<read_strings>()->multitoken()->default_value(
72  {"file:Detectors/DD4hepDetector/compact/OpenDataDetector/"
73  "OpenDataDetector.xml"}),
74  "The locations of the input DD4hep files, use 'file:foo.xml'. In case "
75  "you want to read in multiple files, just seperate the strings by "
76  "space.")(
77  "dd4hep-envelopeR",
78  po::value<double>()->default_value(1. * Acts::UnitConstants::mm),
79  "The envelop cover in R for DD4hep volumes.")(
80  "dd4hep-envelopeR",
81  po::value<double>()->default_value(1. * Acts::UnitConstants::mm),
82  "The tolerance added to the geometrical extension in r of the "
83  "layers contained to build the volume envelope around in mm.")(
84  "dd4hep-envelopeZ",
85  po::value<double>()->default_value(1. * Acts::UnitConstants::mm),
86  "The tolerance added to the geometrical extension in z of the "
87  "layers contained to build the volume envelope around in mm.")(
88  "dd4hep-layerThickness", po::value<double>()->default_value(10e-10),
89  "In case no surfaces (to be contained by the layer) are handed over, "
90  "the layer thickness will be set to this value.")(
91  "dd4hep-buildFCChh", po::value<bool>()->default_value(true),
92  "If you are not building the FCChh detector please set this flag to "
93  "false.")("dd4hep-loglevel", po::value<size_t>()->default_value(2),
94  "The output log level of the geometry building. Please set the "
95  "wished "
96  "number (0 = VERBOSE, 1 = "
97  "DEBUG, 2 = INFO, 3 = WARNING, 4 = ERROR, 5 = FATAL).");
98 }
99 
101 template <typename amap_t>
103  const amap_t& vm) {
105  gsConfig.logLevel =
106  Acts::Logging::Level(vm["dd4hep-loglevel"].template as<size_t>());
107  gsConfig.xmlFileNames = vm["dd4hep-input"].template as<read_strings>();
108  gsConfig.bTypePhi = Acts::equidistant;
109  gsConfig.bTypeR = Acts::arbitrary;
110  gsConfig.bTypeZ = Acts::equidistant;
111  gsConfig.envelopeR = vm["dd4hep-envelopeR"].template as<double>();
112  gsConfig.envelopeZ = vm["dd4hep-envelopeZ"].template as<double>();
113  gsConfig.defaultLayerThickness =
114  vm["dd4hep-layerThickness"].template as<double>();
115  if (vm["dd4hep-buildFCChh"].template as<bool>()) {
117  }
118  return gsConfig;
119 }
120 } // namespace Options
121 } // namespace ActsExamples