CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
mkfit::TrackerInfo Class Reference

#include <TrackerInfo.h>

Public Types

enum  EtaRegion {
  Reg_Begin = 0, Reg_Endcap_Neg = 0, Reg_Transition_Neg, Reg_Barrel,
  Reg_Transition_Pos, Reg_Endcap_Pos, Reg_End, Reg_Count = Reg_End
}
 

Public Member Functions

const std::vector< int > & barrel_layers () const
 
void create_layers (int n_brl, int n_ec_pos, int n_ec_neg)
 
const std::vector< int > & endcap_neg_layers () const
 
const std::vector< int > & endcap_pos_layers () const
 
const LayerInfolayer (int l) const
 
LayerInfolayer_nc (int l)
 
int n_layers () const
 
int n_total_modules () const
 
LayerInfonew_barrel_layer ()
 
LayerInfonew_ecap_neg_layer ()
 
LayerInfonew_ecap_pos_layer ()
 
const LayerInfooperator[] (int l) const
 
const LayerInfoouter_barrel_layer () const
 
void print_tracker (int level) const
 
void read_bin_file (const std::string &fname)
 
void reserve_layers (int n_brl, int n_ec_pos, int n_ec_neg)
 
void write_bin_file (const std::string &fname) const
 

Private Member Functions

int new_layer (LayerInfo::LayerType_e type)
 

Private Attributes

std::vector< int > m_barrel
 
std::vector< int > m_ecap_neg
 
std::vector< int > m_ecap_pos
 
std::vector< LayerInfom_layers
 

Detailed Description

Definition at line 142 of file TrackerInfo.h.

Member Enumeration Documentation

◆ EtaRegion

Enumerator
Reg_Begin 
Reg_Endcap_Neg 
Reg_Transition_Neg 
Reg_Barrel 
Reg_Transition_Pos 
Reg_Endcap_Pos 
Reg_End 
Reg_Count 

Definition at line 144 of file TrackerInfo.h.

Member Function Documentation

◆ barrel_layers()

const std::vector<int>& mkfit::TrackerInfo::barrel_layers ( ) const
inline

Definition at line 171 of file TrackerInfo.h.

References m_barrel.

171 { return m_barrel; }
std::vector< int > m_barrel
Definition: TrackerInfo.h:184

◆ create_layers()

void mkfit::TrackerInfo::create_layers ( int  n_brl,
int  n_ec_pos,
int  n_ec_neg 
)

Definition at line 59 of file TrackerInfo.cc.

References mps_fire::i, new_barrel_layer(), new_ecap_neg_layer(), new_ecap_pos_layer(), and reserve_layers().

59  {
60  reserve_layers(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)
67  }
LayerInfo & new_barrel_layer()
Definition: TrackerInfo.cc:75
LayerInfo & new_ecap_neg_layer()
Definition: TrackerInfo.cc:85
LayerInfo & new_ecap_pos_layer()
Definition: TrackerInfo.cc:80
void reserve_layers(int n_brl, int n_ec_pos, int n_ec_neg)
Definition: TrackerInfo.cc:52

◆ endcap_neg_layers()

const std::vector<int>& mkfit::TrackerInfo::endcap_neg_layers ( ) const
inline

Definition at line 173 of file TrackerInfo.h.

References m_ecap_neg.

173 { return m_ecap_neg; }
std::vector< int > m_ecap_neg
Definition: TrackerInfo.h:186

◆ endcap_pos_layers()

const std::vector<int>& mkfit::TrackerInfo::endcap_pos_layers ( ) const
inline

Definition at line 172 of file TrackerInfo.h.

References m_ecap_pos.

172 { return m_ecap_pos; }
std::vector< int > m_ecap_pos
Definition: TrackerInfo.h:185

◆ layer()

const LayerInfo& mkfit::TrackerInfo::layer ( int  l) const
inline

◆ layer_nc()

LayerInfo& mkfit::TrackerInfo::layer_nc ( int  l)
inline

◆ n_layers()

int mkfit::TrackerInfo::n_layers ( ) const
inline

Definition at line 161 of file TrackerInfo.h.

References m_layers.

