CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
trklet::TrackletProjectionsMemory Class Reference

#include <TrackletProjectionsMemory.h>

Inheritance diagram for trklet::TrackletProjectionsMemory:
trklet::MemoryBase

Public Member Functions

void addProj (Tracklet *tracklet)
 
void clean () override
 
int disk () const
 
TrackletgetTracklet (unsigned int i)
 
int layer () const
 
unsigned int nTracklets () const
 
 TrackletProjectionsMemory (std::string name, Settings const &settings)
 
void writeTPROJ (bool first, unsigned int iSector)
 
 ~TrackletProjectionsMemory () override
 
- Public Member Functions inherited from trklet::MemoryBase
void findAndReplaceAll (std::string &data, std::string toSearch, std::string replaceStr)
 
std::string getLastPartOfName () const
 
std::string const & getName () const
 
void initLayerDisk (unsigned int pos, int &layer, int &disk)
 
unsigned int initLayerDisk (unsigned int pos)
 
void initSpecialSeeding (unsigned int pos, bool &overlap, bool &extra, bool &extended)
 
 MemoryBase (std::string name, Settings const &settings)
 
void openFile (bool first, std::string dirName, std::string filebase)
 
virtual ~MemoryBase ()=default
 

Private Attributes

int disk_
 
bool hasProj_
 
int layer_
 
std::vector< Tracklet * > tracklets_
 

Additional Inherited Members

- Static Public Member Functions inherited from trklet::MemoryBase
static size_t find_nth (const std::string &haystack, size_t pos, const std::string &needle, size_t nth)
 
static std::string hexstr (unsigned int index)
 
- Protected Attributes inherited from trklet::MemoryBase
int bx_
 
int event_
 
unsigned int iSector_
 
std::string name_
 
std::ofstream out_
 
Settings const & settings_
 

Detailed Description

Definition at line 15 of file TrackletProjectionsMemory.h.

Constructor & Destructor Documentation

◆ TrackletProjectionsMemory()

TrackletProjectionsMemory::TrackletProjectionsMemory ( std::string  name,
Settings const &  settings 
)

Definition at line 10 of file TrackletProjectionsMemory.cc.

References cms::cuda::assert(), disk_, trklet::MemoryBase::find_nth(), hasProj_, trklet::MemoryBase::initLayerDisk(), layer_, and Skims_PA_cff::name.

11  : MemoryBase(name, settings) {
12  size_t pos = find_nth(name, 0, "_", 1);
13  assert(pos != string::npos);
15  hasProj_ = false;
16 }
static size_t find_nth(const std::string &haystack, size_t pos, const std::string &needle, size_t nth)
Definition: MemoryBase.cc:104
MemoryBase(std::string name, Settings const &settings)
Definition: MemoryBase.cc:14
assert(be >=bs)
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: MemoryBase.cc:20

◆ ~TrackletProjectionsMemory()

trklet::TrackletProjectionsMemory::~TrackletProjectionsMemory ( )
inlineoverride

Definition at line 19 of file TrackletProjectionsMemory.h.

References trklet::MemoryBase::getName(), hasProj_, trklet::MemoryBase::settings_, and trklet::Settings::writeMonitorData().

19  {
20  if (settings_.writeMonitorData("WriteEmptyProj") && (!hasProj_)) {
21  edm::LogPrint("Tracklet") << "Empty Projection Memory : " << getName() << std::endl;
22  }
23  };
Settings const & settings_
Definition: MemoryBase.h:53
std::string const & getName() const
Definition: MemoryBase.h:19
bool writeMonitorData(std::string module) const
Definition: Settings.h:116
Log< level::Warning, true > LogPrint

Member Function Documentation

◆ addProj()

void TrackletProjectionsMemory::addProj ( Tracklet tracklet)

Definition at line 18 of file TrackletProjectionsMemory.cc.

References funct::abs(), cms::cuda::assert(), disk_, trklet::MemoryBase::getName(), hasProj_, layer_, trklet::N_LAYER, tracklets_, and trklet::Tracklet::validProj().

Referenced by trklet::TrackletCalculatorDisplaced::addProjection(), trklet::TrackletCalculatorBase::addProjection(), trklet::TrackletCalculatorDisplaced::addProjectionDisk(), and trklet::TrackletCalculatorBase::addProjectionDisk().

