ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TpcLoadDistortionCorrection.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TpcLoadDistortionCorrection.cc
1 
9 
11 #include <phool/getClass.h>
12 #include <phool/PHCompositeNode.h>
13 #include <phool/PHDataNode.h>
14 
15 #include <TFile.h>
16 #include <TH3.h>
17 
18 //_____________________________________________________________________
20  SubsysReco( name)
21  {}
22 
23 //_____________________________________________________________________
25 {
26 
27  // look for distortion calibration object
28  PHNodeIterator iter(topNode);
29 
31  auto dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
32  if (!dstNode)
33  {
34  std::cout << "TpcLoadDistortionCorrection::InitRun - DST Node missing, quitting" << std::endl;
36  }
37 
38  // Get the tracking subnode and create if not found
39  auto svtxNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "SVTX"));
40  if (!svtxNode)
41  {
42  svtxNode = new PHCompositeNode("SVTX");
43  dstNode->addNode(svtxNode);
44  }
45 
46  // get distortion correction object and create if not found
47  auto distortion_correction_object = findNode::getClass<TpcDistortionCorrectionContainer>( topNode, m_node_name );
48  if( !distortion_correction_object )
49  {
50  std::cout << "TpcLoadDistortionCorrection::InitRun - creating TpcDistortionCorrectionContainer in node " << m_node_name << std::endl;
51  distortion_correction_object = new TpcDistortionCorrectionContainer;
52  auto node = new PHDataNode<TpcDistortionCorrectionContainer>(distortion_correction_object, m_node_name);
53  svtxNode->addNode(node);
54  }
55 
56  std::cout << "TpcLoadDistortionCorrection::InitRun - reading distortions from " << m_distortion_filename << std::endl;
57  auto distortion_tfile = TFile::Open( m_distortion_filename.c_str());
58  if( !distortion_tfile )
59  {
60  std::cout << "TpcLoadDistortionCorrection::InitRun - cannot open " << m_distortion_filename << std::endl;
61  exit(1);
62  }
63 
64  const std::array<const std::string,2> extension = {{ "_negz", "_posz" }};
65  for( int i =0; i < 2; ++i )
66  {
67  distortion_correction_object->m_hDPint[i] = dynamic_cast<TH3*>(distortion_tfile->Get(Form("hIntDistortionP%s", extension[i].c_str()))); assert( distortion_correction_object->m_hDPint[i] );
68  distortion_correction_object->m_hDRint[i] = dynamic_cast<TH3*>(distortion_tfile->Get(Form("hIntDistortionR%s", extension[i].c_str()))); assert( distortion_correction_object->m_hDRint[i] );
69  distortion_correction_object->m_hDZint[i] = dynamic_cast<TH3*>(distortion_tfile->Get(Form("hIntDistortionZ%s", extension[i].c_str()))); assert( distortion_correction_object->m_hDZint[i] );
70  }
71 
72  // dump axis limits
73  if( Verbosity() )
74  {
75  for( int i =0; i < 2; ++i )
76  {
77  std::cout << "TpcLoadDistortionCorrection::InitRun - histogram: " << distortion_correction_object->m_hDPint[i]->GetName() << std::endl;
78  for(const auto& axis:{
79  distortion_correction_object->m_hDPint[i]->GetXaxis(),
80  distortion_correction_object->m_hDPint[i]->GetYaxis(),
81  distortion_correction_object->m_hDPint[i]->GetZaxis() })
82  {
83  std::cout
84  << "TpcLoadDistortionCorrection::InitRun -"
85  << " axis: " << axis->GetTitle()
86  << " bins: " << axis->GetNbins()
87  << " limits: " << axis->GetXmin() << " " << axis->GetXmax()
88  << std::endl;
89  }
90  }
91  }
92 
94 }
95 
96 //_____________________________________________________________________