Referenced by mkfit::EventOfHits::EventOfHits(), main(), print_tracker(), mkfit::TTreeValidation::TTreeValidation(), and write_bin_file().

161 { return m_layers.size(); }
std::vector< LayerInfo > m_layers
Definition: TrackerInfo.h:182

◆ n_total_modules()

int mkfit::TrackerInfo::n_total_modules ( ) const

Definition at line 90 of file TrackerInfo.cc.

References cmsLHEtoEOSManager::l, and m_layers.

90  {
91  int nm = 0;
92  for (auto& l : m_layers)
93  nm += l.n_modules();
94  return nm;
95  }
std::vector< LayerInfo > m_layers
Definition: TrackerInfo.h:182

◆ new_barrel_layer()

LayerInfo & mkfit::TrackerInfo::new_barrel_layer ( )

Definition at line 75 of file TrackerInfo.cc.

References mkfit::LayerInfo::Barrel, m_barrel, m_layers, and new_layer().

Referenced by create_layers().

75  {
77  return m_layers.back();
78  }
std::vector< int > m_barrel
Definition: TrackerInfo.h:184
int new_layer(LayerInfo::LayerType_e type)
Definition: TrackerInfo.cc:69
std::vector< LayerInfo > m_layers
Definition: TrackerInfo.h:182

◆ new_ecap_neg_layer()

LayerInfo & mkfit::TrackerInfo::new_ecap_neg_layer ( )

Definition at line 85 of file TrackerInfo.cc.

References mkfit::LayerInfo::EndCapNeg, m_ecap_neg, m_layers, and new_layer().

Referenced by create_layers().

85  {
87  return m_layers.back();
88  }
std::vector< int > m_ecap_neg
Definition: TrackerInfo.h:186
int new_layer(LayerInfo::LayerType_e type)
Definition: TrackerInfo.cc:69
std::vector< LayerInfo > m_layers
Definition: TrackerInfo.h:182

◆ new_ecap_pos_layer()

LayerInfo & mkfit::TrackerInfo::new_ecap_pos_layer ( )

Definition at line 80 of file TrackerInfo.cc.

References mkfit::LayerInfo::EndCapPos, m_ecap_pos, m_layers, and new_layer().

Referenced by create_layers().

80  {
82  return m_layers.back();
83  }
int new_layer(LayerInfo::LayerType_e type)
Definition: TrackerInfo.cc:69
std::vector< int > m_ecap_pos
Definition: TrackerInfo.h:185
std::vector< LayerInfo > m_layers
Definition: TrackerInfo.h:182

◆ new_layer()

int mkfit::TrackerInfo::new_layer ( LayerInfo::LayerType_e  type)
private

◆ operator[]()

const LayerInfo& mkfit::TrackerInfo::operator[] ( int  l) const
inline

Definition at line 167 of file TrackerInfo.h.

References cmsLHEtoEOSManager::l, and m_layers.

167 { return m_layers[l]; }
std::vector< LayerInfo > m_layers
Definition: TrackerInfo.h:182

◆ outer_barrel_layer()

const LayerInfo& mkfit::TrackerInfo::outer_barrel_layer ( ) const
inline

Definition at line 169 of file TrackerInfo.h.

References m_barrel, and m_layers.

169 { return m_layers[m_barrel.back()]; }
std::vector< int > m_barrel
Definition: TrackerInfo.h:184
std::vector< LayerInfo > m_layers
Definition: TrackerInfo.h:182

◆ print_tracker()

void mkfit::TrackerInfo::print_tracker ( int  level) const

Definition at line 237 of file TrackerInfo.cc.

References mkfit::ModuleInfo::detid, mps_fire::i, dqmiolumiharvest::j, layer(), personalPlayback::level, mkfit::LayerInfo::module_info(), n_layers(), mkfit::LayerInfo::n_modules(), AlCaHLTBitMon_ParallelJobs::p, mkfit::ModuleInfo::pos, mkfit::LayerInfo::print_layer(), x, mkfit::ModuleInfo::xdir, and mkfit::ModuleInfo::zdir.

