]>
Commit | Line | Data |
---|---|---|
e118b27e | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | // $Id$ | |
17 | // | |
18 | // Class AliMUONGeometryStore | |
19 | // ------------------------------------- | |
20 | // The class contains the array of the detection elements, | |
21 | // which are sorted using the AliMUONVGeometryDEIndexing class. | |
22 | // The class provides fast access to detection element via DetElemId. | |
23 | // | |
24 | // Author: Ivana Hrivnacova, IPN Orsay | |
25 | ||
26 | #include <Riostream.h> | |
27 | #include <TGeoMatrix.h> | |
28 | ||
29 | #include "AliLog.h" | |
30 | ||
31 | #include "AliMUONGeometryStore.h" | |
46829bae | 32 | #include "AliMUONGeometryDEIndexing.h" |
e118b27e | 33 | |
34 | ClassImp(AliMUONGeometryStore) | |
35 | ||
36 | const Int_t AliMUONGeometryStore::fgkInitSize = 100; | |
37 | ||
38 | //______________________________________________________________________________ | |
46829bae | 39 | AliMUONGeometryStore::AliMUONGeometryStore(Bool_t isOwner) |
e118b27e | 40 | : TObject(), |
46829bae | 41 | fObjects(fgkInitSize) |
e118b27e | 42 | { |
692de412 | 43 | /// Standard constructor |
e118b27e | 44 | |
45 | fObjects.SetOwner(isOwner); | |
46 | for (Int_t i=0; i<fgkInitSize; i++) fObjects[i] = 0; | |
47 | } | |
48 | ||
49 | //______________________________________________________________________________ | |
50 | AliMUONGeometryStore::AliMUONGeometryStore() | |
51 | : TObject(), | |
46829bae | 52 | fObjects() |
e118b27e | 53 | { |
692de412 | 54 | /// Default constructor |
e118b27e | 55 | } |
56 | ||
57 | //______________________________________________________________________________ | |
692de412 | 58 | AliMUONGeometryStore::AliMUONGeometryStore(const AliMUONGeometryStore& rhs) |
e118b27e | 59 | : TObject(rhs) |
60 | { | |
692de412 | 61 | /// Protected copy constructor |
62 | ||
e118b27e | 63 | AliFatal("Copy constructor is not implemented."); |
64 | } | |
65 | ||
66 | //______________________________________________________________________________ | |
b42a2af7 | 67 | AliMUONGeometryStore::~AliMUONGeometryStore() |
68 | { | |
692de412 | 69 | /// Destructor |
b42a2af7 | 70 | |
e118b27e | 71 | } |
72 | ||
73 | //______________________________________________________________________________ | |
74 | AliMUONGeometryStore& | |
75 | AliMUONGeometryStore::operator = (const AliMUONGeometryStore& rhs) | |
76 | { | |
692de412 | 77 | /// Protected assignment operator |
78 | ||
79 | // check assignement to self | |
e118b27e | 80 | if (this == &rhs) return *this; |
81 | ||
82 | AliFatal("Assignment operator is not implemented."); | |
83 | ||
84 | return *this; | |
85 | } | |
86 | ||
87 | // | |
88 | // public methods | |
89 | // | |
90 | ||
91 | //______________________________________________________________________________ | |
92 | void AliMUONGeometryStore::Add(Int_t objectId, TObject* object) | |
93 | { | |
692de412 | 94 | /// Add detection element in the array |
95 | /// if detection element with the same Id is not yet present. | |
e118b27e | 96 | |
e118b27e | 97 | // Expand array if the init size has been reached |
46829bae | 98 | Int_t index = AliMUONGeometryDEIndexing::GetDEIndex(objectId); |
e118b27e | 99 | while ( index >= fObjects.GetSize() ) { |
100 | Int_t size = fObjects.GetSize(); | |
101 | fObjects.Expand(size + fgkInitSize); | |
102 | for (Int_t i=size; i<fObjects.GetSize(); i++) fObjects[i] = 0; | |
103 | } | |
104 | ||
105 | // Add to the map | |
106 | if ( !Get(objectId, false) ) | |
107 | fObjects.AddAt(object, index); | |
108 | else | |
109 | AliWarning(Form("The detection element %d is already present", objectId)); | |
110 | } | |
111 | ||
112 | //______________________________________________________________________________ | |
113 | TObject* | |
114 | AliMUONGeometryStore::Get(Int_t objectId, Bool_t warn) const | |
115 | { | |
692de412 | 116 | /// Returns the object for the specified detector element Id |
e118b27e | 117 | |
46829bae | 118 | Int_t index = AliMUONGeometryDEIndexing::GetDEIndex(objectId); |
e118b27e | 119 | |
120 | if ( index >= 0 && index < fObjects.GetEntriesFast() ) | |
121 | return (TObject*) fObjects.At(index); | |
122 | else { | |
123 | if (warn) AliWarning(Form("Index %d out of limits", index)); | |
124 | return 0; | |
125 | } | |
126 | } | |
127 | ||
128 | //______________________________________________________________________________ | |
129 | Int_t AliMUONGeometryStore::GetNofEntries() const | |
130 | { | |
692de412 | 131 | /// Return number of entries |
132 | /// Add check if the array is already filled | |
e118b27e | 133 | |
134 | return fObjects.GetEntriesFast(); | |
135 | } | |
136 | ||
137 | ||
138 | //______________________________________________________________________________ | |
139 | TObject* | |
140 | AliMUONGeometryStore::GetEntry(Int_t index) const | |
141 | { | |
692de412 | 142 | /// Return entry at specified index. |
143 | /// Add check if the array is already filled | |
e118b27e | 144 | |
145 | return (TObject*) fObjects.At(index); | |
146 | } |