CbmRoot
CbmLitMCTrack.h
Go to the documentation of this file.
1 
7 #ifndef CBMLITMCTRACK_H_
8 #define CBMLITMCTRACK_H_
9 
10 #include "CbmDefs.h"
11 #include "CbmLitMCPoint.h"
12 #include <cassert>
13 #include <map>
14 #include <set>
15 #include <vector>
16 
17 using std::endl;
18 using std::map;
19 using std::set;
20 using std::string;
21 using std::stringstream;
22 using std::vector;
23 
31 public:
36  : fPoints()
37  , fStationPoints()
38  , fStationIds()
40  , fNofRichHits(0)
41  , fRingAaxis(0.)
42  , fRingBaxis(0.)
43  , fRingCenterX(0.)
44  , fRingCenterY(0.) {
45  // Initialize all maps
63  }
64 
68  virtual ~CbmLitMCTrack() {};
69 
75  void AddPoint(ECbmModuleId detId, const CbmLitMCPoint& point) {
76  fPoints[detId].push_back(point);
77  if (detId != ECbmModuleId::kRich) {
78  fStationPoints[detId][point.GetStationId()].push_back(point);
79  fStationIds[detId].insert(point.GetStationId());
80  }
81  }
82 
88  const vector<CbmLitMCPoint>& GetPoints(ECbmModuleId detId) const {
89  return fPoints.find(detId)->second;
90  }
91 
98  const CbmLitMCPoint& GetPoint(ECbmModuleId detId, Int_t index) const {
99  assert(GetNofPoints(detId) != 0);
100  return fPoints.find(detId)->second[index];
101  }
102 
108  UInt_t GetNofPoints(ECbmModuleId detId) const {
109  return fPoints.find(detId)->second.size();
110  }
111 
118  assert(detId != ECbmModuleId::kRich);
119  return fStationPoints.find(detId)->second.size();
120  }
121 
128  //assert(detId == kSts);
129  // return fMaxConsecutivePoints.find(detId)->second;
130  return (detId == ECbmModuleId::kSts)
131  ? fMaxConsecutivePoints.find(detId)->second
132  : -1;
133  }
134 
143  }
144 
149  Int_t GetNofRichHits() const { return fNofRichHits; }
150 
155  void SetNofRichHits(Int_t nofRichHits) { fNofRichHits = nofRichHits; }
156 
161  Double_t GetRingAaxis() const { return fRingAaxis; }
162 
167  void SetRingAaxis(Double_t a) { fRingAaxis = a; }
168 
173  Double_t GetRingBaxis() const { return fRingBaxis; }
174 
179  void SetRingBaxis(Double_t b) { fRingBaxis = b; }
180 
185  Double_t GetRingCenterX() const { return fRingCenterX; }
186 
191  void SetRingCenterX(Double_t xc) { fRingCenterX = xc; }
192 
197  Double_t GetRingCenterY() const { return fRingCenterY; }
198 
203  void SetRingCenterY(Double_t yc) { fRingCenterY = yc; }
204 
216  const CbmLitMCPoint&
217  GetPointAtStation(ECbmModuleId detId, Int_t stationId, Int_t index) const {
218  assert((detId != ECbmModuleId::kRich)
219  && (GetNofPointsAtStation(detId, stationId) != 0));
220  return fStationPoints.find(detId)->second.find(stationId)->second[index];
221  }
222 
229  UInt_t GetNofPointsAtStation(ECbmModuleId detId, Int_t stationId) const {
230  assert(detId != ECbmModuleId::kRich);
231  if (fStationPoints.find(detId)->second.count(stationId) > 0) {
232  return fStationPoints.find(detId)->second.find(stationId)->second.size();
233  } else
234  return 0;
235  }
236 
237 private:
238  // map<detector id, vector of MC points>
239  map<ECbmModuleId, vector<CbmLitMCPoint>> fPoints;
240 
241  // map<detector id, map<station id, vector of MC points> >
242  map<ECbmModuleId, map<Int_t, vector<CbmLitMCPoint>>> fStationPoints;
243 
244  // Temporary set to store unique station indices for fast access
245  // map<detector id, set<station index>>
246  map<ECbmModuleId, set<Int_t>> fStationIds;
247 
248  // temporary storage for maximum number of consecutive MC points
249  // map<detector id, number of MC points>
250  map<ECbmModuleId, Int_t> fMaxConsecutivePoints;
251 
252  Int_t fNofRichHits; // Number of hits in RICH ring
253  Double_t fRingAaxis; // major semi-axis of the ellipse
254  Double_t fRingBaxis; // minor semi-axis of the ellipse
255  Double_t fRingCenterX; // X coordinate of the ring center
256  Double_t fRingCenterY; // Y coordinate of the ring center
257 
258 private:
259  Int_t MaxConsecutiveNumbers(const set<Int_t>& numbers) const {
260  if (numbers.size() == 0) return 0;
261  if (numbers.size() == 1) return 1;
262 
263  vector<Int_t> a(numbers.begin(), numbers.end());
264 
265  int maxCnt = 0;
266  int cnt = 1;
267  for (UInt_t i = 0; i < a.size() - 1; i++) {
268  if (a[i] == (a[i + 1] - 1)) {
269  cnt++;
270  } else {
271  maxCnt = std::max(cnt, maxCnt);
272  cnt = 1;
273  }
274  }
275  maxCnt = std::max(cnt, maxCnt);
276  return maxCnt;
277  }
278 
279  string PointsToString(ECbmModuleId detId, const string& detName) const {
280  stringstream ss;
281  ss << detName << " np=" << GetNofPoints(detId)
282  << " npds=" << GetNofPointsInDifferentStations(detId)
283  << " ncp=" << GetNofConsecutivePoints(detId) << " points=(";
284  for (UInt_t i = 0; i < GetNofPoints(detId); i++) {
285  ss << ":" << GetPoint(detId, i).GetRefId() << ":"
286  << GetPoint(detId, i).GetStationId() << ",";
287  //ss << GetPoint(detId, i);
288  }
289  ss << ") ";
290  return ss.str();
291  }
292 
293 public:
298  virtual string ToString() const {
299  stringstream ss;
300  ss << "MCTrack: ";
301  ss << PointsToString(ECbmModuleId::kMvd, "MVD") << "|";
302  ss << PointsToString(ECbmModuleId::kSts, "STS") << "|";
303  ss << PointsToString(ECbmModuleId::kTrd, "TRD") << "|";
304  ss << PointsToString(ECbmModuleId::kMuch, "MUCH") << "|";
305  ss << PointsToString(ECbmModuleId::kTof, "TOF") << "|";
306  ss << endl;
307  return ss.str();
308  }
309 
314  friend std::ostream& operator<<(std::ostream& strm,
315  const CbmLitMCTrack& track) {
316  strm << track.ToString();
317  return strm;
318  }
319 };
320 
321 #endif /* CBMLITMCTRACK_H_ */
CbmLitMCPoint::GetStationId
Int_t GetStationId() const
Definition: CbmLitMCPoint.h:98
CbmLitMCTrack::operator<<
friend std::ostream & operator<<(std::ostream &strm, const CbmLitMCTrack &track)
Operator << for convenient output to ostream.
Definition: CbmLitMCTrack.h:314
CbmLitMCTrack::GetNofPointsAtStation
UInt_t GetNofPointsAtStation(ECbmModuleId detId, Int_t stationId) const
Return number of MC points for specified detector ID and station ID.
Definition: CbmLitMCTrack.h:229
CbmLitMCTrack::GetNofPoints
UInt_t GetNofPoints(ECbmModuleId detId) const
Return number of MC points for specified detector id.
Definition: CbmLitMCTrack.h:108
CbmLitMCTrack::fRingBaxis
Double_t fRingBaxis
Definition: CbmLitMCTrack.h:254
CbmLitMCTrack::SetRingCenterY
void SetRingCenterY(Double_t yc)
Set Y coordinate of the ellipse center.
Definition: CbmLitMCTrack.h:203
CbmLitMCTrack::fRingCenterX
Double_t fRingCenterX
Definition: CbmLitMCTrack.h:255
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmLitMCTrack::fNofRichHits
Int_t fNofRichHits
Definition: CbmLitMCTrack.h:252
CbmLitMCTrack::fPoints
map< ECbmModuleId, vector< CbmLitMCPoint > > fPoints
Definition: CbmLitMCTrack.h:239
ECbmModuleId::kMvd
@ kMvd
Micro-Vertex Detector.
ECbmModuleId
ECbmModuleId
Definition: CbmDefs.h:33
CbmLitMCTrack::PointsToString
string PointsToString(ECbmModuleId detId, const string &detName) const
Definition: CbmLitMCTrack.h:279
CbmLitMCTrack::GetRingBaxis
Double_t GetRingBaxis() const
Return minor semi-axis of the ellipse.
Definition: CbmLitMCTrack.h:173
ECbmModuleId::kTof
@ kTof
Time-of-flight Detector.
CbmLitMCTrack::fStationPoints
map< ECbmModuleId, map< Int_t, vector< CbmLitMCPoint > > > fStationPoints
Definition: CbmLitMCTrack.h:242
CbmLitMCTrack::SetRingCenterX
void SetRingCenterX(Double_t xc)
Set X coordinate of the ellipse center.
Definition: CbmLitMCTrack.h:191
CbmLitMCTrack::GetNofRichHits
Int_t GetNofRichHits() const
Return number of RICH hits in ring.
Definition: CbmLitMCTrack.h:149
CbmLitMCTrack::SetRingAaxis
void SetRingAaxis(Double_t a)
Set major semi-axis of the ellipse.
Definition: CbmLitMCTrack.h:167
CbmLitMCTrack::fRingAaxis
Double_t fRingAaxis
Definition: CbmLitMCTrack.h:253
CbmLitMCPoint
Monte-Carlo point.
Definition: CbmLitMCPoint.h:21
CbmLitMCTrack::MaxConsecutiveNumbers
Int_t MaxConsecutiveNumbers(const set< Int_t > &numbers) const
Definition: CbmLitMCTrack.h:259
CbmLitMCPoint.h
Monte-Carlo point.
CbmLitMCTrack::fMaxConsecutivePoints
map< ECbmModuleId, Int_t > fMaxConsecutivePoints
Definition: CbmLitMCTrack.h:250
CbmLitMCTrack::GetRingCenterY
Double_t GetRingCenterY() const
Return Y coordinate of the ellipse center.
Definition: CbmLitMCTrack.h:197
CbmLitMCTrack::CalculateNofConsecutivePoints
void CalculateNofConsecutivePoints()
Calculates number of consecutive MC points for specified detector id. Currently works only for STS.
Definition: CbmLitMCTrack.h:140
ECbmModuleId::kRich
@ kRich
Ring-Imaging Cherenkov Detector.
CbmLitMCTrack::SetNofRichHits
void SetNofRichHits(Int_t nofRichHits)
SetNumber of RICH hits in ring.
Definition: CbmLitMCTrack.h:155
CbmLitMCTrack::fRingCenterY
Double_t fRingCenterY
Definition: CbmLitMCTrack.h:256
CbmLitMCTrack::GetRingAaxis
Double_t GetRingAaxis() const
Return major semi-axis of the ellipse.
Definition: CbmLitMCTrack.h:161
CbmLitMCTrack::GetPoints
const vector< CbmLitMCPoint > & GetPoints(ECbmModuleId detId) const
Return vector of MC point for specified detector id.
Definition: CbmLitMCTrack.h:88
CbmLitMCTrack::CbmLitMCTrack
CbmLitMCTrack()
Constructor.
Definition: CbmLitMCTrack.h:35
CbmLitMCTrack::SetRingBaxis
void SetRingBaxis(Double_t b)
Set minor semi-axis of the ellipse.
Definition: CbmLitMCTrack.h:179
ECbmModuleId::kTrd
@ kTrd
Transition Radiation Detector.
CbmLitMCTrack::GetNofPointsInDifferentStations
UInt_t GetNofPointsInDifferentStations(ECbmModuleId detId) const
Return number of MC points in different stations for specified detector id.
Definition: CbmLitMCTrack.h:117
CbmLitMCTrack::GetNofConsecutivePoints
Int_t GetNofConsecutivePoints(ECbmModuleId detId) const
Return number of consecutive MC points for specified detector id. Currently works only for STS.
Definition: CbmLitMCTrack.h:127
CbmLitMCTrack::GetRingCenterX
Double_t GetRingCenterX() const
Return X coordinate of the ellipse center.
Definition: CbmLitMCTrack.h:185
CbmLitMCTrack::GetPoint
const CbmLitMCPoint & GetPoint(ECbmModuleId detId, Int_t index) const
Return MC point for specified detector id and point index.
Definition: CbmLitMCTrack.h:98
CbmLitMCTrack
Monte-Carlo track.
Definition: CbmLitMCTrack.h:30
CbmLitMCTrack::ToString
virtual string ToString() const
Returns string representation of the class.
Definition: CbmLitMCTrack.h:298
CbmLitMCPoint::GetRefId
Int_t GetRefId() const
Definition: CbmLitMCPoint.h:97
CbmLitMCTrack::fStationIds
map< ECbmModuleId, set< Int_t > > fStationIds
Definition: CbmLitMCTrack.h:246
CbmLitMCTrack::GetPointAtStation
const CbmLitMCPoint & GetPointAtStation(ECbmModuleId detId, Int_t stationId, Int_t index) const
Return MC point for specified detector id and point index.
Definition: CbmLitMCTrack.h:217
ECbmModuleId::kMuch
@ kMuch
Muon detection system.
CbmLitMCTrack::~CbmLitMCTrack
virtual ~CbmLitMCTrack()
Destructor.
Definition: CbmLitMCTrack.h:68
max
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: L1/vectors/P4_F32vec4.h:36
ECbmModuleId::kSts
@ kSts
Silicon Tracking System.
CbmLitMCTrack::AddPoint
void AddPoint(ECbmModuleId detId, const CbmLitMCPoint &point)
Add point to track.
Definition: CbmLitMCTrack.h:75
CbmDefs.h