BmnRoot
Loading...
Searching...
No Matches
BmnMCTrack.h
Go to the documentation of this file.
1
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 <vector>
16#include <set>
17
18using namespace std;
19
27{
28public:
33 // Initialize all maps
34 fPoints[kSILICON];
35 fPoints[kSSD];
36 fPoints[kGEM];
37 fPoints[kTOF1];
38 fPoints[kDCH];
39 fPoints[kTOF];
40 fPoints[kCSC];
41// fStationPoints[kGEM];
42// fStationPoints[kTOF1];
43// fStationPoints[kDCH1];
44// fStationPoints[kDCH2];
45// fStationPoints[kTOF];
46// fStationIds[kGEM];
47// fStationIds[kTOF1];
48// fStationIds[kDCH1];
49// fStationIds[kDCH2];
50// fStationIds[kTOF];
51// fMaxConsecutivePoints[kGEM] = -1;
52 }
53
57 virtual ~BmnMCTrack() {};
58
64 void AddPoint(DetectorId detId, const BmnMCPoint& point) {
65 fPoints[detId].push_back(point);
66// fStationPoints[detId][point.GetStationId()].push_back(point);
67// fStationIds[detId].insert(point.GetStationId());
68
69 }
70
76 const vector<BmnMCPoint>& GetPoints(DetectorId detId) const {
77 return fPoints.find(detId)->second;
78 }
79
86 const BmnMCPoint& GetPoint(DetectorId detId, Int_t index) const {
87 assert(GetNofPoints(detId) != 0);
88 return fPoints.find(detId)->second[index];
89 }
90
96 UInt_t GetNofPoints(DetectorId detId) const {
97 return fPoints.find(detId)->second.size();
98 }
99
105// UInt_t GetNofPointsInDifferentStations(DetectorId detId) const {
106// return fStationPoints.find(detId)->second.size();
107// }
108
114// Int_t GetNofConsecutivePoints(DetectorId detId) const {
115// //assert(detId == kSTS);
117// return (detId == kGEM) ? fMaxConsecutivePoints.find(detId)->second : -1;
118// }
119
125// void CalculateNofConsecutivePoints() {
126// fMaxConsecutivePoints[kGEM] = MaxConsecutiveNumbers(fStationIds.find(kGEM)->second);
127// }
128
140// const BmnMCPoint& GetPointAtStation(
141// DetectorId detId,
142// Int_t stationId,
143// Int_t index) const {
144// assert(GetNofPointsAtStation(detId, stationId) != 0);
145// return fStationPoints.find(detId)->second.find(stationId)->second[index];
146// }
147
154// UInt_t GetNofPointsAtStation(
155// DetectorId detId,
156// Int_t stationId) const {
157// if (fStationPoints.find(detId)->second.count(stationId) > 0) {
158// return fStationPoints.find(detId)->second.find(stationId)->second.size();
159// } else return 0;
160// }
161
162private:
163 // map<detector id, vector of MC points>
164 map<Int_t, vector<BmnMCPoint> > fPoints;
165
166 // map<detector id, map<station id, vector of MC points> >
167 // map<Int_t, map<Int_t, vector<BmnMCPoint> > > fStationPoints;
168
169 // Temporary set to store unique station indices for fast access
170 // map<detector id, set<station index>>
171 // map<Int_t, set<Int_t> > fStationIds;
172
173 // temporary storage for maximum number of consecutive MC points
174 // map<detector id, number of MC points>
175 // map<Int_t, Int_t> fMaxConsecutivePoints;
176
177private:
178
179 Int_t MaxConsecutiveNumbers(
180 const set<Int_t>& numbers) const {
181 if (numbers.size() == 0) return 0;
182 if (numbers.size() == 1) return 1;
183
184 vector<Int_t> a(numbers.begin(), numbers.end());
185
186 int maxCnt = 0;
187 int cnt = 1;
188 for (size_t i = 0; i < a.size() - 1; i++)
189 {
190 if (a[i] == (a[i + 1] - 1)) {
191 cnt++;
192 } else {
193 maxCnt = std::max(cnt, maxCnt);
194 cnt = 1;
195 }
196 }
197 maxCnt = std::max(cnt, maxCnt);
198 return maxCnt;
199 }
200
201 string PointsToString(
202 DetectorId detId,
203 const string& detName) const {
204 stringstream ss;
205// ss << detName << " np=" << GetNofPoints(detId) << " npds=" << GetNofPointsInDifferentStations(detId)
206// << " ncp=" << GetNofConsecutivePoints(detId) << " points=(";
207// for (Int_t i = 0; i < GetNofPoints(detId); i++) {
208// ss << ":" << GetPoint(detId, i).GetRefId() << ":" << GetPoint(detId, i).GetStationId() << ",";
209// //ss << GetPoint(detId, i);
210// }
211// ss << ") ";
212 return ss.str();
213 }
214
215public:
216
221 virtual string ToString() const {
222 stringstream ss;
223 ss << "MCTrack: ";
224 ss << PointsToString(kGEM, "STS") << "|";
225 ss << PointsToString(kTOF1, "TOF1") << "|";
226 ss << PointsToString(kDCH, "DCH1") << "|";
227 ss << PointsToString(kTOF, "TOF") << "|";
228 ss << endl;
229 return ss.str();
230 }
231
236 friend ostream& operator<<(ostream& strm, const BmnMCTrack& track) {
237 strm << track.ToString();
238 return strm;
239 }
240};
241
242#endif /* BmnMCTRACK_H_ */
int i
Definition P4_F32vec4.h:22
Monte-Carlo point.
DetectorId
@ kSILICON
@ kGEM
@ kTOF
@ kSSD
@ kTOF1
@ kCSC
@ kDCH
Monte-Carlo point.
Definition BmnMCPoint.h:21
Monte-Carlo track.
Definition BmnMCTrack.h:27
const vector< BmnMCPoint > & GetPoints(DetectorId detId) const
Return vector of MC point for specified detector id.
Definition BmnMCTrack.h:76
friend ostream & operator<<(ostream &strm, const BmnMCTrack &track)
Operator << for convenient output to ostream.
Definition BmnMCTrack.h:236
virtual ~BmnMCTrack()
Destructor.
Definition BmnMCTrack.h:57
const BmnMCPoint & GetPoint(DetectorId detId, Int_t index) const
Return MC point for specified detector id and point index.
Definition BmnMCTrack.h:86
UInt_t GetNofPoints(DetectorId detId) const
Return number of MC points for specified detector id.
Definition BmnMCTrack.h:96
BmnMCTrack()
Constructor.
Definition BmnMCTrack.h:32
virtual string ToString() const
Returns string representation of the class.
Definition BmnMCTrack.h:221
void AddPoint(DetectorId detId, const BmnMCPoint &point)
Add point to track.
Definition BmnMCTrack.h:64
Defines unique identifiers (enum) for all BM@N detector systems.
STL namespace.