CMS 3D CMS Logo

StubTripletsMemory.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 StubTripletsMemory::StubTripletsMemory(string name, Settings const& settings, unsigned int iSector)
11  : MemoryBase(name, settings, iSector) {}
12 
14  const string dirSP = settings_.memPath() + "StubPairs/";
15 
16  std::ostringstream oss;
17  oss << dirSP << "StubTriplets_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat";
18  auto const& fname = oss.str();
19 
20  if (first) {
21  bx_ = 0;
22  event_ = 1;
23 
24  if (not std::filesystem::exists(dirSP)) {
25  int fail = system((string("mkdir -p ") + dirSP).c_str());
26  if (fail)
27  throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirSP;
28  }
29  out_.open(fname);
30  if (out_.fail())
31  throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname;
32 
33  } else
34  out_.open(fname, std::ofstream::app);
35 
36  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
37 
38  for (unsigned int j = 0; j < stubs1_.size(); j++) {
39  string stub1index = stubs1_[j]->stubindex().str();
40  string stub2index = stubs2_[j]->stubindex().str();
41  string stub3index = stubs3_[j]->stubindex().str();
42  out_ << std::setfill('0') << std::setw(2);
43  out_ << hex << j << dec;
44  out_ << " " << stub1index << "|" << stub2index << "|" << stub3index << endl;
45  }
46  out_.close();
47 
48  bx_++;
49  event_++;
50  if (bx_ > 7)
51  bx_ = 0;
52 }
trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
L1TStub.h
trklet::StubTripletsMemory::writeST
void writeST(bool first)
Definition: StubTripletsMemory.cc:13
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::StubTripletsMemory::stubs3_
std::vector< const Stub * > stubs3_
Definition: StubTripletsMemory.h:43
StubTripletsMemory.h
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::StubTripletsMemory::stubs1_
std::vector< const Stub * > stubs1_
Definition: StubTripletsMemory.h:41
trklet
Definition: AllProjectionsMemory.h:9
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
std
Definition: JetResolutionObject.h:76
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
cms::Exception
Definition: Exception.h:70
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
Stub.h
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
trklet::StubTripletsMemory::stubs2_
std::vector< const Stub * > stubs2_
Definition: StubTripletsMemory.h:42
trklet::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44