237  {
238  if (level > 0) {
239  for (int i = 0; i < n_layers(); ++i) {
240  const LayerInfo& li = layer(i);
241  li.print_layer();
242  if (level > 1) {
243  printf(" Detailed module list N=%d\n", li.n_modules());
244  for (int j = 0; j < li.n_modules(); ++j) {
245  const ModuleInfo& mi = li.module_info(j);
246  auto* p = mi.pos.Array();
247  auto* z = mi.zdir.Array();
248  auto* x = mi.xdir.Array();
249  // clang-format off
250  printf("Layer %d, mid=%u; detid=0x%x pos=%.3f,%.3f,%.3f, "
251  "norm=%.3f,%.3f,%.3f, phi=%.3f,%.3f,%.3f\n",
252  i, j, mi.detid, p[0], p[1], p[2],
253  z[0], z[1], z[2], x[0], x[1], x[2]);
254  // clang-format on
255  }
256  printf("\n");
257  }
258  }
259  }
260  }
float float float z
int n_layers() const
Definition: TrackerInfo.h:161
const LayerInfo & layer(int l) const
Definition: TrackerInfo.h:162
float x

◆ read_bin_file()

void mkfit::TrackerInfo::read_bin_file ( const std::string &  fname)

Definition at line 168 of file TrackerInfo.cc.

References alignmentValidation::fname, personalPlayback::fp, cmsLHEtoEOSManager::l, visualization-live-secondInstance_cfg::m, m_barrel, mkfit::LayerInfo::m_detid2sid, m_ecap_neg, m_ecap_pos, m_layers, mkfit::LayerInfo::m_modules, and submitPVResolutionJobs::stderr.

Referenced by mkfit::execTrackerInfoCreatorPlugin(), and main().

168  {
169  FILE* fp = fopen(fname.c_str(), "r");
170  if (!fp) {
171  fprintf(stderr,
172  "TrackerInfo::read_bin_file error opening file '%s', errno=%d: '%s'\n",
173  fname.c_str(),
174  errno,
175  strerror(errno));
176  throw std::runtime_error("Failed opening file in TrackerInfo::read_bin_file");
177  }
178  GeomFileHeader fh;
179  fread(&fh, sizeof(GeomFileHeader), 1, fp);
180 
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");
184  }
185  if (fh.f_format_version != GeomFileHeader::s_version) {
186  fprintf(stderr,
187  "Unsupported file version %d. Supported version is %d.\n",
188  fh.f_format_version,
189  GeomFileHeader::s_version);
190  throw std::runtime_error("Unsupported file version in TrackerInfo::read_bin_file");
191  }
192  if (fh.f_sizeof_trackerinfo != sizeof(TrackerInfo)) {
193  fprintf(stderr,
194  "sizeof(TrackerInfo) on file (%d) different from current value (%d).\n",
195  fh.f_sizeof_trackerinfo,
196  (int)sizeof(TrackerInfo));
197  throw std::runtime_error("sizeof(TrackerInfo) mismatch in TrackerInfo::read_bin_file");
198  }
199  if (fh.f_sizeof_layerinfo != sizeof(LayerInfo)) {
200  fprintf(stderr,
201  "sizeof(LayerInfo) on file (%d) different from current value (%d).\n",
202  fh.f_sizeof_layerinfo,
203  (int)sizeof(LayerInfo));
204  throw std::runtime_error("sizeof(LayerInfo) mismatch in TrackerInfo::read_bin_file");
205  }
206  if (fh.f_sizeof_moduleinfo != sizeof(ModuleInfo)) {
207  fprintf(stderr,
208  "sizeof(ModuleInfo) on file (%d) different from current value (%d).\n",
209  fh.f_sizeof_moduleinfo,
210  (int)sizeof(ModuleInfo));
211  throw std::runtime_error("sizeof(ModuleInfo) mismatch in TrackerInfo::read_bin_file");
212  }
213 
214  printf("Opened TrackerInfoGeom file '%s', format version %d, n_layers %d\n",
215  fname.c_str(),
216  fh.f_format_version,
217  fh.f_n_layers);
218 
219  read_std_vec(fp, m_layers, (int)(offsetof(LayerInfo, m_is_pixel)) + 1);
220  read_std_vec(fp, m_barrel);
221  read_std_vec(fp, m_ecap_pos);
222  read_std_vec(fp, m_ecap_neg);
223 
224  for (int l = 0; l < fh.f_n_layers; ++l) {
225  LayerInfo& li = m_layers[l];
226  int nm = read_std_vec(fp, li.m_modules);
227 
228  li.m_detid2sid.clear();
229  for (int m = 0; m < nm; ++m) {
230  li.m_detid2sid.insert({li.m_modules[m].detid, m});
231  }
232  }
233 
234  fclose(fp);
235  }
std::vector< int > m_barrel
Definition: TrackerInfo.h:184
std::vector< int > m_ecap_neg
Definition: TrackerInfo.h:186
std::vector< int > m_ecap_pos
Definition: TrackerInfo.h:185
string fname
main script
std::vector< LayerInfo > m_layers
Definition: TrackerInfo.h:182

