]>
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" | |
32 | #include "AliMUONVGeometryDEIndexing.h" | |
33 | ||
34 | ClassImp(AliMUONGeometryStore) | |
35 | ||
36 | const Int_t AliMUONGeometryStore::fgkInitSize = 100; | |
37 | ||
38 | //______________________________________________________________________________ | |
39 | AliMUONGeometryStore::AliMUONGeometryStore( | |
40 | AliMUONVGeometryDEIndexing* indexing, | |
41 | Bool_t isOwner) | |
42 | : TObject(), | |
43 | fObjects(fgkInitSize), | |
44 | fDEIndexing(indexing) | |
45 | { | |
692de412 | 46 | /// Standard constructor |
e118b27e | 47 | |
48 | fObjects.SetOwner(isOwner); | |
49 | for (Int_t i=0; i<fgkInitSize; i++) fObjects[i] = 0; | |
50 | } | |
51 | ||
52 | //______________________________________________________________________________ | |
53 | AliMUONGeometryStore::AliMUONGeometryStore() | |
54 | : TObject(), | |
55 | fObjects(), | |
56 | fDEIndexing(0) | |
57 | { | |
692de412 | 58 | /// Default constructor |
e118b27e | 59 | } |
60 | ||
61 | //______________________________________________________________________________ | |
692de412 | 62 | AliMUONGeometryStore::AliMUONGeometryStore(const AliMUONGeometryStore& rhs) |
e118b27e | 63 | : TObject(rhs) |
64 | { | |
692de412 | 65 | /// Protected copy constructor |
66 | ||
e118b27e | 67 | AliFatal("Copy constructor is not implemented."); |
68 | } | |
69 | ||
70 | //______________________________________________________________________________ | |
b42a2af7 | 71 | AliMUONGeometryStore::~AliMUONGeometryStore() |
72 | { | |
692de412 | 73 | /// Destructor |
b42a2af7 | 74 | |
e118b27e | 75 | } |
76 | ||
77 | //______________________________________________________________________________ | |
78 | AliMUONGeometryStore& | |
79 | AliMUONGeometryStore::operator = (const AliMUONGeometryStore& rhs) | |
80 | { | |
692de412 | 81 | /// Protected assignment operator |
82 | ||
83 | // check assignement to self | |
e118b27e | 84 | if (this == &rhs) return *this; |
85 | ||
86 | AliFatal("Assignment operator is not implemented."); | |
87 | ||
88 | return *this; | |
89 | } | |
90 | ||
91 | // | |
92 | // public methods | |
93 | // | |
94 | ||
95 | //______________________________________________________________________________ | |
96 | void AliMUONGeometryStore::Add(Int_t objectId, TObject* object) | |
97 | { | |
692de412 | 98 | /// Add detection element in the array |
99 | /// if detection element with the same Id is not yet present. | |
e118b27e | 100 | |
101 | //cout << ".. adding " << objectId | |
102 | // << " index: " << fDEIndexing->GetDetElementIndex(objectId) << endl; | |
103 | ||
104 | // Expand array if the init size has been reached | |
105 | Int_t index = fDEIndexing->GetDetElementIndex(objectId); | |
106 | while ( index >= fObjects.GetSize() ) { | |
107 | Int_t size = fObjects.GetSize(); | |
108 | fObjects.Expand(size + fgkInitSize); | |
109 | for (Int_t i=size; i<fObjects.GetSize(); i++) fObjects[i] = 0; | |
110 | } | |
111 | ||
112 | // Add to the map | |
113 | if ( !Get(objectId, false) ) | |
114 | fObjects.AddAt(object, index); | |
115 | else | |
116 | AliWarning(Form("The detection element %d is already present", objectId)); | |
117 | } | |
118 | ||
119 | //______________________________________________________________________________ | |
120 | TObject* | |
121 | AliMUONGeometryStore::Get(Int_t objectId, Bool_t warn) const | |
122 | { | |
692de412 | 123 | /// Returns the object for the specified detector element Id |
e118b27e | 124 | |
125 | Int_t index = fDEIndexing->GetDetElementIndex(objectId); | |
126 | ||
127 | if ( index >= 0 && index < fObjects.GetEntriesFast() ) | |
128 | return (TObject*) fObjects.At(index); | |
129 | else { | |
130 | if (warn) AliWarning(Form("Index %d out of limits", index)); | |
131 | return 0; | |
132 | } | |
133 | } | |
134 | ||
135 | //______________________________________________________________________________ | |
136 | Int_t AliMUONGeometryStore::GetNofEntries() const | |
137 | { | |
692de412 | 138 | /// Return number of entries |
139 | /// Add check if the array is already filled | |
e118b27e | 140 | |
141 | return fObjects.GetEntriesFast(); | |
142 | } | |
143 | ||
144 | ||
145 | //______________________________________________________________________________ | |
146 | TObject* | |
147 | AliMUONGeometryStore::GetEntry(Int_t index) const | |
148 | { | |
692de412 | 149 | /// Return entry at specified index. |
150 | /// Add check if the array is already filled | |
e118b27e | 151 | |
152 | return (TObject*) fObjects.At(index); | |
153 | } |