ECCE @ 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 
11 #include <Acts/Utilities/Units.hpp>
12 #include <cstdlib>
13 #include <utility>
14 
17 
18 namespace po = boost::program_options;
19 
20 namespace au = Acts::units;
21 
22 namespace FW {
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.")("dd4hep-envelopeR",
77  po::value<double>()->default_value(1. * Acts::units::_mm),
78  "The envelop cover in R for DD4hep volumes.")(
79  "dd4hep-envelopeR",
80  po::value<double>()->default_value(1. * Acts::units::_mm),
81  "The tolerance added to the geometrical extension in r of the "
82  "layers contained to build the volume envelope around in mm.")(
83  "dd4hep-envelopeZ",
84  po::value<double>()->default_value(1. * Acts::units::_mm),
85  "The tolerance added to the geometrical extension in z of the "
86  "layers contained to build the volume envelope around in mm.")(
87  "dd4hep-layerThickness", po::value<double>()->default_value(10e-10),
88  "In case no surfaces (to be contained by the layer) are handed over, "
89  "the layer thickness will be set to this value.")(
90  "dd4hep-buildFCChh", po::value<bool>()->default_value(true),
91  "If you are not building the FCChh detector please set this flag to "
92  "false.")("dd4hep-loglevel", po::value<size_t>()->default_value(2),
93  "The output log level of the geometry building. Please set the "
94  "wished "
95  "number (0 = VERBOSE, 1 = "
96  "DEBUG, 2 = INFO, 3 = WARNING, 4 = ERROR, 5 = FATAL).");
97 }
98 
100 template <typename amap_t>
103  gsConfig.logLevel =
104  Acts::Logging::Level(vm["dd4hep-loglevel"].template as<size_t>());
105  gsConfig.xmlFileNames = vm["dd4hep-input"].template as<read_strings>();
106  gsConfig.bTypePhi = Acts::equidistant;
107  gsConfig.bTypeR = Acts::arbitrary;
108  gsConfig.bTypeZ = Acts::equidistant;
109  gsConfig.envelopeR = vm["dd4hep-envelopeR"].template as<double>();
110  gsConfig.envelopeZ = vm["dd4hep-envelopeZ"].template as<double>();
111  gsConfig.defaultLayerThickness =
112  vm["dd4hep-layerThickness"].template as<double>();
113  if (vm["dd4hep-buildFCChh"].template as<bool>()) {
115  }
116  return gsConfig;
117 }
118 } // namespace Options
119 } // namespace FW