CbmRoot
LitHitDataMuon.h
Go to the documentation of this file.
1 
8 #ifndef LITHITDATAMUON_H_
9 #define LITHITDATAMUON_H_
10 
11 #include "../LitComparators.h"
12 #include "../LitHit.h"
13 #include "LitDetectorLayoutMuon.h"
14 
15 #include <algorithm>
16 #include <vector>
17 
18 namespace lit {
19  namespace parallel {
20 
27  template<class T>
29  public:
34 
38  virtual ~LitHitDataMuon() {}
39 
45  fLayout = layout;
46  int nofGroups = layout.GetNofStationGroups();
47  fHits.resize(nofGroups);
48  fMaxErr.resize(nofGroups);
49  for (int i = 0; i < nofGroups; i++) {
50  int nofStations = layout.GetNofStations(i);
51  fHits[i].resize(nofStations);
52  fMaxErr[i].resize(nofStations);
53  for (int j = 0; j < nofStations; j++) {
54  int nofSubstations = layout.GetNofSubstations(i, j);
55  fHits[i][j].resize(nofSubstations);
56  fMaxErr[i][j].resize(nofSubstations);
57  for (int k = 0; k < nofSubstations; k++) {
58  fHits[i][j][k].reserve(1500);
59  }
60  }
61  }
62  }
63 
71  void AddHit(int stationGroup,
72  int station,
73  int substation,
74  LitScalPixelHit* hit) {
75  fHits[stationGroup][station][substation].push_back(hit);
76  if (fMaxErr[stationGroup][station][substation] < hit->Dx) {
77  fMaxErr[stationGroup][station][substation] = hit->Dx;
78  }
79  }
80 
86  void AddHit(unsigned char planeId, LitScalPixelHit* hit) {
87  unsigned char stationGroup;
88  unsigned char station;
89  unsigned char substation;
90  StationByPlaneId(planeId, stationGroup, station, substation);
91  AddHit(stationGroup, station, substation, hit);
92  }
93 
102  const LitScalPixelHit*
103  GetHit(int stationGroup, int station, int substation, int hitId) const {
104  return fHits[stationGroup][station][substation][hitId];
105  }
106 
114  const std::vector<LitScalPixelHit*>&
115  GetHits(int stationGroup, int station, int substation) {
116  return fHits[stationGroup][station][substation];
117  }
118 
126  unsigned int
127  GetNofHits(int stationGroup, int station, int substation) const {
128  return fHits[stationGroup][station][substation].size();
129  }
130 
138  fscal GetMaxErr(int stationGroup, int station, int substation) const {
139  return fMaxErr[stationGroup][station][substation];
140  }
141 
145  void Clear() {
146  for (unsigned int i = 0; i < fHits.size(); i++) {
147  for (unsigned int j = 0; j < fHits[i].size(); j++) {
148  for (unsigned int k = 0; k < fHits[i][j].size(); k++) {
149  fHits[i][j][k].clear();
150  fHits[i][j][k].reserve(1500);
151  fMaxErr[i][j][k] = 0.;
152  }
153  }
154  }
155  }
156 
160  void SortHits() {
161  // TODO : add threads here
162  for (int i = 0; i < fLayout.GetNofStationGroups(); i++) {
163  for (int j = 0; j < fLayout.GetNofStations(i); j++) {
164  for (int k = 0; k < fLayout.GetNofSubstations(i, j); k++) {
165  std::vector<LitScalPixelHit*>& shits = fHits[i][j][k];
166  std::sort(shits.begin(), shits.end(), ComparePixelHitXLess());
167  // std::cout << "station group " << i << " station " << j
168  // << " substation " << k << std::endl;
169  // for(unsigned int i = 0; i < nh; i++)
170  // std::cout << *shits[i];
171  }
172  }
173  }
174  }
175 
180  std::string ToString() const {
181  std::string str = "HitDataMuon:\n";
182  for (int i = 0; i < fLayout.GetNofStationGroups(); i++) {
183  str += " station group " + lit::parallel::ToString<int>(i) + "\n";
184  for (int j = 0; j < fLayout.GetNofStations(i); j++) {
185  str += " station " + lit::parallel::ToString<int>(j) + "\n";
186  for (int k = 0; k < fLayout.GetNofSubstations(i, j); k++) {
187  str += " substation " + lit::parallel::ToString<int>(k) + ": "
188  + lit::parallel::ToString<int>(GetNofHits(i, j, k))
189  + " hits, " + "max err="
190  + lit::parallel::ToString<T>(GetMaxErr(i, j, k)) + "\n";
191  }
192  }
193  }
194  return str;
195  }
196 
201  friend std::ostream& operator<<(std::ostream& strm,
202  const LitHitDataMuon& hitData) {
203  strm << hitData.ToString();
204  return strm;
205  }
206 
207  public:
215  void StationByPlaneId(unsigned char planeId,
216  unsigned char& stationGroup,
217  unsigned char& station,
218  unsigned char& substation) const {
219  unsigned char counter = 0;
220  for (unsigned char i = 0; i < fLayout.GetNofStationGroups(); i++) {
221  for (unsigned char j = 0; j < fLayout.GetNofStations(i); j++) {
222  counter += fLayout.GetNofSubstations(i, j);
223  if (counter > planeId) {
224  stationGroup = i;
225  station = j;
226  substation =
227  fLayout.GetNofSubstations(i, j) - (counter - planeId);
228  return;
229  }
230  }
231  }
232  }
233 
234  // Arrays of hits
235  std::vector<std::vector<std::vector<PixelHitArray>>> fHits;
236  // Arrays of maximum hit position errors for each substation
237  std::vector<std::vector<std::vector<fscal>>> fMaxErr;
238  // Detector layout
240  } _fvecalignment;
241 
242  } // namespace parallel
243 } // namespace lit
244 #endif /* LITHITDATAMUON_H_ */
fscal
float fscal
Definition: L1/vectors/P4_F32vec4.h:250
lit::parallel::LitScalPixelHit
Base class for scalar pixel hits.
Definition: LitScalPixelHit.h:31
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
lit::parallel::_fvecalignment
class lit::parallel::LitDetectorLayout _fvecalignment
lit::parallel::LitHitDataMuon::GetMaxErr
fscal GetMaxErr(int stationGroup, int station, int substation) const
Return maximum hit error in [cm] for the specified substation.
Definition: LitHitDataMuon.h:138
lit::parallel::LitDetectorLayoutMuon
Muon detector layout.
Definition: LitDetectorLayoutMuon.h:31
lit::parallel::LitHitDataMuon
Definition: LitHitDataMuon.h:28
lit::parallel::LitHitDataMuon::SetDetectorLayout
void SetDetectorLayout(const LitDetectorLayoutMuon< T > &layout)
Set detector layout for which hits are arranged.
Definition: LitHitDataMuon.h:44
lit::parallel::LitHitDataMuon::Clear
void Clear()
Clear hit arrays.
Definition: LitHitDataMuon.h:145
lit::parallel::LitHitDataMuon::SortHits
void SortHits()
Sort hits in each substation by X coordinate.
Definition: LitHitDataMuon.h:160
lit::parallel::LitHitDataMuon::GetHits
const std::vector< LitScalPixelHit * > & GetHits(int stationGroup, int station, int substation)
Return hit vector using station group, station and substation indices.
Definition: LitHitDataMuon.h:115
lit::parallel::LitHitDataMuon::StationByPlaneId
void StationByPlaneId(unsigned char planeId, unsigned char &stationGroup, unsigned char &station, unsigned char &substation) const
Calculate station group, station and substation indices using the detector plane number.
Definition: LitHitDataMuon.h:215
LitDetectorLayoutMuon.h
Classes for muon geometry description of CBM.
lit::parallel::LitHitDataMuon::operator<<
friend std::ostream & operator<<(std::ostream &strm, const LitHitDataMuon &hitData)
Operator << for convenient output to std::ostream.
Definition: LitHitDataMuon.h:201
lit::parallel::LitScalPixelHit::Dx
fscal Dx
Definition: LitScalPixelHit.h:74
lit::parallel::LitDetectorLayoutMuon::GetNofStations
unsigned char GetNofStations(unsigned char stationGroup) const
Return number of stations for specified station group.
Definition: LitDetectorLayoutMuon.h:64
counter
int counter
Definition: CbmMvdSensorDigiToHitTask.cxx:72
lit::parallel::LitHitDataMuon::fMaxErr
std::vector< std::vector< std::vector< fscal > > > fMaxErr
Definition: LitHitDataMuon.h:237
lit::parallel::LitHitDataMuon::GetNofHits
unsigned int GetNofHits(int stationGroup, int station, int substation) const
Return number of hits for the specified substation.
Definition: LitHitDataMuon.h:127
lit::parallel::LitHitDataMuon::fHits
std::vector< std::vector< std::vector< PixelHitArray > > > fHits
Definition: LitHitDataMuon.h:235
lit::parallel::LitDetectorLayoutMuon::GetNofSubstations
unsigned char GetNofSubstations(unsigned char stationGroup, unsigned char station) const
Return number of substations for specified station group and station.
Definition: LitDetectorLayoutMuon.h:74
lit::parallel::LitHitDataMuon::GetHit
const LitScalPixelHit * GetHit(int stationGroup, int station, int substation, int hitId) const
Return hit using station group, station and substation indices.
Definition: LitHitDataMuon.h:103
lit::parallel::LitHitDataMuon::~LitHitDataMuon
virtual ~LitHitDataMuon()
Destructor.
Definition: LitHitDataMuon.h:38
lit::parallel::LitHitDataMuon::fLayout
LitDetectorLayoutMuon< T > fLayout
Definition: LitHitDataMuon.h:239
lit::parallel::LitHitDataMuon::ToString
std::string ToString() const
Return std::string representation for the class.
Definition: LitHitDataMuon.h:180
lit::parallel::LitHitDataMuon::AddHit
void AddHit(int stationGroup, int station, int substation, LitScalPixelHit *hit)
Add hit using station group, station and substation indices.
Definition: LitHitDataMuon.h:71
lit::parallel::LitDetectorLayoutMuon::GetNofStationGroups
unsigned char GetNofStationGroups() const
Return number of station groups.
Definition: LitDetectorLayoutMuon.h:55
lit::parallel::LitHitDataMuon::AddHit
void AddHit(unsigned char planeId, LitScalPixelHit *hit)
Add hit using absolute detector plane (substation) index in the detector.
Definition: LitHitDataMuon.h:86
lit::parallel::LitHitDataMuon::LitHitDataMuon
LitHitDataMuon()
Constructor.
Definition: LitHitDataMuon.h:33
lit
Definition: LitTrackFinderNNVecElectron.h:19