CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes | Static Protected Attributes
l1tpf_impl::COEFile Class Reference

#include <COEFile.h>

Public Member Functions

void close ()
 
 COEFile (const edm::ParameterSet &)
 
template<typename T >
bool getBit (T value, unsigned bit)
 
bool is_open ()
 
void writeHeaderToFile ()
 
void writeTracksToFile (const std::vector< Region > &regions, bool print=false)
 
 ~COEFile ()
 

Protected Attributes

boost::dynamic_bitset bset_
 
std::string bset_string_
 
std::string coeFileName
 
int debug_
 
FILE * file
 
unsigned int ntracksmax
 
unsigned int phiSlices
 
const std::vector< uint32_t > track_word_block_sizes = {14, 1, 12, 16, 12, 13, 4, 3, 7, 14}
 

Static Protected Attributes

static constexpr unsigned int tracksize = 96
 

Detailed Description

Definition at line 19 of file COEFile.h.

Constructor & Destructor Documentation

◆ COEFile()

COEFile::COEFile ( const edm::ParameterSet iConfig)

Definition at line 5 of file COEFile.cc.

References bset_, coeFileName, file, tracksize, and writeHeaderToFile().

6  : file(nullptr),
7  coeFileName(iConfig.getUntrackedParameter<std::string>("coeFileName", "")),
8  bset_string_(""),
9  ntracksmax(iConfig.getUntrackedParameter<unsigned int>("ntracksmax")),
10  phiSlices(iConfig.getParameter<std::vector<edm::ParameterSet>>("regions")[0].getParameter<uint32_t>("phiSlices")),
11  debug_(iConfig.getUntrackedParameter<int>("debug", 0)) {
12  file = fopen(coeFileName.c_str(), "w");
14  bset_.resize(tracksize);
15 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static constexpr unsigned int tracksize
Definition: COEFile.h:37
T getUntrackedParameter(std::string const &, T const &) const
unsigned int phiSlices
Definition: COEFile.h:36
std::string bset_string_
Definition: COEFile.h:35
unsigned int ntracksmax
Definition: COEFile.h:36
boost::dynamic_bitset bset_
Definition: COEFile.h:38
void writeHeaderToFile()
Definition: COEFile.cc:19
std::string coeFileName
Definition: COEFile.h:35

◆ ~COEFile()

COEFile::~COEFile ( )

Definition at line 17 of file COEFile.cc.

17 {}

Member Function Documentation

◆ close()

void l1tpf_impl::COEFile::close ( void  )
inline

Definition at line 24 of file COEFile.h.

References file.

Referenced by esMonitoring.AsyncLineReaderMixin::handle_close(), and esMonitoring.FDJsonServer::handle_close().

24 { fclose(file); }

◆ getBit()

template<typename T >
bool l1tpf_impl::COEFile::getBit ( T  value,
unsigned  bit 
)
inline

Definition at line 26 of file COEFile.h.

26  {
27  return (value >> bit) & 1;
28  }
Definition: value.py:1

◆ is_open()

bool l1tpf_impl::COEFile::is_open ( )
inline

Definition at line 29 of file COEFile.h.

References file.

29 { return (file != nullptr); }

◆ writeHeaderToFile()

void COEFile::writeHeaderToFile ( )

Definition at line 19 of file COEFile.cc.

References file, mps_fire::i, ntracksmax, phiSlices, AlCaHLTBitMon_QueryRunRegistry::string, and tracksize.

Referenced by COEFile().

19  {
20  char depth_width[256];
21  snprintf(depth_width,
22  255,
23  "; of depth=%i, and width=%i. In this case, values are specified\n",
24  ntracksmax,
26  std::vector<std::string> vheader = {"; Sample memory initialization file for Dual Port Block Memory,\n",
27  "; v3.0 or later.\n",
28  "; Board: VCU118\n",
29  "; tmux: 1\n",
30  ";\n",
31  "; This .COE file specifies the contents for a block memory\n",
32  std::string(depth_width),
33  "; in binary format.\n",
34  "memory_initialization_radix=2;\n",
35  "memory_initialization_vector=\n"};
36  for (uint32_t i = 0; i < vheader.size(); ++i)
37  fprintf(file, "%s", vheader[i].c_str());
38 }
static constexpr unsigned int tracksize
Definition: COEFile.h:37
unsigned int phiSlices
Definition: COEFile.h:36
unsigned int ntracksmax
Definition: COEFile.h:36

◆ writeTracksToFile()

void COEFile::writeTracksToFile ( const std::vector< Region > &  regions,
bool  print = false 
)

Definition at line 40 of file COEFile.cc.

References bset_, bset_string_, debug_, ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, file, l1tpf_impl::InputTrack::hwCharge, l1tpf_impl::InputTrack::hwChi2, l1t::L1Candidate::hwEta(), l1t::L1Candidate::hwPhi(), l1t::L1Candidate::hwPt(), l1tpf_impl::PropagatedTrack::hwPt, l1tpf_impl::InputTrack::hwStubs, l1tpf_impl::InputTrack::hwVtxEta, l1tpf_impl::InputTrack::hwVtxPhi, l1tpf_impl::InputTrack::hwZ0, ntracksmax, hltrates_dqm_sourceclient-live_cfg::offset, reco::LeafCandidate::p4(), print(), l1tpf_impl::InputTrack::src, cond::impl::to_string(), HLT_2022v12_cff::track, and track_word_block_sizes.

40  {
41  PropagatedTrack current_track;
42  bool has_track = false;
43  for (unsigned int irow = 0; irow < ntracksmax; irow++) {
44  for (unsigned int icol = 0; icol < regions.size(); icol++) {
45  if (regions[icol].track.size() <= irow)
46  has_track = false;
47  else
48  has_track = true;
49 
50  if (has_track) {
51  // select the track that will be converted to a bit string
52  current_track = regions[icol].track[irow];
53 
54  // convert the values in a PropogatedTrack to a 96-bit track word
55  for (unsigned int iblock = 0; iblock < track_word_block_sizes.size(); iblock++) {
56  for (unsigned int ibit = 0; ibit < track_word_block_sizes[iblock]; ibit++) {
57  int offset = std::accumulate(track_word_block_sizes.begin(), track_word_block_sizes.begin() + iblock, 0);
58  switch (iblock) {
59  case 0:
60  bset_.set(ibit + offset, getBit<uint16_t>(current_track.hwPt, ibit));
61  break;
62  case 1:
63  bset_.set(ibit + offset, current_track.hwCharge);
64  break;
65  case 2:
66  bset_.set(ibit + offset, getBit<uint16_t>(current_track.hwVtxPhi, ibit));
67  break;
68  case 3:
69  bset_.set(ibit + offset, getBit<uint16_t>(current_track.hwVtxEta, ibit));
70  break;
71  case 4:
72  bset_.set(ibit + offset, getBit<uint16_t>(current_track.hwZ0, ibit));
73  break;
74  case 5:
75  bset_.set(ibit + offset, false);
76  break;
77  case 6:
78  bset_.set(ibit + offset, getBit<uint16_t>(current_track.hwChi2, ibit));
79  break;
80  case 7:
81  bset_.set(ibit + offset, false);
82  break;
83  case 8:
84  bset_.set(ibit + offset, getBit<uint16_t>(current_track.hwStubs, ibit));
85  break;
86  case 9:
87  bset_.set(ibit + offset, false);
88  break;
89  }
90  }
91  }
92 
93  // print the track word to the COE file
95  fprintf(file, "%s", bset_string_.c_str());
96 
97  // print some debugging information
98  if (debug_ && print && irow == 0 && icol == 0) {
99  printf("region: eta=[%f,%f] phi=%f+/-%f\n",
100  regions[icol].etaMin,
101  regions[icol].etaMax,
102  regions[icol].phiCenter,
103  regions[icol].phiHalfWidth);
104  printf("l1t::PFTrack (pT,eta,phi) [float] = (%f,%f,%f)\n",
105  current_track.src->p4().Pt(),
106  current_track.src->p4().Eta(),
107  current_track.src->p4().Phi());
108  printf("l1t::PFTrack (pT,eta,phi) [int] = (%i,%i,%i)\n",
109  current_track.src->hwPt(),
110  current_track.src->hwEta(),
111  current_track.src->hwPhi());
112  printf("l1tpf_impl::PropagatedTrack (1/pT,eta,phi) [int,10] = (%i,%i,%i)\n",
113  current_track.hwPt,
114  current_track.hwVtxEta,
115  current_track.hwVtxPhi);
116  printf("l1tpf_impl::PropagatedTrack (1/pT,eta,phi) [int,2] = (%s,%s,%s)\n",
117  std::bitset<16>(current_track.hwPt).to_string().c_str(),
118  std::bitset<32>(current_track.hwVtxEta).to_string().c_str(),
119  std::bitset<32>(current_track.hwVtxPhi).to_string().c_str());
120  printf("bitset = %s\n", bset_string_.c_str());
121  }
122  } else {
123  bset_.reset();
125  fprintf(file, "%s", bset_string_.c_str());
126  }
127  }
128  fprintf(file, (irow == ntracksmax - 1) ? ";\n" : ",\n");
129  }
130 }
const std::vector< uint32_t > track_word_block_sizes
Definition: COEFile.h:39
int hwPhi() const
Definition: L1Candidate.h:37
std::string to_string(const V &value)
Definition: OMSAccess.h:71
const LorentzVector & p4() const final
four-momentum Lorentz vector
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
const l1t::PFTrack * src
int hwEta() const
Definition: L1Candidate.h:36
std::string bset_string_
Definition: COEFile.h:35
unsigned int ntracksmax
Definition: COEFile.h:36
boost::dynamic_bitset bset_
Definition: COEFile.h:38
int hwPt() const
Definition: L1Candidate.h:35

Member Data Documentation

◆ bset_

boost::dynamic_bitset l1tpf_impl::COEFile::bset_
protected

Definition at line 38 of file COEFile.h.

Referenced by COEFile(), and writeTracksToFile().

◆ bset_string_

std::string l1tpf_impl::COEFile::bset_string_
protected

Definition at line 35 of file COEFile.h.

Referenced by writeTracksToFile().

◆ coeFileName

std::string l1tpf_impl::COEFile::coeFileName
protected

Definition at line 35 of file COEFile.h.

Referenced by COEFile().

◆ debug_

int l1tpf_impl::COEFile::debug_
protected

Definition at line 40 of file COEFile.h.

Referenced by writeTracksToFile().

◆ file

FILE* l1tpf_impl::COEFile::file
protected

◆ ntracksmax

unsigned int l1tpf_impl::COEFile::ntracksmax
protected

Definition at line 36 of file COEFile.h.

Referenced by writeHeaderToFile(), and writeTracksToFile().

◆ phiSlices

unsigned int l1tpf_impl::COEFile::phiSlices
protected

Definition at line 36 of file COEFile.h.

Referenced by writeHeaderToFile().

◆ track_word_block_sizes

const std::vector<uint32_t> l1tpf_impl::COEFile::track_word_block_sizes = {14, 1, 12, 16, 12, 13, 4, 3, 7, 14}
protected

Definition at line 39 of file COEFile.h.

Referenced by writeTracksToFile().

◆ tracksize

constexpr unsigned int l1tpf_impl::COEFile::tracksize = 96
staticprotected

Definition at line 37 of file COEFile.h.

Referenced by COEFile(), and writeHeaderToFile().