Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHTpcTrackSeedCircleFit.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHTpcTrackSeedCircleFit.cc
2 
3 #include <trackbase/TrkrDefs.h> // for cluskey, getTrkrId, tpcId
9 
11 
12 #include <g4main/PHG4Hit.h> // for PHG4Hit
13 #include <g4main/PHG4Particle.h> // for PHG4Particle
14 #include <g4main/PHG4HitDefs.h> // for keytype
15 
17 
18 #include <phool/getClass.h>
19 #include <phool/phool.h>
20 
21 #if __cplusplus < 201402L
22 #include <boost/make_unique.hpp>
23 #endif
24 
25 #include <TF1.h>
26 
27 #include <climits> // for UINT_MAX
28 #include <iostream> // for operator<<, basic_ostream
29 #include <cmath> // for fabs, std::sqrt
30 #include <set> // for _Rb_tree_const_iterator
31 #include <utility> // for pair
32 #include <memory>
33 
34 namespace
35 {
36 
37  // square
38  template<class T> inline constexpr T square( const T& x ) { return x*x; }
39 
40  // radius
41  template<class T> T get_r( const T& x, const T& y ) { return std::sqrt( square(x) + square(y) ); }
42 
43 }
44 
45 //____________________________________________________________________________..
47  SubsysReco(name)
48 {}
49 
50 //____________________________________________________________________________..
52 {
53  // get relevant nodes
54  int ret = GetNodes( topnode );
55  if( ret != Fun4AllReturnCodes::EVENT_OK ) return ret;
56 
58 
59 //____________________________________________________________________________..
61 {
62 
63  // _track_map contains the TPC seed track stubs
64  // We want to associate these TPC track seeds with a collision vertex
65  // All we need is to project the TPC clusters in Z to the beam line.
66  // The TPC track seeds are given a position that is the PCA of the line and circle fit to the beam line
67 
68  if(Verbosity() > 0)
69  std::cout << PHWHERE << " TPC track map size " << _track_map->size() << std::endl;
70 
71  unsigned int track_key = 0;
72  // loop over the TPC track seeds
73  for (auto phtrk_iter = _track_map->begin();
74  phtrk_iter != _track_map->end();
75  ++phtrk_iter)
76  {
77  TrackSeed* tracklet_tpc = *phtrk_iter;
78 
79  if (Verbosity() > 1)
80  {
81  std::cout
82  << __LINE__
83  << ": Processing seed itrack: " << track_key
84  << ": nhits: " << tracklet_tpc-> size_cluster_keys()
85  << ": pT: " << tracklet_tpc->get_pt()
86  << ": phi: " << tracklet_tpc->get_phi(_cluster_map, _surfmaps, _tGeometry)
87  << ": eta: " << tracklet_tpc->get_eta()
88  << std::endl;
89  }
90 
91  if(tracklet_tpc->size_cluster_keys() < 3)
92  {
93  if(Verbosity() > 3) std::cout << PHWHERE << " -- skip this tpc tracklet, not enough TPC clusters " << std::endl;
94  continue; // skip to the next TPC tracklet
95  }
96 
98  tracklet_tpc->lineFit(_cluster_map, _surfmaps, _tGeometry, 7, 58);
99  tracklet_tpc->circleFitByTaubin(_cluster_map, _surfmaps, _tGeometry, 7, 58);
100 
101  if(Verbosity() > 5)
102  {
103  std::cout << " new mom " << tracklet_tpc->get_p() << " new eta " << tracklet_tpc->get_eta()
104  << " new phi " << tracklet_tpc->get_phi(_cluster_map, _surfmaps, _tGeometry) * 180.0 / M_PI << std::endl;
105  }
106 
107  track_key++;
108  } // end loop over TPC track seeds
109 
110  if(Verbosity() > 0)
111  std::cout << " Final track map size " << _track_map->size() << std::endl;
112 
113  if (Verbosity() > 0)
114  std::cout << "PHTpcTrackSeedCircleFit::process_event(PHCompositeNode *topNode) Leaving process_event" << std::endl;
115 
117 }
118 
121 
123 {
124  _surfmaps = findNode::getClass<ActsSurfaceMaps>(topNode,"ActsSurfaceMaps");
125  if(!_surfmaps)
126  {
127  std::cout << PHWHERE << "Error, can't find acts surface maps" << std::endl;
129  }
130 
131  _tGeometry = findNode::getClass<ActsTrackingGeometry>(topNode,"ActsTrackingGeometry");
132  if(!_tGeometry)
133  {
134  std::cout << PHWHERE << "Error, can't find acts tracking geometry" << std::endl;
136  }
137 
139  _cluster_map = findNode::getClass<TrkrClusterContainer>(topNode, "TRKR_CLUSTER_TRUTH");
140  else
141  {
142  _cluster_map = findNode::getClass<TrkrClusterContainer>(topNode, "TRKR_CLUSTER");
143  }
144  if (!_cluster_map)
145  {
146  std::cerr << PHWHERE << " ERROR: Can't find node TRKR_CLUSTER" << std::endl;
148  }
149 
150  // tpc distortion correction
151  _dcc = findNode::getClass<TpcDistortionCorrectionContainer>(topNode,"TpcDistortionCorrectionContainerStatic");
152  if( _dcc )
153  { std::cout << "PHTpcTrackSeedCircleFit::get_Nodes - found static TPC distortion correction container" << std::endl; }
154 
155  _track_map = findNode::getClass<TrackSeedContainer>(topNode, _track_map_name);
156  if (!_track_map)
157  {
158  std::cerr << PHWHERE << " ERROR: Can't find TrackSeedContainer" << std::endl;
160  }
161 
163 }
164 
165 
167 {
168  // get global position from Acts transform
169  auto globalpos = _surfmaps->getGlobalPosition(key, cluster, _tGeometry);
170 
171  // ADF: in streaming mode we need to add a step here to take care of the fact that we do not know the crossing yet
172  // possibly move the track to point at z=0 to make distortion corrections (circularize the track) then move it back after the fit?
173 
174  // check if TPC distortion correction are in place and apply
175  if(_dcc) { globalpos = _distortionCorrection.get_corrected_position( globalpos, _dcc ); }
176 
177  return globalpos;
178 }
179