KaliVeda
Toolkit for HIC analysis
KVGroup.cpp
1 #include "KVGroup.h"
2 
3 using namespace std;
4 
6 
7 
8 
9 
12 {
13  init();
14 }
15 
16 
17 
18 
22 
24 {
25  // Default initialisation
26  // KVGroup does not own the structures which it groups together
27 
28  SetType("GROUP");
29  SetOwnsDaughters(kFALSE);
30  fReconTraj.SetOwner();
31  //fReconstructedNuclei.SetCleanup();
32 }
33 
34 
35 
41 
43 {
44  // Calculate all possible (sub-)trajectories
45  // for particle reconstruction (GetReconTrajectories())
46  //
47  // Returns number of (unique) trajectories in group
48 
49  fReconTraj.Clear();
50  TIter next_traj(GetTrajectories());
51  KVGeoDNTrajectory* traj;
52  while ((traj = (KVGeoDNTrajectory*)next_traj())) { // loop over all trajectories
53 
54  traj->IterateFrom(); // from furthest-out to closest-in detector
55 
57  while ((N = traj->GetNextNode())) {
58  fReconTraj.Add(KVGeoDNTrajectory::Factory("KVReconNucTrajectory", traj, N));
59  }
60  }
61 
62  // There may be trajectories with different names but identical titles
63  // (=physically same trajectories)
64  // We find the duplicates, delete them, and set up a map between the names of the
65  // duplicates and the name of the one remaining trajectory in the list
66  TList toRemove;
67  KVUniqueNameList unique_trajectories(kFALSE);//no replace
68  unique_trajectories.SetOwner();
69  fReconTrajMap.Clear();
70  TIter nxtRT(GetReconTrajectories());
71  KVGeoDNTrajectory* rnt;
72  while ((rnt = (KVGeoDNTrajectory*)nxtRT())) {
73 
74  TNamed* n = new TNamed(rnt->GetTitle(), rnt->GetName());
75  unique_trajectories.Add(n);
76  TNamed* orig = n;
77  if (!unique_trajectories.ObjectAdded()) {
78  orig = (TNamed*)unique_trajectories.FindObject(rnt->GetTitle());
79  toRemove.Add(rnt);
80  delete n;
81  }
82  // set up mapping from duplicate trajectory name to orginal trajectory name
83  fReconTrajMap.SetValue(rnt->GetName(), orig->GetTitle());
84 
85  }
86 
87  // now remove & delete the duplicates
88  TIter nxtDel(&toRemove);
89  while ((rnt = (KVGeoDNTrajectory*)nxtDel())) {
90  fReconTraj.Remove(rnt);
91  }
92  toRemove.Delete();
93 
94  return fReconTraj.GetEntries();
95 }
96 
97 
98 
101 
102 void KVGroup::PrintData() const
103 {
104  // list detectors of group with any data they contain
105  KVDetector* det;
106  TIter it(GetDetectors());
107  while ((det = (KVDetector*)it())) det->Print("data");
108 }
109 
110 
111 
int Int_t
constexpr Bool_t kFALSE
#define N
Path taken by particles through multidetector geometry.
KVGeoDetectorNode * GetNextNode() const
static KVGeoDNTrajectory * Factory(const char *plugin, const KVGeoDNTrajectory *, const KVGeoDetectorNode *)
Instantiate & return object of class corresponding to plugin.
void IterateFrom(const KVGeoDetectorNode *node0=nullptr) 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:20
void init()
Definition: KVGroup.cpp:23
void PrintData() const
list detectors of group with any data they contain
Definition: KVGroup.cpp:102
Int_t CalculateReconstructionTrajectories()
Definition: KVGroup.cpp:42
TObject * FindObject(const char *name) const override
void SetOwner(Bool_t enable=kTRUE) override
Optimised list in which named objects can only be placed once.
Bool_t ObjectAdded() const
void Add(TObject *obj) override
void Add(TObject *obj) override
void Delete(Option_t *option="") override
const char * GetName() const override
const char * GetTitle() const override
const Int_t n
void init()
ClassImp(TPyArg)