KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVGeoDNTrajectory.h
Go to the documentation of this file.
1 #ifndef __KVGEODNTRAJECTORY_H
2 #define __KVGEODNTRAJECTORY_H
3 
4 #include "KVBase.h"
5 #include "KVUniqueNameList.h"
6 #include "TObjArray.h"
7 #include "KVGeoDetectorNode.h"
8 
41 
71 
76 class KVGeoDNTrajectory : public KVBase {
77 
78  friend class KVGroup;
79 
80  static KVGeoDNTrajectory* Factory(const char* plugin, const KVGeoDNTrajectory*, const KVGeoDetectorNode*);
81 
82  void init();
83 
86  mutable Int_t fIter_idx;
87  mutable Int_t fIter_limit;
88  mutable Int_t fIter_delta;
94 
95  void rebuild_title();
96 
97  void increment_identified_particle_counters(int identified, int unidentified) const;
98 
99 protected:
101 
102 public:
106  virtual ~KVGeoDNTrajectory();
107  void Copy(TObject& obj) const;
109 
110  void Clear(Option_t* = "");
111 
112  void SetAddToNodes(Bool_t yes = kTRUE)
113  {
114  fAddToNodes = yes;
115  }
116 
117  KVGeoDetectorNode* GetNode(const Char_t* name) const
118  {
120  return (KVGeoDetectorNode*)fNodes.FindObject(name);
121  }
123  {
125  if (Contains(n) && !EndsAt(n)) {
126  return GetNodeAt(Index(n) + 1);
127  }
128  return nullptr;
129  }
130  Bool_t Contains(const Char_t* name) const
131  {
134  return GetNode(name) != nullptr;
135  }
136 
137  Int_t GetN() const
138  {
140  return fNodes.GetEntries();
141  }
142  Int_t Index(const TObject* node) const
143  {
145  return fNodes.IndexOf(node);
146  }
147 
149  {
151  fNodes.AddLast(n);
152  if (fAddToNodes) n->AddTrajectory(this);
153  rebuild_title();
154  }
155 
156  void ReverseOrder();
157  void AddToNodes();
158 
159  void ls(Option_t* = "") const
160  {
161  std::cout << GetTrajectoryName() << " : " << GetPathString() << std::endl;
162  }
163 
164  Bool_t EndsAt(const Char_t* node_name) const
165  {
168 
169  return !strcmp(node_name, fNodes.Last()->GetName());
170  }
171 
172  Bool_t BeginsAt(const Char_t* node_name) const
173  {
176 
177  return !strcmp(node_name, fNodes.First()->GetName());
178  }
179 
181  {
184 
185  return (d == (KVGeoDetectorNode*)fNodes.Last());
186  }
187 
189  {
192 
193  return (d == (KVGeoDetectorNode*)fNodes.First());
194  }
195 
197  {
198  return (fNodes.FindObject(n) != NULL);
199  }
201  {
204  TIter next(l);
205  TObject* o;
206  while ((o = next())) {
207  if (!Contains(o->GetName())) return kFALSE;
208  }
209  return kTRUE;
210  }
211 
213  {
217 
218  return (KVGeoDetectorNode*)fNodes[i];
219  }
220 
221  void SaveIterationState() const
222  {
229  }
231  {
233 
237  }
238  void IterateFrom(const KVGeoDetectorNode* node0 = nullptr) const
239  {
246 
247  fIter_idx = (node0 == nullptr ? 0 : Index(node0));
248  fIter_delta = 1;
249  fIter_limit = GetN() - 1;
250  }
251  void IterateBackFrom(const KVGeoDetectorNode* node0 = nullptr) const
252  {
259 
260  fIter_idx = (node0 == nullptr ? GetN() - 1 : Index(node0));
261  fIter_delta = -1;
262  fIter_limit = 0;
263  }
264 
266  {
269 
270  if (fIter_idx > -1) {
271  if (fIter_delta * (fIter_limit - fIter_idx) > 0) {
272  Int_t idx = fIter_idx;
274  return GetNodeAt(idx);
275  }
276  else {
278  fIter_idx = -1;
279  return GetNodeAt(fIter_limit);
280  }
281  }
282  return nullptr;
283  }
284 
286  {
288  return &fIDTelescopes;
289  }
291  {
293  return &fIDTelescopes;
294  }
296  {
297  return fIDTelescopes.GetEntries();
298  }
300  {
302  return GetPathString().Contains(other->GetPathString());
303  }
305  {
307  if (fPathInTitle) return GetTitle();
308  return GetName();
309  }
310  const Char_t* GetTrajectoryName() const
311  {
313  if (fPathInTitle) return GetName();
314  return GetTitle();
315  }
316  void SetPathInTitle(Bool_t intitle = kTRUE)
317  {
322 
323  if (intitle != fPathInTitle) {
324  TString s = GetName();
325  SetName(GetTitle());
326  SetTitle(s);
327  fPathInTitle = intitle;
328  }
329  }
331  {
333  return fPathInTitle;
334  }
335  void AddIdentifiedParticle(int modify_unidentified = -1) const
336  {
338  increment_identified_particle_counters(1, modify_unidentified);
339  }
340  void AddUnidentifiedParticle(int modify_identified = -1) const
341  {
343  increment_identified_particle_counters(modify_identified, 1);
344  }
345 
346  ClassDef(KVGeoDNTrajectory, 1) //Path taken by particles through multidetector geometry
347 };
348 
349 #endif
int Int_t
#define d(i)
char Char_t
const Bool_t kFALSE
bool Bool_t
const Bool_t kTRUE
const char Option_t
#define ClassDef(name, id)
Base class for KaliVeda framework.
Definition: KVBase.h:141
Path taken by particles through multidetector geometry.
void SaveIterationState() const
Bool_t ContainsAll(const TCollection *l) const
Bool_t fAddToNodes
if kTRUE, add trajectory to node's list
const Char_t * GetTrajectoryName() const
KVGeoDNTrajectory()
Default constructor.
Int_t fIter_delta_sav
increment/decrement for each iteration
KVGeoDetectorNode * GetNextNode() const
TString GetPathString() const
KVSeqCollection * AccessIDTelescopeList()
Bool_t EndsAt(const Char_t *node_name) const
static Int_t fGDNTrajNumber
Int_t Index(const TObject *node) const
void AddUnidentifiedParticle(int modify_identified=-1) const
void ls(Option_t *="") const
Bool_t Contains(const Char_t *name) const
void increment_identified_particle_counters(int identified, int unidentified) const
increment counters in all detectors on trajectory
static KVGeoDNTrajectory * Factory(const char *plugin, const KVGeoDNTrajectory *, const KVGeoDetectorNode *)
Instantiate & return object of class corresponding to plugin.
void SetPathInTitle(Bool_t intitle=kTRUE)
Int_t fIter_delta
increment/decrement for each iteration
Bool_t Contains(const KVGeoDetectorNode *n) const
Bool_t BeginsAt(const KVGeoDetectorNode *d) const
void ReverseOrder()
Reverse the order of the nodes in the trajectory.
void AddLast(KVGeoDetectorNode *n)
void AddToNodes()
Add reference to this trajectory to all nodes on it.
Bool_t EndsAt(const KVGeoDetectorNode *d) const
void IterateFrom(const KVGeoDetectorNode *node0=nullptr) const
Int_t GetNumberOfIdentifications() const
void Clear(Option_t *="")
Clear list of nodes in trajectory.
void AddIdentifiedParticle(int modify_unidentified=-1) const
Bool_t BeginsAt(const Char_t *node_name) const
const KVSeqCollection * GetIDTelescopes() const
Bool_t ContainsPath(KVGeoDNTrajectory *other)
Int_t fIter_limit
last index for iteration
KVUniqueNameList fIDTelescopes
list of id telescopes on this trajectory
Int_t fIter_limit_sav
last index for iteration
Int_t fIter_idx_sav
index for iteration
Int_t fIter_idx
index for iteration
KVGeoDetectorNode * GetNodeInFront(const KVGeoDetectorNode *n) const
TObjArray fNodes
list of nodes on trajectory
void IterateBackFrom(const KVGeoDetectorNode *node0=nullptr) const
virtual ~KVGeoDNTrajectory()
Destructor.
void Copy(TObject &obj) const
Make a copy of this object.
void RestoreIterationState() const
Bool_t IsPathInTitle() const
Bool_t fPathInTitle
true if path is in title, false if path is in name
KVGeoDetectorNode * GetNode(const Char_t *name) const
KVGeoDNTrajectory & operator=(const KVGeoDNTrajectory &)
void SetAddToNodes(Bool_t yes=kTRUE)
KVGeoDetectorNode * GetNodeAt(Int_t i) const
Information on relative positions of detectors & particle trajectories.
Group of detectors which can be treated independently of all others in array.
Definition: KVGroup.h:19
KaliVeda extensions to ROOT collection classes.
Optimised list in which named objects can only be placed once.
virtual Int_t GetEntries() const
virtual const char * GetName() const
virtual void SetTitle(const char *title="")
virtual const char * GetTitle() const
virtual void SetName(const char *name)
Int_t IndexOf(const TObject *obj) const
virtual void AddLast(TObject *obj)
TObject * Last() const
Int_t GetEntries() const
TObject * First() const
virtual TObject * FindObject(const char *name) const
virtual const char * GetName() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
const Int_t n
const long double s
Definition: KVUnits.h:94
auto * l