KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVGroup.cpp
1#include "Riostream.h"
2#include "KVGroup.h"
3#include "KVNucleus.h"
4#include "KVList.h"
5#include "KVDetector.h"
6#include "KVLayer.h"
7#include "TROOT.h"
8#include "KVNameValueList.h"
9
10using namespace std;
11
13
14
15
16
17
19{
20 init();
21}
22
23
24
25
29
31{
32 // Default initialisation
33 // KVGroup does not own the structures which it groups together
34
36 SetType("GROUP");
39}
40
41
42
43
45
56
57
58
63
65{
66 // The number of detector layers is the maximum number of detectors in the
67 // group which are placed one in front of the other, i.e. we interrogate
68 // each detector as to how many detectors there are in front of it
69
70 UInt_t max = 0;
71 TIter next(GetDetectors());
73 while ((d = (KVDetector*)next())) {
74 UInt_t e = d->GetAlignedDetectors()->GetEntries();
75 if (e > max) max = e;
76 }
77 return max;
78}
79
80
81
87
89{
90 // lay=1 : create and fill list with detectors closest to target
91 // lay=GetNumberOfDetectorLayers() : detectors furthest from target
92 //
93 // Delete TList after use!
94
95 TList* dets = new TList;
96 TIter next(GetDetectors());
98
99 while ((d = (KVDetector*)next())) {
100 if (lay == (UInt_t)d->GetAlignedDetectors()->GetEntries()) dets->Add(d);
101 }
102 return dets;
103}
104
105
106
107
113
115{
116 //Reset the group, i.e. wipe the list of reconstructed nuclei and call "Reset" method of
117 //each and every detector in the group.
118 // The option 'opt' is passed to KVDetector::Reset
119
120 //Info("Reset","Call %s",GetName());
123 }
124 //reset energy loss and KVDetector::IsAnalysed() state
125 //plus ACQParams set to zero if opt!="N" (for No Reset)
127}
128
129
130
131
133
142
143
144
145
149
151{
152 //Remove reconstructed nucleus from group's list of reconstructed
153 //particles.
156 if (fReconstructedNuclei->GetSize() == 0) {
159 }
160 }
161 else {
162 Warning("RemoveHit", "No reconstructed nuclei in this group");
163 }
164}
165
166
167
176
178{
179 //Fill TList with all detectors aligned with "det" which are closer to the target.
180 //These are the detectors through which any particle stopping in "det" will have
181 //to pass. By default (dir=KVGroup::kBackwards) the list starts with "det" and
182 //goes towards the target. Use dir=KVGroup::kForwards to have the list in the
183 //order seen by an impinging particle.
184 //
185 //Delete TList after use.
186
187 TList* tmp = new TList;
188
189 while (det) {
190 tmp->Add(det);
191 KVGeoDetectorNode* node = det->GetNode();
192 KVSeqCollection* infront = node->GetDetectorsInFront();
193 if (!infront) break;
194 if (infront->GetEntries() > 1) {
195 Warning("GetAlignedDetectors",
196 "No unique solution. There are %d detectors in front of %s.",
197 infront->GetEntries(), det->GetName());
198 infront->ls();
199 }
200 det = (KVDetector*)infront->First();
201 }
202
203 if (dir == kForwards) {
204 TIter next(tmp, kIterBackward);
205 TList* tmp2 = new TList;
206 while ((det = (KVDetector*)next())) tmp2->Add(det);
207 delete tmp;
208 tmp = tmp2;
209 }
210 return tmp;
211}
212
213
214
215
216
217
221
223{
224 // Loop over all detectors in group and clear their list of 'hits'
225 // i.e. the lists of particles which hit each detector
226 const_cast<KVSeqCollection*>(GetDetectors())->R__FOR_EACH(KVDetector, ClearHits)();
227}
228
229
230
236
238{
239 // Calculate all possible (sub-)trajectories
240 // for particle reconstruction (GetReconTrajectories())
241 //
242 // Returns number of (unique) trajectories in group
243
245 TIter next_traj(GetTrajectories());
246 KVGeoDNTrajectory* traj;
247 while ((traj = (KVGeoDNTrajectory*)next_traj())) { // loop over all trajectories
248
249 traj->IterateFrom(); // from furthest-out to closest-in detector
250
252 while ((N = traj->GetNextNode())) {
253 fReconTraj.Add(KVGeoDNTrajectory::Factory("KVReconNucTrajectory", traj, N));
254 }
255 }
256
257 // There may be trajectories with different names but identical titles
258 // (=physically same trajectories)
259 // We find the duplicates, delete them, and set up a map between the names of the
260 // duplicates and the name of the one remaining trajectory in the list
261 TList toRemove;
262 KVUniqueNameList unique_trajectories(kFALSE);//no replace
263 unique_trajectories.SetOwner();
267 while ((rnt = (KVGeoDNTrajectory*)nxtRT())) {
268
269 TNamed* n = new TNamed(rnt->GetTitle(), rnt->GetName());
270 unique_trajectories.Add(n);
271 TNamed* orig = n;
272 if (!unique_trajectories.ObjectAdded()) {
273 orig = (TNamed*)unique_trajectories.FindObject(rnt->GetTitle());
274 toRemove.Add(rnt);
275 delete n;
276 }
277 // set up mapping from duplicate trajectory name to orginal trajectory name
278 fReconTrajMap.SetValue(rnt->GetName(), orig->GetTitle());
279
280 }
281
282 // now remove & delete the duplicates
283 TIter nxtDel(&toRemove);
284 while ((rnt = (KVGeoDNTrajectory*)nxtDel())) {
285 fReconTraj.Remove(rnt);
286 }
287 toRemove.Delete();
288
289 return fReconTraj.GetEntries();
290}
291
292
293
296
298{
299 // list detectors of group with any data they contain
300 KVDetector* det;
301 TIter it(GetDetectors());
302 while ((det = (KVDetector*)it())) det->Print("data");
303}
304
305
306
int Int_t
unsigned int UInt_t
#define d(i)
#define e(i)
unsigned char UChar_t
constexpr Bool_t kFALSE
const char Option_t
const Bool_t kIterBackward
#define R__FOR_EACH(type, proc)
#define N
virtual void SetType(const Char_t *str)
Definition KVBase.h:173
Base class for detector geometry description.
Definition KVDetector.h:160
KVGeoDetectorNode * GetNode()
Definition KVDetector.h:326
virtual void Print(Option_t *option="") const
Path taken by particles through multidetector geometry.
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
KVGeoDetectorNode * GetNextNode() const
Information on relative positions of detectors & particle trajectories.
KVSeqCollection * GetDetectorsInFront() const
void SetOwnsDaughters(Bool_t yes=kTRUE)
const KVSeqCollection * GetDetectors() const
Group of detectors which can be treated independently of all others in array.
Definition KVGroup.h:20
KVHashList fTrajectories
Trajectories passing through group.
Definition KVGroup.h:27
void Reset(Option_t *opt="")
Definition KVGroup.cpp:114
virtual TList * GetAlignedDetectors(KVDetector *, UChar_t dir=kBackwards)
Definition KVGroup.cpp:177
@ kForwards
Definition KVGroup.h:33
KVHashList fReconTraj
list of all possible trajectories for reconstructed particles
Definition KVGroup.h:28
void init()
Definition KVGroup.cpp:30
const TCollection * GetTrajectories() const
Definition KVGroup.h:79
KVNameValueList fReconTrajMap
map names of duplicate trajectories for reconstructed particles
Definition KVGroup.h:29
const TSeqCollection * GetReconTrajectories() const
Definition KVGroup.h:93
virtual TList * GetDetectorsInLayer(UInt_t lay)
Definition KVGroup.cpp:88
virtual UInt_t GetNumberOfDetectorLayers()
Definition KVGroup.cpp:64
void ClearHitDetectors()
Definition KVGroup.cpp:222
void AddHit(KVNucleus *kvd)
Definition KVGroup.cpp:134
void RemoveHit(KVNucleus *kvd)
Definition KVGroup.cpp:150
void PrintData() const
list detectors of group with any data they contain
Definition KVGroup.cpp:297
KVList * fReconstructedNuclei
Particles reconstructed in this group.
Definition KVGroup.h:26
virtual ~KVGroup()
Definition KVGroup.cpp:46
Int_t CalculateReconstructionTrajectories()
Definition KVGroup.cpp:237
Extended TList class which owns its objects by default.
Definition KVList.h:28
void SetValue(const Char_t *name, value_type value)
virtual void Clear(Option_t *opt="")
Description of properties and kinematics of atomic nuclei.
Definition KVNucleus.h:126
KaliVeda extensions to ROOT collection classes.
virtual TObject * FindObject(const char *name) const
virtual void SetOwner(Bool_t enable=kTRUE)
virtual void Clear(Option_t *option="")
virtual Int_t GetSize() const
virtual TObject * First() const
virtual void SetCleanup(Bool_t enable=kTRUE)
virtual void Add(TObject *obj)
virtual TObject * Remove(TObject *obj)
Remove object from list.
Optimised list in which named objects can only be placed once.
Bool_t ObjectAdded() const
virtual void Add(TObject *obj)
void ls(Option_t *option="") const override
virtual Int_t GetEntries() const
void Add(TObject *obj) override
void Delete(Option_t *option="") override
const char * GetName() const override
const char * GetTitle() const override
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void Warning(const char *method, const char *msgfmt,...) const
const Int_t n
void init()
double max(double x, double y)
ClassImp(TPyArg)