KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVGeoStrucElement.cpp
1//Created by KVClassFactory on Tue May 7 09:22:02 2013
2//Author: John Frankland,,,
3
4#include "KVGeoStrucElement.h"
5#include "KVDetector.h"
6#include "Riostream.h"
7#include <TROOT.h>
8using namespace std;
9
11
12
13
15
17{
18 // Default initialisations
19 fStructures.SetOwner();
20 fStructures.SetCleanup();
21 fDetectors.SetCleanup();
22 fParentStrucList.SetCleanup();
23}
24
25
26
28
33
34
35
37
42
43
44
47
49{
50 // Default constructor
51 init();
52}
53
54
55
56
59
61{
62 // Create a geometry structure element with given name and type
63 init();
64}
65
66
67
70
72{
73 // Destructor
74 Clear();
75}
76
77
78
82
84{
85 // Remove detectors of given type from this structure (default: all detectors)
86 // If they belong to the structure, they will be deleted.
87
88 TList dummy;
89 dummy.AddAll(&fDetectors);
90 TIter next(&dummy);
92 while ((d = (KVDetector*)next())) {
93 if (!strcmp(type, d->GetType()) || !strcmp(type, "")) {
94 Remove(d);
95 if (fDetectors.IsOwner()) delete d;
96 }
97 }
98 // avoid spurious warnings from TList::Clear with ROOT6
99 dummy.Clear("nodelete");
100}
101
102
103
107
109{
110 // Remove daughter structures of given type from this structure (default: all detectors)
111 // If they belong to the structure, they will be deleted.
112
113 TList dummy;
114 dummy.AddAll(&fStructures);
115 TIter next(&dummy);
117 while ((e = (KVGeoStrucElement*)next())) {
118 if (!strcmp(type, e->GetType()) || !strcmp(type, "")) {
119 Remove(e);
120 if (fStructures.IsOwner()) delete e;
121 }
122 }
123 // avoid spurious warnings from TList::Clear with ROOT6
124 dummy.Clear("nodelete");
125}
126
127
128
134
136{
137 // Add a detector or a daughter structure to this structure.
138 // Note that daughter structures are by defeault owned by their mother and will be
139 // deleted by her destructor. Call SetOwnsDaughters(kFALSE) to change.
140 // Detectors are not owned by default - call SetOwnsDetectors(kTRUE) to change.
141
142 if (element->InheritsFrom(KVDetector::Class())) {
143 fDetectors.Add(element);
144 dynamic_cast<KVDetector*>(element)->AddParentStructure(this);
145 }
146 else if (element->InheritsFrom(KVGeoStrucElement::Class())) {
147 fStructures.Add(element);
148 dynamic_cast<KVGeoStrucElement*>(element)->AddParentStructure(this);
149 }
150 else {
151 Error("Add", "Cannot add elements of class %s", element->ClassName());
152 }
153}
154
155
156
160
162{
163 // Remove a detector or structure element from this structure
164 // User's responsibility to delete the detector or structure element.
165
166 if (element->InheritsFrom(KVDetector::Class())) {
167 fDetectors.Remove(element);
168 dynamic_cast<KVDetector*>(element)->RemoveParentStructure(this);
169 }
170 else if (element->InheritsFrom(KVGeoStrucElement::Class())) {
171 fStructures.Remove(element);
172 dynamic_cast<KVGeoStrucElement*>(element)->RemoveParentStructure(this);
173 }
174 else {
175 Error("Add", "Cannot add elements of class %s", element->ClassName());
176 }
177}
178
179
180
183
185{
186 // Empty lists of detectors, daughter structures, and parent structures
187
191}
192
193
194
197
199{
200 // Get structure with type and number
201
202 unique_ptr<KVSeqCollection> typelist(GetStructureTypeList(type));
203 KVGeoStrucElement* elem = (KVGeoStrucElement*)typelist->FindObjectByNumber(num);
204 return elem;
205}
206
207
208
211
213{
214 // Get structure with type and name
216}
217
218
219
224
226{
227 // Create and fill a list with all structures of given type which are daughters
228 // of this structure.
229 // DELETE LIST AFTER USE - or, better: unique_ptr<KVSeqCollection> list(toto->GetStructureTypeList(...))
230
232}
233
234
235
238
240{
241 // Return detector in this structure with given name
243}
244
245
246
249
251{
252 // Return detector in this structure with given type
254}
255
256
257
261
263{
264 // Create and fill a list with all detectors of given type in this structure.
265 // DELETE LIST AFTER USE - or, better: unique_ptr<KVSeqCollection> list(toto->GetDetectorTypeList(...))
266
268}
269
270
271
275
277{
278 // Create and fill a list with all detectors of given type in this structure.
279 // DELETE LIST AFTER USE - or, better: unique_ptr<KVSeqCollection> list(toto->GetDetectorNameList(...))
280
282}
283
284
285
290
292{
293 // Return detector in structure with given name.
294 // If not found in this structure, we look in all daughter structures
295 // for a detector with the name.
296
298 if (!det) {
299 TIter next(GetStructures());
300 KVGeoStrucElement* elem;
301 while ((elem = (KVGeoStrucElement*)next())) {
302 det = elem->GetDetectorAny(name);
303 if (det) return det;
304 }
305 }
306 return (KVDetector*)nullptr;
307
308}
309
310
311
315
317{
318 // Returns kTRUE if any detector or structure element in this structure
319 // has 'Fired' with the given option
320
321 TIter nextd(GetDetectors());
322 KVDetector* det;
323 while ((det = (KVDetector*)nextd())) if (det->Fired(opt)) return kTRUE;
324 TIter nexts(GetStructures());
325 KVGeoStrucElement* elem;
326 while ((elem = (KVGeoStrucElement*)nexts())) if (elem->Fired(opt)) return kTRUE;
327 return kFALSE;
328}
329
330
331
335
337{
338 // Get parent geometry structure element of given type.
339 // Give unique name of structure if more than one element of same type is possible.
340 KVGeoStrucElement* el = 0;
341 if (strcmp(name, "")) {
343 el = (KVGeoStrucElement*)strucs->FindObject(name);
344 delete strucs;
345 }
346 else
348 return el;
349}
350
351
352
354
356{
358 cout << ClassName() << "::" << GetName() << " [TYPE=" << GetType() << "]" << endl << endl;
360 if (GetDetectors()->GetEntries()) {
362 cout << "DETECTORS : " << endl << endl;
363 TIter next(GetDetectors());
364 TObject* d;
366 while ((d = next())) {
368 cout << " " << d->GetName() << endl;
369 }
370 cout << endl;
372 }
373 TIter next(GetStructures());
375 //TROOT::IncreaseDirLevel();
376 while ((el = (KVGeoStrucElement*)next())) {
377 el->Print(option);
378 }
380 cout << endl;
381}
382
383
int Int_t
#define d(i)
#define e(i)
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
const char Option_t
Option_t Option_t option
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 UChar_t Atom_t typelist
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]
Base class for KaliVeda framework.
Definition KVBase.h:142
virtual const Char_t * GetType() const
Definition KVBase.h:177
Base class for detector geometry description.
Definition KVDetector.h:160
virtual Bool_t Fired(Option_t *opt="any") const
Definition KVDetector.h:451
Base class describing elements of array geometry.
virtual Bool_t Fired(Option_t *opt="any") const
const KVSeqCollection * GetStructures() const
void RemoveParentStructure(KVGeoStrucElement *)
KVUniqueNameList fDetectors
detectors in this structure element
void Print(Option_t *option="") const
void AddParentStructure(KVGeoStrucElement *)
KVGeoStrucElement * GetStructure(const Char_t *name) const
KVDetector * GetDetector(const Char_t *name) const
Return detector in this structure with given name.
KVUniqueNameList fStructures
daughter structures
virtual void Remove(KVBase *)
KVSeqCollection * GetDetectorTypeList(const Char_t *type) const
KVUniqueNameList fParentStrucList
parent structures
KVDetector * GetDetectorAny(const Char_t *name)
KVGeoStrucElement()
Default constructor.
virtual void Add(KVBase *)
virtual ~KVGeoStrucElement()
Destructor.
KVSeqCollection * GetStructureTypeList(const Char_t *type) const
void Clear(Option_t *opt="")
Empty lists of detectors, daughter structures, and parent structures.
void ClearStructures(const Char_t *type="")
void init()
Default initialisations.
KVSeqCollection * GetDetectorNameList(const Char_t *name) const
KVGeoStrucElement * GetParentStructure(const Char_t *type, const Char_t *name="") const
void ClearDetectors(const Char_t *type="")
const KVSeqCollection * GetDetectors() const
KVDetector * GetDetectorByType(const Char_t *type) const
Return detector in this structure with given type.
KaliVeda extensions to ROOT collection classes.
virtual TObject * FindObject(const char *name) const
KVSeqCollection * GetSubListWithName(const Char_t *retvalue) const
virtual void Clear(Option_t *option="")
KVSeqCollection * GetSubListWithType(const Char_t *retvalue) const
virtual TObject * FindObjectByType(const Char_t *) const
virtual TObject * FindObjectWithNameAndType(const Char_t *name, const Char_t *type) const
virtual TObject * Remove(TObject *obj)
Remove object from list.
virtual void Add(TObject *obj)
virtual void AddAll(const TCollection *col)
Bool_t IsOwner() const
void Clear(Option_t *option="") override
const char * GetName() const override
static TClass * Class()
virtual const char * ClassName() const
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Error(const char *method, const char *msgfmt,...) const
static Int_t IncreaseDirLevel()
static void IndentLevel()
static Int_t DecreaseDirLevel()
ClassImp(TPyArg)