CMS 3D CMS Logo

VMProjectionsMemory.cc
Go to the documentation of this file.
4 #include <iomanip>
5 #include <filesystem>
6 
7 using namespace std;
8 using namespace trklet;
9 
10 VMProjectionsMemory::VMProjectionsMemory(string name, Settings const& settings) : MemoryBase(name, settings) {
12 }
13 
14 void VMProjectionsMemory::addTracklet(Tracklet* tracklet, unsigned int allprojindex) {
15  std::pair<Tracklet*, unsigned int> tmp(tracklet, allprojindex);
16  //Check that order of TCID is correct
17  if (!tracklets_.empty()) {
18  assert(tracklets_[tracklets_.size() - 1].first->TCID() <= tracklet->TCID());
19  }
20  tracklets_.push_back(tmp);
21 }
22 
23 void VMProjectionsMemory::writeVMPROJ(bool first, unsigned int iSector) {
24  iSector_ = iSector;
25  const string dirVM = settings_.memPath() + "VMProjections/";
26 
27  std::ostringstream oss;
28  oss << dirVM + "VMProjections_" << getName();
29  //get rid of duplicates
30  auto const& tmp = oss.str();
31  int len = tmp.size();
32  if (tmp[len - 2] == 'n' && tmp[len - 1] > '1' && tmp[len - 1] <= '9')
33  return;
34  oss << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat";
35  auto const& fname = oss.str();
36 
37  openfile(out_, first, dirVM, fname, __FILE__, __LINE__);
38 
39  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
40 
41  for (unsigned int j = 0; j < tracklets_.size(); j++) {
42  string vmproj = (layer_ > 0) ? tracklets_[j].first->vmstrlayer(layer_, tracklets_[j].second)
43  : tracklets_[j].first->vmstrdisk(disk_, tracklets_[j].second);
44  out_ << hexstr(j) << " " << vmproj << " " << trklet::hexFormat(vmproj) << endl;
45  }
46  out_.close();
47 
48  bx_++;
49  event_++;
50  if (bx_ > 7)
51  bx_ = 0;
52 }
void writeVMPROJ(bool first, unsigned int iSector)
unsigned int iSector_
Definition: MemoryBase.h:47
assert(be >=bs)
int TCID() const
Definition: Tracklet.h:214
std::string hexFormat(const std::string &binary)
Definition: Util.h:19
std::string memPath() const
Definition: Settings.h:192
U second(std::pair< T, U > const &p)
Settings const & settings_
Definition: MemoryBase.h:53
std::ofstream out_
Definition: MemoryBase.h:49
std::string const & getName() const
Definition: MemoryBase.h:19
static std::string hexstr(unsigned int index)
Definition: MemoryBase.cc:111
string fname
main script
tmp
align.sh
Definition: createJobs.py:716
void addTracklet(Tracklet *tracklet, unsigned int allprojindex)
std::vector< std::pair< Tracklet *, unsigned int > > tracklets_
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: MemoryBase.cc:20
std::ofstream openfile(const std::string &dir, const std::string &fname, const char *file, int line)
Definition: Util.h:137