1 #include "../inc/decaychain.h"
2 #include "../inc/vertex.h"
3 #include "../inc/track.h"
10 bool Trackd0Ascending(
const Track* rpStart,
const Track* rpEnd)
12 return rpStart->helixRep().d0() < rpEnd->helixRep().d0();
16 bool Vertexd0Ascending(
const Vertex* rpStart,
const Vertex* rpEnd)
18 return rpStart->position().mag() < rpEnd->position().mag();
22 :_OwnerJet(OldDecayChain.jet()),_AttachedTracks(OldDecayChain.attachedTracks()),_Vertices(OldDecayChain.vertices())
27 std::vector<Vertex*> OldVerts = _Vertices;
29 for (std::vector<Vertex*>::const_iterator iVertex = OldVerts.begin();iVertex!=OldVerts.end();++iVertex)
34 _Vertices.push_back(NewVert);
37 std::sort(_AttachedTracks.begin(),_AttachedTracks.end(),Trackd0Ascending);
38 std::sort(_Vertices.begin(),_Vertices.end(),Vertexd0Ascending);
40 this->_invalidateCache();
44 :_OwnerJet(MyJet),_AttachedTracks(Tracks),_Vertices(Vertices)
46 std::sort(_AttachedTracks.begin(),_AttachedTracks.end(),Trackd0Ascending);
47 std::sort(_Vertices.begin(),_Vertices.end(),Vertexd0Ascending);
49 this->_invalidateCache();
60 for (std::vector<Track*>::const_iterator iTrack = _AttachedTracks.begin();iTrack!=_AttachedTracks.end();++iTrack)
62 _AllTracks.push_back(*iTrack);
65 for (std::vector<Vertex*>::const_iterator iVertex = _Vertices.begin();iVertex!=_Vertices.end();++iVertex)
67 for (std::vector<Track*>::const_iterator iTrack = (*iVertex)->tracks().begin();iTrack!=(*iVertex)->tracks().end();++iTrack)
68 _AllTracks.push_back(*iTrack);
70 std::sort(_AllTracks.begin(),_AllTracks.end(),Trackd0Ascending);
77 return _AttachedTracks;
94 for (std::vector<Track*>::const_iterator iTrack = allTracks.begin();iTrack!=allTracks.end();++iTrack)
97 int numVertsWithTrack = 0;
98 for (std::vector<Vertex*>::const_iterator iVertex = _Vertices.begin();iVertex!=_Vertices.end();++iVertex)
100 if ((*iVertex)->hasTrack(*iTrack))
103 if (numVertsWithTrack < 2) _Charge += (*iTrack)->charge();
118 for (std::vector<Track*>::const_iterator iTrack = allTracks.begin();iTrack!=allTracks.end();++iTrack)
121 int numVertsWithTrack = 0;
122 for (std::vector<Vertex*>::const_iterator iVertex = _Vertices.begin();iVertex!=_Vertices.end();++iVertex)
124 if ((*iVertex)->hasTrack(*iTrack))
127 if (numVertsWithTrack < 2) _Momentum += (*iTrack)->momentum();
135 _AttachedTracks.push_back(ATrack);
136 this->_invalidateCache();
137 std::sort(_AttachedTracks.begin(),_AttachedTracks.end(),Trackd0Ascending);
143 std::vector<Track*>::iterator position = std::find(_AttachedTracks.begin(), _AttachedTracks.end(), TrackR);
144 if (position!=_AttachedTracks.end())
146 _AttachedTracks.erase(position);
150 for (std::vector<Vertex*>::iterator iVertex = _Vertices.begin();iVertex!=_Vertices.end();++iVertex)
152 if ((*iVertex)->removeTrack(TrackR))
157 this->_invalidateCache();
158 std::sort(_AttachedTracks.begin(),_AttachedTracks.end(),Trackd0Ascending);
159 std::sort(_Vertices.begin(),_Vertices.end(),Vertexd0Ascending);
166 if (find(_AttachedTracks.begin(), _AttachedTracks.end(), HTrack) != _AttachedTracks.end())
171 for (std::vector<Vertex*>::const_iterator iVertex = _Vertices.begin();iVertex!=_Vertices.end();++iVertex)
173 if ((*iVertex)->hasTrack(HTrack))
182 _Vertices.push_back(AVertex);
183 this->_invalidateCache();
184 std::sort(_Vertices.begin(),_Vertices.end(),Vertexd0Ascending);
189 std::vector<Vertex*>::iterator position = std::find(_Vertices.begin(), _Vertices.end(), VertexR);
190 if (position!=_Vertices.end())
192 _Vertices.erase(position);
193 this->_invalidateCache();
194 std::sort(_Vertices.begin(),_Vertices.end(),Vertexd0Ascending);
203 if (find(_Vertices.begin(), _Vertices.end(), HVertex) != _Vertices.end())
211 void DecayChain::_invalidateCache()
const
bool removeVertex(Vertex *Vertex)
Remove Vertex.
bool removeTrack(Track *Track)
Remove Track.
const std::vector< Track * > & allTracks() const
All tracks contained in DecayChain.
void addVertex(Vertex *Vertex)
Add Vertex.
DecayChain()
Default Constructor.
bool hasVertex(Vertex *Vertex) const
Does the DecayChain have this Vertex?
void addTrack(Track *Track)
Add Track.
bool hasTrack(Track *Track) const
Does the DecayChain have this Track?
const std::vector< Vertex * > & vertices() const
Vertices contained in DecayChain.
double charge() const
Charge sum of all tracks in the DecayChain.
Unique Track representation.
const util::Vector3 & momentum() const
Perigee momentum sum of all tracks in the DecayChain.
const std::vector< Track * > & attachedTracks() const
Attached tracks contained in DecayChain.