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"
32 #include "AliMpVSegmentation.h"
33 #include "AliMpDEManager.h"
38 ClassImp(AliMUONSegmentation)
41 //______________________________________________________________________________
42 AliMUONSegmentation::AliMUONSegmentation(Int_t nofModules)
46 /// Standard constructor
48 // Create array for DE segmentations
49 fDESegmentations = new TObjArray();
50 fDESegmentations->SetOwner(kTRUE);
52 // Create array for modules segmentations
53 for (Int_t cathod = 0; cathod < 2; cathod++) {
54 fModuleSegmentations[cathod] = new TObjArray(nofModules);
55 fModuleSegmentations[cathod]->SetOwner(true);
57 for (Int_t i=0; i<nofModules; i++)
58 fModuleSegmentations[cathod]->AddAt(0, i);
61 AliDebug(1, Form("ctor this = %p", this) );
64 //______________________________________________________________________________
65 AliMUONSegmentation::AliMUONSegmentation()
69 /// Default constructor
71 fModuleSegmentations[0] = 0;
72 fModuleSegmentations[1] = 0;
74 AliDebug(1, Form("default (empty) ctor this = %p", this));
77 //______________________________________________________________________________
78 AliMUONSegmentation::~AliMUONSegmentation()
82 AliDebug(1, Form("dtor this = %p", this));
84 delete fDESegmentations;
85 delete fModuleSegmentations[0];
86 delete fModuleSegmentations[1];
93 //_____________________________________________________________________________
94 AliMUONGeometrySegmentation*
95 AliMUONSegmentation::GetModuleSegmentation(
96 Int_t moduleId, Int_t cathod, Bool_t warn) const
98 /// Return the geometry module segmentation specified by moduleId
100 if (cathod < 0 || cathod >= 2) {
103 << "Cathod: " << cathod << " outside limits" << std::endl;
108 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
111 << "Index: " << moduleId << " outside limits" << std::endl;
116 return (AliMUONGeometrySegmentation*)
117 fModuleSegmentations[cathod]->At(moduleId);
124 //_____________________________________________________________________________
125 void AliMUONSegmentation::AddDESegmentation(
126 AliMUONVGeometryDESegmentation* segmentation)
128 /// Add the DE segmentation to the array
130 fDESegmentations->Add(segmentation);
133 //_____________________________________________________________________________
134 void AliMUONSegmentation::AddModuleSegmentation(Int_t moduleId, Int_t cathod,
135 AliMUONGeometrySegmentation* segmentation)
137 /// Add the module segmentation to the array
139 if (cathod < 0 || cathod >= 2) {
141 << "Cathod: " << cathod << " outside limits" << std::endl;
145 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
147 << "Module Id: " << moduleId << " outside limits" << std::endl;
151 fModuleSegmentations[cathod]->AddAt(segmentation, moduleId);
154 //_____________________________________________________________________________
155 void AliMUONSegmentation::Init()
157 /// Initialize all segmentations
159 for (Int_t cathod = 0; cathod < 2; cathod++) {
160 for (Int_t i = 0; i < fModuleSegmentations[cathod]->GetEntriesFast(); i++) {
162 AliMUONGeometrySegmentation* moduleSegmentation
163 = (AliMUONGeometrySegmentation*)fModuleSegmentations[cathod]->At(i);
165 if (moduleSegmentation) moduleSegmentation->Init(i);
170 //_____________________________________________________________________________
171 AliMUONGeometrySegmentation*
172 AliMUONSegmentation::GetModuleSegmentationByDEId(
173 Int_t detElemId, Int_t cathod, Bool_t warn) const
175 /// Return the geometry module specified by detElemId/cathod
178 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
180 return GetModuleSegmentation(moduleId, cathod, warn);
183 //_____________________________________________________________________________
184 const AliMUONVGeometryDESegmentation*
185 AliMUONSegmentation::GetDESegmentation(
186 Int_t detElemId, Int_t cathod, Bool_t warn) const
188 /// Return the DE segmentation specified by detElemId/cathod
190 // Get geometry segmentation
191 AliMUONGeometrySegmentation* moduleSegmentation
192 = GetModuleSegmentationByDEId(detElemId, cathod, warn);
194 if ( !moduleSegmentation ) return 0;
196 return moduleSegmentation->GetDESegmentation(detElemId, warn);
199 //_____________________________________________________________________________
201 AliMUONSegmentation::HasDE(Int_t detElemId, Int_t cathod) const
203 /// Return true if segmentation for detElemId and cathod is defined.
205 const AliMUONVGeometryDESegmentation* kdeSegmentation
206 = GetDESegmentation(detElemId, cathod, false);
208 return ( kdeSegmentation != 0 );
212 //_____________________________________________________________________________
214 AliMUONSegmentation::GetDEName(Int_t detElemId, Int_t cathod) const
216 /// Get detection element name
218 AliMUONGeometrySegmentation* moduleSegmentation
219 = GetModuleSegmentationByDEId(detElemId, cathod, true);
221 return moduleSegmentation->GetDEName(detElemId);