EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmRichRadiusCorrection.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmRichRadiusCorrection.h
1 
10 #ifndef CBM_RICH_RADIUS_CORRECTION
11 #define CBM_RICH_RADIUS_CORRECTION
12 
13 #include "CbmRichRingLight.h"
14 #include "TROOT.h"
15 #include "TDirectory.h"
16 #include "TFile.h"
17 #include "TH2D.h"
18 #include "TSystem.h"
19 
20 #include <string>
21 #include <iostream>
22 
23 using std::string;
24 using std::cout;
25 using std::endl;
26 
36 {
37 public:
38 
43  static void DoCorrection(
44  CbmRichRingLight* ring)
45  {
46  if ( NULL == fhMapAaxisXY || NULL == fhMapBaxisXY){
47  Init();
48  }
49  if ( NULL == fhMapAaxisXY || NULL == fhMapBaxisXY) return;
50 
51  double centerX = ring->GetCenterX();
52  double centerY = ring->GetCenterY();
53  double axisA = ring->GetAaxis() + fhMapAaxisXY->GetBinContent(fhMapAaxisXY->FindBin(centerX,centerY));
54  double axisB = ring->GetBaxis() + fhMapBaxisXY->GetBinContent(fhMapBaxisXY->FindBin(centerX,centerY));
55 
56  ring->SetAaxis(axisA);
57  ring->SetBaxis(axisB);
58  }
59 
60 private:
66  static void Init()
67  {
68  string fileName = gSystem->Getenv("VMCWORKDIR");
69  fileName += "/parameters/rich/radius_correction_map_compact.root";
70 
71  TDirectory *current = gDirectory;
72  TFile *file = new TFile(fileName.c_str(), "READ");
73 
74  if (NULL == file || !file->IsOpen()) {
75  cout << " -E- Read correction maps " << endl;
76  cout << " -E- Could not open input file " << fileName << endl;
77  return;
78  } else {
79  cout <<" -I- Map Correction input file: "<< fileName << endl;
80  }
81 
82  gROOT->cd();
83 
84  fhMapAaxisXY = (TH2D*) file->Get("fh_mapaxisAXY")->Clone();
85  fhMapBaxisXY = (TH2D*) file->Get("fh_mapaxisBXY")->Clone();
86 
87  file->Close();
88  delete file;
89  current->cd();
90  }
91 
92  static TH2D* fhMapAaxisXY;
93  static TH2D* fhMapBaxisXY;
94 };
95 
96 #endif