CMS 3D CMS Logo

MemoryBase.h
Go to the documentation of this file.
1 #ifndef L1Trigger_TrackFindingTracklet_interface_MemoryBase_h
2 #define L1Trigger_TrackFindingTracklet_interface_MemoryBase_h
3 
5 
6 #include <fstream>
7 #include <sstream>
8 #include <cassert>
9 #include <bitset>
10 
11 namespace trklet {
12 
13  class MemoryBase {
14  public:
15  MemoryBase(std::string name, Settings const& settings);
16 
17  virtual ~MemoryBase() = default;
18 
19  std::string const& getName() const { return name_; }
20  std::string getLastPartOfName() const { return name_.substr(name_.find_last_of('_') + 1); }
21 
22  virtual void clean() = 0;
23 
24  //method sets the layer and disk based on the name. pos is the position in the memory name where the layer or disk is specified
25  void initLayerDisk(unsigned int pos, int& layer, int& disk);
26 
27  unsigned int initLayerDisk(unsigned int pos);
28 
29  // Based on memory name check if this memory is used for special seeding:
30  // overlap is layer-disk seeding
31  // extra is the L2L3 seeding
32  // extended is the seeding for displaced tracks
33  void initSpecialSeeding(unsigned int pos, bool& overlap, bool& extra, bool& extended);
34 
35  //Used for a hack below due to MAC OS case insensitiviy problem for files
36  void findAndReplaceAll(std::string& data, std::string toSearch, std::string replaceStr);
37 
38  void openFile(bool first, std::string dirName, std::string filebase);
39 
40  static size_t find_nth(const std::string& haystack, size_t pos, const std::string& needle, size_t nth);
41 
42  //Format index position in hex
43  static std::string hexstr(unsigned int index);
44 
45  protected:
47  unsigned int iSector_;
48 
49  std::ofstream out_;
50  int bx_;
51  int event_;
52 
54  };
55 }; // namespace trklet
56 #endif
static size_t find_nth(const std::string &haystack, size_t pos, const std::string &needle, size_t nth)
Definition: MemoryBase.cc:104
unsigned int iSector_
Definition: MemoryBase.h:47
void initSpecialSeeding(unsigned int pos, bool &overlap, bool &extra, bool &extended)
Definition: MemoryBase.cc:43
virtual void clean()=0
MemoryBase(std::string name, Settings const &settings)
Definition: MemoryBase.cc:14
void openFile(bool first, std::string dirName, std::string filebase)
Definition: MemoryBase.cc:75
virtual ~MemoryBase()=default
Settings const & settings_
Definition: MemoryBase.h:53
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
static std::string hexstr(unsigned int index)
Definition: MemoryBase.cc:111
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::string getLastPartOfName() const
Definition: MemoryBase.h:20
std::string name_
Definition: MemoryBase.h:46
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: MemoryBase.cc:20