57 printf(
"Layer %2d r(%7.4f, %7.4f) z(% 9.4f, % 9.4f)" 58 " is_brl=%d, is_pix=%d, is_stereo=%d, has_charge=%d, q_bin=%.2f\n",
71 m_layers.reserve(n_brl + n_ec_pos + n_ec_neg);
79 for (
int i = 0;
i < n_brl; ++
i)
81 for (
int i = 0;
i < n_ec_pos; ++
i)
83 for (
int i = 0;
i < n_ec_neg; ++
i)
130 struct GeomFileHeader {
131 int f_magic = s_magic;
132 int f_format_version = s_version;
134 int f_sizeof_layerinfo =
sizeof(
LayerInfo);
139 GeomFileHeader() =
default;
145 template <
typename T>
146 int write_std_vec(FILE*
fp,
const std::vector<T>& vec,
int el_size = 0) {
148 fwrite(&
n,
sizeof(
int), 1,
fp);
150 fwrite(vec.data(),
sizeof(
T),
n,
fp);
152 for (
int i = 0;
i <
n; ++
i)
153 fwrite(&vec[
i], el_size, 1,
fp);
158 template <
typename T>
159 int read_std_vec(FILE*
fp, std::vector<T>& vec,
int el_size = 0) {
161 fread(&
n,
sizeof(
int), 1,
fp);
164 fread(vec.data(),
sizeof(
T),
n,
fp);
166 for (
int i = 0;
i <
n; ++
i)
167 fread(&vec[
i], el_size, 1,
fp);
172 void assert_sizeof_match(
int size_on_file,
int size_of_class,
const char* class_name) {
173 if (size_on_file != size_of_class) {
175 "sizeof(%s) on file (%d) different from current value (%d).\n",
179 throw std::runtime_error(
"class sizeof mismatch for " +
std::string(class_name));
185 FILE*
fp = fopen(
fname.c_str(),
"w");
188 "TrackerInfo::write_bin_file error opening file '%s', errno=%d: '%s'",
192 throw std::runtime_error(
"Filed opening file in TrackerInfo::write_bin_file");
196 fwrite(&fh,
sizeof(GeomFileHeader), 1,
fp);
203 for (
int l = 0;
l < fh.f_n_layers; ++
l) {
216 FILE*
fp = fopen(
fname.c_str(),
"r");
219 "TrackerInfo::read_bin_file error opening file '%s', errno=%d: '%s'\n",
223 throw std::runtime_error(
"Failed opening file in TrackerInfo::read_bin_file");
226 fread(&fh,
sizeof(GeomFileHeader), 1,
fp);
228 if (fh.f_magic != GeomFileHeader::s_magic) {
229 fprintf(
stderr,
"Incompatible input file (wrong magick).\n");
230 throw std::runtime_error(
"Filed opening file in TrackerInfo::read_bin_file");
232 if (fh.f_format_version != GeomFileHeader::s_version) {
234 "Unsupported file version %d. Supported version is %d.\n",
236 GeomFileHeader::s_version);
237 throw std::runtime_error(
"Unsupported file version in TrackerInfo::read_bin_file");
239 assert_sizeof_match(fh.f_sizeof_trackerinfo,
sizeof(
TrackerInfo),
"TrackerInfo");
240 assert_sizeof_match(fh.f_sizeof_layerinfo,
sizeof(
LayerInfo),
"LayerInfo");
241 assert_sizeof_match(fh.f_sizeof_moduleinfo,
sizeof(
ModuleInfo),
"ModuleInfo");
242 assert_sizeof_match(fh.f_sizeof_moduleshape,
sizeof(
ModuleShape),
"ModuleShape");
244 printf(
"Opened TrackerInfoGeom file '%s', format version %d, n_layers %d\n",
254 for (
int l = 0;
l < fh.f_n_layers; ++
l) {
259 for (
int m = 0;
m < nm; ++
m) {
280 printf(
" Detailed module list N=%d, N_shapes=%d\n", li.
n_modules(), li.
n_shapes());
284 printf(
" Shape id=%u: dx1=%.*f, dx2=%.*f, dy=%.*f, dz=%.*f\n",
289 auto*
p = mi.
pos.Array();
290 auto* z = mi.
zdir.Array();
291 auto*
x = mi.
xdir.Array();
293 printf(
" Module id=%u: detid=0x%x shapeid=%u pos=%.*f,%.*f,%.*f, " 294 "norm=%.*f,%.*f,%.*f, phi=%.*f,%.*f,%.*f\n",
296 w, z[0],
w, z[1],
w, z[2],
w,
x[0],
w,
x[1],
w,
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
PropagationFlags forward_fit_pflags
LayerInfo & new_barrel_layer()
PropagationFlags backward_fit_pflags
const TrackerInfo * tracker_info
std::vector< int > m_ecap_neg
LayerInfo & new_ecap_neg_layer()
void create_material(int nBinZ, float rngZ, int nBinR, float rngR)
void set_r_in_out(float r1, float r2)
std::vector< ModuleInfo > m_modules
PropagationFlags finding_inter_layer_pflags
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)
PropagationFlags seed_fit_pflags
void create_layers(int n_brl, int n_ec_pos, int n_ec_neg)
PropagationFlags pca_prop_pflags
const LayerInfo & layer(int l) const
rectvec< Material > m_mat_vec
int n_total_modules() const
const ModuleShape & module_shape(unsigned short msid) const
std::vector< int > m_ecap_pos
void apply_tracker_info(const TrackerInfo *ti)
void print_tracker(int level, int precision=3) const
void write_bin_file(const std::string &fname) const
PropagationFlags finding_intra_layer_pflags
std::unordered_map< unsigned int, unsigned int > m_detid2sid
std::vector< ModuleShape > m_shapes
std::vector< LayerInfo > m_layers
void reserve_layers(int n_brl, int n_ec_pos, int n_ec_neg)