PandaRoot
PndMatrixUtil.h
Go to the documentation of this file.
1 /*
2  matrix helper macro
3 
4  NOTE: we're always using column-major notation for vectors and matrices.
5  Even though ROOT uses column major notation for TGeoMatrices and TGeoHMatrices
6  (sometimes), the actual implementation is wrong. Inside the homogenous matrix,
7  the rotation matrix is stored colum-major, but the translation matrix is stored
8  row-major. Therefore, the matrix elements must be picked individually.
9 
10  */
11 
12 #ifndef PNDMATRIXUTIL_H
13 #define PNDMATRIXUTIL_H
14 
15 #include <TFile.h>
16 #include <TGeoMatrix.h>
17 #include <TROOT.h>
18 #include <TGeoManager.h>
19 
20 #include <nlohmann/json.hpp>
21 
22 #include <iomanip> // for setw
23 #include <iostream>
24 #include <fstream>
25 #include <ostream>
26 #include <map>
27 #include <string>
28 
29 using std::cerr;
30 using std::cout;
31 using std::map;
32 using std::string;
33 
35 
37 
38  private:
39  static bool saveMatricesToJson(std::map<std::string, TGeoHMatrix> *matrices, std::string &outfilename);
40  static bool saveMatricesToRootFile(std::map<std::string, TGeoHMatrix> *matrices, std::string &fileName);
41 
42  static std::map<string, TGeoHMatrix> *readMatricesFromRootFile(string &fileName);
43  static std::map<std::string, TGeoHMatrix> *readMatricesFromJSON(string &filename);
44 
45  static bool saveGeoManagerMatricesToDisk(std::vector<string> &paths, string &fileName);
46  static bool hasEnding(std::string const &fullString, std::string const &ending);
47  static std::vector<string> getPathsFromMatrixFile(string &fileName);
48 
49  public:
50  PndMatrixUtil();
51  static bool saveMatrices(std::map<std::string, TGeoHMatrix> *matrices, std::string &outfilename);
52  static std::map<string, TGeoHMatrix> *readMatrices(std::string &fileName);
53 
55 };
56 
57 #endif
static std::map< string, TGeoHMatrix > * readMatrices(std::string &fileName)
static bool saveMatrices(std::map< std::string, TGeoHMatrix > *matrices, std::string &outfilename)
ClassDef(PndMatrixUtil, 0)
nlohmann::json json
Definition: PndMatrixUtil.h:34