1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * SigmaEffect_thetadegrees *
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 purpeateose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 // ----------------------------
19 // Class AliMUONSegmentation
20 // ----------------------------
21 // Manager class for geometry construction via geometry builders.
22 // Author: Ivana Hrivnacova, IPN Orsay
26 #include <TObjArray.h>
28 #include "AliMUONSegmentation.h"
29 #include "AliMUONVGeometryDESegmentation.h"
30 #include "AliMUONGeometrySegmentation.h"
31 #include "AliMUONGeometryStore.h"
33 #include "AliMpVSegmentation.h"
38 ClassImp(AliMUONSegmentation)
41 //______________________________________________________________________________
42 AliMUONSegmentation::AliMUONSegmentation(Int_t nofModules)
47 /// Standard constructor
49 // Create array for mapping segmentations
50 fMpSegmentations = new TObjArray();
51 fMpSegmentations->SetOwner(kTRUE);
53 // Create array for DE segmentations
54 fDESegmentations = new TObjArray();
55 fDESegmentations->SetOwner(kTRUE);
57 // Create array for modules segmentations
58 for (Int_t cathod = 0; cathod < 2; cathod++) {
59 fModuleSegmentations[cathod] = new TObjArray(nofModules);
60 fModuleSegmentations[cathod]->SetOwner(true);
62 for (Int_t i=0; i<nofModules; i++)
63 fModuleSegmentations[cathod]->AddAt(0, i);
66 AliDebug(1, Form("ctor this = %p", this) );
69 //______________________________________________________________________________
70 AliMUONSegmentation::AliMUONSegmentation()
75 /// Default constructor
77 fModuleSegmentations[0] = 0;
78 fModuleSegmentations[1] = 0;
80 AliDebug(1, Form("default (empty) ctor this = %p", this));
83 //______________________________________________________________________________
84 AliMUONSegmentation::~AliMUONSegmentation()
88 AliDebug(1, Form("dtor this = %p", this));
90 delete fMpSegmentations;
91 delete fDESegmentations;
92 delete fModuleSegmentations[0];
93 delete fModuleSegmentations[1];
100 //_____________________________________________________________________________
101 void AliMUONSegmentation::AddMpSegmentation(AliMpVSegmentation* segmentation)
103 /// Add the mapping segmentation to the array if not present
105 Bool_t isPresent = false;
106 for (Int_t i=0; i<fMpSegmentations->GetEntries(); i++)
107 if ( (AliMpVSegmentation*)fMpSegmentations->At(i) == segmentation ) {
112 if (!isPresent) fMpSegmentations->Add(segmentation);
115 //_____________________________________________________________________________
116 void AliMUONSegmentation::AddDESegmentation(
117 AliMUONVGeometryDESegmentation* segmentation)
119 /// Add the DE segmentation to the array
121 fDESegmentations->Add(segmentation);
123 // Deregister the mapping segmentation contained in DE segmentation
124 // from fMpSegmentations, if present
125 const AliMpVSegmentation* kmpSeg = segmentation->GetMpSegmentation();
127 for (Int_t i=0; i<fMpSegmentations->GetEntries(); i++)
128 if ( (const AliMpVSegmentation*)fMpSegmentations->At(i) == kmpSeg ) {
129 fMpSegmentations->RemoveAt(i);
134 //_____________________________________________________________________________
135 void AliMUONSegmentation::AddModuleSegmentation(Int_t moduleId, Int_t cathod,
136 AliMUONGeometrySegmentation* segmentation)
138 /// Add the module segmentation to the array
140 if (cathod < 0 || cathod >= 2) {
142 << "Cathod: " << cathod << " outside limits" << std::endl;
146 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
148 << "Module Id: " << moduleId << " outside limits" << std::endl;
152 fModuleSegmentations[cathod]->AddAt(segmentation, moduleId);
155 //_____________________________________________________________________________
156 void AliMUONSegmentation::Init()
158 /// Initialize all segmentations
160 for (Int_t cathod = 0; cathod < 2; cathod++) {
161 for (Int_t i = 0; i < fModuleSegmentations[cathod]->GetEntriesFast(); i++) {
163 AliMUONGeometrySegmentation* moduleSegmentation
164 = (AliMUONGeometrySegmentation*)fModuleSegmentations[cathod]->At(i);
166 if (moduleSegmentation) moduleSegmentation->Init(i);
171 //_____________________________________________________________________________
172 AliMUONGeometrySegmentation*
173 AliMUONSegmentation::GetModuleSegmentation(
174 Int_t moduleId, Int_t cathod, Bool_t warn) const
176 /// Return the geometry module segmentation specified by moduleId
178 if (cathod < 0 || cathod >= 2) {
181 << "Cathod: " << cathod << " outside limits" << std::endl;
186 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
189 << "Index: " << moduleId << " outside limits" << std::endl;
194 return (AliMUONGeometrySegmentation*)
195 fModuleSegmentations[cathod]->At(moduleId);
198 //_____________________________________________________________________________
199 AliMUONGeometrySegmentation*
200 AliMUONSegmentation::GetModuleSegmentationByDEId(
201 Int_t detElemId, Int_t cathod, Bool_t warn) const
203 /// Return the geometry module specified by detElemId/cathod
206 Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
208 return GetModuleSegmentation(moduleId, cathod, warn);
211 //_____________________________________________________________________________
212 const AliMUONVGeometryDESegmentation*
213 AliMUONSegmentation::GetDESegmentation(
214 Int_t detElemId, Int_t cathod, Bool_t warn) const
216 /// Return the DE segmentation specified by detElemId/cathod
218 // Get geometry segmentation
219 AliMUONGeometrySegmentation* moduleSegmentation
220 = GetModuleSegmentationByDEId(detElemId, cathod, warn);
222 if ( !moduleSegmentation ) return 0;
224 return moduleSegmentation->GetDESegmentation(detElemId, warn);
227 //_____________________________________________________________________________
228 const AliMpVSegmentation*
229 AliMUONSegmentation::GetMpSegmentation(
230 Int_t detElemId, Int_t cathod, Bool_t warn) const
232 /// Return the mapping segmentation specified by detElemId/cathod
235 // Get DE segmentation
236 const AliMUONVGeometryDESegmentation* kdeSegmentation
237 = GetDESegmentation(detElemId, cathod, warn);
239 if ( !kdeSegmentation ) return 0;
241 return kdeSegmentation->GetMpSegmentation();
244 //_____________________________________________________________________________
246 AliMUONSegmentation::HasDE(Int_t detElemId, Int_t cathod) const
248 /// Return true if segmentation for detElemId and cathod is defined.
250 const AliMUONVGeometryDESegmentation* kdeSegmentation
251 = GetDESegmentation(detElemId, cathod, false);
253 return ( kdeSegmentation != 0 );
257 //_____________________________________________________________________________
259 AliMUONSegmentation::GetDEName(Int_t detElemId, Int_t cathod) const
261 /// Get detection element name
263 AliMUONGeometrySegmentation* moduleSegmentation
264 = GetModuleSegmentationByDEId(detElemId, cathod, true);
266 return moduleSegmentation->GetDEName(detElemId);