KaliVeda
Toolkit for HIC analysis
KVGeoNavigator.h
1 
4 #ifndef __KVGEONAVIGATOR_H
5 #define __KVGEONAVIGATOR_H
6 
7 #include "KVBase.h"
8 #include "TVector3.h"
9 #include "TClonesArray.h"
10 #include "KVDetector.h"
11 #include <KVNameValueList.h>
12 #include <TGeoMatrix.h>
13 class KVNucleus;
14 class TGeoManager;
15 class TGeoVolume;
16 class TGeoNode;
17 class TEnv;
18 
46 class KVGeoNavigator : public KVBase {
47 private:
48  TGeoManager* fGeometry;
49  TGeoVolume* fCurrentVolume;
50  TGeoNode* fCurrentNode;
51  TGeoNode* fCurrentDetectorNode;
52  TGeoHMatrix fCurrentMatrix;
53  TString fCurrentPath;
54  TClonesArray fCurrentStructures;
55  Int_t fCurStrucNumber;
56  TGeoNode* fMotherNode;
57  Double_t fStepSize;
58  TVector3 fEntryPoint;
59  TVector3 fExitPoint;
60  Bool_t fStopPropagation;
61  Int_t fTrackID;
62  Bool_t fTracking;
63 protected:
64  KVNameValueList fStrucNameFmt;
65  KVString fDetNameFmt;
66  TEnv* fDetStrucNameCorrespList;
67  void FormatStructureName(const Char_t* type, Int_t number, KVString& name);
68  void FormatDetectorName(const Char_t* basename, KVString& name);
69 
70 public:
75  class KVGeoDetectorPath : public TNamed {
76  KVDetector* fDetector;
77  public:
78  KVGeoDetectorPath() : TNamed(), fDetector(nullptr) {}
79  KVGeoDetectorPath(const Char_t* path, KVDetector* det) :
80  TNamed(path, ""), fDetector(det) {}
82  {
83  return fDetector;
84  }
85  ClassDef(KVGeoDetectorPath, 1) //Link physical path to node in geometry with detector
86  };
87 protected:
88  KVUniqueNameList fDetectorPaths;
89  KVDetector* GetDetectorFromPath(const TString& p)
90  {
93  KVGeoDetectorPath* gdp = (KVGeoDetectorPath*)fDetectorPaths.FindObject(p);
94  return (KVDetector*)(gdp ? gdp->GetDetector() : nullptr);
95  }
96  Int_t GetSubDetectorFromPathAndNodeName(KVDetector* det, const TString& p, const TString& n)
97  {
101 
102  if (p.Contains(Form("DET_%s/SUBDET_", det->GetName())) && n.BeginsWith("SUBDET_")) {
103  TString sub(n);
104  sub.Remove(0, 7);
105  return sub.Atoi();
106  }
107  return -1;
108  }
109 
110 public:
112  virtual ~KVGeoNavigator();
113 
114  void ResetTrackID(Int_t id = 0)
115  {
116  fTrackID = id;
117  }
119  {
120  return fTrackID;
121  }
123  {
124  ++fTrackID;
125  }
126  void SetTracking(Bool_t on = kTRUE)
127  {
128  fTracking = on;
129  }
131  {
132  return fTracking;
133  }
134 
135  void SetStructureNameFormat(const Char_t* type, const Char_t* fmt);
136  void SetDetectorNameFormat(const Char_t* fmt)
137  {
157  fDetNameFmt = fmt;
158  }
160  {
161  return fDetNameFmt.Data();
162  }
163  void SetNameCorrespondanceList(const Char_t*);
164  void SetNameCorrespondanceList(const TEnv*);
166 
167  void PropagateEvent(KVEvent*, TVector3* TheOrigin = 0);
168  virtual void PropagateParticle(KVNucleus*, TVector3* TheOrigin = 0);
169  virtual void ParticleEntersNewVolume(KVNucleus*);
170 
172  {
173  return fGeometry;
174  }
176  {
177  return fCurrentVolume;
178  }
180  {
181  return fCurrentNode;
182  }
183  const TGeoHMatrix* GetCurrentMatrix() const;
185  {
186  return fStepSize;
187  }
188  const TVector3& GetEntryPoint() const
189  {
190  return fEntryPoint;
191  }
192  const TVector3& GetExitPoint() const
193  {
194  return fExitPoint;
195  }
199  {
200  return fCurrentPath;
201  }
202 
204  {
205  return fStopPropagation;
206  }
207  void SetStopPropagation(Bool_t stop = kTRUE)
208  {
209  fStopPropagation = stop;
210  }
211 
214  {
215  return fCurrentStructures;
216  }
218  void DrawTracks(KVNumberList* = nullptr);
219 
221  {
225 
226  fDetectorPaths.AddAll(&GN->fDetectorPaths);
227  GN->fDetectorPaths.SetOwner(kFALSE);
228  }
230  {
231  TIter it(&fDetectorPaths);
232  KVGeoDetectorPath* gdp;
233  while ((gdp = (KVGeoDetectorPath*)it())) {
234  std::cout << gdp->GetDetector()->GetName() << " : " << gdp->GetName() << std::endl;
235  }
236  }
237 
238  ClassDef(KVGeoNavigator, 0) //Propagate particles of an event through a TGeo geometry
239 };
240 
241 #endif
int Int_t
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
#define ClassDef(name, id)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
char * Form(const char *fmt,...)
Base class for KaliVeda framework.
Definition: KVBase.h:140
Base class for detector geometry description, interface to energy-loss calculations.
Definition: KVDetector.h:173
Abstract base class container for multi-particle events.
Definition: KVEvent.h:67
Link physical path to node in geometry with detector.
KVDetector * GetDetector() const
KVGeoDetectorPath(const Char_t *path, KVDetector *det)
Base class for propagation of particles through array geometry.
virtual void AddPointToCurrentTrack(Double_t, Double_t, Double_t)
Bool_t IsTracking() const
const Char_t * GetDetectorNameFormat() const
void SetDetectorNameFormat(const Char_t *fmt)
void PropagateEvent(KVEvent *, TVector3 *TheOrigin=0)
const TGeoHMatrix * GetCurrentMatrix() const
Returns pointer to internal copy of current global transformation matrix.
void AbsorbDetectorPaths(KVGeoNavigator *GN)
Int_t GetTrackID() const
void IncrementTrackID()
void ExtractDetectorNameFromPath(KVString &)
void PrintDetectorPaths()
TGeoNode * GetCurrentNode() const
void SetTracking(Bool_t on=kTRUE)
KVGeoNavigator(TGeoManager *)
Constructor. Call with pointer to geometry.
Double_t GetStepSize() const
const TClonesArray & CurrentStructures() const
void SetNameCorrespondanceList(const Char_t *)
void SetStopPropagation(Bool_t stop=kTRUE)
virtual void PropagateParticle(KVNucleus *, TVector3 *TheOrigin=0)
TGeoVolume * GetCurrentDetectorNameAndVolume(KVString &, Bool_t &, Bool_t &segmented)
TGeoNode * GetCurrentDetectorNode() const
virtual void ParticleEntersNewVolume(KVNucleus *)
TString GetCurrentPath() const
TGeoVolume * GetCurrentVolume() const
Bool_t GetNameCorrespondance(const Char_t *, TString &)
Bool_t StopPropagation() const
virtual ~KVGeoNavigator()
Destructor.
void ResetTrackID(Int_t id=0)
const TVector3 & GetExitPoint() const
void SetStructureNameFormat(const Char_t *type, const Char_t *fmt)
const TVector3 & GetEntryPoint() const
TGeoManager * GetGeometry() const
void DrawTracks(KVNumberList *=nullptr)
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:123
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
TObject * FindObject(const char *name) const override
void SetOwner(Bool_t enable=kTRUE) override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
Optimised list in which named objects can only be placed once.
virtual void AddAll(const TCollection *col)
const char * GetName() const override
const char * Data() const
const Int_t n