18  {
19  if (layer_ != 0 && disk_ == 0)
20  assert(tracklet->validProj(layer_ - 1));
21  if (layer_ == 0 && disk_ != 0)
22  assert(tracklet->validProj(N_LAYER + abs(disk_) - 1));
23  if (layer_ != 0 && disk_ != 0)
24  assert(tracklet->validProj(layer_ - 1) || tracklet->validProj(N_LAYER + abs(disk_) - 1));
25 
26  for (auto& itracklet : tracklets_) {
27  if (itracklet == tracklet) {
28  edm::LogPrint("Tracklet") << "Adding same tracklet " << tracklet << " twice in " << getName();
29  }
30  assert(itracklet != tracklet);
31  }
32 
33  hasProj_ = true;
34  tracklets_.push_back(tracklet);
35 }
assert(be >=bs)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::string const & getName() const
Definition: MemoryBase.h:19
Log< level::Warning, true > LogPrint
bool validProj(int layerdisk) const
Definition: Tracklet.h:82
constexpr int N_LAYER
Definition: Settings.h:25

◆ clean()

void TrackletProjectionsMemory::clean ( )
overridevirtual

Implements trklet::MemoryBase.

Definition at line 37 of file TrackletProjectionsMemory.cc.

References tracklets_.

37 { tracklets_.clear(); }

◆ disk()

int trklet::TrackletProjectionsMemory::disk ( ) const
inline

Definition at line 36 of file TrackletProjectionsMemory.h.

References disk_.

◆ getTracklet()

Tracklet* trklet::TrackletProjectionsMemory::getTracklet ( unsigned int  i)
inline

Definition at line 29 of file TrackletProjectionsMemory.h.

References mps_fire::i, and tracklets_.

Referenced by trklet::MatchProcessor::execute().

29 { return tracklets_[i]; }

◆ layer()

int trklet::TrackletProjectionsMemory::layer ( ) const
inline

◆ nTracklets()

unsigned int trklet::TrackletProjectionsMemory::nTracklets ( ) const
inline

Definition at line 27 of file TrackletProjectionsMemory.h.

References tracklets_.

Referenced by trklet::MatchProcessor::execute().

27 { return tracklets_.size(); }

◆ writeTPROJ()

void TrackletProjectionsMemory::writeTPROJ ( bool  first,
unsigned int  iSector 
)

Definition at line 39 of file TrackletProjectionsMemory.cc.

References trklet::MemoryBase::bx_, disk_, trklet::MemoryBase::event_, dqmdumpme::first, alignmentValidation::fname, trklet::MemoryBase::getName(), trklet::hexFormat(), trklet::MemoryBase::hexstr(), trklet::MemoryBase::iSector_, dqmiolumiharvest::j, layer_, trklet::Settings::memPath(), trklet::openfile(), trklet::MemoryBase::out_, amptDefault_cfi::proj, trklet::MemoryBase::settings_, and tracklets_.

39  {
40  iSector_ = iSector;
41  const string dirTP = settings_.memPath() + "TrackletProjections/";
42 
43  std::ostringstream oss;
44  oss << dirTP << "TrackletProjections_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1)
45  << ".dat";
46  auto const& fname = oss.str();
47 
48  openfile(out_, first, dirTP, fname, __FILE__, __LINE__);
49 
50  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
51 
52  for (unsigned int j = 0; j < tracklets_.size(); j++) {
53  string proj = (layer_ > 0 && tracklets_[j]->validProj(layer_ - 1)) ? tracklets_[j]->trackletprojstrlayer(layer_)
54  : tracklets_[j]->trackletprojstrdisk(disk_);
55  out_ << hexstr(j) << " " << proj << " " << trklet::hexFormat(proj) << endl;
56  }
57  out_.close();
58 
59  bx_++;
60  event_++;
61  if (bx_ > 7)
62  bx_ = 0;
63 }
unsigned int iSector_
Definition: MemoryBase.h:47
std::string hexFormat(const std::string &binary)
Definition: Util.h:19
std::string memPath() const
Definition: Settings.h:202
Settings const & settings_
Definition: MemoryBase.h:53
std::ofstream out_
Definition: MemoryBase.h:49
std::string const & getName() const
Definition: MemoryBase.h:19
static std::string hexstr(unsigned int index)
Definition: MemoryBase.cc:111
string fname
main script
std::ofstream openfile(const std::string &dir, const std::string &fname, const char *file, int line)
Definition: Util.h:154

Member Data Documentation

◆ disk_

int trklet::TrackletProjectionsMemory::disk_
private

Definition at line 43 of file TrackletProjectionsMemory.h.

Referenced by addProj(), disk(), TrackletProjectionsMemory(), and writeTPROJ().

◆ hasProj_

bool trklet::TrackletProjectionsMemory::hasProj_
private

◆ layer_

int trklet::TrackletProjectionsMemory::layer_
private

Definition at line 42 of file TrackletProjectionsMemory.h.

Referenced by addProj(), layer(), TrackletProjectionsMemory(), and writeTPROJ().

◆ tracklets_

std::vector<Tracklet*> trklet::TrackletProjectionsMemory::tracklets_
private

Definition at line 39 of file TrackletProjectionsMemory.h.

Referenced by addProj(), clean(), getTracklet(), nTracklets(), and writeTPROJ().