PandaRoot
PndSttTubeIdMap.h
Go to the documentation of this file.
1 /*
2  * PndSttTubeIdMap.h
3  *
4  * Created on: 02.08.2018
5  * Author: tstockmanns
6  */
7 
8 #ifndef DETECTORS_STT_PNDSTTTUBEIDMAP_H_
9 #define DETECTORS_STT_PNDSTTTUBEIDMAP_H_
10 
11 #include <TObject.h>
12 #include <vector>
13 #include <map>
14 #include <algorithm>
15 
16 using std::vector;
17 
18 class PndSttTubeIdMap : public TObject {
19  public:
20  // Instanton: Constructor is in private
21  virtual ~PndSttTubeIdMap();
22  static PndSttTubeIdMap *Instance();
23 
24  vector<vector<int>> GetSector(int sector) { return fTubeMap[sector]; }
25  vector<int> GetRowInSector(int sector, int row) { return fTubeMap[sector][row]; }
26  int GetNTubesInRow(int sector, int row) { return fTubeMap[sector][row].size(); }
27  int GetNTubes() { return fFlatTubeMap.size(); }
28  int GetTube(int sector, int row, int posInRow) { return fTubeMap[sector][row][posInRow]; }
29  bool IsSkewed(int row) { return std::find(fSkewedRows.begin(), fSkewedRows.end(), row) != fSkewedRows.end(); }
30  void SetSkewedRows(std::vector<int> &values) { fSkewedRows = values; }
31  // vector<int> GetRowInAllSectors(int row);
32  int GetTubeIdFlat(int index)
33  {
34  if (index < fFlatTubeMap.size())
35  return fFlatTubeMap[index];
36  else
37  return -1;
38  }
39 
40  std::pair<int, int> GetSectorRowFromTubeId(int tubeId)
41  {
42  if (fMapTubeIdSectorRow.count(tubeId) > 0)
43  return fMapTubeIdSectorRow[tubeId];
44  else {
45  std::pair<int, int> noTubeId(-1, -1);
46  return noTubeId;
47  }
48  }
49 
50  void AddTube(int sector, int row, int tubeId);
51 
52  private:
54  static PndSttTubeIdMap *fInstance;
55  vector<vector<vector<int>>> fTubeMap; //< [sector][row][posInRow] holds tubeId
56  vector<int> fFlatTubeMap;
57  std::map<int, std::pair<int, int>> fMapTubeIdSectorRow; //< key tubeId, value sector,row pair
58  std::vector<int> fSkewedRows;
59  ClassDef(PndSttTubeIdMap, 1);
60 };
61 
62 #endif /* DETECTORS_STT_PNDSTTTUBEIDMAP_H_ */
vector< int > GetRowInSector(int sector, int row)
vector< vector< int > > GetSector(int sector)
void AddTube(int sector, int row, int tubeId)
std::pair< int, int > GetSectorRowFromTubeId(int tubeId)
virtual ~PndSttTubeIdMap()
int GetTubeIdFlat(int index)
void SetSkewedRows(std::vector< int > &values)
int GetNTubesInRow(int sector, int row)
bool IsSkewed(int row)
int GetTube(int sector, int row, int posInRow)
static PndSttTubeIdMap * Instance()