61 #include "StTrackNode.h"
62 #include "StGlobalTrack.h"
63 #include "StPrimaryTrack.h"
67 static const
char rcsid[] = "$Id:
StTrackNode.cxx,v 2.17 2013/07/23 11:21:49 jeromel Exp $";
71 StTrackNode::~StTrackNode() { }
77 switch (track->type()) {
80 mReferencedTracks.push_back(track);
83 cerr <<
"StTrackNode::addTrack(): track type 'secondary' not implemented yet." << endl;
88 mOwnedTracks.push_back(track);
91 cerr <<
"StTrackNode::addTrack(): cannot add, unknown track type." << endl;
100 StTrackNode::removeTrack(
StTrack* track)
102 StPtrVecTrackIterator iter;
103 StSPtrVecTrackIterator iterS;
105 switch (track->type()) {
108 for (iter = mReferencedTracks.begin(); iter < mReferencedTracks.end(); iter++)
109 if (*iter == track) mReferencedTracks.erase(iter);
112 cerr <<
"StTrackNode::removeTrack(): track type 'secondary' not implemented yet." << endl;
117 for (iterS = mOwnedTracks.begin(); iterS < mOwnedTracks.end(); iterS++)
118 if (*iterS == track) mOwnedTracks.erase(iterS);
121 cerr <<
"StTrackNode::removeTrack(): cannot remove, unknown track type." << endl;
129 StTrackNode::entries()
const
131 return mReferencedTracks.size() + mOwnedTracks.size();
135 StTrackNode::track(
unsigned int i)
const
137 if (i < mOwnedTracks.size())
138 return mOwnedTracks[i];
140 i -= mOwnedTracks.size();
141 if (i < mReferencedTracks.size())
142 return mReferencedTracks[i];
149 StTrackNode::track(
unsigned int i)
151 if (i < mOwnedTracks.size())
152 return mOwnedTracks[i];
154 i -= mOwnedTracks.size();
155 if (i < mReferencedTracks.size())
156 return mReferencedTracks[i];
163 StTrackNode::entries(StTrackType type)
const
168 unsigned int counter;
173 for (counter=0, i=0; i < mReferencedTracks.size(); i++)
174 if (mReferencedTracks[i]->type() == type) counter++;
178 cerr <<
"StTrackNode::entries(): track type 'secondary' not implemented yet." << endl;
184 for (counter=0, i=0; i < mOwnedTracks.size(); i++)
185 if (mOwnedTracks[i]->type() == type) counter++;
189 cerr <<
"StTrackNode::entries(): unknown track type." << endl;
196 StTrackNode::track(StTrackType type,
unsigned int i)
const
204 for (j=-1, k=0; k < mReferencedTracks.size(); k++) {
205 if (mReferencedTracks[k]->type() == type) j++;
206 if (j == static_cast<int>(i))
return mReferencedTracks[k];
211 cerr <<
"StTrackNode::track(): track type 'secondary' not implemented yet." << endl;
217 for (j=-1, k=0; k < mOwnedTracks.size(); k++) {
218 if (mOwnedTracks[k]->type() == type) j++;
219 if (j == static_cast<int>(i))
return mOwnedTracks[k];
224 cerr <<
"StTrackNode::track(): unknown track type." << endl;
231 StTrackNode::track(StTrackType type,
unsigned int i)
239 for (j=-1, k=0; k < mReferencedTracks.size(); k++) {
240 if (mReferencedTracks[k]->type() == type) j++;
241 if (j == static_cast<int>(i))
return mReferencedTracks[k];
246 cerr <<
"StTrackNode::track(): track type 'secondary' not implemented yet." << endl;
252 for (j=-1, k=0; k < mOwnedTracks.size(); k++) {
253 if (mOwnedTracks[k]->type() == type) j++;
254 if (j == static_cast<int>(i))
return mOwnedTracks[k];
259 cerr <<
"StTrackNode::track(): unknown track type." << endl;