CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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_ << "0x";
37  out_ << std::setfill('0') << std::setw(2);
38  out_ << hex << j << dec;
39  out_ << " " << tpar << " " << trklet::hexFormat(tpar) << endl;
40  }
41  out_.close();
42 
43  bx_++;
44  event_++;
45  if (bx_ > 7)
46  bx_ = 0;
47 }
std::string memPath() const
Definition: Settings.h:192
unsigned int iSector_
Definition: MemoryBase.h:44
std::string hexFormat(const std::string &binary)
Definition: Util.h:19
std::string const & getName() const
Definition: MemoryBase.h:19
Settings const & settings_
Definition: MemoryBase.h:50
std::ofstream out_
Definition: MemoryBase.h:46
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:139