PandaRoot
PndSttTubeIdMap.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /*
14  * PndSttTubeIdMap.h
15  *
16  * Created on: 02.08.2018
17  * Author: tstockmanns
18  */
19 
20 #ifndef DETECTORS_STT_PNDSTTTUBEIDMAP_H_
21 #define DETECTORS_STT_PNDSTTTUBEIDMAP_H_
22 
23 #include <TObject.h>
24 #include <vector>
25 #include <map>
26 #include <algorithm>
27 
28 using std::vector;
29 
30 class PndSttTubeIdMap : public TObject {
31  public:
32  // Instanton: Constructor is in private
33  virtual ~PndSttTubeIdMap();
34  static PndSttTubeIdMap *Instance();
35 
36  vector<vector<int>> GetSector(int sector) { return fTubeMap[sector]; }
37  vector<int> GetRowInSector(int sector, int row) { return fTubeMap[sector][row]; }
38  int GetNTubesInRow(int sector, int row) { return fTubeMap[sector][row].size(); }
39  int GetNTubes() { return fFlatTubeMap.size(); }
40  int GetTube(int sector, int row, int posInRow) { return fTubeMap[sector][row][posInRow]; }
41  bool IsSkewed(int row) { return std::find(fSkewedRows.begin(), fSkewedRows.end(), row) != fSkewedRows.end(); }
42  void SetSkewedRows(std::vector<int> &values) { fSkewedRows = values; }
43  // vector<int> GetRowInAllSectors(int row);
44  int GetTubeIdFlat(int index)
45  {
46  if (index < fFlatTubeMap.size())
47  return fFlatTubeMap[index];
48  else
49  return -1;
50  }
51 
52  std::pair<int, int> GetSectorRowFromTubeId(int tubeId)
53  {
54  if (fMapTubeIdSectorRow.count(tubeId) > 0)
55  return fMapTubeIdSectorRow[tubeId];
56  else {
57  std::pair<int, int> noTubeId(-1, -1);
58  return noTubeId;
59  }
60  }
61 
62  void AddTube(int sector, int row, int tubeId);
63 
64  private:
66  static PndSttTubeIdMap *fInstance;
67  vector<vector<vector<int>>> fTubeMap; //< [sector][row][posInRow] holds tubeId
68  vector<int> fFlatTubeMap;
69  std::map<int, std::pair<int, int>> fMapTubeIdSectorRow; //< key tubeId, value sector,row pair
70  std::vector<int> fSkewedRows;
71  ClassDef(PndSttTubeIdMap, 1);
72 };
73 
74 #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()