CbmRoot
Loading...
Searching...
No Matches
LitHitDataMuon.h
Go to the documentation of this file.
1/* Copyright (C) 2009-2012 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
12#ifndef LITHITDATAMUON_H_
13#define LITHITDATAMUON_H_
14
15#include "LitComparators.h"
17#include "LitHit.h"
18
19#include <algorithm>
20#include <vector>
21
22namespace lit
23{
24 namespace parallel
25 {
26
33 template<class T>
35 public:
40
44 virtual ~LitHitDataMuon() {}
45
51 {
52 fLayout = layout;
53 int nofGroups = layout.GetNofStationGroups();
54 fHits.resize(nofGroups);
55 fMaxErr.resize(nofGroups);
56 for (int i = 0; i < nofGroups; i++) {
57 int nofStations = layout.GetNofStations(i);
58 fHits[i].resize(nofStations);
59 fMaxErr[i].resize(nofStations);
60 for (int j = 0; j < nofStations; j++) {
61 int nofSubstations = layout.GetNofSubstations(i, j);
62 fHits[i][j].resize(nofSubstations);
63 fMaxErr[i][j].resize(nofSubstations);
64 for (int k = 0; k < nofSubstations; k++) {
65 fHits[i][j][k].reserve(1500);
66 }
67 }
68 }
69 }
70
78 void AddHit(int stationGroup, int station, int substation, LitScalPixelHit* hit)
79 {
80 fHits[stationGroup][station][substation].push_back(hit);
81 if (fMaxErr[stationGroup][station][substation] < hit->Dx) {
82 fMaxErr[stationGroup][station][substation] = hit->Dx;
83 }
84 }
85
91 void AddHit(unsigned char planeId, LitScalPixelHit* hit)
92 {
93 unsigned char stationGroup;
94 unsigned char station;
95 unsigned char substation;
96 StationByPlaneId(planeId, stationGroup, station, substation);
97 AddHit(stationGroup, station, substation, hit);
98 }
99
108 const LitScalPixelHit* GetHit(int stationGroup, int station, int substation, int hitId) const
109 {
110 return fHits[stationGroup][station][substation][hitId];
111 }
112
120 const std::vector<LitScalPixelHit*>& GetHits(int stationGroup, int station, int substation)
121 {
122 return fHits[stationGroup][station][substation];
123 }
124
132 unsigned int GetNofHits(int stationGroup, int station, int substation) const
133 {
134 return fHits[stationGroup][station][substation].size();
135 }
136
144 fscal GetMaxErr(int stationGroup, int station, int substation) const
145 {
146 return fMaxErr[stationGroup][station][substation];
147 }
148
152 void Clear()
153 {
154 for (unsigned int i = 0; i < fHits.size(); i++) {
155 for (unsigned int j = 0; j < fHits[i].size(); j++) {
156 for (unsigned int k = 0; k < fHits[i][j].size(); k++) {
157 fHits[i][j][k].clear();
158 fHits[i][j][k].reserve(1500);
159 fMaxErr[i][j][k] = 0.;
160 }
161 }
162 }
163 }
164
168 void SortHits()
169 {
170 // TODO : add threads here
171 for (int i = 0; i < fLayout.GetNofStationGroups(); i++) {
172 for (int j = 0; j < fLayout.GetNofStations(i); j++) {
173 for (int k = 0; k < fLayout.GetNofSubstations(i, j); k++) {
174 std::vector<LitScalPixelHit*>& shits = fHits[i][j][k];
175 std::sort(shits.begin(), shits.end(), ComparePixelHitXLess());
176 // std::cout << "station group " << i << " station " << j
177 // << " substation " << k << std::endl;
178 // for(unsigned int i = 0; i < nh; i++)
179 // std::cout << *shits[i];
180 }
181 }
182 }
183 }
184
189 std::string ToString() const
190 {
191 std::string str = "HitDataMuon:\n";
192 for (int i = 0; i < fLayout.GetNofStationGroups(); i++) {
193 str += " station group " + lit::parallel::ToString<int>(i) + "\n";
194 for (int j = 0; j < fLayout.GetNofStations(i); j++) {
195 str += " station " + lit::parallel::ToString<int>(j) + "\n";
196 for (int k = 0; k < fLayout.GetNofSubstations(i, j); k++) {
197 str += " substation " + lit::parallel::ToString<int>(k) + ": "
198 + lit::parallel::ToString<int>(GetNofHits(i, j, k)) + " hits, "
199 + "max err=" + lit::parallel::ToString<T>(GetMaxErr(i, j, k)) + "\n";
200 }
201 }
202 }
203 return str;
204 }
205
210 friend std::ostream& operator<<(std::ostream& strm, const LitHitDataMuon& hitData)
211 {
212 strm << hitData.ToString();
213 return strm;
214 }
215
216 public:
224 void StationByPlaneId(unsigned char planeId, unsigned char& stationGroup, unsigned char& station,
225 unsigned char& substation) const
226 {
227 unsigned char counter = 0;
228 for (unsigned char i = 0; i < fLayout.GetNofStationGroups(); i++) {
229 for (unsigned char j = 0; j < fLayout.GetNofStations(i); j++) {
230 counter += fLayout.GetNofSubstations(i, j);
231 if (counter > planeId) {
232 stationGroup = i;
233 station = j;
234 substation = fLayout.GetNofSubstations(i, j) - (counter - planeId);
235 return;
236 }
237 }
238 }
239 }
240
241 // Arrays of hits
242 std::vector<std::vector<std::vector<PixelHitArray>>> fHits;
243 // Arrays of maximum hit position errors for each substation
244 std::vector<std::vector<std::vector<fscal>>> fMaxErr;
245 // Detector layout
248
249 } // namespace parallel
250} // namespace lit
251#endif /* LITHITDATAMUON_H_ */
Classes for muon geometry description of CBM.
unsigned char GetNofStationGroups() const
Return number of station groups.
unsigned char GetNofStations(unsigned char stationGroup) const
Return number of stations for specified station group.
unsigned char GetNofSubstations(unsigned char stationGroup, unsigned char station) const
Return number of substations for specified station group and station.
std::vector< std::vector< std::vector< PixelHitArray > > > fHits
void SortHits()
Sort hits in each substation by X coordinate.
void Clear()
Clear hit arrays.
virtual ~LitHitDataMuon()
Destructor.
void AddHit(unsigned char planeId, LitScalPixelHit *hit)
Add hit using absolute detector plane (substation) index in the detector.
void AddHit(int stationGroup, int station, int substation, LitScalPixelHit *hit)
Add hit using station group, station and substation indices.
fscal GetMaxErr(int stationGroup, int station, int substation) const
Return maximum hit error in [cm] for the specified substation.
unsigned int GetNofHits(int stationGroup, int station, int substation) const
Return number of hits for the specified substation.
const LitScalPixelHit * GetHit(int stationGroup, int station, int substation, int hitId) const
Return hit using station group, station and substation indices.
const std::vector< LitScalPixelHit * > & GetHits(int stationGroup, int station, int substation)
Return hit vector using station group, station and substation indices.
void SetDetectorLayout(const LitDetectorLayoutMuon< T > &layout)
Set detector layout for which hits are arranged.
std::string ToString() const
Return std::string representation for the class.
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.
LitDetectorLayoutMuon< T > fLayout
friend std::ostream & operator<<(std::ostream &strm, const LitHitDataMuon &hitData)
Operator << for convenient output to std::ostream.
std::vector< std::vector< std::vector< fscal > > > fMaxErr
Base class for scalar pixel hits.
class lit::parallel::LitDetectorLayout _fvecalignment
std::string ToString(const T &value)
Function converts object into a std::string.
Definition LitUtils.h:37