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 "AliMUONGeometryStore.h"
33 #include "AliMpVSegmentation.h"
38 ClassImp(AliMUONSegmentation)
40 //______________________________________________________________________________
41 AliMUONSegmentation::AliMUONSegmentation(Int_t nofModules)
46 /// Standard constructor
48 // Create array for mapping segmentations
49 fMpSegmentations = new TObjArray();
50 fMpSegmentations->SetOwner(kTRUE);
52 // Create array for DE segmentations
53 fDESegmentations = new TObjArray();
54 fDESegmentations->SetOwner(kTRUE);
56 // Create array for modules segmentations
57 for (Int_t cathod = 0; cathod < 2; cathod++) {
58 fModuleSegmentations[cathod] = new TObjArray(nofModules);
59 fModuleSegmentations[cathod]->SetOwner(true);
61 for (Int_t i=0; i<nofModules; i++)
62 fModuleSegmentations[cathod]->AddAt(0, i);
65 AliDebug(1, Form("ctor this = %p", this) );
68 //______________________________________________________________________________
69 AliMUONSegmentation::AliMUONSegmentation()
74 /// Default constructor
76 fModuleSegmentations[0] = 0;
77 fModuleSegmentations[1] = 0;
79 AliDebug(1, Form("default (empty) ctor this = %p", this));
82 //______________________________________________________________________________
83 AliMUONSegmentation::AliMUONSegmentation(const AliMUONSegmentation& right)
86 /// Copy constructor (not implemented)
88 AliFatal("Copy constructor not provided.");
91 //______________________________________________________________________________
92 AliMUONSegmentation::~AliMUONSegmentation()
96 AliDebug(1, Form("dtor this = %p", this));
98 delete fMpSegmentations;
99 delete fDESegmentations;
100 delete fModuleSegmentations[0];
101 delete fModuleSegmentations[1];
104 //______________________________________________________________________________
106 AliMUONSegmentation::operator=(const AliMUONSegmentation& right)
108 /// Assignement operator (not implemented)
110 // check assignement to self
111 if (this == &right) return *this;
113 AliFatal("Assignement operator not provided.");
122 //_____________________________________________________________________________
123 void AliMUONSegmentation::AddMpSegmentation(AliMpVSegmentation* segmentation)
125 /// Add the mapping segmentation to the array if not present
127 Bool_t isPresent = false;
128 for (Int_t i=0; i<fMpSegmentations->GetEntries(); i++)
129 if ( (AliMpVSegmentation*)fMpSegmentations->At(i) == segmentation ) {
134 if (!isPresent) fMpSegmentations->Add(segmentation);
137 //_____________________________________________________________________________
138 void AliMUONSegmentation::AddDESegmentation(
139 AliMUONVGeometryDESegmentation* segmentation)
141 /// Add the DE segmentation to the array
143 fDESegmentations->Add(segmentation);
145 // Deregister the mapping segmentation contained in DE segmentation
146 // from fMpSegmentations, if present
147 const AliMpVSegmentation* kmpSeg = segmentation->GetMpSegmentation();
149 for (Int_t i=0; i<fMpSegmentations->GetEntries(); i++)
150 if ( (const AliMpVSegmentation*)fMpSegmentations->At(i) == kmpSeg ) {
151 fMpSegmentations->RemoveAt(i);
156 //_____________________________________________________________________________
157 void AliMUONSegmentation::AddModuleSegmentation(Int_t moduleId, Int_t cathod,
158 AliMUONGeometrySegmentation* segmentation)
160 /// Add the module segmentation to the array
162 if (cathod < 0 || cathod >= 2) {
164 << "Cathod: " << cathod << " outside limits" << std::endl;
168 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
170 << "Module Id: " << moduleId << " outside limits" << std::endl;
174 fModuleSegmentations[cathod]->AddAt(segmentation, moduleId);
177 //_____________________________________________________________________________
178 void AliMUONSegmentation::Init()
180 /// Initialize all segmentations
182 for (Int_t cathod = 0; cathod < 2; cathod++) {
183 for (Int_t i = 0; i < fModuleSegmentations[cathod]->GetEntriesFast(); i++) {
185 AliMUONGeometrySegmentation* moduleSegmentation
186 = (AliMUONGeometrySegmentation*)fModuleSegmentations[cathod]->At(i);
188 if (moduleSegmentation) moduleSegmentation->Init(i);
193 //_____________________________________________________________________________
194 AliMUONGeometrySegmentation*
195 AliMUONSegmentation::GetModuleSegmentation(
196 Int_t moduleId, Int_t cathod, Bool_t warn) const
198 /// Return the geometry module specified by moduleId
200 if (cathod < 0 || cathod >= 2) {
203 << "Cathod: " << cathod << " outside limits" << std::endl;
208 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
211 << "Index: " << moduleId << " outside limits" << std::endl;
216 return (AliMUONGeometrySegmentation*)
217 fModuleSegmentations[cathod]->At(moduleId);
220 //_____________________________________________________________________________
221 AliMUONGeometrySegmentation*
222 AliMUONSegmentation::GetModuleSegmentationByDEId(
223 Int_t detElemId, Int_t cathod, Bool_t warn) const
225 /// Return the geometry module specified by detElemId/cathod
228 Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
230 return GetModuleSegmentation(moduleId, cathod, warn);
233 //_____________________________________________________________________________
234 const AliMUONVGeometryDESegmentation*
235 AliMUONSegmentation::GetDESegmentation(
236 Int_t detElemId, Int_t cathod, Bool_t warn) const
238 /// Return the DE segmentation specified by detElemId/cathod
240 // Get geometry segmentation
241 AliMUONGeometrySegmentation* moduleSegmentation
242 = GetModuleSegmentationByDEId(detElemId, cathod, warn);
244 if ( !moduleSegmentation ) return 0;
246 return moduleSegmentation->GetDESegmentation(detElemId, warn);
249 //_____________________________________________________________________________
250 const AliMpVSegmentation*
251 AliMUONSegmentation::GetMpSegmentation(
252 Int_t detElemId, Int_t cathod, Bool_t warn) const
254 /// Return the mapping segmentation specified by detElemId/cathod
257 // Get DE segmentation
258 const AliMUONVGeometryDESegmentation* kdeSegmentation
259 = GetDESegmentation(detElemId, cathod, warn);
261 if ( !kdeSegmentation ) return 0;
263 return kdeSegmentation->GetMpSegmentation();
266 //_____________________________________________________________________________
268 AliMUONSegmentation::HasDE(Int_t detElemId, Int_t cathod) const
270 // Get DE segmentation
271 const AliMUONVGeometryDESegmentation* kdeSegmentation
272 = GetDESegmentation(detElemId, cathod, false);
274 return ( kdeSegmentation != 0 );
278 //_____________________________________________________________________________
280 AliMUONSegmentation::GetDEName(Int_t detElemId, Int_t cathod) const
283 // Get geometry segmentation
284 AliMUONGeometrySegmentation* moduleSegmentation
285 = GetModuleSegmentationByDEId(detElemId, cathod, true);
287 return moduleSegmentation->GetDEName(detElemId);