EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrKalmanNodeLocation.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrKalmanNodeLocation.h
1 //
2 // AYK (ayk@bnl.gov)
3 //
4 // Extracted from KalmanNode in Oct'2015;
5 //
6 
7 #include <Mgrid.h>
8 
9 #include <MediaSliceArray.h>
10 #include <KalmanFilter.h>
11 
12 #include <RungeKuttaRequest.h>
13 
14 #ifndef _TR_KALMAN_NODE_LOCATION_
15 #define _TR_KALMAN_NODE_LOCATION_
16 
17 class MediaSliceArray;
18 
19 struct ProcessNoise {
20 public:
21 ProcessNoise(): mCxx(0), mCyy(0), mCxy(0) {};
22 
23  // If transport matrix does not mix XY-coordinates (like in a field-free
24  // region or - approximately? - when field is mostly oriented along Y axis),
25  // it makes sense to split process noise covariance matrix into 3
26  // non-overlapping blocks and add all slices up; in general one should
27  // always recalculate full covariance matrix using real transport matrix
28  // in this given XYZ-point, momentum and slopes; want them to be pointers
29  // so that FillLowerTriangle() works on them :-);
30  double **mCxx, **mCyy, **mCxy;
31 };
32 
33 class TrKalmanNode;
34 class SensitiveVolume;
35 class EicKfNodeTemplate;
36 
38  public:
40  mSensitiveVolumeNodeWrapperCount(0)*/ {
41  mProcessNoise[0] = mProcessNoise[1] = 0;
42  memset(mRungeKutta, 0x00, sizeof(mRungeKutta));
43 
44  mPlane = t_3d_plane(TVector3(0,0,z), TVector3(0,0,1));
45  };
47 
48  void SetPrev(TrKalmanNodeLocation *location) { mPrev = location; };
49  void SetNext(TrKalmanNodeLocation *location) { mNext = location; };
50 
52 
53  // Media layers from this node to the next one (for the
54  // case of tracking Kalman filter);
56 
57  // [2]: F/B;
59 
60  // '[2]': FORWARD/BACKWARD separately;
62 
63  void AddNode(TrKalmanNode *node) { mNodes.push_back(node); };
64  void AddSensitiveVolume(SensitiveVolume *sv) { if (sv) mSensitiveVolumes.insert(sv); };
65 
66  TrKalmanNodeLocation *GetNext(unsigned fb) { return (fb ? mPrev : mNext); };
67  TrKalmanNodeLocation *GetPrev(unsigned fb) { return (fb ? mNext : mPrev); };
68 
69  unsigned GetNodeCount() const { return mNodes.size(); };
70  TrKalmanNode *GetNode(unsigned nd) const { return (nd < mNodes.size() ? mNodes[nd] : 0); };
71  double GetZ() const { return mPlane.GetCoord()[2]; };
72 
73  unsigned GetFiredNodeCount();
74 
75  bool HasSensitiveVolumes() const { return (mSensitiveVolumes.size() > 0); };
76  const std::set<SensitiveVolume*> &GetSensitiveVolumes() const {
77  return mSensitiveVolumes;
78  };
79 
80  const t_3d_plane *GetPlane() const { return &mPlane; };
81 
82  void SetNextMdimValue(unsigned mdim) {
83  // This indeed assumes, that TrKalmanFilter::SetUpLocations() fills out
84  // all entries at once (so they are guaranteed to be in the right order);
85  mDims.push_back(mdim);
86  };
87  unsigned GetSensitiveVolumeNodeWrapperCount() const { return mDims.size(); };
88  unsigned GetMdim(unsigned nd) const { return (nd < mDims.size() ? mDims[nd] : 0); };
89  void SetNextNodeToMaster(const TGeoHMatrix *mtx) {
90  // See SetNextMdimValue() above, same implicit assumption;
91  mNodeToMasters.push_back(mtx);
92  };
93  const TGeoHMatrix *GetNodeToMaster(unsigned nd) const {
94  return (nd < mNodeToMasters.size() ? mNodeToMasters[nd] : 0);
95  };
96  void SetNextTemplate(const EicKfNodeTemplate *tmpl) {
97  // See SetNextMdimValue() above, same implicit assumption;
98  mDigiTemplates.push_back(tmpl);
99  };
100  const EicKfNodeTemplate *GetTemplate(unsigned nd) const {
101  return (nd < mDigiTemplates.size() ? mDigiTemplates[nd] : 0);
102  };
103  //void SetNextCylindricalPreference(bool what) {
104  //mCylindricalPreferences.push_back(what);
105  //};
106  //void SetCylindricalPreference(unsigned nd) { mCylindricalPreferences[nd] = true; };
107  //bool GetCylindricalPreference(unsigned nd) const {
108  //return (nd < mCylindricalPreferences.size() ? mCylindricalPreferences[nd] : false);
109  //};
110 
111  private:
112  // Well, admittedly, this is forward-application-specific;
114 
115  // Yes, it looks like I want to know the nodes participating in this location;
116  // sometimes it is useful to loop through locations rather than through the KF
117  // node pool;
118  std::vector<TrKalmanNode*> mNodes;
119 
120  // Previous/next location in "natural" direction of ascending Z;
122 
123  // Can probably live without this set, as well as the other value below,
124  // but it allows to simplify logic in TrKalmanFilter::SetUpLocations();
125  //unsigned mSensitiveVolumeNodeWrapperCount;
126  std::set<SensitiveVolume*> mSensitiveVolumes;
127 
128  // FIXME: may want to put all this stuff into a separate structure;
129 
130  // Will store a mSensitiveVolumeNodeWrapperCount-long vector where nd-th value
131  // is a copy of respective KF template GetMdim();
132  std::vector<unsigned> mDims;
133  // And the same for 3D transformation from the respective KF nd-th node
134  // to MARS; NB: it is taken from the very first node at this location (and it
135  // is assumed, that transformations are "more or less the same"); THINK: some
136  // misalignment-caused smearing?; THINK: I guess this should work for phi-sectors
137  // as well (everything will be presentetd in the coordinate system of the very
138  // first sector, fine);
139  std::vector<const TGeoHMatrix*> mNodeToMasters;
140 
141  std::vector<const EicKfNodeTemplate*> mDigiTemplates;
142  //std::vector<bool> mCylindricalPreferences;
143 };
144 
145 #endif