CbmRoot
CbmLitHitData.cxx
Go to the documentation of this file.
1 
7 #include "base/CbmLitHitData.h"
8 
9 #include "data/CbmLitHit.h"
10 #include "data/CbmLitPixelHit.h"
11 #include "data/CbmLitStripHit.h"
12 
13 #include <cassert>
14 #include <cmath>
15 #include <iostream>
16 #include <sstream>
17 
18 using std::endl;
19 using std::max;
20 
21 const litfloat CbmLitHitData::EPSILON = 0.005;
22 
24  : fHits(), fMaxErrX(), fMaxErrY(), fMaxErrT(), fNofStations(0) {}
25 
27 
28 void CbmLitHitData::SetNofStations(Int_t nofStations) {
29  fNofStations = nofStations;
30  fHits.resize(nofStations);
31  fMaxErrX.resize(nofStations);
32  fMaxErrY.resize(nofStations);
33  fMaxErrT.resize(nofStations);
34  fZPosSet.resize(nofStations);
35  fZPosBins.resize(nofStations);
36  for (Int_t i = 0; i < nofStations; i++) {
37  fHits[i].reserve(nofStations);
38  fMaxErrX[i] = 0.;
39  fMaxErrY[i] = 0.;
40  fMaxErrT[i] = 0.;
41  }
42 }
43 
45  Int_t station = hit->GetStation();
46  assert(station > -1 && station < fNofStations);
47  fHits[station].push_back(hit);
48 
49  // Find different Z positions of hits
50  fZPosSet[station].insert(hit->GetZ());
51 
52  // Find maximum hit error for X and Y
53  if (hit->GetType() == kLITPIXELHIT) {
54  CbmLitPixelHit* pixelHit = static_cast<CbmLitPixelHit*>(hit);
55  fMaxErrX[station] = max(pixelHit->GetDx(), fMaxErrX[station]);
56  fMaxErrY[station] = max(pixelHit->GetDy(), fMaxErrY[station]);
57  fMaxErrT[station] =
58  max(pixelHit->GetDt() > 0 ? pixelHit->GetDt() : 100, fMaxErrT[station]);
59  }
60 }
61 
62 const CbmLitHit* CbmLitHitData::GetHit(Int_t station, Int_t hitId) const {
63  return fHits[station][hitId];
64 }
65 
66 const HitPtrVector& CbmLitHitData::GetHits(Int_t station) {
67  return fHits[station];
68 }
69 
70 Int_t CbmLitHitData::GetNofHits(Int_t station) const {
71  return fHits[station].size();
72 }
73 
74 litfloat CbmLitHitData::GetMaxErrX(Int_t station) const {
75  return fMaxErrX[station];
76 }
77 
78 litfloat CbmLitHitData::GetMaxErrY(Int_t station) const {
79  return fMaxErrY[station];
80 }
81 
82 litfloat CbmLitHitData::GetMaxErrT(Int_t station) const {
83  return fMaxErrT[station];
84 }
85 
86 //const vector<litfloat>& CbmLitHitData::GetZPos(
87 // Int_t station) const
88 //{
89 // return fZPos[station];
90 //}
91 
92 const vector<Int_t>& CbmLitHitData::GetZPosBins(Int_t station) const {
93  return fZPosBins[station];
94 }
95 
96 litfloat CbmLitHitData::GetZPosByBin(Int_t station, Int_t bin) const {
97  return GetMinZPos(station) + bin * EPSILON;
98 }
99 
100 Int_t CbmLitHitData::GetBinByZPos(Int_t station, litfloat zPos) const {
101  return (zPos - GetMinZPos(station)) / EPSILON;
102 }
103 
104 litfloat CbmLitHitData::GetMinZPos(Int_t station) const {
105  return (fZPosSet[station].empty()) ? 0. : *fZPosSet[station].begin();
106 }
107 
109  for (UInt_t i = 0; i < fHits.size(); i++) {
110  fHits[i].clear();
111  fHits[i].reserve(1500);
112  fMaxErrX[i] = 0.;
113  fMaxErrY[i] = 0.;
114  fMaxErrT[i] = 0.;
115  fZPosSet[i].clear();
116  fZPosBins[i].clear();
117  }
118 }
119 
121  for (Int_t iStation = 0; iStation < fNofStations; iStation++) {
122  if (fZPosSet[iStation].empty()) continue;
123  Double_t minZ = *fZPosSet[iStation].begin();
124  Double_t maxZ = *fZPosSet[iStation].rbegin();
125  set<Int_t> binSet;
126  set<Double_t>::const_iterator it;
127  for (it = fZPosSet[iStation].begin(); it != fZPosSet[iStation].end();
128  it++) {
129  Double_t z = *it;
130  Int_t bin = (z - minZ) / EPSILON;
131  binSet.insert(bin);
132  }
133 
134  set<Int_t>::const_iterator it2;
135  for (it2 = binSet.begin(); it2 != binSet.end(); it2++) {
136  Int_t bin = *it2;
137  Double_t z = minZ + bin * EPSILON;
138  // fZPos[iStation].push_back(z);
139  fZPosBins[iStation].push_back(bin);
140  }
141  }
142 }
143 
144 string CbmLitHitData::ToString() const {
145  stringstream ss;
146  ss << "HitData: nofStations=" << fNofStations << endl;
147  for (UInt_t i = 0; i < fHits.size(); i++) {
148  ss << " station " << i << ": " << GetNofHits(i) << " hits, "
149  << "maxerrx=" << GetMaxErrX(i) << ", maxerry=" << GetMaxErrY(i)
150  << ", maxerrt=" << GetMaxErrT(i) << ", ";
151  ss << "zposset=(";
152  for (set<litfloat>::const_iterator it = fZPosSet[i].begin();
153  it != fZPosSet[i].end();
154  it++) {
155  ss << *it << ", ";
156  }
157  ss << ") ";
158  ss << "zposbins=(";
159  for (vector<Int_t>::const_iterator it = fZPosBins[i].begin();
160  it != fZPosBins[i].end();
161  it++) {
162  ss << "|" << *it << "," << GetZPosByBin(i, *it) << "| ";
163  }
164  ss << ")" << endl;
165  }
166  return ss.str();
167 }
CbmLitHitData::fMaxErrT
vector< litfloat > fMaxErrT
Definition: CbmLitHitData.h:153
CbmLitHitData::Arrange
void Arrange()
Must be called after all hits are added.
Definition: CbmLitHitData.cxx:120
litfloat
double litfloat
Definition: CbmLitFloat.h:15
CbmLitPixelHit::GetDy
litfloat GetDy() const
Definition: CbmLitPixelHit.h:40
CbmLitHitData::GetZPosByBin
litfloat GetZPosByBin(Int_t station, Int_t bin) const
Return Z positions of hit.
Definition: CbmLitHitData.cxx:96
CbmLitStripHit.h
Base data class for strip hits.
CbmLitHitData::fZPosSet
vector< set< litfloat > > fZPosSet
Definition: CbmLitHitData.h:155
CbmLitHit::GetZ
litfloat GetZ() const
Definition: CbmLitHit.h:48
CbmLitHitData::fHits
vector< HitPtrVector > fHits
Definition: CbmLitHitData.h:147
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmLitPixelHit.h
Base data class for pixel hits.
CbmLitHitData::Clear
void Clear()
Clear array of hits.
Definition: CbmLitHitData.cxx:108
CbmLitHitData::GetNofHits
Int_t GetNofHits(Int_t station) const
Return number of hits for the specified station index.
Definition: CbmLitHitData.cxx:70
CbmLitHitData::CbmLitHitData
CbmLitHitData()
Constructor.
Definition: CbmLitHitData.cxx:23
CbmLitHitData::GetMaxErrY
litfloat GetMaxErrY(Int_t station) const
Definition: CbmLitHitData.cxx:78
CbmLitHitData::EPSILON
static const litfloat EPSILON
Definition: CbmLitHitData.h:146
CbmLitHitData::GetZPosBins
const vector< Int_t > & GetZPosBins(Int_t station) const
Return bin numbers for Z positions of hits.
Definition: CbmLitHitData.cxx:92
CbmLitHit
Base data class for hits.
Definition: CbmLitHit.h:26
CbmLitPixelHit
Base data class for pixel hits.
Definition: CbmLitPixelHit.h:22
kLITPIXELHIT
@ kLITPIXELHIT
Definition: CbmLitEnums.h:16
CbmLitHitData.h
Class for accessing the hits in the track reconstruction.
CbmLitHit::GetStation
Int_t GetStation() const
Definition: CbmLitHit.h:55
CbmLitHit::GetDt
litfloat GetDt() const
Definition: CbmLitHit.h:51
CbmLitHitData::GetHits
const HitPtrVector & GetHits(Int_t station)
Return array of hits.
Definition: CbmLitHitData.cxx:66
CbmLitHitData::GetBinByZPos
Int_t GetBinByZPos(Int_t station, litfloat zPos) const
Return bin number for hit Z position.
Definition: CbmLitHitData.cxx:100
CbmLitHitData::fMaxErrY
vector< litfloat > fMaxErrY
Definition: CbmLitHitData.h:151
CbmLitHitData::fMaxErrX
vector< litfloat > fMaxErrX
Definition: CbmLitHitData.h:149
CbmLitHitData::GetMaxErrT
litfloat GetMaxErrT(Int_t station) const
Definition: CbmLitHitData.cxx:82
CbmLitHitData::AddHit
void AddHit(CbmLitHit *hit)
Add hit.
Definition: CbmLitHitData.cxx:44
CbmLitHitData::fZPosBins
vector< vector< Int_t > > fZPosBins
Definition: CbmLitHitData.h:159
max
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: L1/vectors/P4_F32vec4.h:36
CbmLitHitData::fNofStations
Int_t fNofStations
Definition: CbmLitHitData.h:154
CbmLitHitData::GetHit
const CbmLitHit * GetHit(Int_t station, Int_t hitId) const
Return hit pointer.
Definition: CbmLitHitData.cxx:62
CbmLitHit::GetType
LitHitType GetType() const
Definition: CbmLitHit.h:47
CbmLitPixelHit::GetDx
litfloat GetDx() const
Definition: CbmLitPixelHit.h:39
CbmLitHitData::GetMinZPos
litfloat GetMinZPos(Int_t station) const
Return minimum Z position of hits.
Definition: CbmLitHitData.cxx:104
CbmLitHit.h
Base data class for hits.
CbmLitHitData::~CbmLitHitData
virtual ~CbmLitHitData()
Destructor.
Definition: CbmLitHitData.cxx:26
HitPtrVector
std::vector< CbmTofHit * > HitPtrVector
Definition: CbmTofTypes.h:14
CbmLitHitData::ToString
virtual string ToString() const
Return string representation of this class.
Definition: CbmLitHitData.cxx:144
CbmLitHitData::GetMaxErrX
litfloat GetMaxErrX(Int_t station) const
Definition: CbmLitHitData.cxx:74
CbmLitHitData::SetNofStations
void SetNofStations(Int_t nofStations)
Set number of stations.
Definition: CbmLitHitData.cxx:28