Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:20:24

0001 /*
0002  * \file TpcGlobalPositionWrapper.cc
0003  * \brief provides the tpc 3d global position with all distortion and crossing corrections applied
0004  * \author Joe Osborn <josborn1@bnl.gov>, Hugo Pereira Da Costa <hugo.pereira-da-costa@lanl.gov>
0005  */
0006 
0007 #include "TpcGlobalPositionWrapper.h"
0008 
0009 #include "TpcClusterZCrossingCorrection.h"
0010 #include "TpcDistortionCorrectionContainer.h"
0011 
0012 #include <phool/getClass.h>
0013 #include <phool/PHCompositeNode.h>
0014 #include <trackbase/ActsGeometry.h>
0015 #include <trackbase/TpcDefs.h>
0016 #include <trackbase/TrkrCluster.h>
0017 
0018 //____________________________________________________________________________________________________________________
0019 void TpcGlobalPositionWrapper::loadNodes( PHCompositeNode* topNode )
0020 {
0021   // acts geometry
0022   m_tGeometry = findNode::getClass<ActsGeometry>(topNode, "ActsGeometry");
0023 
0024   // tpc distortion corrections
0025   m_dcc_module_edge = findNode::getClass<TpcDistortionCorrectionContainer>(topNode, "TpcDistortionCorrectionContainerModuleEdge");
0026   if (m_dcc_module_edge && m_verbosity > 0)
0027   {
0028     std::cout << "TpcGlobalPositionWrapper::loadNodes - found module edge TPC distortion correction container" << std::endl;
0029   }
0030 
0031   m_dcc_static = findNode::getClass<TpcDistortionCorrectionContainer>(topNode, "TpcDistortionCorrectionContainerStatic");
0032   if (m_dcc_static && m_verbosity > 0)
0033   {
0034     std::cout << "TpcGlobalPositionWrapper::loadNodes - found static TPC distortion correction container" << std::endl;
0035   }
0036   m_dcc_average = findNode::getClass<TpcDistortionCorrectionContainer>(topNode, "TpcDistortionCorrectionContainerAverage");
0037   if (m_dcc_average && m_verbosity > 0)
0038   {
0039     std::cout << "TpcGlobalPositionWrapper::loadNodes - found average TPC distortion correction container" << std::endl;
0040   }
0041   m_dcc_fluctuation = findNode::getClass<TpcDistortionCorrectionContainer>(topNode, "TpcDistortionCorrectionContainerFluctuation");
0042   if (m_dcc_fluctuation && m_verbosity > 0)
0043   {
0044     std::cout << "TpcGlobalPositionWrapper::loadNodes - found fluctuation TPC distortion correction container" << std::endl;
0045   }
0046 }
0047 
0048 //____________________________________________________________________________________________________________________
0049 Acts::Vector3 TpcGlobalPositionWrapper::applyDistortionCorrections(Acts::Vector3 global) const
0050 {
0051   // apply distortion corrections
0052   if (m_enable_module_edge_corr && m_dcc_module_edge)
0053   {
0054     global = m_distortionCorrection.get_corrected_position(global, m_dcc_module_edge);
0055   }
0056 
0057   if (m_enable_static_corr && m_dcc_static)
0058   {
0059     global = m_distortionCorrection.get_corrected_position(global, m_dcc_static);
0060   }
0061 
0062   if (m_enable_average_corr && m_dcc_average)
0063   {
0064     global = m_distortionCorrection.get_corrected_position(global, m_dcc_average);
0065   }
0066 
0067   if (m_enable_fluctuation_corr && m_dcc_fluctuation)
0068   {
0069     global = m_distortionCorrection.get_corrected_position(global, m_dcc_fluctuation);
0070   }
0071 
0072   return global;
0073 }
0074 
0075 //____________________________________________________________________________________________________________________
0076 Acts::Vector3 TpcGlobalPositionWrapper::getGlobalPositionDistortionCorrected(const TrkrDefs::cluskey& key, TrkrCluster* cluster, short int crossing ) const
0077 {
0078 
0079   if( !m_tGeometry )
0080   {
0081     std::cout << "TpcGlobalPositionWrapper::getGlobalPositionDistortionCorrected - m_tGeometry not set" << std::endl;
0082     return {0,0,0};
0083   }
0084 
0085   // get global position from acts
0086   Acts::Vector3 global = m_tGeometry->getGlobalPosition(key, cluster);
0087 
0088   // make sure cluster is from TPC
0089   if( TrkrDefs::getTrkrId(key) == TrkrDefs::TrkrId::tpcId )
0090   {
0091 
0092     // verify crossing validity
0093     if(crossing == SHRT_MAX)
0094     {
0095       if(!m_suppressCrossing)
0096       {
0097         std::cout << "TpcGlobalPositionWrapper::getGlobalPositionDistortionCorrected - invalid crossing." << std::endl;
0098       }
0099       return global;
0100     }
0101 
0102     // apply crossing correction
0103     global.z() = TpcClusterZCrossingCorrection::correctZ(global.z(), TpcDefs::getSide(key), crossing);
0104     // std::cout << "Global: " << global.x() << "  " << global.y() << "  " << global.z() << std::endl;
0105 
0106     // apply distortion corrections
0107     global = applyDistortionCorrections(global);
0108     //std::cout << "Global after dist corr: " << global.x() << "  " << global.y() << "  " << global.z() << std::endl;
0109   }
0110 
0111   return global;
0112 }