39 printf(
"Layer %2d r(%7.4f, %7.4f) z(% 9.4f, % 9.4f) is_brl=%d, is_pix=%d, is_stereo=%d, q_bin=%.2f\n",
53 m_layers.reserve(n_brl + n_ec_pos + n_ec_neg);
61 for (
int i = 0;
i < n_brl; ++
i)
63 for (
int i = 0;
i < n_ec_pos; ++
i)
65 for (
int i = 0;
i < n_ec_neg; ++
i)
100 struct GeomFileHeader {
101 int f_magic = s_magic;
102 int f_format_version = s_version;
104 int f_sizeof_layerinfo =
sizeof(
LayerInfo);
108 GeomFileHeader() =
default;
110 constexpr
static int s_magic = 0xB00F;
111 constexpr
static int s_version = 1;
114 template <
typename T>
115 int write_std_vec(FILE*
fp,
const std::vector<T>& vec,
int el_size = 0) {
117 fwrite(&
n,
sizeof(
int), 1,
fp);
119 fwrite(vec.data(),
sizeof(
T),
n,
fp);
121 for (
int i = 0;
i <
n; ++
i)
122 fwrite(&vec[
i], el_size, 1,
fp);
127 template <
typename T>
128 int read_std_vec(FILE*
fp, std::vector<T>& vec,
int el_size = 0) {
130 fread(&
n,
sizeof(
int), 1,
fp);
133 fread(vec.data(),
sizeof(
T),
n,
fp);
135 for (
int i = 0;
i <
n; ++
i)
136 fread(&vec[
i], el_size, 1,
fp);
143 FILE*
fp = fopen(
fname.c_str(),
"w");
146 "TrackerInfo::write_bin_file error opening file '%s', errno=%d: '%s'",
150 throw std::runtime_error(
"Filed opening file in TrackerInfo::write_bin_file");
154 fwrite(&fh,
sizeof(GeomFileHeader), 1,
fp);
161 for (
int l = 0;
l < fh.f_n_layers; ++
l) {
169 FILE*
fp = fopen(
fname.c_str(),
"r");
172 "TrackerInfo::read_bin_file error opening file '%s', errno=%d: '%s'\n",
176 throw std::runtime_error(
"Failed opening file in TrackerInfo::read_bin_file");
179 fread(&fh,
sizeof(GeomFileHeader), 1,
fp);
181 if (fh.f_magic != GeomFileHeader::s_magic) {
182 fprintf(
stderr,
"Incompatible input file (wrong magick).\n");
183 throw std::runtime_error(
"Filed opening file in TrackerInfo::read_bin_file");
185 if (fh.f_format_version != GeomFileHeader::s_version) {
187 "Unsupported file version %d. Supported version is %d.\n",
189 GeomFileHeader::s_version);
190 throw std::runtime_error(
"Unsupported file version in TrackerInfo::read_bin_file");
192 if (fh.f_sizeof_trackerinfo !=
sizeof(
TrackerInfo)) {
194 "sizeof(TrackerInfo) on file (%d) different from current value (%d).\n",
195 fh.f_sizeof_trackerinfo,
197 throw std::runtime_error(
"sizeof(TrackerInfo) mismatch in TrackerInfo::read_bin_file");
199 if (fh.f_sizeof_layerinfo !=
sizeof(
LayerInfo)) {
201 "sizeof(LayerInfo) on file (%d) different from current value (%d).\n",
202 fh.f_sizeof_layerinfo,
204 throw std::runtime_error(
"sizeof(LayerInfo) mismatch in TrackerInfo::read_bin_file");
206 if (fh.f_sizeof_moduleinfo !=
sizeof(
ModuleInfo)) {
208 "sizeof(ModuleInfo) on file (%d) different from current value (%d).\n",
209 fh.f_sizeof_moduleinfo,
211 throw std::runtime_error(
"sizeof(ModuleInfo) mismatch in TrackerInfo::read_bin_file");
214 printf(
"Opened TrackerInfoGeom file '%s', format version %d, n_layers %d\n",
224 for (
int l = 0;
l < fh.f_n_layers; ++
l) {
229 for (
int m = 0;
m < nm; ++
m) {
243 printf(
" Detailed module list N=%d\n", li.
n_modules());
246 auto*
p = mi.
pos.Array();
247 auto* z = mi.
zdir.Array();
248 auto*
x = mi.
xdir.Array();
250 printf(
"Layer %d, mid=%u; detid=0x%x pos=%.3f,%.3f,%.3f, " 251 "norm=%.3f,%.3f,%.3f, phi=%.3f,%.3f,%.3f\n",
253 z[0], z[1], z[2],
x[0],
x[1],
x[2]);
void extend_limits(float r, float z)
void read_bin_file(const std::string &fname)
void set_r_hole_range(float rh1, float rh2)
std::vector< int > m_barrel
LayerInfo & new_barrel_layer()
std::vector< int > m_ecap_neg
LayerInfo & new_ecap_neg_layer()
void set_r_in_out(float r1, float r2)
std::vector< ModuleInfo > m_modules
void set_limits(float r1, float r2, float z1, float z2)
const ModuleInfo & module_info(unsigned int sid) const
LayerInfo & new_ecap_pos_layer()
int new_layer(LayerInfo::LayerType_e type)
void create_layers(int n_brl, int n_ec_pos, int n_ec_neg)
const LayerInfo & layer(int l) const
int n_total_modules() const
void print_tracker(int level) const
std::vector< int > m_ecap_pos
void write_bin_file(const std::string &fname) const
std::unordered_map< unsigned int, unsigned int > m_detid2sid
std::vector< LayerInfo > m_layers
void reserve_layers(int n_brl, int n_ec_pos, int n_ec_neg)