CMS 3D CMS Logo

AllProjectionsMemory.cc
Go to the documentation of this file.
5 
6 #include <iomanip>
7 #include <filesystem>
8 
9 using namespace trklet;
10 using namespace std;
11 
12 AllProjectionsMemory::AllProjectionsMemory(string name, Settings const& settings, unsigned int iSector)
13  : MemoryBase(name, settings, iSector) {
15 }
16 
18  const string dirTP = settings_.memPath() + "TrackletProjections/";
19 
20  std::ostringstream oss;
21  oss << dirTP << "AllProj_" << 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(dirTP)) {
29  int fail = system((string("mkdir -p ") + dirTP).c_str());
30  if (fail)
31  throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirTP;
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 < tracklets_.size(); j++) {
43  string proj =
44  (layer_ > 0) ? tracklets_[j]->trackletprojstrlayer(layer_) : tracklets_[j]->trackletprojstrdisk(disk_);
45  out_ << "0x";
46  out_ << std::setfill('0') << std::setw(2);
47  out_ << hex << j << dec;
48  out_ << " " << proj << " " << trklet::hexFormat(proj) << endl;
49  }
50  out_.close();
51 
52  bx_++;
53  event_++;
54  if (bx_ > 7)
55  bx_ = 0;
56 }
Settings.h
trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
MessageLogger.h
trklet::AllProjectionsMemory::writeAP
void writeAP(bool first)
Definition: AllProjectionsMemory.cc:17
trklet::AllProjectionsMemory::disk_
int disk_
Definition: AllProjectionsMemory.h:34
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::AllProjectionsMemory::layer_
int layer_
Definition: AllProjectionsMemory.h:33
trklet::MemoryBase::initLayerDisk
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: MemoryBase.cc:18
trklet::MemoryBase::bx_
int bx_
Definition: MemoryBase.h:47
trklet::AllProjectionsMemory::tracklets_
std::vector< Tracklet * > tracklets_
Definition: AllProjectionsMemory.h:31
trklet::MemoryBase::getName
std::string const & getName() const
Definition: MemoryBase.h:19
AllProjectionsMemory.h
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
amptDefault_cfi.proj
proj
Definition: amptDefault_cfi.py:13
trklet::MemoryBase
Definition: MemoryBase.h:13
trklet
Definition: AllProjectionsMemory.h:9
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
std
Definition: JetResolutionObject.h:76
trklet::AllProjectionsMemory::AllProjectionsMemory
AllProjectionsMemory(std::string name, Settings const &settings, unsigned int iSector)
Definition: AllProjectionsMemory.cc:12
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