CbmRoot
CbmRichMirrorMisalignmentCorrectionUtils.h
Go to the documentation of this file.
1 #ifndef CBM_RICH_MIRROR_MISALIGNMENT_CORRECTION_UTILS
2 #define CBM_RICH_MIRROR_MISALIGNMENT_CORRECTION_UTILS
3 
4 using namespace std;
5 using std::string;
6 #include "FairLogger.h"
7 #include <fstream>
8 #include <iostream>
9 #include <map>
10 
21 public:
25  CbmRichMirrorMisalignmentCorrectionUtils() : tBoolCorrection(false) {}
26 
31 
35  // virtual void Init() { }
36 
37  void Init(const string& s) {
38  SetMirrorCorrectionParameterFile(s);
39  tBoolCorrection = CheckMirrorCorrectionParameterFile();
40  if (tBoolCorrection) {
41  ReadAndStoreMirrorCorrectionParamMap(
42  fMirrorMisalignmentCorrectionParameterMap);
43  } else {
44  LOG(info)
45  << "CbmRichProjectionProducerAnalytical::Init() No correction table.";
46  }
47  }
48 
49  void SetMirrorCorrectionParameterFile(const string& s) {
50  fPathToMirrorMisalignmentCorrectionParameterFile = s;
51  }
52 
54  if (fPathToMirrorMisalignmentCorrectionParameterFile
55  == "/correction_table/correction_param_array.txt") {
56  return false;
57  }
58  ifstream corrFile;
59  corrFile.open(fPathToMirrorMisalignmentCorrectionParameterFile);
60  if (!corrFile.is_open()) {
61  Fatal("CbmRichMirrorMisalignmentCorrectionUtils::"
62  "CheckMirrorCorrectionParameterFile:",
63  "Wrong correction parameter path given!");
64  }
65  return true;
66  }
67 
69  std::map<string, std::pair<Double_t, Double_t>>& mirrorCorrectionParamMap) {
70  string mirrorID = "", fileLine = "";
71  Double_t misX = 0., misY = 0.;
72  ifstream corrFile;
73  corrFile.open(fPathToMirrorMisalignmentCorrectionParameterFile, ios::in);
74  if (corrFile.is_open()) {
75  LOG(info)
76  << "CbmRichProjectionProducerUtils::CheckMirrorCorrectionParameterFile("
77  ") Correction table used at: "
78  << fPathToMirrorMisalignmentCorrectionParameterFile;
79  cout << "mirrorID: \t\t\t (misY, misX): " << endl;
80  while (corrFile >> mirrorID >> misY >> misX) {
81  cout << mirrorID << " \t ; \t(" << misY << ", " << misX << ")" << endl;
82  mirrorCorrectionParamMap[mirrorID] = std::make_pair(misX, misY);
83  }
84  corrFile.close();
85  } else {
86  Fatal("CbmRichMirrorMisalignmentCorrectionUtils::"
87  "ReadAndStoreMirrorCorrectionParam:",
88  "Wrong correction parameter path given!");
89  }
90 
91  cout << endl << "Mapping:" << endl;
92  cout << "mirrorID: \t\t\t (misY, misX): " << endl;
93  for (std::map<string, std::pair<Double_t, Double_t>>::iterator it =
94  fMirrorMisalignmentCorrectionParameterMap.begin();
95  it != fMirrorMisalignmentCorrectionParameterMap.end();
96  ++it) {
97  cout << it->first << " \t ; \t(" << it->second.first << ", "
98  << it->second.second << ")" << endl;
99  }
100  cout << endl;
101  }
102 
103  std::map<string, std::pair<Double_t, Double_t>>
105  return fMirrorMisalignmentCorrectionParameterMap;
106  }
107 
108  bool GetMirrorCorrectionParamBool() { return tBoolCorrection; }
109 
110 private:
113  std::map<string, pair<Double_t, Double_t>>
115 };
116 
117 #endif
CbmRichMirrorMisalignmentCorrectionUtils::Init
void Init(const string &s)
Initialization in case one needs to initialize some TCloneArrays.
Definition: CbmRichMirrorMisalignmentCorrectionUtils.h:37
CbmRichMirrorMisalignmentCorrectionUtils::SetMirrorCorrectionParameterFile
void SetMirrorCorrectionParameterFile(const string &s)
Definition: CbmRichMirrorMisalignmentCorrectionUtils.h:49
CbmRichMirrorMisalignmentCorrectionUtils::GetMirrorCorrectionParamMap
std::map< string, std::pair< Double_t, Double_t > > GetMirrorCorrectionParamMap()
Definition: CbmRichMirrorMisalignmentCorrectionUtils.h:104
CbmRichMirrorMisalignmentCorrectionUtils::CheckMirrorCorrectionParameterFile
bool CheckMirrorCorrectionParameterFile()
Definition: CbmRichMirrorMisalignmentCorrectionUtils.h:53
CbmRichMirrorMisalignmentCorrectionUtils
class checks correction parameter file containing mirror misalignment information.
Definition: CbmRichMirrorMisalignmentCorrectionUtils.h:20
CbmRichMirrorMisalignmentCorrectionUtils::fMirrorMisalignmentCorrectionParameterMap
std::map< string, pair< Double_t, Double_t > > fMirrorMisalignmentCorrectionParameterMap
Definition: CbmRichMirrorMisalignmentCorrectionUtils.h:114
CbmRichMirrorMisalignmentCorrectionUtils::~CbmRichMirrorMisalignmentCorrectionUtils
virtual ~CbmRichMirrorMisalignmentCorrectionUtils()
Destructor.
Definition: CbmRichMirrorMisalignmentCorrectionUtils.h:30
CbmRichMirrorMisalignmentCorrectionUtils::ReadAndStoreMirrorCorrectionParamMap
void ReadAndStoreMirrorCorrectionParamMap(std::map< string, std::pair< Double_t, Double_t >> &mirrorCorrectionParamMap)
Definition: CbmRichMirrorMisalignmentCorrectionUtils.h:68
CbmRichMirrorMisalignmentCorrectionUtils::GetMirrorCorrectionParamBool
bool GetMirrorCorrectionParamBool()
Definition: CbmRichMirrorMisalignmentCorrectionUtils.h:108
CbmRichMirrorMisalignmentCorrectionUtils::tBoolCorrection
bool tBoolCorrection
Definition: CbmRichMirrorMisalignmentCorrectionUtils.h:111
CbmRichMirrorMisalignmentCorrectionUtils::CbmRichMirrorMisalignmentCorrectionUtils
CbmRichMirrorMisalignmentCorrectionUtils()
Definition: CbmRichMirrorMisalignmentCorrectionUtils.h:25
CbmRichMirrorMisalignmentCorrectionUtils::fPathToMirrorMisalignmentCorrectionParameterFile
string fPathToMirrorMisalignmentCorrectionParameterFile
Definition: CbmRichMirrorMisalignmentCorrectionUtils.h:112