LCFIVertex  0.7.2
vertexfinderclassic.cpp
1 #include "../include/vertexfinderclassic.h"
2 
3 #include "../../inc/track.h"
4 #include "../include/candidatevertex.h"
5 #include "../include/interactionpoint.h"
6 #include "../include/vertexfunction.h"
7 #include "../include/vertexfunctionclassic.h"
8 #include "../../inc/trackstate.h"
9 #include "../../util/inc/memorymanager.h"
10 #include <vector>
11 #include <list>
12 #include <ctime>
13 namespace vertex_lcfi { namespace ZVTOP
14 {
15 VertexFinderClassic::VertexFinderClassic(const std::vector<Track*> &Tracks, InteractionPoint* IP,const Vector3 &JetAxis, double Kip, double Kalpha, double TwoProngCut, double TrackTrimCut, double ResolverCutOff)
16 : _TrackList(Tracks),_IP(IP),_Kip(Kip),_Kalpha(Kalpha),_JetAxis(JetAxis),_TwoProngCut(TwoProngCut),_TrackTrimCut(TrackTrimCut),_ResolverCutOff(ResolverCutOff)
17 {
18 }
19 
20 
21 void VertexFinderClassic::addTrack(Track* const Track)
22 {
23  _TrackList.push_back(Track);
24 }
25 
26 void VertexFinderClassic::setIP(InteractionPoint* const IP)
27 {
28  _IP=IP;
29 }
30 // returns true if track was in jet and removed
31 bool VertexFinderClassic::removeTrack(Track* const TrackToRemove)
32 {
33  std::vector<Track*>::iterator iTrack;
34 
35  for (iTrack = _TrackList.begin();((*iTrack) != TrackToRemove) && iTrack!=_TrackList.end();++iTrack)
36  ;
37  //iTrack now points to end or the track we want to remove
38  if (iTrack!=_TrackList.end())
39  {
40 
41  _TrackList.erase(iTrack);
42  return 1;
43  }
44  else
45  return 0;
46 }
47 
48 bool VertexFinderClassic::clearIP()
49 {
50  _IP=0;
51  return true;
52 }
53 
54 // Ascending sorting function (nearest maxima)
56 {
57  bool operator()(CandidateVertex*& rpStart, CandidateVertex*& rpEnd)
58  {
59  return rpStart->vertexFuncMaxValue() < rpEnd->vertexFuncMaxValue();
60  }
61 };
62 
63 // Descending sorting function (nearest maxima)
65 {
66  bool operator()(CandidateVertex*& rpStart, CandidateVertex*& rpEnd)
67  {
68  return rpStart->vertexFuncMaxValue() > rpEnd->vertexFuncMaxValue();
69  }
70 };
71 
72 // Ascending sorting function (fitted position)
74 {
75  bool operator()(CandidateVertex*& rpStart, CandidateVertex*& rpEnd)
76  {
77  return rpStart->vertexFuncValue() < rpEnd->vertexFuncValue();
78  }
79 };
80 
81 // Descending sorting function (fitted position)
83 {
84  bool operator()(CandidateVertex*& rpStart, CandidateVertex*& rpEnd)
85  {
86  return rpStart->vertexFuncValue() > rpEnd->vertexFuncValue();
87  }
88 };
89 
90 // Ascending distance from IP func
92 {
93  InteractionPoint* IP;
94 
95  IPDistAscending(InteractionPoint* _IP) : IP(_IP) {}
96 
97  bool operator()(CandidateVertex*& rpStart, CandidateVertex*& rpEnd)
98  {
99  if (IP)
100  {
101  return rpStart->position().distanceTo2(IP->position()) < rpEnd->position().distanceTo2(IP->position());
102  }
103  else
104  {
105  return rpStart->position().distanceTo2(Vector3(0,0,0)) < rpEnd->position().distanceTo2(Vector3(0,0,0));
106  }
107  }
108 };
109 
110 std::list<CandidateVertex*> VertexFinderClassic::findVertices()
111 {
112  using std::cout;using std::endl;clock_t start,pstart;int debug=0;
113  //Make vertex function
114  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Constructing Vertex Function....."; cout.flush();pstart=clock();}start=clock();
115  _VF = new VertexFunctionClassic(_TrackList,_IP,_Kip,_Kalpha,_JetAxis);
116  MemoryManager<VertexFunctionClassic>::Event()->registerObject(dynamic_cast<VertexFunctionClassic*>(_VF));
117  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "\tdone!\t\t\t" << ((double)clock()-(double)pstart)*1000.0/CLOCKS_PER_SEC << "ms" << endl; cout.flush();}
118  //Make two prong candidates, discarding if above chi squared cut, remembering to assign vertex function
119  //std::cout << "1";
120  //And a working list of CandidateVertices
121  std::list<CandidateVertex*> CVList;
122  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "2-Prong Creation....."; cout.flush();pstart=clock();}
123  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug<0) std::cout << std::endl;
124  //Iterate over the track list making unique 2-prong candidates containing two trackstates
125  int N = _TrackList.size();
126  //Make trackstates of the tracks
127  std::vector<TrackState*> TrackStates;
128  for (std::vector<Track*>::iterator iTrack = _TrackList.begin();iTrack != _TrackList.end();++iTrack)
129  {
130  TrackState* Track = (*iTrack)->makeState();
131  TrackStates.push_back(Track);
132  }
133  for (int OuterIndex=0;OuterIndex < N-1;++OuterIndex)
134  {
135  for (int InnerIndex=OuterIndex+1;InnerIndex < N;++InnerIndex)
136  {
137  std::vector<TrackState*> Tracks;
138  Tracks.push_back(TrackStates[OuterIndex]);
139  Tracks.push_back(TrackStates[InnerIndex]);
140 
141  CandidateVertex* CV = new CandidateVertex(Tracks,_VF);
143  //If we keep this one as chi squared lower than cut we add it to our lists
144  //TODO cut on V(r) from FORTRAN, keep?
145  /*ofstream case2file ("chi2track.txt", ofstream::out | ofstream::app);
146  if (case2file.is_open())
147  {
148  Track1->swimToStateNearest(Track2);
149  Track2->swimToStateNearest(Track1->position());
150  case2file << Track1->position().distanceTo(Track2->position()) << " " << CV->chiSquaredOfFit() << std::endl;
151  }*/
152  if (CV->maxChiSquaredOfTrackIP() <= _TwoProngCut && CV->vertexFuncValue()>0.001)
153  {
154  CVList.push_back(CV);
155  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug<0) std::cout << "2-prong of:" << TrackStates[OuterIndex]->parentTrack()->trackingNum() << "," << TrackStates[InnerIndex]->parentTrack()->trackingNum() << " @ " << CV->position() << std::endl;
156  }
157  else
158  {
159  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug<0) std::cout << "-";
160  }
161  //cout << OuterIndex << ":" << InnerIndex <<" ";
162  //cout.flush();
163  }
164  }
165  //cout << endl;
166  //Now we make the ones that contain an IP if we have an IP
167  //Make a record of how many CV's we have so we can see home many we make in the next loop.
168  //int NumBefore = CVList.size();
169  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Track+IP....."; cout.flush();}
170  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug<0) std::cout << std::endl;
171  if (_IP)
172  {
173  for (int Index=0;Index < N;++Index)
174  {
175  std::vector<TrackState*> Tracks;
176  Tracks.push_back(TrackStates[Index]);
177 
178  CandidateVertex* CV = new CandidateVertex(Tracks,_IP,_VF);
180  /*ofstream case2file ("chiip.txt", ofstream::out | ofstream::app);
181  if (case2file.is_open())
182  {
183  Track->swimToStateNearest(_IP->position());
184  case2file << Track->position().distanceTo(_IP->position()) << " " << CV->chiSquaredOfFit() << " " << Track->parentTrack()->helixRep() << std::endl;
185  }*/
186  //TODO Special fitter needed here? - IP handling etc
187  //If we keep this one as chi squared lower than cut add it to our lists
188  if (CV->maxChiSquaredOfTrackIP() <= _TwoProngCut)
189  {
190  CVList.push_back(CV);
191  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug<0) std::cout << "2-prong of:" << "IP" << "," << TrackStates[Index]->parentTrack()->trackingNum() << " @ " << CV->position() << std::endl;
192  }
193  else
194  {
195  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug<0) std::cout << "-";
196  }
197  }
198  }
199  //And add one that is just the IP if we didn't add any IP-track vertices in the loop above - ensures we have a ip object
200  //Commented out as FORTRAN doesn't add IP back in till before chi cut
201  /*if (_IP && (NumBefore == CVList.size()))
202  {
203  std::vector<TrackState*> Tracks;
204  CandidateVertex* CV = new CandidateVertex(Tracks,_IP,_VF);
205  MemoryManager<CandidateVertex>::Event()->registerObject(CV);
206  CVList.push_back(CV);
207  }
208  */
209  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "\tdone!" << " "<< CVList.size() << " Vertices" << "\t" << ((double(clock())-double(pstart))/CLOCKS_PER_SEC)*1000 << "ms" << endl; cout.flush();}
210  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug>1) {for (std::list<CandidateVertex*>::iterator iCV = CVList.begin();iCV != CVList.end();++iCV) cout << **iCV <<endl;}
211  //std::cout << "2";
212  //if (CVList.empty()) return CVList;
213 
214  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Find V(r) max....."; cout.flush();pstart=clock();}
215  for (std::list<CandidateVertex*>::iterator iCV = CVList.begin();iCV != CVList.end();++iCV)
216  {
217  (*iCV)->findVertexFuncMax();
218  }
219  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "\t\t\tdone!" << " "<< CVList.size() << " Vertices" << "\t" << ((double(clock())-double(pstart))/CLOCKS_PER_SEC)*1000 << "ms" <<endl; cout.flush();}
220  /*////////////////////////////////////////////////////////DEBUGLINE*///if (debug>1) {for (std::list<CandidateVertex*>::iterator iCV = CVList.begin();iCV != CVList.end();++iCV) cout << **iCV <<endl;}
221  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Track removal based on clustering....."; cout.flush();pstart=clock();}
222  //We now make sure the track k is only associated with the CV with highest
223  //V(r) at fitted position (not nearest maxima) in any unresolved set currently associated with the track
224  std::vector<CandidateVertex*> RemoveFrom;
225  std::vector<Track*> TrackToRemove;
226  //Loop over tracks
227  for (std::vector<Track*>::iterator iTrack = _TrackList.begin();iTrack != _TrackList.end();++iTrack)
228  {
229  //Get a list of the CV's associated with this Track
230  std::list<CandidateVertex*> AssocCVs;
231  for (std::list<CandidateVertex*>::iterator iCV = CVList.begin();iCV != CVList.end();++iCV)
232  {
233  if ((*iCV)->hasTrack(*iTrack)) AssocCVs.push_back(*iCV);
234  }
235  if (AssocCVs.empty())
236  {
237  continue;
238  }
239  //Sort so highest V(r) at begining
240  AssocCVs.sort(CVVFPosDescending());
242  CandidateVertex* HighCV = *(AssocCVs.begin());
244  std::list<CandidateVertex*> TempAssocCVs = AssocCVs;
245  for (std::list<CandidateVertex*>::iterator iCV = TempAssocCVs.begin();iCV != TempAssocCVs.end();++iCV)
246  {
247  if ((*iCV)->vertexFuncValue() < 0.1 * HighCV->vertexFuncValue())
248  {
249  RemoveFrom.push_back(*iCV);
250  TrackToRemove.push_back(*iTrack);
251  AssocCVs.remove(*iCV);
252  }
253  }
254  //Keep a list of the ones we retain
255  std::list<CandidateVertex*> RetainedCVs;
256  //Sort so highest V(r) at begining
257  AssocCVs.sort(CVVFPosDescending());
258  //Now in descending order retain tracks that are resolved from those already retained
259  for (std::list<CandidateVertex*>::iterator iCV = AssocCVs.begin();iCV != AssocCVs.end();++iCV)
260  {
261  bool resolved = true;
262  for (std::list<CandidateVertex*>::iterator iRetainedCV = RetainedCVs.begin();iRetainedCV != RetainedCVs.end();++iRetainedCV)
263  {
264  resolved = (*iCV)->isResolvedFrom((*iRetainedCV),_ResolverCutOff, CandidateVertex::FittedPosition);
265  //If we were not resolved then theres no need to check the rest
266  if (!resolved)
267  {
268  RemoveFrom.push_back(*iCV);
269  TrackToRemove.push_back(*iTrack);
270  break;
271  }
272  }
273  if (resolved)
274  {
275  RetainedCVs.push_back(*iCV);
276  }
277  }
278  }
279  //Now go over the list we just made removing tracks
280  std::vector<Track*>::iterator iTrack = TrackToRemove.begin();
281  for (std::vector<CandidateVertex*>::iterator iCV = RemoveFrom.begin();iCV != RemoveFrom.end();++iCV)
282  {
283  (*iCV)->removeTrack(*iTrack);
284  ++iTrack;
285  }
286  //std::cout << "3";
287  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "\tdone!" << " "<< CVList.size() << " Vertices" << "\t" << ((double(clock())-double(pstart))/CLOCKS_PER_SEC)*1000 << "ms" << endl; cout.flush();}
288  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug>1) {for (std::list<CandidateVertex*>::iterator iCV = CVList.begin();iCV != CVList.end();++iCV) cout << **iCV <<endl;}
289  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Remove IP from all but highest V(r)....."; cout.flush();pstart=clock();}
290  //Find highest one with IP
291  double HighValue=-2;
292  CandidateVertex* HighVertex=0;
293  for (std::list<CandidateVertex*>::iterator iCV = CVList.begin();iCV != CVList.end();++iCV)
294  {
295  //std::cout << *iCV<<" ";
296  if ((*iCV)->interactionPoint() && ((*iCV)->vertexFuncValue()>HighValue))
297  {
298  HighValue = (*iCV)->vertexFuncValue();
299  HighVertex = *iCV;
300  }
301  }
302  //Remove from all but highest
303  for (std::list<CandidateVertex*>::iterator iCV = CVList.begin();iCV != CVList.end();++iCV)
304  if ((*iCV)->interactionPoint() && ((*iCV) != HighVertex))
305  (*iCV)->removeIP();
306 
307  //Discard 0 track and no IP CV's
308  {
309  std::vector<CandidateVertex*> removed;
310  for (std::list<CandidateVertex*>::iterator iVertex=CVList.begin();iVertex != CVList.end();++iVertex)
311  {
312  if ((*iVertex)->trackStateList().empty() && !(*iVertex)->interactionPoint())
313  {
314  removed.push_back(*iVertex);
315  }
316  }
317  for (std::vector<CandidateVertex*>::iterator iCVertex=removed.begin();iCVertex != removed.end();++iCVertex)
318  {
319  CVList.remove(*iCVertex);
320  }
321  }
322  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "done!" << " "<< CVList.size() << " Vertices" << "\t" << ((double(clock())-double(pstart))/CLOCKS_PER_SEC)*1000 << "ms" << endl; cout.flush();}
323  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug>1) {for (std::list<CandidateVertex*>::iterator iCV = CVList.begin();iCV != CVList.end();++iCV) cout << **iCV <<endl;}
324  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Sort in V(r)max....."; cout.flush();pstart=clock();}
325  //std::cout << "4";
326  //Sort in order of V(r) at nearest maxima
327  if (!CVList.empty()) CVList.sort(CVVFMaxDescending());
328  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "\t\t\tdone!" << " "<< CVList.size() << " Vertices" << "\t" << ((double(clock())-double(pstart))/CLOCKS_PER_SEC)*1000 << "ms" << endl; cout.flush();}
330  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Clustering by V(r)Max resolution....."; cout.flush();pstart=clock();}
331  //Get lists of CV's that are unresolved. then merge.
332  if (!CVList.empty())
333  {
334  std::list<std::list<CandidateVertex*> > ClusterLists;
335  do
336  {
337  //Get the CV with highest v(r) as seed for a cluster
338  CandidateVertex* Seed = *CVList.begin();
339  //Remove it from the CV list
340  CVList.erase(CVList.begin());
341  //Add it to its cluster
342  std::list<CandidateVertex*> Cluster;
343  Cluster.push_back(Seed);
344  int added = 0;
345  do
346  {
347  //Iterate over cluster
348  added = 0;
349  std::list<CandidateVertex*>::iterator iCVertex;
350  for (iCVertex=Cluster.begin();iCVertex != Cluster.end();++iCVertex)
351  {
352  //Iterate over the remaining CV's
353  std::list<CandidateVertex*>::iterator iVertex;
354  for (iVertex=CVList.begin();iVertex != CVList.end();++iVertex)
355  {
356  //If not resolved
357  if (!(*iCVertex)->isResolvedFrom(*iVertex,_ResolverCutOff, CandidateVertex::NearestMaximum))
358  {
359  //Add to this Cluster
360  Cluster.push_back(*iVertex);
361  ++added;
362  }
363  }
364  //Remove from the CVList
365  for (std::list<CandidateVertex*>::iterator iCVertex2=Cluster.begin();iCVertex2 != Cluster.end();++iCVertex2)
366  {
367  CVList.remove(*iCVertex2);
368  }
369 
370  }
371  //Keep looping over the cluster till none added
372  } while (added > 0);
373  //Add the cluster the cluster list
374  ClusterLists.push_back(Cluster);
375  }
376  while (!CVList.empty());
377  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "\tdone!" << "\t\t\t" << ((double(clock())-double(pstart))/CLOCKS_PER_SEC)*1000 << "ms" << endl; cout.flush();}
378  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug>1) {for (std::list<CandidateVertex*>::iterator iCV = CVList.begin();iCV != CVList.end();++iCV) cout << **iCV <<endl;}
379  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Merging....."; cout.flush();pstart=clock();}
380  //We now have nice lists of clusters, so we can merge away
381  std::list<std::list<CandidateVertex*> >::iterator iList;
382  for (iList=ClusterLists.begin();iList != ClusterLists.end();++iList)
383  {
384  std::list<CandidateVertex*>::iterator iVertex;
385  for (iVertex=(++((*iList).begin()));iVertex != (*iList).end(); ++iVertex)
386  {
387  (*((*iList).begin()))->mergeCandidateVertex(*iVertex);
388  }
389  //Add the resulting merged CV back to the master list
390  CVList.push_back(*((*iList).begin()));
391  }
392  }
393 
394  _ifNoIPAddIP(&CVList);
395 
396  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "\t\t\t\tdone!" << " "<< CVList.size() << " Vertices" << "\t" << ((double(clock())-double(pstart))/CLOCKS_PER_SEC)*1000 << "ms" << endl; cout.flush();}
397  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug>1) {for (std::list<CandidateVertex*>::iterator iCV = CVList.begin();iCV != CVList.end();++iCV) cout << **iCV <<endl;}
398  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Sort in V(r)Max....."; cout.flush();pstart=clock();}
399  //std::cout << "6";
400  //Sort in order of V(r)
401  if (!CVList.empty()) CVList.sort(CVVFMaxDescending());
402  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "\t\t\tdone!" << " "<< CVList.size() << " Vertices" << "\t" << ((double(clock())-double(pstart))/CLOCKS_PER_SEC)*1000 << "ms" << endl; cout.flush();}
403 
404  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Chi Squared Track Cut....."; cout.flush();pstart=clock();}
405  //Chi square track cutting
406  for (std::list<CandidateVertex*>::iterator iVertex=CVList.begin();iVertex != CVList.end();++iVertex)
407  {
408  (*iVertex)->trimByChi2(_TrackTrimCut);
409  }
410  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "\t\tdone!" << " "<< CVList.size() << " Vertices" << "\t" << ((double(clock())-double(pstart))/CLOCKS_PER_SEC)*1000 << "ms" << endl; cout.flush();}
411 
412  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Discard <2 Track Vertices....."; cout.flush();}pstart=clock();
413  //Discard <2 track CV's
414  _removeOneTrackNoIPVertices(&CVList);
415  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "\t\tdone!" << " "<< CVList.size() << " Vertices" << "\t" << ((double(clock())-double(pstart))/CLOCKS_PER_SEC)*1000 << "ms" << endl; cout.flush();}
416  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug>1) {for (std::list<CandidateVertex*>::iterator iCV = CVList.begin();iCV != CVList.end();++iCV) cout << **iCV <<endl;}
417  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Claim tracks by V(r)....."; cout.flush();pstart=clock();}
418  //Decending order of V(r) claim tracks from lower to ensure each track only in one vertex.
419  std::list<CandidateVertex*> LosingList;
420  std::list<CandidateVertex*> LeftToDo;
421  for (std::list<CandidateVertex*>::iterator iCVertex=CVList.begin();iCVertex != CVList.end();++iCVertex)
422  {
423  LosingList.push_back(*iCVertex);
424  LeftToDo.push_back(*iCVertex);
425  }
426  while (!LeftToDo.empty())
427  {
428  //Remove the one thats claiming (the higest one) from the losing list
429  LosingList.erase(LosingList.begin());
430  //Claim from the others
431  (*LeftToDo.begin())->claimTracksFrom(LosingList);
432  LeftToDo.erase(LeftToDo.begin());
433  //Remove CVs that are now just 1 track (with no IP) or no tracks
434  std::vector<CandidateVertex*> removed = _removeOneTrackNoIPVertices(&CVList);
435  //And remove them from the remaining losing vertices
436  for (std::vector<CandidateVertex*>::iterator iCVertex=removed.begin();iCVertex != removed.end();++iCVertex)
437  {
438  LosingList.remove(*iCVertex);
439  LeftToDo.remove(*iCVertex);
440  }
441  } ;
442 
443  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "\t\tdone!" << " "<< CVList.size() << " Vertices" << "\t" << ((double(clock())-double(pstart))/CLOCKS_PER_SEC)*1000 << "ms" << endl; cout.flush();}
444  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug>1) {for (std::list<CandidateVertex*>::iterator iCV = CVList.begin();iCV != CVList.end();++iCV) cout << **iCV <<endl;}
445  /*////////////////////////////////////////////////////////DEBUGLINE*/if (debug) {cout << "Vertex find complete" << "\t" << (double(clock())-double(start))/CLOCKS_PER_SEC << "s" << " " << ((double(clock())-double(start))*1000)/(CLOCKS_PER_SEC*_TrackList.size()*_TrackList.size()) << "ms per track^2" << endl; cout.flush();}
446  //std::ofstream outfile ("restime.txt", std::ofstream::out|std::ofstream::app);
447  //outfile << _TrackList.size() << " " << (double(clock())-double(start))/CLOCKS_PER_SEC*1000.0 << std::endl;
448  //std::cout << "7";
449  CVList.sort(IPDistAscending(_IP));
450  //Done
451  return CVList;
452 }
453 
454 std::vector<CandidateVertex*> VertexFinderClassic::_removeOneTrackNoIPVertices(std::list<CandidateVertex*>* CVList)
455 {
456  //Discard <2 track CV's
457  std::vector<CandidateVertex*> removed;
458  for (std::list<CandidateVertex*>::iterator iVertex=CVList->begin();iVertex != CVList->end();++iVertex)
459  {
460  if ((*iVertex)->trackStateList().size() < 2)
461  {
462  //But only discard if theres no IP.
463  if (!(*iVertex)->interactionPoint())
464  removed.push_back(*iVertex);
465  }
466  }
467  for (std::vector<CandidateVertex*>::iterator iCVertex=removed.begin();iCVertex != removed.end();++iCVertex)
468  {
469  CVList->remove(*iCVertex);
470  }
471 
472  return removed;
473 
474 }
475 
476 void VertexFinderClassic::_ifNoIPAddIP(std::list<CandidateVertex*>* CVList)
477 {
478  //Loop over CV's
479  for (std::list<CandidateVertex*>::iterator iVertex=CVList->begin();iVertex != CVList->end();++iVertex)
480  {
481  if ((*iVertex)->interactionPoint()) return;
482  }
483  //None was found so add one!
484  std::vector<TrackState*> Tracks;
485  CandidateVertex* CV = new CandidateVertex(Tracks,_IP,_VF);
486  MemoryManager<CandidateVertex>::Event()->registerObject(CV);
487  CVList->push_back(CV);
488 }
489 
490 }}
double vertexFuncMaxValue() const
Return the value of the vertex function at this vertexes local maximum.
void registerObject(T *pointer)
Register an object for memory management.
double maxChiSquaredOfTrackIP() const
Return the chi squared contribution of the Track or IP with the highest chi square contribution...
A collection of TrackState objects with a fit and vertex function maximum.
double vertexFuncValue() const
Return the value of the vertex function at the vertices position.
const Vector3 & position() const
Return the fitted position of this Vertex.
bool removeIP()
Remove this vertices InteractionPoint.