CMS 3D CMS Logo

VMStubsMEMemory.cc
Go to the documentation of this file.
3 #include <iomanip>
4 #include <filesystem>
5 
6 using namespace std;
7 using namespace trklet;
8 
9 VMStubsMEMemory::VMStubsMEMemory(string name, Settings const& settings) : MemoryBase(name, settings) {
10  unsigned int layerdisk = initLayerDisk(6);
11  if (layerdisk < N_LAYER) {
13  } else {
14  //For disks we have NLONGVMBITS on each disk
15  binnedstubs_.resize(2 * settings_.NLONGVMBINS());
16  }
17 }
18 
19 void VMStubsMEMemory::writeStubs(bool first, unsigned int iSector) {
20  iSector_ = iSector;
21  const string dirVM = settings_.memPath() + "VMStubsME/";
22 
23  std::ostringstream oss;
24  oss << dirVM << "VMStubs_" << getName();
25  //get rid of duplicates
26  auto const& tmp = oss.str();
27  int len = tmp.size();
28  if (tmp[len - 2] == 'n' && tmp[len - 1] > '1' && tmp[len - 1] <= '9')
29  return;
30  oss << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat";
31  auto const& fname = oss.str();
32 
33  openfile(out_, first, dirVM, fname, __FILE__, __LINE__);
34 
35  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
36 
37  for (unsigned int i = 0; i < binnedstubs_.size(); i++) {
38  for (unsigned int j = 0; j < binnedstubs_[i].size(); j++) {
39  string stub = binnedstubs_[i][j].stubindex().str();
40  stub += "|" + binnedstubs_[i][j].bend().str();
41 
42  FPGAWord finephipos = binnedstubs_[i][j].finephi();
43  stub += "|" + finephipos.str();
44  FPGAWord finepos = binnedstubs_[i][j].finerz();
45  stub += "|" + finepos.str();
46  out_ << hex << i << " " << j << dec << " " << stub << " " << trklet::hexFormat(stub) << endl;
47  }
48  }
49  out_.close();
50 
51  bx_++;
52  event_++;
53  if (bx_ > 7)
54  bx_ = 0;
55 }
std::vector< std::vector< VMStubME > > binnedstubs_
unsigned int iSector_
Definition: MemoryBase.h:44
std::string hexFormat(const std::string &binary)
Definition: Util.h:19
unsigned int NLONGVMBINS() const
Definition: Settings.h:329
std::string memPath() const
Definition: Settings.h:192
void writeStubs(bool first, unsigned int iSector)
Settings const & settings_
Definition: MemoryBase.h:50
std::ofstream out_
Definition: MemoryBase.h:46
std::string const & getName() const
Definition: MemoryBase.h:19
string fname
main script
tmp
align.sh
Definition: createJobs.py:716
std::string str() const
Definition: FPGAWord.cc:54
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: MemoryBase.cc:19
std::ofstream openfile(const std::string &dir, const std::string &fname, const char *file, int line)
Definition: Util.h:139
constexpr int N_LAYER
Definition: Settings.h:21