CMS 3D CMS Logo

CleanTrackMemory.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 CleanTrackMemory::CleanTrackMemory(string name, Settings const& settings, double phimin, double phimax)
11  : MemoryBase(name, settings) {
12  phimin_ = phimin;
13  phimax_ = phimax;
14 }
15 
16 void CleanTrackMemory::writeCT(bool first, unsigned int iSector) {
17  iSector_ = iSector;
18  const string dirCT = settings_.memPath() + "CleanTrack/";
19 
20  std::ostringstream oss;
21  oss << dirCT << "CleanTrack_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat";
22  auto const& fname = oss.str();
23 
24  openfile(out_, first, dirCT, fname, __FILE__, __LINE__);
25 
26  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
27 
28  for (unsigned int j = 0; j < tracks_.size(); j++) {
29  out_ << hexstr(j) << " " << tracks_[j]->trackfitstr() << " " << trklet::hexFormat(tracks_[j]->trackfitstr());
30  out_ << "\n";
31  }
32  out_.close();
33 
34  // --------------------------------------------------------------
35  // print separately ALL cleaned tracks in single file
36  if (settings_.writeMonitorData("CT")) {
37  std::string fnameAll = "CleanTracksAll.dat";
38  if (first && getName() == "CT_L1L2" && iSector_ == 0)
39  out_.open(fnameAll);
40  else
41  out_.open(fnameAll, std::ofstream::app);
42 
43  if (!tracks_.empty())
44  out_ << "BX= " << (bitset<3>)bx_ << " event= " << event_ << " seed= " << getName()
45  << " phisector= " << iSector_ + 1 << endl;
46 
47  for (unsigned int j = 0; j < tracks_.size(); j++) {
48  if (j < 16)
49  out_ << "0";
50  out_ << hex << j << dec << " ";
51  out_ << tracks_[j]->trackfitstr();
52  out_ << "\n";
53  }
54  out_.close();
55  }
56  // --------------------------------------------------------------
57 
58  bx_++;
59  event_++;
60  if (bx_ > 7)
61  bx_ = 0;
62 }
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
void writeCT(bool first, unsigned int iSector)
std::string const & getName() const
Definition: MemoryBase.h:19
bool writeMonitorData(std::string module) const
Definition: Settings.h:116
static std::string hexstr(unsigned int index)
Definition: MemoryBase.cc:111
string fname
main script
std::vector< Tracklet * > tracks_
std::ofstream openfile(const std::string &dir, const std::string &fname, const char *file, int line)
Definition: Util.h:154