CMS 3D CMS Logo

TrackletProjectionsMemory.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 TrackletProjectionsMemory::TrackletProjectionsMemory(string name, Settings const& settings, unsigned int iSector)
11  : MemoryBase(name, settings, iSector) {
12  size_t pos = find_nth(name, 0, "_", 1);
13  assert(pos != string::npos);
15 }
16 
18  if (layer_ != 0 && disk_ == 0)
19  assert(tracklet->validProj(layer_));
20  if (layer_ == 0 && disk_ != 0)
21  assert(tracklet->validProjDisk(disk_));
22  if (layer_ != 0 && disk_ != 0)
23  assert(tracklet->validProj(layer_) || tracklet->validProjDisk(disk_));
24 
25  for (auto& itracklet : tracklets_) {
26  if (itracklet == tracklet) {
27  edm::LogPrint("Tracklet") << "Adding same tracklet " << tracklet << " twice in " << getName();
28  }
29  assert(itracklet != tracklet);
30  }
31 
32  tracklets_.push_back(tracklet);
33 }
34 
36 
38  const string dirTP = settings_.memPath() + "TrackletProjections/";
39  if (not std::filesystem::exists(dirTP)) {
40  int fail = system((string("mkdir -p ") + dirTP).c_str());
41  if (fail)
42  throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirTP;
43  }
44 
45  std::ostringstream oss;
46  oss << dirTP << "TrackletProjections_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1)
47  << ".dat";
48  auto const& fname = oss.str();
49 
50  if (first) {
51  bx_ = 0;
52  event_ = 1;
53  out_.open(fname);
54  } else
55  out_.open(fname, std::ofstream::app);
56 
57  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
58 
59  for (unsigned int j = 0; j < tracklets_.size(); j++) {
60  string proj = (layer_ > 0 && tracklets_[j]->validProj(layer_)) ? tracklets_[j]->trackletprojstrlayer(layer_)
61  : tracklets_[j]->trackletprojstrdisk(disk_);
62  out_ << "0x";
63  out_ << std::setfill('0') << std::setw(2);
64  out_ << hex << j << dec;
65  out_ << " " << proj << " " << trklet::hexFormat(proj) << endl;
66  }
67  out_.close();
68 
69  bx_++;
70  event_++;
71  if (bx_ > 7)
72  bx_ = 0;
73 }
trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
MessageLogger.h
trklet::MemoryBase::find_nth
static size_t find_nth(const std::string &haystack, size_t pos, const std::string &needle, size_t nth)
Definition: MemoryBase.cc:118
pos
Definition: PixelAliasList.h:18
edm::LogPrint
Log< level::Warning, true > LogPrint
Definition: MessageLogger.h:130
trklet::Settings
Definition: Settings.h:31
trklet::Settings::memPath
std::string const & memPath() const
Definition: Settings.h:169
cms::cuda::assert
assert(be >=bs)
trklet::MemoryBase::event_
int event_
Definition: MemoryBase.h:48
trklet::MemoryBase::out_
std::ofstream out_
Definition: MemoryBase.h:46
trklet::MemoryBase::initLayerDisk
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: MemoryBase.cc:18
trklet::TrackletProjectionsMemory::clean
void clean() override
Definition: TrackletProjectionsMemory.cc:35
trklet::MemoryBase::bx_
int bx_
Definition: MemoryBase.h:47
trklet::Tracklet::validProj
bool validProj(int layer) const
Definition: Tracklet.h:89
trklet::Tracklet
Definition: Tracklet.h:28
TrackletProjectionsMemory.h
trklet::MemoryBase::getName
std::string const & getName() const
Definition: MemoryBase.h:19
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
amptDefault_cfi.proj
proj
Definition: amptDefault_cfi.py:13
trklet::MemoryBase
Definition: MemoryBase.h:13
trklet::TrackletProjectionsMemory::disk_
int disk_
Definition: TrackletProjectionsMemory.h:38
trklet::TrackletProjectionsMemory::writeTPROJ
void writeTPROJ(bool first)
Definition: TrackletProjectionsMemory.cc:37
trklet
Definition: AllProjectionsMemory.h:9
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
std
Definition: JetResolutionObject.h:76
trklet::TrackletProjectionsMemory::addProj
void addProj(Tracklet *tracklet)
Definition: TrackletProjectionsMemory.cc:17
trklet::TrackletProjectionsMemory::tracklets_
std::vector< Tracklet * > tracklets_
Definition: TrackletProjectionsMemory.h:35
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
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
trklet::Tracklet::validProjDisk
bool validProjDisk(int disk) const
Definition: Tracklet.h:206
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
Tracklet.h
trklet::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44
trklet::TrackletProjectionsMemory::layer_
int layer_
Definition: TrackletProjectionsMemory.h:37