CbmRoot
Loading...
Searching...
No Matches
CbmLitMCTrack.h
Go to the documentation of this file.
1/* Copyright (C) 2011-2020 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer], Semen Lebedev, Florian Uhlig */
4
11#ifndef CBMLITMCTRACK_H_
12#define CBMLITMCTRACK_H_
13
14#include "CbmDefs.h"
15#include "CbmLitMCPoint.h"
16
17#include <cassert>
18#include <map>
19#include <set>
20#include <vector>
21
22using std::endl;
23using std::map;
24using std::set;
25using std::string;
26using std::stringstream;
27using std::vector;
28
36 public:
70
74 virtual ~CbmLitMCTrack(){};
75
81 void AddPoint(ECbmModuleId detId, const CbmLitMCPoint& point)
82 {
83 fPoints[detId].push_back(point);
84 if (detId != ECbmModuleId::kRich) {
85 fStationPoints[detId][point.GetStationId()].push_back(point);
86 fStationIds[detId].insert(point.GetStationId());
87 }
88 }
89
95 const vector<CbmLitMCPoint>& GetPoints(ECbmModuleId detId) const { return fPoints.find(detId)->second; }
96
103 const CbmLitMCPoint& GetPoint(ECbmModuleId detId, Int_t index) const
104 {
105 assert(GetNofPoints(detId) != 0);
106 return fPoints.find(detId)->second[index];
107 }
108
114 UInt_t GetNofPoints(ECbmModuleId detId) const { return fPoints.find(detId)->second.size(); }
115
122 {
123 assert(detId != ECbmModuleId::kRich);
124 return fStationPoints.find(detId)->second.size();
125 }
126
133 {
134 //assert(detId == kSts);
135 // return fMaxConsecutivePoints.find(detId)->second;
136 return (detId == ECbmModuleId::kSts) ? fMaxConsecutivePoints.find(detId)->second : -1;
137 }
138
148
153 Int_t GetNofRichHits() const { return fNofRichHits; }
154
159 void SetNofRichHits(Int_t nofRichHits) { fNofRichHits = nofRichHits; }
160
165 Double_t GetRingAaxis() const { return fRingAaxis; }
166
171 void SetRingAaxis(Double_t a) { fRingAaxis = a; }
172
177 Double_t GetRingBaxis() const { return fRingBaxis; }
178
183 void SetRingBaxis(Double_t b) { fRingBaxis = b; }
184
189 Double_t GetRingCenterX() const { return fRingCenterX; }
190
195 void SetRingCenterX(Double_t xc) { fRingCenterX = xc; }
196
201 Double_t GetRingCenterY() const { return fRingCenterY; }
202
207 void SetRingCenterY(Double_t yc) { fRingCenterY = yc; }
208
220 const CbmLitMCPoint& GetPointAtStation(ECbmModuleId detId, Int_t stationId, Int_t index) const
221 {
222 assert((detId != ECbmModuleId::kRich) && (GetNofPointsAtStation(detId, stationId) != 0));
223 return fStationPoints.find(detId)->second.find(stationId)->second[index];
224 }
225
232 UInt_t GetNofPointsAtStation(ECbmModuleId detId, Int_t stationId) const
233 {
234 assert(detId != ECbmModuleId::kRich);
235 if (fStationPoints.find(detId)->second.count(stationId) > 0) {
236 return fStationPoints.find(detId)->second.find(stationId)->second.size();
237 }
238 else
239 return 0;
240 }
241
242 private:
243 // map<detector id, vector of MC points>
244 map<ECbmModuleId, vector<CbmLitMCPoint>> fPoints;
245
246 // map<detector id, map<station id, vector of MC points> >
247 map<ECbmModuleId, map<Int_t, vector<CbmLitMCPoint>>> fStationPoints;
248
249 // Temporary set to store unique station indices for fast access
250 // map<detector id, set<station index>>
251 map<ECbmModuleId, set<Int_t>> fStationIds;
252
253 // temporary storage for maximum number of consecutive MC points
254 // map<detector id, number of MC points>
255 map<ECbmModuleId, Int_t> fMaxConsecutivePoints;
256
257 Int_t fNofRichHits; // Number of hits in RICH ring
258 Double_t fRingAaxis; // major semi-axis of the ellipse
259 Double_t fRingBaxis; // minor semi-axis of the ellipse
260 Double_t fRingCenterX; // X coordinate of the ring center
261 Double_t fRingCenterY; // Y coordinate of the ring center
262
263 private:
264 Int_t MaxConsecutiveNumbers(const set<Int_t>& numbers) const
265 {
266 if (numbers.size() == 0) return 0;
267 if (numbers.size() == 1) return 1;
268
269 vector<Int_t> a(numbers.begin(), numbers.end());
270
271 int maxCnt = 0;
272 int cnt = 1;
273 for (UInt_t i = 0; i < a.size() - 1; i++) {
274 if (a[i] == (a[i + 1] - 1)) {
275 cnt++;
276 }
277 else {
278 maxCnt = std::max(cnt, maxCnt);
279 cnt = 1;
280 }
281 }
282 maxCnt = std::max(cnt, maxCnt);
283 return maxCnt;
284 }
285
286 string PointsToString(ECbmModuleId detId, const string& detName) const
287 {
288 stringstream ss;
289 ss << detName << " np=" << GetNofPoints(detId) << " npds=" << GetNofPointsInDifferentStations(detId)
290 << " ncp=" << GetNofConsecutivePoints(detId) << " points=(";
291 for (UInt_t i = 0; i < GetNofPoints(detId); i++) {
292 ss << ":" << GetPoint(detId, i).GetRefId() << ":" << GetPoint(detId, i).GetStationId() << ",";
293 //ss << GetPoint(detId, i);
294 }
295 ss << ") ";
296 return ss.str();
297 }
298
299 public:
304 virtual string ToString() const
305 {
306 stringstream ss;
307 ss << "MCTrack: ";
308 ss << PointsToString(ECbmModuleId::kMvd, "MVD") << "|";
309 ss << PointsToString(ECbmModuleId::kSts, "STS") << "|";
310 ss << PointsToString(ECbmModuleId::kTrd, "TRD") << "|";
311 ss << PointsToString(ECbmModuleId::kMuch, "MUCH") << "|";
312 ss << PointsToString(ECbmModuleId::kTof, "TOF") << "|";
313 ss << endl;
314 return ss.str();
315 }
316
321 friend std::ostream& operator<<(std::ostream& strm, const CbmLitMCTrack& track)
322 {
323 strm << track.ToString();
324 return strm;
325 }
326};
327
328#endif /* CBMLITMCTRACK_H_ */
ECbmModuleId
Definition CbmDefs.h:39
@ kMvd
Micro-Vertex Detector.
@ kTrd
Transition Radiation Detector.
@ kTof
Time-of-flight Detector.
@ kSts
Silicon Tracking System.
@ kMuch
Muon detection system.
@ kRich
Ring-Imaging Cherenkov Detector.
Monte-Carlo point.
Monte-Carlo point.
Int_t GetRefId() const
Int_t GetStationId() const
Monte-Carlo track.
map< ECbmModuleId, Int_t > fMaxConsecutivePoints
Double_t GetRingCenterY() const
Return Y coordinate of the ellipse center.
void CalculateNofConsecutivePoints()
Calculates number of consecutive MC points for specified detector id. Currently works only for STS.
Double_t GetRingAaxis() const
Return major semi-axis of the ellipse.
virtual string ToString() const
Returns string representation of the class.
map< ECbmModuleId, set< Int_t > > fStationIds
UInt_t GetNofPointsInDifferentStations(ECbmModuleId detId) const
Return number of MC points in different stations for specified detector id.
Double_t GetRingCenterX() const
Return X coordinate of the ellipse center.
void SetRingCenterY(Double_t yc)
Set Y coordinate of the ellipse center.
UInt_t GetNofPointsAtStation(ECbmModuleId detId, Int_t stationId) const
Return number of MC points for specified detector ID and station ID.
Double_t fRingCenterX
virtual ~CbmLitMCTrack()
Destructor.
void SetRingCenterX(Double_t xc)
Set X coordinate of the ellipse center.
Int_t GetNofConsecutivePoints(ECbmModuleId detId) const
Return number of consecutive MC points for specified detector id. Currently works only for STS.
const CbmLitMCPoint & GetPointAtStation(ECbmModuleId detId, Int_t stationId, Int_t index) const
Return MC point for specified detector id and point index.
UInt_t GetNofPoints(ECbmModuleId detId) const
Return number of MC points for specified detector id.
Double_t fRingAaxis
map< ECbmModuleId, map< Int_t, vector< CbmLitMCPoint > > > fStationPoints
const CbmLitMCPoint & GetPoint(ECbmModuleId detId, Int_t index) const
Return MC point for specified detector id and point index.
void SetRingBaxis(Double_t b)
Set minor semi-axis of the ellipse.
Double_t fRingBaxis
Int_t GetNofRichHits() const
Return number of RICH hits in ring.
friend std::ostream & operator<<(std::ostream &strm, const CbmLitMCTrack &track)
Operator << for convenient output to ostream.
CbmLitMCTrack()
Constructor.
Int_t MaxConsecutiveNumbers(const set< Int_t > &numbers) const
void SetRingAaxis(Double_t a)
Set major semi-axis of the ellipse.
void SetNofRichHits(Int_t nofRichHits)
SetNumber of RICH hits in ring.
const vector< CbmLitMCPoint > & GetPoints(ECbmModuleId detId) const
Return vector of MC point for specified detector id.
void AddPoint(ECbmModuleId detId, const CbmLitMCPoint &point)
Add point to track.
map< ECbmModuleId, vector< CbmLitMCPoint > > fPoints
Double_t fRingCenterY
Double_t GetRingBaxis() const
Return minor semi-axis of the ellipse.
string PointsToString(ECbmModuleId detId, const string &detName) const