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 // Class AliMUONSegmentation
19 // ----------------------------
20 // 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 "AliMUONGeometryDEIndexing.h"
35 ClassImp(AliMUONSegmentation)
37 //______________________________________________________________________________
38 AliMUONSegmentation::AliMUONSegmentation(Int_t nofModules)
42 /// Standard constructor
44 // Create array for DE segmentations
45 fDESegmentations = new TObjArray();
46 fDESegmentations->SetOwner(kTRUE);
48 // Create array for modules segmentations
49 for (Int_t cathod = 0; cathod < 2; cathod++) {
50 fModuleSegmentations[cathod] = new TObjArray(nofModules);
51 fModuleSegmentations[cathod]->SetOwner(true);
53 for (Int_t i=0; i<nofModules; i++)
54 fModuleSegmentations[cathod]->AddAt(0, i);
57 AliDebug(1, Form("ctor this = %p", this) );
60 //______________________________________________________________________________
61 AliMUONSegmentation::AliMUONSegmentation()
65 /// Default constructor
67 fModuleSegmentations[0] = 0;
68 fModuleSegmentations[1] = 0;
70 AliDebug(1, Form("default (empty) ctor this = %p", this));
73 //______________________________________________________________________________
74 AliMUONSegmentation::AliMUONSegmentation(const AliMUONSegmentation& right)
77 /// Copy constructor (not implemented)
79 AliFatal("Copy constructor not provided.");
82 //______________________________________________________________________________
83 AliMUONSegmentation::~AliMUONSegmentation()
87 AliDebug(1, Form("dtor this = %p", this));
89 delete fDESegmentations;
90 delete fModuleSegmentations[0];
91 delete fModuleSegmentations[1];
94 //______________________________________________________________________________
96 AliMUONSegmentation::operator=(const AliMUONSegmentation& right)
98 /// Assignement operator (not implemented)
100 // check assignement to self
101 if (this == &right) return *this;
103 AliFatal("Assignement operator not provided.");
112 //_____________________________________________________________________________
113 void AliMUONSegmentation::AddDESegmentation(
114 AliMUONVGeometryDESegmentation* segmentation)
116 /// Add the DE segmentation to the array
118 fDESegmentations->Add(segmentation);
121 //_____________________________________________________________________________
122 void AliMUONSegmentation::AddModuleSegmentation(Int_t moduleId, Int_t cathod,
123 AliMUONGeometrySegmentation* segmentation)
125 /// Add the module segmentation to the array
127 if (cathod < 0 || cathod >= 2) {
129 << "Cathod: " << cathod << " outside limits" << std::endl;
133 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
135 << "Module Id: " << moduleId << " outside limits" << std::endl;
139 fModuleSegmentations[cathod]->AddAt(segmentation, moduleId);
142 //_____________________________________________________________________________
143 void AliMUONSegmentation::Init()
145 /// Initialize all segmentations
147 for (Int_t cathod = 0; cathod < 2; cathod++) {
148 for (Int_t i = 0; i < fModuleSegmentations[cathod]->GetEntriesFast(); i++) {
150 AliMUONGeometrySegmentation* moduleSegmentation
151 = (AliMUONGeometrySegmentation*)fModuleSegmentations[cathod]->At(i);
153 if (moduleSegmentation) moduleSegmentation->Init(i);
158 //_____________________________________________________________________________
159 AliMUONGeometrySegmentation*
160 AliMUONSegmentation::GetModuleSegmentation(
161 Int_t moduleId, Int_t cathod, Bool_t warn) const
163 /// Return the geometry module specified by moduleId
165 if (cathod < 0 || cathod >= 2) {
168 << "Cathod: " << cathod << " outside limits" << std::endl;
173 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
176 << "Index: " << moduleId << " outside limits" << std::endl;
181 return (AliMUONGeometrySegmentation*)
182 fModuleSegmentations[cathod]->At(moduleId);
185 //_____________________________________________________________________________
186 AliMUONGeometrySegmentation*
187 AliMUONSegmentation::GetModuleSegmentationByDEId(
188 Int_t detElemId, Int_t cathod, Bool_t warn) const
190 /// Return the geometry module specified by detElemId/cathod
193 Int_t moduleId = AliMUONGeometryDEIndexing::GetModuleId(detElemId);
195 return GetModuleSegmentation(moduleId, cathod, warn);
198 //_____________________________________________________________________________
199 const AliMUONVGeometryDESegmentation*
200 AliMUONSegmentation::GetDESegmentation(
201 Int_t detElemId, Int_t cathod, Bool_t warn) const
203 /// Return the DE segmentation specified by detElemId/cathod
205 // Get geometry segmentation
206 AliMUONGeometrySegmentation* moduleSegmentation
207 = GetModuleSegmentationByDEId(detElemId, cathod, warn);
209 if ( !moduleSegmentation ) return 0;
211 return moduleSegmentation->GetDESegmentation(detElemId);
214 //_____________________________________________________________________________
215 const AliMpVSegmentation*
216 AliMUONSegmentation::GetMpSegmentation(
217 Int_t detElemId, Int_t cathod, Bool_t warn) const
219 /// Return the mapping segmentation specified by detElemId/cathod
222 // Get DE segmentation
223 const AliMUONVGeometryDESegmentation* kdeSegmentation
224 = GetDESegmentation(detElemId, cathod, warn);
226 if ( !kdeSegmentation ) return 0;
228 return kdeSegmentation->GetMpSegmentation();
231 //_____________________________________________________________________________
233 AliMUONSegmentation::HasDE(Int_t detElemId, Int_t cathod) const
235 // Get geometry segmentation
236 AliMUONGeometrySegmentation* moduleSegmentation
237 = GetModuleSegmentationByDEId(detElemId, cathod, false);
239 return ( moduleSegmentation != 0 );
243 //_____________________________________________________________________________
245 AliMUONSegmentation::GetDEName(Int_t detElemId, Int_t cathod) const
248 // Get geometry segmentation
249 AliMUONGeometrySegmentation* moduleSegmentation
250 = GetModuleSegmentationByDEId(detElemId, cathod, true);
252 return moduleSegmentation->GetDEName(detElemId);