Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SvtxTrack_v4.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SvtxTrack_v4.cc
1 #include "SvtxTrack_v4.h"
2 #include "SvtxTrackState.h"
3 #include "SvtxTrackState_v1.h"
4 
5 #include <trackbase/TrkrDefs.h> // for cluskey
6 
7 #include <phool/PHObject.h> // for PHObject
8 
9 #include <climits>
10 #include <map>
11 #include <vector> // for vector
12 
14 {
15  // always include the pca point
16  _states.insert( std::make_pair(0, new SvtxTrackState_v1(0)));
17 
18 }
19 
21 { SvtxTrack_v4::CopyFrom( source ); }
22 
23 // have to suppress missingMemberCopy from cppcheck, it does not
24 // go down to the CopyFrom method where things are done correctly
25 // cppcheck-suppress missingMemberCopy
27 { SvtxTrack_v4::CopyFrom( source ); }
28 
30 { CopyFrom( source ); return *this; }
31 
33 { clear_states(); }
34 
36 {
37  // do nothing if copying onto oneself
38  if( this == &source ) return;
39 
40  // parent class method
41  SvtxTrack::CopyFrom( source );
42 
43  _tpc_seed = source.get_tpc_seed();
45  _vertex_id = source.get_vertex_id();
47  _chisq = source.get_chisq();
48  _ndf = source.get_ndf();
49  _track_crossing = source.get_crossing();
50 
51  // copy the states over into new state objects stored here
52  clear_states();
53  for( auto iter = source.begin_states(); iter != source.end_states(); ++iter )
54  { _states.insert( std::make_pair(iter->first, static_cast<SvtxTrackState*>(iter->second->CloneMe() ) ) ); }
55 
56 }
57 
58 void SvtxTrack_v4::identify(std::ostream& os) const
59 {
60  os << "SvtxTrack_v4 Object ";
61  os << "id: " << get_id() << " ";
62  os << "vertex id: " << get_vertex_id() << " ";
63  os << "charge: " << get_charge() << " ";
64  os << "chisq: " << get_chisq() << " ndf:" << get_ndf() << " ";
65  os << "nstates: " << _states.size() << " ";
66  os << std::endl;
67 
68  os << "(px,py,pz) = ("
69  << get_px() << ","
70  << get_py() << ","
71  << get_pz() << ")" << std::endl;
72 
73  os << "(x,y,z) = (" << get_x() << "," << get_y() << "," << get_z() << ")" << std::endl;
74 
75  os << "Silicon clusters " << std::endl;
76  if(_silicon_seed)
77  {
78  for(auto iter = _silicon_seed->begin_cluster_keys();
80  ++iter)
81  {
82  std::cout << *iter << ", ";
83  }
84  }
85  os << std::endl << "Tpc + TPOT clusters " << std::endl;
86  if(_tpc_seed)
87  {
88  for(auto iter = _tpc_seed->begin_cluster_keys();
89  iter != _tpc_seed->end_cluster_keys();
90  ++iter)
91  {
92  std::cout << *iter << ", ";
93  }
94  }
95  os << std::endl;
96 
97  return;
98 }
99 
101 {
102  for( const auto& pair:_states )
103  { delete pair.second; }
104 
105  _states.clear();
106 }
107 
109 {
110  return 1;
111 }
112 
113 const SvtxTrackState* SvtxTrack_v4::get_state(float pathlength) const
114 {
115  const auto iter = _states.find(pathlength);
116  return (iter == _states.end()) ? nullptr:iter->second;
117 }
118 
120 {
121  const auto iter = _states.find(pathlength);
122  return (iter == _states.end()) ? nullptr:iter->second;
123 }
124 
126 {
127  // find closest iterator
128  const auto pathlength = state->get_pathlength();
129  auto iterator = _states.lower_bound( pathlength );
130  if( iterator == _states.end() || pathlength < iterator->first )
131  {
132  // pathlength not found. Make a copy and insert
133  const auto copy = static_cast<SvtxTrackState*> (state->CloneMe());
134  iterator = _states.insert(iterator, std::make_pair( pathlength, copy ));
135  }
136 
137  // return matching state
138  return iterator->second;
139 }
140 
141 size_t SvtxTrack_v4::erase_state(float pathlength)
142 {
143  StateIter iter = _states.find(pathlength);
144  if (iter == _states.end()) return _states.size();
145 
146  delete iter->second;
147  _states.erase(iter);
148  return _states.size();
149 }
150 
151