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