BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnMCTrack.h
Go to the documentation of this file.
1
/**
2
* \file BmnMCTrack.h
3
* \brief Monte-Carlo track.
4
* \author Andrey Lebedev <andrey.lebedev@gsi.de>
5
* \date 2011
6
**/
7
#ifndef BMNMCTRACK_H_
8
#define BMNMCTRACK_H_
9
10
#include "
BmnDetectorList.h
"
11
#include "
BmnMCPoint.h
"
12
13
#include <cassert>
14
#include <map>
15
#include <set>
16
#include <vector>
17
18
using namespace
std
;
19
20
/**
21
* \class BmnMCTrack
22
* \brief Monte-Carlo track.
23
* \author Andrey Lebedev <andrey.lebedev@gsi.de>
24
* \date 2011
25
**/
26
class
BmnMCTrack
27
{
28
public
:
29
/**
30
* \brief Constructor.
31
*/
32
BmnMCTrack
()
33
{
34
// Initialize all maps
35
fPoints
[
kSILICON
];
36
fPoints
[
kSSD
];
37
fPoints
[
kGEM
];
38
fPoints
[
kTOF1
];
39
fPoints
[
kDCH
];
40
fPoints
[
kTOF
];
41
fPoints
[
kCSC
];
42
// fStationPoints[kGEM];
43
// fStationPoints[kTOF1];
44
// fStationPoints[kDCH1];
45
// fStationPoints[kDCH2];
46
// fStationPoints[kTOF];
47
// fStationIds[kGEM];
48
// fStationIds[kTOF1];
49
// fStationIds[kDCH1];
50
// fStationIds[kDCH2];
51
// fStationIds[kTOF];
52
// fMaxConsecutivePoints[kGEM] = -1;
53
}
54
55
/**
56
* \brief Destructor.
57
*/
58
virtual
~BmnMCTrack
() {};
59
60
/**
61
* \brief Add point to track.
62
* \param[in] detId Detector identificator.
63
* \param[in] point MC point to be added.
64
*/
65
void
AddPoint
(DetectorId detId,
const
BmnMCPoint
& point)
66
{
67
fPoints
[detId].push_back(point);
68
// fStationPoints[detId][point.GetStationId()].push_back(point);
69
// fStationIds[detId].insert(point.GetStationId());
70
}
71
72
/**
73
* \brief Return vector of MC point for specified detector id.
74
* \param[in] detId Detector identificator.
75
* \return Array of MC points.
76
*/
77
const
vector<BmnMCPoint>&
GetPoints
(DetectorId detId)
const
{
return
fPoints
.find(detId)->second; }
78
79
/**
80
* \brief Return MC point for specified detector id and point index.
81
* \param[in] detId Detector identificator.
82
* \param[in] index Index of MC point.
83
* \return MC point.
84
*/
85
const
BmnMCPoint
&
GetPoint
(DetectorId detId,
Int_t
index)
const
86
{
87
assert(
GetNofPoints
(detId) != 0);
88
return
fPoints
.find(detId)->second[index];
89
}
90
91
/**
92
* \brief Return number of MC points for specified detector id.
93
* \param[in] detId Detector identificator.
94
* \return Number of MC points.
95
*/
96
UInt_t
GetNofPoints
(DetectorId detId)
const
{
return
fPoints
.find(detId)->second.size(); }
97
98
/**
99
* \brief Return number of MC points in different stations for specified detector id.
100
* \param[in] detId Detector identificator.
101
* \return Number of MC points.
102
*/
103
// UInt_t GetNofPointsInDifferentStations(DetectorId detId) const {
104
// return fStationPoints.find(detId)->second.size();
105
// }
106
107
/**
108
* \brief Return number of consecutive MC points for specified detector id. Currently works only for STS.
109
* \param[in] detId Detector identificator.
110
* \return Number of MC points.
111
*/
112
// Int_t GetNofConsecutivePoints(DetectorId detId) const {
113
// //assert(detId == kSTS);
114
//// return fMaxConsecutivePoints.find(detId)->second;
115
// return (detId == kGEM) ? fMaxConsecutivePoints.find(detId)->second : -1;
116
// }
117
118
/**
119
* \brief Calculates number of consecutive MC points for specified detector id. Currently works only for STS.
120
* \param[in] detId Detector identificator.
121
* \return Number of MC points.
122
*/
123
// void CalculateNofConsecutivePoints() {
124
// fMaxConsecutivePoints[kGEM] = MaxConsecutiveNumbers(fStationIds.find(kGEM)->second);
125
// }
126
127
/**
128
* \brief Return MC point for specified detector id and point index.
129
*
130
* Before accessing points with this function one has to check
131
* the number of points on this station!
132
*
133
* \param[in] detId Detector identificator.
134
* \param[in] stationId Station id.
135
* \param[in] index Index of MC point.
136
* \return MC point.
137
*/
138
// const BmnMCPoint& GetPointAtStation(
139
// DetectorId detId,
140
// Int_t stationId,
141
// Int_t index) const {
142
// assert(GetNofPointsAtStation(detId, stationId) != 0);
143
// return fStationPoints.find(detId)->second.find(stationId)->second[index];
144
// }
145
146
/**
147
* \brief Return number of MC points for specified detector ID and station ID.
148
* \param[in] detId Detector identificator.
149
* \param[in] stationId Station id.
150
* \return Number of MC points.
151
*/
152
// UInt_t GetNofPointsAtStation(
153
// DetectorId detId,
154
// Int_t stationId) const {
155
// if (fStationPoints.find(detId)->second.count(stationId) > 0) {
156
// return fStationPoints.find(detId)->second.find(stationId)->second.size();
157
// } else return 0;
158
// }
159
160
private
:
161
// map<detector id, vector of MC points>
162
map<Int_t, vector<BmnMCPoint>>
fPoints
;
163
164
// map<detector id, map<station id, vector of MC points> >
165
// map<Int_t, map<Int_t, vector<BmnMCPoint> > > fStationPoints;
166
167
// Temporary set to store unique station indices for fast access
168
// map<detector id, set<station index>>
169
// map<Int_t, set<Int_t> > fStationIds;
170
171
// temporary storage for maximum number of consecutive MC points
172
// map<detector id, number of MC points>
173
// map<Int_t, Int_t> fMaxConsecutivePoints;
174
175
private
:
176
Int_t
MaxConsecutiveNumbers
(
const
set<Int_t>& numbers)
const
177
{
178
if
(numbers.size() == 0)
179
return
0;
180
if
(numbers.size() == 1)
181
return
1;
182
183
vector<Int_t> a(numbers.begin(), numbers.end());
184
185
int
maxCnt = 0;
186
int
cnt = 1;
187
for
(
size_t
i
= 0;
i
< a.size() - 1;
i
++) {
188
if
(a[
i
] == (a[
i
+ 1] - 1)) {
189
cnt++;
190
}
else
{
191
maxCnt = std::max(cnt, maxCnt);
192
cnt = 1;
193
}
194
}
195
maxCnt = std::max(cnt, maxCnt);
196
return
maxCnt;
197
}
198
199
string
PointsToString
(DetectorId detId,
const
string
& detName)
const
200
{
201
stringstream ss;
202
// ss << detName << " np=" << GetNofPoints(detId) << " npds=" << GetNofPointsInDifferentStations(detId)
203
// << " ncp=" << GetNofConsecutivePoints(detId) << " points=(";
204
// for (Int_t i = 0; i < GetNofPoints(detId); i++) {
205
// ss << ":" << GetPoint(detId, i).GetRefId() << ":" << GetPoint(detId, i).GetStationId() << ",";
206
// //ss << GetPoint(detId, i);
207
// }
208
// ss << ") ";
209
return
ss.str();
210
}
211
212
public
:
213
/**
214
* \brief Returns string representation of the class.
215
* \return Class representation as string.
216
*/
217
virtual
string
ToString
()
const
218
{
219
stringstream ss;
220
ss <<
"MCTrack: "
;
221
ss <<
PointsToString
(
kGEM
,
"STS"
) <<
"|"
;
222
ss <<
PointsToString
(
kTOF1
,
"TOF1"
) <<
"|"
;
223
ss <<
PointsToString
(
kDCH
,
"DCH1"
) <<
"|"
;
224
ss <<
PointsToString
(
kTOF
,
"TOF"
) <<
"|"
;
225
ss << endl;
226
return
ss.str();
227
}
228
229
/**
230
* \brief Operator << for convenient output to ostream.
231
* \return Insertion stream in order to be able to call a succession of insertion operations.
232
*/
233
friend
ostream&
operator<<
(ostream& strm,
const
BmnMCTrack
& track)
234
{
235
strm << track.
ToString
();
236
return
strm;
237
}
238
};
239
240
#endif
/* BmnMCTRACK_H_ */
i
int i
Definition
P4_F32vec4.h:22
Int_t
int Int_t
kSILICON
@ kSILICON
Definition
BmnDetectorList.h:25
kGEM
@ kGEM
Definition
BmnDetectorList.h:15
kTOF
@ kTOF
Definition
BmnDetectorList.h:18
kSSD
@ kSSD
Definition
BmnDetectorList.h:37
kTOF1
@ kTOF1
Definition
BmnDetectorList.h:16
kCSC
@ kCSC
Definition
BmnDetectorList.h:24
kDCH
@ kDCH
Definition
BmnDetectorList.h:17
BmnMCPoint
Monte-Carlo point.
Definition
BmnMCPoint.h:23
BmnMCTrack::GetPoints
const vector< BmnMCPoint > & GetPoints(DetectorId detId) const
Return vector of MC point for specified detector id.
Definition
BmnMCTrack.h:77
BmnMCTrack::operator<<
friend ostream & operator<<(ostream &strm, const BmnMCTrack &track)
Operator << for convenient output to ostream.
Definition
BmnMCTrack.h:233
BmnMCTrack::fPoints
map< Int_t, vector< BmnMCPoint > > fPoints
Return number of MC points in different stations for specified detector id.
Definition
BmnMCTrack.h:162
BmnMCTrack::MaxConsecutiveNumbers
Int_t MaxConsecutiveNumbers(const set< Int_t > &numbers) const
Definition
BmnMCTrack.h:176
BmnMCTrack::~BmnMCTrack
virtual ~BmnMCTrack()
Destructor.
Definition
BmnMCTrack.h:58
BmnMCTrack::GetPoint
const BmnMCPoint & GetPoint(DetectorId detId, Int_t index) const
Return MC point for specified detector id and point index.
Definition
BmnMCTrack.h:85
BmnMCTrack::GetNofPoints
UInt_t GetNofPoints(DetectorId detId) const
Return number of MC points for specified detector id.
Definition
BmnMCTrack.h:96
BmnMCTrack::BmnMCTrack
BmnMCTrack()
Constructor.
Definition
BmnMCTrack.h:32
BmnMCTrack::PointsToString
string PointsToString(DetectorId detId, const string &detName) const
Definition
BmnMCTrack.h:199
BmnMCTrack::ToString
virtual string ToString() const
Returns string representation of the class.
Definition
BmnMCTrack.h:217
BmnMCTrack::AddPoint
void AddPoint(DetectorId detId, const BmnMCPoint &point)
Add point to track.
Definition
BmnMCTrack.h:65
BmnDetectorList.h
Defines unique identifiers (enum) for all BM@N detector systems.
BmnMCPoint.h
Monte-Carlo point.
std
Definition
json.hpp:4446
install
include
BmnMCTrack.h
Generated on
for BmnRoot by
1.17.0