Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
materialPlotHelper.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file materialPlotHelper.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 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 #include "materialPlotHelper.hpp"
10 
11 #include <iomanip>
12 #include <ostream>
13 #include <string>
14 
16 
17 struct sinfo {
21  int type;
22  float pos;
23  float range_min;
24  float range_max;
25 };
26 
27 std::ostream& Acts::operator<<(std::ostream& os, Acts::GeometryIdentifier id) {
28  os << "[ " << std::setw(3) << id.volume();
29  os << " | " << std::setw(3) << id.boundary();
30  os << " | " << std::setw(3) << id.layer();
31  os << " | " << std::setw(3) << id.approach();
32  os << " | " << std::setw(4) << id.sensitive() << " ]";
33  return os;
34 }
35 
37 
38 void Initialise_info(sinfo& surface_info,
39  const std::map<std::string, std::string>& surface_name,
40  const uint64_t& id, const int& type, const float& pos,
41  const float& range_min, const float& range_max) {
43  std::ostringstream layerID;
44  layerID << ID;
45  std::string surface_id = layerID.str();
46 
47  std::string Id_temp = surface_id;
48  std::string delimiter = " | ";
49  size_t del_pos = 0;
50  std::vector<std::string> Ids;
51  while ((del_pos = Id_temp.find(delimiter)) != std::string::npos) {
52  Ids.push_back(Id_temp.substr(0, del_pos));
53  Id_temp.erase(0, del_pos + delimiter.length());
54  }
55  Ids.push_back(Id_temp);
56 
57  for (int tag = 0; tag < 5; tag++) {
58  Ids[tag].erase(std::remove(Ids[tag].begin(), Ids[tag].end(), ' '),
59  Ids[tag].end());
60  Ids[tag].erase(std::remove(Ids[tag].begin(), Ids[tag].end(), '['),
61  Ids[tag].end());
62  Ids[tag].erase(std::remove(Ids[tag].begin(), Ids[tag].end(), ']'),
63  Ids[tag].end());
64  }
65 
66  surface_info.idname = "v" + Ids[0] + "_b" + Ids[1] + "_l" + Ids[2] + "_a" +
67  Ids[3] + "_s" + Ids[4];
68  surface_info.type = type;
69 
70  if (surface_name.find(surface_id) != surface_name.end()) {
71  surface_info.name = surface_name.at(surface_id);
72  } else
73  surface_info.name = "";
74 
75  surface_info.id = surface_id;
76  surface_info.pos = pos;
77  surface_info.range_min = range_min;
78  surface_info.range_max = range_max;
79 }