ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TpcDistortionCorrection.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TpcDistortionCorrection.cc
1 
9 
10 #include <TH3.h>
11 #include <cmath>
12 
13 namespace
14 {
15  template<class T> inline constexpr T square( const T& x ) { return x*x; }
16 }
17 
18 //________________________________________________________
20 {
21  // get cluster radius, phi and z
22  const auto r = std::sqrt( square( source.x() ) + square( source.y() ) );
23  auto phi = std::atan2( source.y(), source.x() );
24  if( phi < 0 ) phi += 2*M_PI;
25 
26  const auto z = source.z();
27  const int index = z > 0 ? 1:0;
28 
29  // apply corrections
30  const auto phi_new = (dcc->m_hDPint[index] && (mask&COORD_PHI)) ? phi - dcc->m_hDPint[index]->Interpolate(phi,r,z)/r : phi;
31  const auto r_new = (dcc->m_hDRint[index] && (mask&COORD_R)) ? r - dcc->m_hDRint[index]->Interpolate(phi,r,z) : r;
32  const auto z_new = (dcc->m_hDZint[index] && (mask&COORD_Z)) ? z - dcc->m_hDZint[index]->Interpolate(phi,r,z) : z;
33 
34  // update cluster
35  const auto x_new = r_new*std::cos( phi_new );
36  const auto y_new = r_new*std::sin( phi_new );
37 
38  return {x_new, y_new, z_new};
39 }