◆ reserve_layers()

void mkfit::TrackerInfo::reserve_layers ( int  n_brl,
int  n_ec_pos,
int  n_ec_neg 
)

Definition at line 52 of file TrackerInfo.cc.

References m_barrel, m_ecap_neg, m_ecap_pos, and m_layers.

Referenced by create_layers().

52  {
53  m_layers.reserve(n_brl + n_ec_pos + n_ec_neg);
54  m_barrel.reserve(n_brl);
55  m_ecap_pos.reserve(n_ec_pos);
56  m_ecap_neg.reserve(n_ec_neg);
57  }
std::vector< int > m_barrel
Definition: TrackerInfo.h:184
std::vector< int > m_ecap_neg
Definition: TrackerInfo.h:186
std::vector< int > m_ecap_pos
Definition: TrackerInfo.h:185
std::vector< LayerInfo > m_layers
Definition: TrackerInfo.h:182

◆ write_bin_file()

void mkfit::TrackerInfo::write_bin_file ( const std::string &  fname) const

Definition at line 142 of file TrackerInfo.cc.

References alignmentValidation::fname, personalPlayback::fp, cmsLHEtoEOSManager::l, m_barrel, m_ecap_neg, m_ecap_pos, m_layers, n_layers(), and submitPVResolutionJobs::stderr.

142  {
143  FILE* fp = fopen(fname.c_str(), "w");
144  if (!fp) {
145  fprintf(stderr,
146  "TrackerInfo::write_bin_file error opening file '%s', errno=%d: '%s'",
147  fname.c_str(),
148  errno,
149  strerror(errno));
150  throw std::runtime_error("Filed opening file in TrackerInfo::write_bin_file");
151  }
152  GeomFileHeader fh;
153  fh.f_n_layers = n_layers();
154  fwrite(&fh, sizeof(GeomFileHeader), 1, fp);
155 
156  write_std_vec(fp, m_layers, (int)(offsetof(LayerInfo, m_is_pixel)) + 1);
157  write_std_vec(fp, m_barrel);
158  write_std_vec(fp, m_ecap_pos);
159  write_std_vec(fp, m_ecap_neg);
160 
161  for (int l = 0; l < fh.f_n_layers; ++l) {
162  write_std_vec(fp, m_layers[l].m_modules);
163  }
164 
165  fclose(fp);
166  }
std::vector< int > m_barrel
Definition: TrackerInfo.h:184
std::vector< int > m_ecap_neg
Definition: TrackerInfo.h:186
int n_layers() const
Definition: TrackerInfo.h:161
std::vector< int > m_ecap_pos
Definition: TrackerInfo.h:185
string fname
main script
std::vector< LayerInfo > m_layers
Definition: TrackerInfo.h:182

Member Data Documentation

◆ m_barrel

std::vector<int> mkfit::TrackerInfo::m_barrel
private

◆ m_ecap_neg

std::vector<int> mkfit::TrackerInfo::m_ecap_neg
private

◆ m_ecap_pos

std::vector<int> mkfit::TrackerInfo::m_ecap_pos
private

◆ m_layers

std::vector<LayerInfo> mkfit::TrackerInfo::m_layers
private