37 #include <TIterator.h>
41 #include <boost/algorithm/string.hpp>
42 #include <boost/algorithm/string/finder.hpp>
43 #include <boost/algorithm/string/iter_find.hpp>
46 class ISurfaceMaterial;
47 class IVolumeMaterial;
56 if (
m_cfg.folderSurfaceNameBase.empty()) {
57 throw std::invalid_argument(
"Missing surface folder name base");
58 }
else if (
m_cfg.folderVolumeNameBase.empty()) {
59 throw std::invalid_argument(
"Missing volume folder name base");
60 }
else if (
m_cfg.fileName.empty()) {
61 throw std::invalid_argument(
"Missing file name");
65 m_inputFile = TFile::Open(
m_cfg.fileName.c_str());
66 if (m_inputFile ==
nullptr) {
67 throw std::ios_base::failure(
"Could not open '" +
m_cfg.fileName);
71 TList*
tlist = m_inputFile->GetListOfKeys();
72 auto tIter = tlist->MakeIterator();
76 while (TKey* key = (TKey*)(
tIter->Next())) {
83 std::vector<std::string> splitNames;
84 iter_split(splitNames, tdName,
85 boost::algorithm::first_finder(
m_cfg.voltag));
87 if (splitNames[0] ==
m_cfg.folderSurfaceNameBase) {
89 std::shared_ptr<const Acts::ISurfaceMaterial> sMaterial =
nullptr;
91 boost::split(splitNames, splitNames[1], boost::is_any_of(
"_"));
94 iter_split(splitNames, tdName,
95 boost::algorithm::first_finder(
m_cfg.boutag));
96 boost::split(splitNames, splitNames[1], boost::is_any_of(
"_"));
99 iter_split(splitNames, tdName,
100 boost::algorithm::first_finder(
m_cfg.laytag));
101 boost::split(splitNames, splitNames[1], boost::is_any_of(
"_"));
104 iter_split(splitNames, tdName,
105 boost::algorithm::first_finder(
m_cfg.apptag));
106 boost::split(splitNames, splitNames[1], boost::is_any_of(
"_"));
109 iter_split(splitNames, tdName,
110 boost::algorithm::first_finder(
m_cfg.sentag));
120 ACTS_VERBOSE(
"GeometryIdentifier re-constructed as " << geoID);
136 TH1F*
n =
dynamic_cast<TH1F*
>(m_inputFile->Get(nName.c_str()));
137 TH1F*
v =
dynamic_cast<TH1F*
>(m_inputFile->Get(vName.c_str()));
138 TH1F* o =
dynamic_cast<TH1F*
>(m_inputFile->Get(oName.c_str()));
139 TH1F*
min =
dynamic_cast<TH1F*
>(m_inputFile->Get(minName.c_str()));
140 TH1F* max =
dynamic_cast<TH1F*
>(m_inputFile->Get(maxName.c_str()));
141 TH2F*
t =
dynamic_cast<TH2F*
>(m_inputFile->Get(tName.c_str()));
142 TH2F*
x0 =
dynamic_cast<TH2F*
>(m_inputFile->Get(x0Name.c_str()));
143 TH2F* l0 =
dynamic_cast<TH2F*
>(m_inputFile->Get(l0Name.c_str()));
144 TH2F*
A =
dynamic_cast<TH2F*
>(m_inputFile->Get(aName.c_str()));
145 TH2F*
Z =
dynamic_cast<TH2F*
>(m_inputFile->Get(zName.c_str()));
146 TH2F*
rho =
dynamic_cast<TH2F*
>(m_inputFile->Get(rhoName.c_str()));
148 std::vector<const TH1*> hists{
n,
v, o,
min, max,
t,
x0, l0,
A,
Z, rho};
151 if (std::all_of(hists.begin(), hists.end(),
152 [](
const auto*
hist) {
return hist !=
nullptr; })) {
154 int nbins0 = t->GetNbinsX();
155 int nbins1 = t->GetNbinsY();
162 if (nbins0 * nbins1 > 1) {
164 for (
int ib0 = 1; ib0 <= nbins0; ++ib0) {
165 for (
int ib1 = 1; ib1 <= nbins1; ++ib1) {
166 double dt = t->GetBinContent(ib0, ib1);
168 double dx0 = x0->GetBinContent(ib0, ib1);
169 double dl0 = l0->GetBinContent(ib0, ib1);
170 double da = A->GetBinContent(ib0, ib1);
171 double dz = Z->GetBinContent(ib0, ib1);
172 double drho = rho->GetBinContent(ib0, ib1);
176 materialMatrix[ib1 - 1][ib0 - 1] =
184 for (
int ib = 1;
ib < n->GetNbinsX() + 1; ++
ib) {
185 size_t nbins = size_t(n->GetBinContent(
ib));
188 float rmin = min->GetBinContent(
ib);
189 float rmax = max->GetBinContent(
ib);
195 sMaterial = std::make_shared<const Acts::BinnedSurfaceMaterial>(
200 double dt = t->GetBinContent(1, 1);
201 double dx0 = x0->GetBinContent(1, 1);
202 double dl0 = l0->GetBinContent(1, 1);
203 double da = A->GetBinContent(1, 1);
204 double dz = Z->GetBinContent(1, 1);
205 double drho = rho->GetBinContent(1, 1);
209 sMaterial = std::make_shared<const Acts::HomogeneousSurfaceMaterial>(
213 ACTS_VERBOSE(
"Successfully read Material for : " << geoID);
218 }
else if (splitNames[0] ==
m_cfg.folderVolumeNameBase) {
220 std::shared_ptr<const Acts::IVolumeMaterial> vMaterial =
nullptr;
222 boost::split(splitNames, splitNames[1], boost::is_any_of(
"_"));
228 ACTS_VERBOSE(
"GeometryIdentifier re-constructed as " << geoID);
243 TH1F*
n =
dynamic_cast<TH1F*
>(m_inputFile->Get(nName.c_str()));
244 TH1F*
v =
dynamic_cast<TH1F*
>(m_inputFile->Get(vName.c_str()));
245 TH1F* o =
dynamic_cast<TH1F*
>(m_inputFile->Get(oName.c_str()));
246 TH1F*
min =
dynamic_cast<TH1F*
>(m_inputFile->Get(minName.c_str()));
247 TH1F* max =
dynamic_cast<TH1F*
>(m_inputFile->Get(maxName.c_str()));
248 TH1F*
x0 =
dynamic_cast<TH1F*
>(m_inputFile->Get(x0Name.c_str()));
249 TH1F* l0 =
dynamic_cast<TH1F*
>(m_inputFile->Get(l0Name.c_str()));
250 TH1F*
A =
dynamic_cast<TH1F*
>(m_inputFile->Get(aName.c_str()));
251 TH1F*
Z =
dynamic_cast<TH1F*
>(m_inputFile->Get(zName.c_str()));
252 TH1F*
rho =
dynamic_cast<TH1F*
>(m_inputFile->Get(rhoName.c_str()));
255 if ((x0 !=
nullptr) and (l0 !=
nullptr) and (A !=
nullptr) and
256 (Z !=
nullptr) and (rho !=
nullptr)) {
258 int points = x0->GetNbinsX();
261 if ((n !=
nullptr) and (v !=
nullptr) and (o !=
nullptr) and
262 (min !=
nullptr) and (max !=
nullptr)) {
264 int dim = n->GetNbinsX();
267 for (
int ib = 1;
ib < dim + 1; ++
ib) {
268 size_t nbins = size_t(n->GetBinContent(
ib));
271 float rmin = min->GetBinContent(
ib);
272 float rmax = max->GetBinContent(
ib);
279 std::function<Acts::Vector2(Acts::Vector3)> transfoGlobalToLocal;
292 for (
int p = 1;
p <= points;
p++) {
293 double dx0 = x0->GetBinContent(
p);
294 double dl0 = l0->GetBinContent(
p);
295 double da = A->GetBinContent(
p);
296 double dz = Z->GetBinContent(
p);
297 double drho = rho->GetBinContent(
p);
304 transfoGlobalToLocal, mGrid);
308 }
else if (dim == 3) {
310 std::function<Acts::Vector3(Acts::Vector3)> transfoGlobalToLocal;
324 for (
int p = 1;
p <= points;
p++) {
325 double dx0 = x0->GetBinContent(
p);
326 double dl0 = l0->GetBinContent(
p);
327 double da = A->GetBinContent(
p);
328 double dz = Z->GetBinContent(
p);
329 double drho = rho->GetBinContent(
p);
336 transfoGlobalToLocal, mGrid);
343 double dx0 = x0->GetBinContent(1);
344 double dl0 = l0->GetBinContent(1);
345 double da = A->GetBinContent(1);
346 double dz = Z->GetBinContent(1);
347 double drho = rho->GetBinContent(1);
352 std::make_shared<Acts::HomogeneousVolumeMaterial>(
material);
355 ACTS_VERBOSE(
"Successfully read Material for : " << geoID);
363 "Invalid FolderName, does not match any entry in the root file");
369 if (m_inputFile !=
nullptr) {
370 m_inputFile->Close();