ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TGeoDetectorOptions.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TGeoDetectorOptions.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018 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 <boost/program_options.hpp>
12 #include <cstdlib>
13 #include <iostream>
14 #include <utility>
15 
18 #include "Acts/Utilities/Units.hpp"
19 
20 namespace po = boost::program_options;
21 
22 namespace au = Acts::units;
23 
24 namespace FW {
25 
26 namespace Options {
27 
33 template <typename options_t>
34 void addTGeoGeometryOptions(options_t& opt) {
35  opt.add_options()("geo-tgeo-filename",
36  po::value<std::string>()->default_value(""),
37  "Root file name.")(
38  "geo-tgeo-worldvolume", po::value<std::string>()->default_value(""),
39  "Root world volume to start search from.")(
40  "geo-tgeo-unitScalor", po::value<double>()->default_value(10.),
41  "Unit scalor from ROOT to Acts.")(
42  "geo-tgeo-nlayers",
43  po::value<read_series>()->multitoken()->default_value({}),
44  "Number of layers on the negative side.")(
45  "geo-tgeo-clayers",
46  po::value<read_series>()->multitoken()->default_value({}),
47  "Number of layers in the barrel.")(
48  "geo-tgeo-players",
49  po::value<read_series>()->multitoken()->default_value({}),
50  "Number of layers on the positive side.")(
51  "geo-tgeo-nlayernames",
52  po::value<read_strings>()->multitoken()->default_value({}),
53  "Name identifier for negative layer objects, odered along the series.")(
54  "geo-tgeo-clayernames",
55  po::value<read_strings>()->multitoken()->default_value({}),
56  "Name identifier for central layer objects, odered along the series.")(
57  "geo-tgeo-playernames",
58  po::value<read_strings>()->multitoken()->default_value({}),
59  "Name identifier for positive layer objects, odered along the series.")(
60  "geo-tgeo-nmodulenames",
61  po::value<read_strings>()->multitoken()->default_value({}),
62  "Name identifier for negative sensitive objects, odered along the "
63  "series.")("geo-tgeo-cmodulenames",
64  po::value<read_strings>()->multitoken()->default_value({}),
65  "Name identifier for central sensitive objects, odered "
66  "along the series.")(
67  "geo-tgeo-pmodulenames",
68  po::value<read_strings>()->multitoken()->default_value({}),
69  "Name identifier for positive sensitive objects, odered along the "
70  "series.")("geo-tgeo-nmoduleaxes",
71  po::value<read_strings>()->multitoken()->default_value({}),
72  "Axes definition for negative sensitive objects, odered "
73  "along the series.")(
74  "geo-tgeo-cmoduleaxes",
75  po::value<read_strings>()->multitoken()->default_value({}),
76  "Axes definition for central sensitive objects, odered along the "
77  "series.")("geo-tgeo-pmoduleaxes",
78  po::value<read_strings>()->multitoken()->default_value({}),
79  "Axes definition for positive sensitive objects, odered "
80  "along the series.");
81 }
82 
91 template <typename variable_map_t>
92 std::vector<Acts::TGeoLayerBuilder::Config> readTGeoLayerBuilderConfigs(
93  const variable_map_t& vm,
94  std::shared_ptr<const Acts::LayerCreator> layerCreator) {
95  std::vector<Acts::TGeoLayerBuilder::Config> detLayerConfigs;
96 
97  // general stuff
98  read_strings subdetectors =
99  vm["geo-subdetectors"].template as<read_strings>();
100  double unitScalor = vm["geo-tgeo-unitScalor"].template as<double>();
101  // these define a series, such as 1, 3, 4
102  read_series nlayers = vm["geo-tgeo-nlayers"].template as<read_series>();
103  read_series clayers = vm["geo-tgeo-clayers"].template as<read_series>();
104  read_series players = vm["geo-tgeo-players"].template as<read_series>();
105  // these are going continously through the series, such as i in [ 1 + 3 + 4
106  // ]
107  read_strings nlayernames =
108  vm["geo-tgeo-nlayernames"].template as<read_strings>();
109  read_strings clayernames =
110  vm["geo-tgeo-clayernames"].template as<read_strings>();
111  read_strings playernames =
112  vm["geo-tgeo-playernames"].template as<read_strings>();
113  read_strings nsensitivenames =
114  vm["geo-tgeo-nmodulenames"].template as<read_strings>();
115  read_strings csensitivenames =
116  vm["geo-tgeo-cmodulenames"].template as<read_strings>();
117  read_strings psensitivenames =
118  vm["geo-tgeo-pmodulenames"].template as<read_strings>();
119  read_strings nsensitiveaxes =
120  vm["geo-tgeo-nmoduleaxes"].template as<read_strings>();
121  read_strings csensitiveaxes =
122  vm["geo-tgeo-cmoduleaxes"].template as<read_strings>();
123  read_strings psensitiveaxes =
124  vm["geo-tgeo-pmoduleaxes"].template as<read_strings>();
125  // todo consistency checks
126 
127  // total coutners
128  int tin = 0;
129  int tic = 0;
130  int tip = 0;
131  // prepare the TGeoLayerBuilder::Configs
132  for (size_t idet = 0; idet < clayers.size(); ++idet) {
133  Acts::TGeoLayerBuilder::Config layerBuilderConfig;
134  // get the current numbers
135  int cn = nlayers[idet];
136  int cc = clayers[idet];
137  int cp = players[idet];
138  // fill the configs - for negative
139  for (int in = 0; in < cn; ++in, ++tin) {
141  lConfig.layerName = nlayernames[tin];
142  lConfig.sensorName = nsensitivenames[tin];
143  lConfig.localAxes = nsensitiveaxes[tin];
144  layerBuilderConfig.layerConfigurations[0].push_back(lConfig);
145  }
146  // fill the configs - for barrel
147  for (int ic = 0; ic < cc; ++ic, ++tic) {
149  lConfig.layerName = clayernames[tic];
150  lConfig.sensorName = csensitivenames[tic];
151  lConfig.localAxes = csensitiveaxes[tic];
152  layerBuilderConfig.layerConfigurations[1].push_back(lConfig);
153  }
154  // fill the configs - for positive
155  for (int ip = 0; ip < cp; ++ip, ++tip) {
157  lConfig.layerName = playernames[tip];
158  lConfig.sensorName = psensitivenames[tip];
159  lConfig.localAxes = psensitiveaxes[tip];
160  layerBuilderConfig.layerConfigurations[2].push_back(lConfig);
161  }
162  // set the scale and the layer creator
163  layerBuilderConfig.configurationName = subdetectors[idet];
164  layerBuilderConfig.unit = unitScalor;
165  layerBuilderConfig.layerCreator = layerCreator;
166  // now add it to the configs
167  detLayerConfigs.push_back(layerBuilderConfig);
168  }
169  return detLayerConfigs;
170 }
171 } // namespace Options
172 } // namespace FW