CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes
trklet::MemoryBase Class Referenceabstract

#include <MemoryBase.h>

Inheritance diagram for trklet::MemoryBase:
trklet::AllInnerStubsMemory trklet::AllProjectionsMemory trklet::AllStubsMemory trklet::CandidateMatchMemory trklet::CleanTrackMemory trklet::DTCLinkMemory trklet::FullMatchMemory trklet::InputLinkMemory trklet::StubPairsMemory trklet::StubTripletsMemory trklet::TrackFitMemory trklet::TrackletParametersMemory trklet::TrackletProjectionsMemory trklet::VMProjectionsMemory trklet::VMStubsMEMemory trklet::VMStubsTEMemory

Public Member Functions

virtual void clean ()=0
 
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
 

Static Public Member Functions

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

int bx_
 
int event_
 
unsigned int iSector_
 
std::string name_
 
std::ofstream out_
 
Settings const & settings_
 

Detailed Description

Definition at line 13 of file MemoryBase.h.

Constructor & Destructor Documentation

◆ MemoryBase()

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

Definition at line 14 of file MemoryBase.cc.

References bx_, event_, and iSector_.

14  : name_(name), settings_(settings) {
15  iSector_ = 0;
16  bx_ = 0;
17  event_ = 0;
18 }
unsigned int iSector_
Definition: MemoryBase.h:47
Settings const & settings_
Definition: MemoryBase.h:53
std::string name_
Definition: MemoryBase.h:46

◆ ~MemoryBase()

virtual trklet::MemoryBase::~MemoryBase ( )
virtualdefault

Member Function Documentation

◆ clean()

virtual void trklet::MemoryBase::clean ( )
pure virtual

◆ find_nth()

size_t MemoryBase::find_nth ( const std::string &  haystack,
size_t  pos,
const std::string &  needle,
size_t  nth 
)
static

Definition at line 104 of file MemoryBase.cc.

Referenced by trklet::FullMatchMemory::FullMatchMemory(), and trklet::TrackletProjectionsMemory::TrackletProjectionsMemory().

104  {
105  size_t found_pos = haystack.find(needle, pos);
106  if (0 == nth || string::npos == found_pos)
107  return found_pos;
108  return find_nth(haystack, found_pos + 1, needle, nth - 1);
109 }
static size_t find_nth(const std::string &haystack, size_t pos, const std::string &needle, size_t nth)
Definition: MemoryBase.cc:104

◆ findAndReplaceAll()

void MemoryBase::findAndReplaceAll ( std::string &  data,
std::string  toSearch,
std::string  replaceStr 
)

Definition at line 62 of file MemoryBase.cc.

References data.

Referenced by openFile().

