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 "AliMUONVGeometryDEIndexing.h"
34 ClassImp(AliMUONGeometryStore)
36 const Int_t AliMUONGeometryStore::fgkInitSize = 100;
38 //______________________________________________________________________________
39 AliMUONGeometryStore::AliMUONGeometryStore(
40 AliMUONVGeometryDEIndexing* indexing,
43 fObjects(fgkInitSize),
46 // Standard constructor
48 fObjects.SetOwner(isOwner);
49 for (Int_t i=0; i<fgkInitSize; i++) fObjects[i] = 0;
52 //______________________________________________________________________________
53 AliMUONGeometryStore::AliMUONGeometryStore()
58 // Default constructor
61 //______________________________________________________________________________
62 AliMUONGeometryStore::AliMUONGeometryStore(
63 const AliMUONGeometryStore& rhs)
66 AliFatal("Copy constructor is not implemented.");
69 //______________________________________________________________________________
70 AliMUONGeometryStore::~AliMUONGeometryStore()
75 //______________________________________________________________________________
77 AliMUONGeometryStore::operator = (const AliMUONGeometryStore& rhs)
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.
98 //cout << ".. adding " << objectId
99 // << " index: " << fDEIndexing->GetDetElementIndex(objectId) << endl;
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;
110 if ( !Get(objectId, false) )
111 fObjects.AddAt(object, index);
113 AliWarning(Form("The detection element %d is already present", objectId));
116 //______________________________________________________________________________
118 AliMUONGeometryStore::Get(Int_t objectId, Bool_t warn) const
120 // Returns transformation for the specified detector element Id
123 Int_t index = fDEIndexing->GetDetElementIndex(objectId);
125 if ( index >= 0 && index < fObjects.GetEntriesFast() )
126 return (TObject*) fObjects.At(index);
128 if (warn) AliWarning(Form("Index %d out of limits", index));
133 //______________________________________________________________________________
134 Int_t AliMUONGeometryStore::GetNofEntries() const
136 // Add check if the array is already filled
138 return fObjects.GetEntriesFast();
142 //______________________________________________________________________________
144 AliMUONGeometryStore::GetEntry(Int_t index) const
147 // Add check if the array is already filled
149 return (TObject*) fObjects.At(index);