CMS 3D CMS Logo

StubPairsMemory.cc
Go to the documentation of this file.
3 #include <iomanip>
4 #include <filesystem>
5 
6 using namespace std;
7 using namespace trklet;
8 
9 StubPairsMemory::StubPairsMemory(string name, Settings const& settings, unsigned int iSector)
10  : MemoryBase(name, settings, iSector) {}
11 
13  const string dirSP = settings_.memPath() + "StubPairs/";
14 
15  std::ostringstream oss;
16  oss << dirSP << "StubPairs_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat";
17  auto const& fname = oss.str();
18 
19  if (first) {
20  bx_ = 0;
21  event_ = 1;
22 
23  if (not std::filesystem::exists(dirSP)) {
24  int fail = system((string("mkdir -p ") + dirSP).c_str());
25  if (fail)
26  throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirSP;
27  }
28  out_.open(fname);
29  if (out_.fail())
30  throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname;
31 
32  } else
33  out_.open(fname, std::ofstream::app);
34 
35  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
36 
37  for (unsigned int j = 0; j < stubs_.size(); j++) {
38  string stub1index = stubs_[j].first.stub()->stubindex().str();
39  string stub2index = stubs_[j].second.stub()->stubindex().str();
40  out_ << "0x";
41  out_ << std::setfill('0') << std::setw(2);
42  out_ << hex << j << dec;
43  out_ << " " << stub1index << "|" << stub2index << " " << trklet::hexFormat(stub1index + stub2index) << endl;
44  }
45  out_.close();
46 
47  bx_++;
48  event_++;
49  if (bx_ > 7)
50  bx_ = 0;
51 }
trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
trklet::StubPairsMemory::writeSP
void writeSP(bool first)
Definition: StubPairsMemory.cc:12
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
trklet::MemoryBase::bx_
int bx_
Definition: MemoryBase.h:47
trklet::MemoryBase::getName
std::string const & getName() const
Definition: MemoryBase.h:19
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
trklet::MemoryBase
Definition: MemoryBase.h:13
trklet::StubPairsMemory::stubs_
std::vector< std::pair< const VMStubTE, const VMStubTE > > stubs_
Definition: StubPairsMemory.h:45
StubPairsMemory.h
trklet
Definition: AllProjectionsMemory.h:9
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
std
Definition: JetResolutionObject.h:76
VMStubTE.h
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
trklet::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44