]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONGeometryStore.cxx
Removed with merging transform/svmap data files in one
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryStore.cxx
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 "AliMUONGeometryDEIndexing.h"
33
34 ClassImp(AliMUONGeometryStore)
35
36 const Int_t AliMUONGeometryStore::fgkInitSize = 100;
37
38 //______________________________________________________________________________
39 AliMUONGeometryStore::AliMUONGeometryStore(Bool_t isOwner)
40  : TObject(),
41    fObjects(fgkInitSize)
42
43 /// Standard constructor
44   
45   fObjects.SetOwner(isOwner);
46   for (Int_t i=0; i<fgkInitSize; i++) fObjects[i] = 0;
47 }
48
49 //______________________________________________________________________________
50 AliMUONGeometryStore::AliMUONGeometryStore()
51  : TObject(),
52    fObjects()
53 {
54 /// Default constructor
55 }
56
57 //______________________________________________________________________________
58 AliMUONGeometryStore::AliMUONGeometryStore(const AliMUONGeometryStore& rhs)
59   : TObject(rhs)
60 {
61 /// Protected copy constructor
62
63   AliFatal("Copy constructor is not implemented.");
64 }
65
66 //______________________________________________________________________________
67 AliMUONGeometryStore::~AliMUONGeometryStore() 
68 {
69 /// Destructor
70
71 }
72
73 //______________________________________________________________________________
74 AliMUONGeometryStore& 
75 AliMUONGeometryStore::operator = (const AliMUONGeometryStore& rhs) 
76 {
77 /// Protected assignment operator 
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 //______________________________________________________________________________
92 void 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   // 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;
103   }  
104
105   // Add to the map  
106   if ( !Get(objectId, false) )
107     fObjects.AddAt(object, index);
108   else 
109     AliWarning(Form("The detection element %d is already present", objectId));  
110 }                     
111
112 //______________________________________________________________________________
113 TObject* 
114 AliMUONGeometryStore::Get(Int_t objectId, Bool_t warn) const
115 {
116 /// Returns the object for the specified detector element Id
117
118   Int_t index = AliMUONGeometryDEIndexing::GetDEIndex(objectId);
119   
120   if ( index >= 0 && index < fObjects.GetEntriesFast() )
121     return (TObject*) fObjects.At(index);
122   else {
123     if (warn) AliWarning(Form("Index %d out of limits", index));
124     return 0;  
125   }  
126 }  
127
128 //______________________________________________________________________________
129 Int_t  AliMUONGeometryStore::GetNofEntries() const
130 {
131 /// Return number of entries
132 /// Add check if the array is already filled
133
134   return fObjects.GetEntriesFast();
135 }  
136  
137
138 //______________________________________________________________________________
139 TObject* 
140 AliMUONGeometryStore::GetEntry(Int_t index) const
141 {
142 /// Return entry at specified index.
143 /// Add check if the array is already filled
144   
145   return (TObject*) fObjects.At(index);
146 }