1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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.
24 // Author: Ivana Hrivnacova, IPN Orsay
26 #include <Riostream.h>
27 #include <TGeoMatrix.h>
31 #include "AliMUONGeometryStore.h"
32 #include "AliMUONGeometryDEIndexing.h"
34 ClassImp(AliMUONGeometryStore)
36 const Int_t AliMUONGeometryStore::fgkInitSize = 100;
38 //______________________________________________________________________________
39 AliMUONGeometryStore::AliMUONGeometryStore(Bool_t isOwner)
43 /// Standard constructor
45 fObjects.SetOwner(isOwner);
46 for (Int_t i=0; i<fgkInitSize; i++) fObjects[i] = 0;
49 //______________________________________________________________________________
50 AliMUONGeometryStore::AliMUONGeometryStore()
54 /// Default constructor
57 //______________________________________________________________________________
58 AliMUONGeometryStore::AliMUONGeometryStore(const AliMUONGeometryStore& rhs)
61 /// Protected copy constructor
63 AliFatal("Copy constructor is not implemented.");
66 //______________________________________________________________________________
67 AliMUONGeometryStore::~AliMUONGeometryStore()
73 //______________________________________________________________________________
75 AliMUONGeometryStore::operator = (const AliMUONGeometryStore& rhs)
77 /// Protected assignment operator
79 // check assignement to self
80 if (this == &rhs) return *this;
82 AliFatal("Assignment operator is not implemented.");
91 //______________________________________________________________________________
92 void AliMUONGeometryStore::Add(Int_t objectId, TObject* object)
94 /// Add detection element in the array
95 /// if detection element with the same Id is not yet present.
97 // Expand array if the init size has been reached
98 Int_t index = AliMUONGeometryDEIndexing::GetDEIndex(objectId);
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;
106 if ( !Get(objectId, false) )
107 fObjects.AddAt(object, index);
109 AliWarning(Form("The detection element %d is already present", objectId));
112 //______________________________________________________________________________
114 AliMUONGeometryStore::Get(Int_t objectId, Bool_t warn) const
116 /// Returns the object for the specified detector element Id
118 Int_t index = AliMUONGeometryDEIndexing::GetDEIndex(objectId);
120 if ( index >= 0 && index < fObjects.GetEntriesFast() )
121 return (TObject*) fObjects.At(index);
123 if (warn) AliWarning(Form("Index %d out of limits", index));
128 //______________________________________________________________________________
129 Int_t AliMUONGeometryStore::GetNofEntries() const
131 /// Return number of entries
132 /// Add check if the array is already filled
134 return fObjects.GetEntriesFast();
138 //______________________________________________________________________________
140 AliMUONGeometryStore::GetEntry(Int_t index) const
142 /// Return entry at specified index.
143 /// Add check if the array is already filled
145 return (TObject*) fObjects.At(index);