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