FairRoot/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  if (index < fFlatTubeMap.size())
34  return fFlatTubeMap[index];
35  else
36  return -1;
37  }
38 
39  std::pair<int, int> GetSectorRowFromTubeId(int tubeId){
40  if (fMapTubeIdSectorRow.count(tubeId) > 0)
41  return fMapTubeIdSectorRow[tubeId];
42  else {
43  std::pair<int, int> noTubeId(-1, -1);
44  return noTubeId;
45  }
46  }
47 
48  void AddTube(int sector, int row, int tubeId);
49 
50 private:
53  vector< vector < vector <int> > > fTubeMap; //< [sector][row][posInRow] holds tubeId
54  vector<int> fFlatTubeMap;
55  std::map<int, std::pair<int, int> > fMapTubeIdSectorRow; //< key tubeId, value sector,row pair
56  std::vector<int> fSkewedRows;
58 };
59 
60 #endif /* DETECTORS_STT_PNDSTTTUBEIDMAP_H_ */
vector< int > GetRowInSector(int sector, int row)
int row
Definition: anaLmdDigi.C:67
virtual ~PndSttTubeIdMap()
vector< vector< int > > GetSector(int sector)
void AddTube(int sector, int row, int tubeId)
std::pair< int, int > GetSectorRowFromTubeId(int tubeId)
std::map< int, std::pair< int, int > > fMapTubeIdSectorRow
int GetTubeIdFlat(int index)
ClassDef(PndSttTubeIdMap, 1)
static PndSttTubeIdMap * fInstance
static PndSttTubeIdMap * Instance()
void SetSkewedRows(std::vector< int > &values)
int GetNTubesInRow(int sector, int row)
bool IsSkewed(int row)
vector< vector< vector< int > > > fTubeMap
int GetTube(int sector, int row, int posInRow)
std::vector< int > fSkewedRows
vector< int > fFlatTubeMap