CbmRoot
Loading...
Searching...
No Matches
LitHitData.h
Go to the documentation of this file.
1/* Copyright (C) 2010-2016 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
12#ifndef LITHITDATA_H_
13#define LITHITDATA_H_
14
15#include "LitScalPixelHit.h"
16#include "LitScalStripHit.h"
17
18#include <cassert>
19#include <cmath>
20#include <set>
21#include <sstream>
22#include <vector>
23using std::endl;
24using std::max;
25using std::ostream;
26using std::set;
27using std::string;
28using std::stringstream;
29using std::vector;
30
31namespace lit
32{
33 namespace parallel
34 {
35
42 class LitHitData {
43 public:
48
52 virtual ~LitHitData() {}
53
58 void SetNofStations(unsigned char nofStations)
59 {
60 fNofStations = nofStations;
61 fHits.resize(nofStations);
62 fMaxErrX.resize(nofStations);
63 fMaxErrY.resize(nofStations);
64 fZPosSet.resize(nofStations);
65 fZPosBins.resize(nofStations);
66 for (unsigned char i = 0; i < nofStations; i++) {
67 fHits[i].reserve(1500);
68 }
69 }
70
77 {
78 unsigned char station = hit->stationId;
79 assert(station < fNofStations);
80 fHits[station].push_back(hit);
81 fZPosSet[station].insert(hit->Z); // Find different Z positions of hits
82 fMaxErrX[station] = max(hit->Dx, fMaxErrX[station]);
83 fMaxErrY[station] = max(hit->Dy, fMaxErrY[station]);
84 }
85
92 const LitScalPixelHit* GetHit(unsigned char station, unsigned int hitId) const { return fHits[station][hitId]; }
93
99 const vector<LitScalPixelHit*>& GetHits(unsigned char station) { return fHits[station]; }
100
106 unsigned int GetNofHits(unsigned char station) const { return fHits[station].size(); }
107
113 fscal GetMaxErrX(unsigned char station) const { return fMaxErrX[station]; }
114
120 fscal GetMaxErrY(unsigned char station) const { return fMaxErrY[station]; }
121
122 const vector<int>& GetZPosBins(unsigned char station) const { return fZPosBins[station]; }
123
124 fscal GetZPosByBin(unsigned char station, int bin) const { return GetMinZPos(station) + bin * EPSILON; }
125
126 int GetBinByZPos(unsigned char station, fscal zPos) const { return (zPos - GetMinZPos(station)) / EPSILON; }
127
128 fscal GetMinZPos(unsigned char station) const
129 {
130 return (fZPosSet[station].empty()) ? 0. : *fZPosSet[station].begin();
131 }
132
136 void Clear()
137 {
138 for (unsigned int i = 0; i < fNofStations; i++) {
139 fHits[i].clear();
140 fHits[i].reserve(1500);
141 fMaxErrX[i] = 0.;
142 fMaxErrY[i] = 0.;
143 fZPosSet[i].clear();
144 fZPosBins[i].clear();
145 }
146 }
147
151 void Arrange()
152 {
153 for (int iStation = 0; iStation < fNofStations; iStation++) {
154 if (fZPosSet[iStation].empty()) continue;
155 fscal minZ = *fZPosSet[iStation].begin();
156 // fscal maxZ = *fZPosSet[iStation].rbegin();
157 set<int> binSet;
158 set<fscal>::const_iterator it;
159 for (it = fZPosSet[iStation].begin(); it != fZPosSet[iStation].end(); it++) {
160 fscal z = *it;
161 int bin = (z - minZ) / EPSILON;
162 binSet.insert(bin);
163 }
164
165 set<int>::const_iterator it2;
166 for (it2 = binSet.begin(); it2 != binSet.end(); it2++) {
167 int bin = *it2;
168 // fscal z = minZ + bin * EPSILON;
169 // fZPos[iStation].push_back(z);
170 fZPosBins[iStation].push_back(bin);
171 }
172 }
173 }
174
179 string ToString() const
180 {
181 stringstream ss;
182 ss << "LitHitData:" << endl;
183 for (unsigned int i = 0; i < fHits.size(); i++) {
184 ss << " station " << i << ": " << GetNofHits(i) << " hits, "
185 << "maxerrx=" << GetMaxErrX(i) << ", maxerry=" << GetMaxErrY(i) << ", ";
186 ss << "zposset=(";
187 for (set<fscal>::const_iterator it = fZPosSet[i].begin(); it != fZPosSet[i].end(); it++) {
188 ss << *it << ", ";
189 }
190 ss << ")" << endl;
191 ss << "zposbins=(";
192 for (vector<int>::const_iterator it = fZPosBins[i].begin(); it != fZPosBins[i].end(); it++) {
193 ss << "|" << *it << "," << GetZPosByBin(i, *it) << "| ";
194 }
195 ss << ")" << endl;
196 }
197 return ss.str();
198 }
199
204 friend ostream& operator<<(ostream& strm, const LitHitData& hitData)
205 {
206 strm << hitData.ToString();
207 return strm;
208 }
209
210 private:
211 static const fscal EPSILON;
212 vector<vector<LitScalPixelHit*>> fHits; // Array of hits
213 vector<fscal> fMaxErrX; // Array of maximum X error for each station
214 vector<fscal> fMaxErrY; // Array of maximum Y error for each station
215 unsigned char fNofStations; // Number of stations
216 vector<set<fscal>> fZPosSet; // Set of Z positions of hits in each station
217 // Temporarily used for Z different Z positions calculation
218 vector<vector<int>> fZPosBins; // Array of Z positions bin number of hits in each station
220
221 } // namespace parallel
222} // namespace lit
223
224#endif /* LITHITDATA_H_ */
friend fscal max(fscal x, fscal y)
Base class for scalar pixel hits.
Base class for scalar strip hits.
Class for accessing hits in track reconstruction.
Definition LitHitData.h:42
const LitScalPixelHit * GetHit(unsigned char station, unsigned int hitId) const
Return hit pointer.
Definition LitHitData.h:92
fscal GetZPosByBin(unsigned char station, int bin) const
Definition LitHitData.h:124
string ToString() const
Returns string representation of the class.
Definition LitHitData.h:179
vector< vector< int > > fZPosBins
Definition LitHitData.h:218
friend ostream & operator<<(ostream &strm, const LitHitData &hitData)
Operator << for convenient output to ostream.
Definition LitHitData.h:204
unsigned int GetNofHits(unsigned char station) const
Return number of hits for specified station.
Definition LitHitData.h:106
void AddHit(LitScalPixelHit *hit)
Add hit.
Definition LitHitData.h:76
const vector< int > & GetZPosBins(unsigned char station) const
Definition LitHitData.h:122
void Clear()
Clear hit arrays.
Definition LitHitData.h:136
void Arrange()
Must be called after all hits are added.
Definition LitHitData.h:151
vector< fscal > fMaxErrY
Definition LitHitData.h:214
fscal GetMinZPos(unsigned char station) const
Definition LitHitData.h:128
const vector< LitScalPixelHit * > & GetHits(unsigned char station)
Return vector of hits.
Definition LitHitData.h:99
fscal GetMaxErrX(unsigned char station) const
Return maximum X error in [cm] for specified station.
Definition LitHitData.h:113
LitHitData()
Constructor.
Definition LitHitData.h:47
fscal GetMaxErrY(unsigned char station) const
Return maximum Y error in [cm] for specified station.
Definition LitHitData.h:120
virtual ~LitHitData()
Destructor.
Definition LitHitData.h:52
unsigned char fNofStations
Definition LitHitData.h:215
void SetNofStations(unsigned char nofStations)
Set number of stations.
Definition LitHitData.h:58
vector< vector< LitScalPixelHit * > > fHits
Definition LitHitData.h:212
vector< set< fscal > > fZPosSet
Definition LitHitData.h:216
int GetBinByZPos(unsigned char station, fscal zPos) const
Definition LitHitData.h:126
static const fscal EPSILON
Definition LitHitData.h:211
vector< fscal > fMaxErrX
Definition LitHitData.h:213
Base class for scalar pixel hits.
class lit::parallel::LitDetectorLayout _fvecalignment