CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
lst::TiltedGeometry Class Reference

#include <TiltedGeometry.h>

Public Member Functions

float getDrDz (unsigned int detid) const
 
float getDxDy (unsigned int detid) const
 
void load (std::string const &)
 
 TiltedGeometry ()=default
 
 TiltedGeometry (std::string const &filename)
 

Private Attributes

std::map< unsigned int, float > drdzs_
 
std::map< unsigned int, float > dxdys_
 

Detailed Description

Definition at line 9 of file TiltedGeometry.h.

Constructor & Destructor Documentation

◆ TiltedGeometry() [1/2]

lst::TiltedGeometry::TiltedGeometry ( )
default

◆ TiltedGeometry() [2/2]

lst::TiltedGeometry::TiltedGeometry ( std::string const &  filename)

Definition at line 8 of file TiltedGeometry.cc.

References corrVsCorr::filename, and load().

8 { load(filename); }
void load(std::string const &)

Member Function Documentation

◆ getDrDz()

float lst::TiltedGeometry::getDrDz ( unsigned int  detid) const

Definition at line 40 of file TiltedGeometry.cc.

References ALCARECOPPSCalTrackBasedSel_cff::detid.

Referenced by lst::loadModulesFromFile().

40  {
41  auto res = drdzs_.find(detid);
42  return res == drdzs_.end() ? 0.f : res->second;
43 }
std::map< unsigned int, float > drdzs_
Definition: Electron.h:6

◆ getDxDy()

float lst::TiltedGeometry::getDxDy ( unsigned int  detid) const

Definition at line 45 of file TiltedGeometry.cc.

References ALCARECOPPSCalTrackBasedSel_cff::detid.

Referenced by lst::loadModulesFromFile().

45  {
46  auto res = dxdys_.find(detid);
47  return res == dxdys_.end() ? 0.f : res->second;
48 }
std::map< unsigned int, float > dxdys_
Definition: Electron.h:6

◆ load()

void lst::TiltedGeometry::load ( std::string const &  filename)

Definition at line 10 of file TiltedGeometry.cc.

References ALCARECOPPSCalTrackBasedSel_cff::detid, corrVsCorr::filename, and compare_using_db::ifile.

Referenced by TiltedGeometry().

10  {
11  drdzs_.clear();
12  dxdys_.clear();
13 
14  std::ifstream ifile(filename, std::ios::binary);
15  if (!ifile.is_open()) {
16  throw std::runtime_error("Unable to open file: " + filename);
17  }
18 
19  while (!ifile.eof()) {
20  unsigned int detid;
21  float drdz, dxdy;
22 
23  // Read the detid, drdz, and dxdy from binary file
24  ifile.read(reinterpret_cast<char*>(&detid), sizeof(detid));
25  ifile.read(reinterpret_cast<char*>(&drdz), sizeof(drdz));
26  ifile.read(reinterpret_cast<char*>(&dxdy), sizeof(dxdy));
27 
28  if (ifile) {
29  drdzs_[detid] = drdz;
30  dxdys_[detid] = dxdy;
31  } else {
32  // End of file or read failed
33  if (!ifile.eof()) {
34  throw std::runtime_error("Failed to read Tilted Geometry binary data.");
35  }
36  }
37  }
38 }
std::map< unsigned int, float > dxdys_
std::map< unsigned int, float > drdzs_

Member Data Documentation

◆ drdzs_

std::map<unsigned int, float> lst::TiltedGeometry::drdzs_
private

Definition at line 11 of file TiltedGeometry.h.

◆ dxdys_

std::map<unsigned int, float> lst::TiltedGeometry::dxdys_
private

Definition at line 12 of file TiltedGeometry.h.