62  {
63  // Get the first occurrence
64  size_t pos = data.find(toSearch);
65 
66  // Repeat till end is reached
67  while (pos != std::string::npos) {
68  // Replace this occurrence of Sub String
69  data.replace(pos, toSearch.size(), replaceStr);
70  // Get the next occurrence from the current position
71  pos = data.find(toSearch, pos + replaceStr.size());
72  }
73 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ getLastPartOfName()

std::string trklet::MemoryBase::getLastPartOfName ( ) const
inline

Definition at line 20 of file MemoryBase.h.

References name_.

20 { return name_.substr(name_.find_last_of('_') + 1); }
std::string name_
Definition: MemoryBase.h:46

◆ getName()

std::string const& trklet::MemoryBase::getName ( void  ) const
inline

◆ hexstr()

std::string MemoryBase::hexstr ( unsigned int  index)
static

◆ initLayerDisk() [1/2]

void MemoryBase::initLayerDisk ( unsigned int  pos,
int &  layer,
int &  disk 
)

Definition at line 20 of file MemoryBase.cc.

References Exception, and name_.

Referenced by trklet::AllProjectionsMemory::AllProjectionsMemory(), trklet::FullMatchMemory::FullMatchMemory(), initLayerDisk(), trklet::TrackletProjectionsMemory::TrackletProjectionsMemory(), trklet::VMProjectionsMemory::VMProjectionsMemory(), trklet::VMStubsMEMemory::VMStubsMEMemory(), and trklet::VMStubsTEMemory::VMStubsTEMemory().

20  {
21  string subname = name_.substr(pos, 2);
22  layer = 0;
23  disk = 0;
24 
25  if (subname.substr(0, 1) == "L")
26  layer = stoi(subname.substr(1, 1));
27  else if (subname.substr(0, 1) == "D")
28  disk = stoi(subname.substr(1, 1));
29  else
30  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " name = " << name_ << " subname = " << subname
31  << " " << layer << " " << disk;
32 }
std::string name_
Definition: MemoryBase.h:46

◆ initLayerDisk() [2/2]

unsigned int MemoryBase::initLayerDisk ( unsigned int  pos)

Definition at line 34 of file MemoryBase.cc.

References initLayerDisk(), and trklet::N_DISK.

34  {
35  int layer, disk;
36  initLayerDisk(pos, layer, disk);
37 
38  if (disk > 0)
39  return N_DISK + disk;
40  return layer - 1;
41 }
constexpr int N_DISK
Definition: Settings.h:26
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: MemoryBase.cc:20

◆ initSpecialSeeding()

void MemoryBase::initSpecialSeeding ( unsigned int  pos,
bool &  overlap,
bool &  extra,
bool &  extended 
)

Definition at line 43 of file MemoryBase.cc.

References name_, and hltL1SingleMuFiltered5_cfi::overlap.

Referenced by trklet::VMStubsTEMemory::VMStubsTEMemory().

43  {
44  overlap = false;
45  extra = false;
46  extended = false;
47 
48  char subname = name_[pos];
49 
50  static const std::set<char> overlapset = {
51  'X', 'Y', 'W', 'Q', 'R', 'S', 'T', 'Z', 'x', 'y', 'w', 'q', 'r', 's', 't', 'z'};
52  overlap = overlapset.find(subname) != overlapset.end();
53 
54  static const std::set<char> extraset = {'I', 'J', 'K', 'L'};
55  extra = extraset.find(subname) != extraset.end();
56 
57  static const std::set<char> extendedset = {
58  'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'x', 'y', 'z', 'w', 'q', 'r', 's', 't'};
59  extended = extendedset.find(subname) != extendedset.end();
60 }
std::string name_
Definition: MemoryBase.h:46

◆ openFile()

void MemoryBase::openFile ( bool  first,
std::string  dirName,
std::string  filebase 
)

Definition at line 75 of file MemoryBase.cc.

References bx_, TrackerOfflineValidation_Dqm_cff::dirName, event_, findAndReplaceAll(), dqmdumpme::first, alignmentValidation::fname, getName(), iSector_, trklet::openfile(), out_, AlCaHLTBitMon_QueryRunRegistry::string, and to_string().

Referenced by trklet::InputLinkMemory::writeStubs(), trklet::DTCLinkMemory::writeStubs(), trklet::AllStubsMemory::writeStubs(), trklet::AllInnerStubsMemory::writeStubs(), and trklet::VMStubsTEMemory::writeStubs().

75  {
76  std::string fname = filebase + getName();
77 
78  findAndReplaceAll(fname, "PHIa", "PHIaa");
79  findAndReplaceAll(fname, "PHIb", "PHIbb");
80  findAndReplaceAll(fname, "PHIc", "PHIcc");
81  findAndReplaceAll(fname, "PHId", "PHIdd");
82 
83  findAndReplaceAll(fname, "PHIx", "PHIxx");
84  findAndReplaceAll(fname, "PHIy", "PHIyy");
85  findAndReplaceAll(fname, "PHIz", "PHIzz");
86  findAndReplaceAll(fname, "PHIw", "PHIww");
87 
88  fname += "_";
89  if (iSector_ + 1 < 10)
90  fname += "0";
92  fname += ".dat";
93 
94  openfile(out_, first, dirName, dirName + fname, __FILE__, __LINE__);
95 
96  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
97 
98  bx_++;
99  event_++;
100  if (bx_ > 7)
101  bx_ = 0;
102 }
unsigned int iSector_
Definition: MemoryBase.h:47
static std::string to_string(const XMLCh *ch)
void findAndReplaceAll(std::string &data, std::string toSearch, std::string replaceStr)
Definition: MemoryBase.cc:62
std::ofstream out_
Definition: MemoryBase.h:49
std::string const & getName() const
Definition: MemoryBase.h:19
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

◆ bx_

int trklet::MemoryBase::bx_
protected

◆ event_

int trklet::MemoryBase::event_
protected

◆ iSector_

unsigned int trklet::MemoryBase::iSector_
protected

◆ name_

std::string trklet::MemoryBase::name_
protected

Definition at line 46 of file MemoryBase.h.

Referenced by getLastPartOfName(), getName(), initLayerDisk(), and initSpecialSeeding().

◆ out_

std::ofstream trklet::MemoryBase::out_
protected

◆ settings_

Settings const& trklet::MemoryBase::settings_
protected