CMS 3D CMS Logo

TrackletParametersMemory.cc
Go to the documentation of this file.
5 #include <iomanip>
6 #include <filesystem>
7 
8 using namespace std;
9 using namespace trklet;
10 
11 TrackletParametersMemory::TrackletParametersMemory(string name, Settings const& settings)
12  : MemoryBase(name, settings) {}
13 
15  for (auto& tracklet : tracklets_) {
16  delete tracklet;
17  }
18  tracklets_.clear();
19 }
20 
21 void TrackletParametersMemory::writeTPAR(bool first, unsigned int iSector) {
22  iSector_ = iSector;
23  const string dirTP = settings_.memPath() + "TrackletParameters/";
24 
25  std::ostringstream oss;
26  oss << dirTP << "TrackletParameters_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1)
27  << ".dat";
28  auto const& fname = oss.str();
29 
30  openfile(out_, first, dirTP, fname, __FILE__, __LINE__);
31 
32  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
33 
34  for (unsigned int j = 0; j < tracklets_.size(); j++) {
35  string tpar = tracklets_[j]->trackletparstr();
36  out_ << hexstr(j) << " " << tpar << " " << trklet::hexFormat(tpar) << endl;
37  }
38  out_.close();
39 
40  bx_++;
41  event_++;
42  if (bx_ > 7)
43  bx_ = 0;
44 }
unsigned int iSector_
Definition: MemoryBase.h:47
std::string hexFormat(const std::string &binary)
Definition: Util.h:19
std::string memPath() const
Definition: Settings.h:202
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
void writeTPAR(bool first, unsigned int iSector)
std::ofstream openfile(const std::string &dir, const std::string &fname, const char *file, int line)
Definition: Util.h:154