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"
33 const Int_t AliMUONGeometryStore::fgkInitSize = 100;
34 const Int_t AliMUONGeometryStore::fgkCoefficient = 100;
36 ClassImp(AliMUONGeometryStore)
42 //______________________________________________________________________________
43 Int_t AliMUONGeometryStore::GetModuleId(Int_t detElemId)
45 // Get module Id from detection element Id
48 return detElemId/fgkCoefficient - 1;
52 // Constructor/destructor
55 //______________________________________________________________________________
56 AliMUONGeometryStore::AliMUONGeometryStore(Bool_t isOwner)
60 /// Standard constructor
62 fObjects.SetOwner(isOwner);
63 for (Int_t i=0; i<fgkInitSize; i++) fObjects[i] = 0;
66 //______________________________________________________________________________
67 AliMUONGeometryStore::AliMUONGeometryStore()
71 /// Default constructor
74 //______________________________________________________________________________
75 AliMUONGeometryStore::AliMUONGeometryStore(const AliMUONGeometryStore& rhs)
78 /// Protected copy constructor
80 AliFatal("Copy constructor is not implemented.");
83 //______________________________________________________________________________
84 AliMUONGeometryStore::~AliMUONGeometryStore()
90 //______________________________________________________________________________
92 AliMUONGeometryStore::operator = (const AliMUONGeometryStore& rhs)
94 /// Protected assignment operator
96 // check assignement to self
97 if (this == &rhs) return *this;
99 AliFatal("Assignment operator is not implemented.");
108 //______________________________________________________________________________
109 Int_t AliMUONGeometryStore::GetDEIndex(Int_t detElemId) const
111 /// Returns the index of detector element specified by detElemId
113 return detElemId - detElemId/fgkCoefficient*fgkCoefficient;
120 //______________________________________________________________________________
121 void AliMUONGeometryStore::Add(Int_t objectId, TObject* object)
123 /// Add detection element in the array
124 /// if detection element with the same Id is not yet present.
126 // Expand array if the init size has been reached
127 Int_t index = GetDEIndex(objectId);
128 while ( index >= fObjects.GetSize() ) {
129 Int_t size = fObjects.GetSize();
130 fObjects.Expand(size + fgkInitSize);
131 for (Int_t i=size; i<fObjects.GetSize(); i++) fObjects[i] = 0;
135 if ( !Get(objectId, false) )
136 fObjects.AddAt(object, index);
138 AliWarning(Form("The detection element %d is already present", objectId));
141 //______________________________________________________________________________
143 AliMUONGeometryStore::Get(Int_t objectId, Bool_t warn) const
145 /// Returns the object for the specified detector element Id
147 Int_t index = GetDEIndex(objectId);
149 if ( index >= 0 && index < fObjects.GetEntriesFast() )
150 return (TObject*) fObjects.At(index);
152 if (warn) AliWarning(Form("Index %d out of limits", index));
157 //______________________________________________________________________________
158 Int_t AliMUONGeometryStore::GetNofEntries() const
160 /// Return number of entries
161 /// Add check if the array is already filled
163 return fObjects.GetEntriesFast();
167 //______________________________________________________________________________
169 AliMUONGeometryStore::GetEntry(Int_t index) const
171 /// Return entry at specified index.
172 /// Add check if the array is already filled
174 return (TObject*) fObjects.At(index);