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)
11  : MemoryBase(name, settings) {
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_ - 1));
20  if (layer_ == 0 && disk_ != 0)
21  assert(tracklet->validProj(N_LAYER + abs(disk_) - 1));
22  if (layer_ != 0 && disk_ != 0)
23  assert(tracklet->validProj(layer_ - 1) || tracklet->validProj(N_LAYER + abs(disk_) - 1));
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 
37 void TrackletProjectionsMemory::writeTPROJ(bool first, unsigned int iSector) {
38  iSector_ = iSector;
39  const string dirTP = settings_.memPath() + "TrackletProjections/";
40 
41  std::ostringstream oss;
42  oss << dirTP << "TrackletProjections_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1)
43  << ".dat";
44  auto const& fname = oss.str();
45 
46  openfile(out_, first, dirTP, fname, __FILE__, __LINE__);
47 
48  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
49 
50  for (unsigned int j = 0; j < tracklets_.size(); j++) {
51  string proj = (layer_ > 0 && tracklets_[j]->validProj(layer_ - 1)) ? tracklets_[j]->trackletprojstrlayer(layer_)
52  : tracklets_[j]->trackletprojstrdisk(disk_);
53  out_ << "0x";
54  out_ << std::setfill('0') << std::setw(2);
55  out_ << hex << j << dec;
56  out_ << " " << proj << " " << trklet::hexFormat(proj) << endl;
57  }
58  out_.close();
59 
60  bx_++;
61  event_++;
62  if (bx_ > 7)
63  bx_ = 0;
64 }
trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
MessageLogger.h
trklet::TrackletProjectionsMemory::writeTPROJ
void writeTPROJ(bool first, unsigned int iSector)
Definition: TrackletProjectionsMemory.cc:37
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:103
trklet::openfile
std::ofstream openfile(const std::string &dir, const std::string &fname, const char *file, int line)
Definition: Util.h:138
pos
Definition: PixelAliasList.h:18
edm::LogPrint
Log< level::Warning, true > LogPrint
Definition: MessageLogger.h:130
trklet::Settings
Definition: Settings.h:52
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:19
trklet::TrackletProjectionsMemory::clean
void clean() override
Definition: TrackletProjectionsMemory.cc:35
trklet::MemoryBase::bx_
int bx_
Definition: MemoryBase.h:47
trklet::Tracklet
Definition: Tracklet.h:27
TrackletProjectionsMemory.h
trklet::MemoryBase::getName
std::string const & getName() const
Definition: MemoryBase.h:19
trklet::Tracklet::validProj
bool validProj(int layerdisk) const
Definition: Tracklet.h:82
trklet::N_LAYER
constexpr int N_LAYER
Definition: Settings.h:21
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
amptDefault_cfi.proj
proj
Definition: amptDefault_cfi.py:13
trklet::MemoryBase
Definition: MemoryBase.h:13
trklet::Settings::memPath
std::string memPath() const
Definition: Settings.h:192
trklet::TrackletProjectionsMemory::disk_
int disk_
Definition: TrackletProjectionsMemory.h:38
trklet
Definition: AllInnerStubsMemory.h:10
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
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
trklet::hexFormat
std::string hexFormat(const std::string &binary)
Definition: Util.h:19
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
Tracklet.h
trklet::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44
trklet::TrackletProjectionsMemory::layer_
int layer_
Definition: TrackletProjectionsMemory.h:37