CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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(
11  string name, Settings const& settings, unsigned int iSector, double phimin, double phimax)
12  : MemoryBase(name, settings, iSector) {
13  phimin_ = phimin;
14  phimax_ = phimax;
15 }
16 
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  if (first) {
25  bx_ = 0;
26  event_ = 1;
27 
28  if (not std::filesystem::exists(dirCT)) {
29  int fail = system((string("mkdir -p ") + dirCT).c_str());
30  if (fail)
31  throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirCT;
32  }
33  out_.open(fname);
34  if (out_.fail())
35  throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname;
36 
37  } else
38  out_.open(fname, std::ofstream::app);
39 
40  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
41 
42  for (unsigned int j = 0; j < tracks_.size(); j++) {
43  out_ << "0x";
44  out_ << std::setfill('0') << std::setw(2);
45  out_ << hex << j << dec << " ";
46  out_ << tracks_[j]->trackfitstr() << " " << trklet::hexFormat(tracks_[j]->trackfitstr());
47  out_ << "\n";
48  }
49  out_.close();
50 
51  // --------------------------------------------------------------
52  // print separately ALL cleaned tracks in single file
53  if (settings_.writeMonitorData("CT")) {
54  std::string fnameAll = "CleanTracksAll.dat";
55  if (first && getName() == "CT_L1L2" && iSector_ == 0)
56  out_.open(fnameAll);
57  else
58  out_.open(fnameAll, std::ofstream::app);
59 
60  if (!tracks_.empty())
61  out_ << "BX= " << (bitset<3>)bx_ << " event= " << event_ << " seed= " << getName()
62  << " phisector= " << iSector_ + 1 << endl;
63 
64  for (unsigned int j = 0; j < tracks_.size(); j++) {
65  if (j < 16)
66  out_ << "0";
67  out_ << hex << j << dec << " ";
68  out_ << tracks_[j]->trackfitstr();
69  out_ << "\n";
70  }
71  out_.close();
72  }
73  // --------------------------------------------------------------
74 
75  bx_++;
76  event_++;
77  if (bx_ > 7)
78  bx_ = 0;
79 }
trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
trklet::Settings
Definition: Settings.h:31
trklet::Settings::memPath
std::string const & memPath() const
Definition: Settings.h:169
trklet::MemoryBase::event_
int event_
Definition: MemoryBase.h:48
trklet::MemoryBase::out_
std::ofstream out_
Definition: MemoryBase.h:46
CleanTrackMemory.h
trklet::MemoryBase::bx_
int bx_
Definition: MemoryBase.h:47
trklet::MemoryBase::getName
std::string const & getName() const
Definition: MemoryBase.h:19
trklet::CleanTrackMemory::phimin_
double phimin_
Definition: CleanTrackMemory.h:28
SLHCEvent.h
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
trklet::CleanTrackMemory::phimax_
double phimax_
Definition: CleanTrackMemory.h:29
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
trklet::MemoryBase
Definition: MemoryBase.h:13
trklet::CleanTrackMemory::writeCT
void writeCT(bool first)
Definition: CleanTrackMemory.cc:17
trklet::CleanTrackMemory::tracks_
std::vector< Tracklet * > tracks_
Definition: CleanTrackMemory.h:30
trklet
Definition: AllProjectionsMemory.h:9
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
trklet::Settings::writeMonitorData
bool writeMonitorData(std::string module) const
Definition: Settings.h:96
std
Definition: JetResolutionObject.h:76
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
trklet::hexFormat
std::string hexFormat(const std::string &binary)
Definition: Util.h:15
cms::Exception
Definition: Exception.h:70
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
Tracklet.h
trklet::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44