EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoordSystem.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CoordSystem.h
1 /* -------------------------------------------------------------------------- */
2 /* CoordSystem.h */
3 /* */
4 /* A.Kisselev, PNPI, St.Petersburg, Russia. */
5 /* e-mail: kisselev@hermes.desy.de */
6 /* -------------------------------------------------------------------------- */
7 
8 #include <3d.h>
9 
10 // Well, want easy access to __u64 definition; think later;
11 #include <MgridDirection.h>
12 
13 #ifndef _COORD_SYSTEM_
14 #define _COORD_SYSTEM_
15 
16 // Prefer users to specify axes by name; just in order to avoid
17 // bad mistakes like specifying _R_ coordinate for _CARTESIAN_
18 // system (which in this case will be silently interpreted as _X_);
19 struct t_coord_name {
20  // Name --> 'X', 'Y', 'Z', 'F', 'R';
21  char name;
22  // ID in the interval 0..2;
23  int id;
24  // Bitwise OR of allowed system types;
25  unsigned char allowed_systems;
26 } ;
27 
28 // NB: 2-dim grids (like RZ-grid for the recoil detector
29 // simulation) will be expanded into 3-dim grids setting 3-d
30 // dimension - number of cells - to '1'; NB: next entry
31 // should be 0x04 (since 'coord_names[]' uses bitwise pattern);
32 #define _CARTESIAN_ 0x01
33 #define _CYLINDRICAL_ 0x02
34 
35 //
36 // -> never change data fields order, etc in this class!;
37 //
38 
39 //class Mgrid;
40 
41 class CoordSystem {
42  friend class Mgrid;
43  friend class MgridInterpolation;
44 
45  //friend Mgrid *create_mgrid_heap_header(char *name, int field_calculation_method);
46 
47  public:
48  // Again, is the place holder usage correct for mgrid import?;
50  // Meaningful constructor;
51  CoordSystem(unsigned char _system_type, int _coord_num, char
52  _coord_names[]);
53 
54  // Wan to keep "system_type" private; no range check?; do enum later;
55  void setSystemType(unsigned type) { system_type = type;};
56 
57  unsigned getCoordNum() { return coord_num;};
58  void setCoordNum(unsigned num) { coord_num = num;};
59 
60  private:
61  int calculateExpansionRules(int **expansion);
62  void projectToLocalCoordinates(double in[], double out[]);
63 
64  // _CARTESIAN_/_CYLINDRICAL_ for now; do not mind to spend 8 bytes;
66 
67  // Number of coordinates; yes, it's redundant (see 'fake[]' field);
69 
70  // Make life easier ...;
71  public:
72  // If '1', this coordinate is missing; natural XYZ (RFZ) sequence;
73  __u64 fake[3];
74 } ;
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79  t_coord_name *find_coord_by_name(unsigned char system_type, char name);
80 
81  void expand_to_global_coordinates(int ldim, TVector3 &in, TVector3 &out, int l2g[]);
82 #ifdef __cplusplus
83 }
84 #endif
85 
86 #endif