]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSegmentation.cxx
Removed - functionality of this class moved to geometry and mapping
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentation.cxx
CommitLineData
fb921a27 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. *
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 purpeateose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16// $Id$
17//
18// Class AliMUONSegmentation
19// ----------------------------
20// Manager class for geometry construction via geometry builders.
21//
22// Author: Ivana Hrivnacova, IPN Orsay
23
24#include <iostream>
25
26#include <TObjArray.h>
27
28#include "AliMUONSegmentation.h"
29#include "AliMUONVGeometryDESegmentation.h"
30#include "AliMUONGeometrySegmentation.h"
e81a0d4f 31#include "AliMUONGeometryStore.h"
32
33#include "AliMpVSegmentation.h"
34
fb921a27 35#include "AliLog.h"
36
37
38ClassImp(AliMUONSegmentation)
39
40//______________________________________________________________________________
41AliMUONSegmentation::AliMUONSegmentation(Int_t nofModules)
42 : TObject(),
e81a0d4f 43 fMpSegmentations(0),
fb921a27 44 fDESegmentations(0)
45{
46/// Standard constructor
47
e81a0d4f 48 // Create array for mapping segmentations
49 fMpSegmentations = new TObjArray();
50 fMpSegmentations->SetOwner(kTRUE);
51
fb921a27 52 // Create array for DE segmentations
53 fDESegmentations = new TObjArray();
54 fDESegmentations->SetOwner(kTRUE);
55
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);
60
61 for (Int_t i=0; i<nofModules; i++)
62 fModuleSegmentations[cathod]->AddAt(0, i);
63 }
64
65 AliDebug(1, Form("ctor this = %p", this) );
66}
67
68//______________________________________________________________________________
69AliMUONSegmentation::AliMUONSegmentation()
70 : TObject(),
e81a0d4f 71 fMpSegmentations(0),
fb921a27 72 fDESegmentations(0)
73{
74/// Default constructor
75
76 fModuleSegmentations[0] = 0;
77 fModuleSegmentations[1] = 0;
78
79 AliDebug(1, Form("default (empty) ctor this = %p", this));
80}
81
82//______________________________________________________________________________
83AliMUONSegmentation::AliMUONSegmentation(const AliMUONSegmentation& right)
84 : TObject(right)
85{
86/// Copy constructor (not implemented)
87
88 AliFatal("Copy constructor not provided.");
89}
90
91//______________________________________________________________________________
92AliMUONSegmentation::~AliMUONSegmentation()
93{
94/// Destructor
95
96 AliDebug(1, Form("dtor this = %p", this));
97
e81a0d4f 98 delete fMpSegmentations;
fb921a27 99 delete fDESegmentations;
100 delete fModuleSegmentations[0];
101 delete fModuleSegmentations[1];
102}
103
104//______________________________________________________________________________
105AliMUONSegmentation&
106AliMUONSegmentation::operator=(const AliMUONSegmentation& right)
107{
108/// Assignement operator (not implemented)
109
110 // check assignement to self
111 if (this == &right) return *this;
112
113 AliFatal("Assignement operator not provided.");
114
115 return *this;
116}
117
118//
119// public functions
120//
121
e81a0d4f 122//_____________________________________________________________________________
123void AliMUONSegmentation::AddMpSegmentation(AliMpVSegmentation* segmentation)
124{
125/// Add the mapping segmentation to the array if not present
126
127 Bool_t isPresent = false;
128 for (Int_t i=0; i<fMpSegmentations->GetEntries(); i++)
129 if ( (AliMpVSegmentation*)fMpSegmentations->At(i) == segmentation ) {
130 isPresent = true;
131 break;
132 }
133
134 if (!isPresent) fMpSegmentations->Add(segmentation);
135}
136
fb921a27 137//_____________________________________________________________________________
138void AliMUONSegmentation::AddDESegmentation(
e81a0d4f 139 AliMUONVGeometryDESegmentation* segmentation)
fb921a27 140{
141/// Add the DE segmentation to the array
142
143 fDESegmentations->Add(segmentation);
e81a0d4f 144
145 // Deregister the mapping segmentation contained in DE segmentation
146 // from fMpSegmentations, if present
147 const AliMpVSegmentation* kmpSeg = segmentation->GetMpSegmentation();
148
149 for (Int_t i=0; i<fMpSegmentations->GetEntries(); i++)
150 if ( (const AliMpVSegmentation*)fMpSegmentations->At(i) == kmpSeg ) {
151 fMpSegmentations->RemoveAt(i);
152 break;
153 }
fb921a27 154}
155
156//_____________________________________________________________________________
157void AliMUONSegmentation::AddModuleSegmentation(Int_t moduleId, Int_t cathod,
158 AliMUONGeometrySegmentation* segmentation)
159{
160/// Add the module segmentation to the array
161
162 if (cathod < 0 || cathod >= 2) {
163 AliErrorStream()
164 << "Cathod: " << cathod << " outside limits" << std::endl;
165 return;
166 }
167
168 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
169 AliErrorStream()
170 << "Module Id: " << moduleId << " outside limits" << std::endl;
171 return;
172 }
173
174 fModuleSegmentations[cathod]->AddAt(segmentation, moduleId);
175}
176
177//_____________________________________________________________________________
178void AliMUONSegmentation::Init()
179{
180/// Initialize all segmentations
181
182 for (Int_t cathod = 0; cathod < 2; cathod++) {
183 for (Int_t i = 0; i < fModuleSegmentations[cathod]->GetEntriesFast(); i++) {
184
185 AliMUONGeometrySegmentation* moduleSegmentation
186 = (AliMUONGeometrySegmentation*)fModuleSegmentations[cathod]->At(i);
187
188 if (moduleSegmentation) moduleSegmentation->Init(i);
189 }
190 }
191}
192
193//_____________________________________________________________________________
194AliMUONGeometrySegmentation*
195AliMUONSegmentation::GetModuleSegmentation(
196 Int_t moduleId, Int_t cathod, Bool_t warn) const
197{
198/// Return the geometry module specified by moduleId
199
200 if (cathod < 0 || cathod >= 2) {
201 if (warn) {
202 AliWarningStream()
203 << "Cathod: " << cathod << " outside limits" << std::endl;
204 }
205 return 0;
206 }
207
208 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
209 if (warn) {
210 AliWarningStream()
211 << "Index: " << moduleId << " outside limits" << std::endl;
212 }
213 return 0;
214 }
215
216 return (AliMUONGeometrySegmentation*)
217 fModuleSegmentations[cathod]->At(moduleId);
218}
219
220//_____________________________________________________________________________
221AliMUONGeometrySegmentation*
222AliMUONSegmentation::GetModuleSegmentationByDEId(
223 Int_t detElemId, Int_t cathod, Bool_t warn) const
224{
225/// Return the geometry module specified by detElemId/cathod
226
227 // Get moduleId
e81a0d4f 228 Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
fb921a27 229
230 return GetModuleSegmentation(moduleId, cathod, warn);
231}
232
233//_____________________________________________________________________________
234const AliMUONVGeometryDESegmentation*
235AliMUONSegmentation::GetDESegmentation(
236 Int_t detElemId, Int_t cathod, Bool_t warn) const
237{
238/// Return the DE segmentation specified by detElemId/cathod
239
240 // Get geometry segmentation
241 AliMUONGeometrySegmentation* moduleSegmentation
242 = GetModuleSegmentationByDEId(detElemId, cathod, warn);
243
244 if ( !moduleSegmentation ) return 0;
245
f1b4bfb7 246 return moduleSegmentation->GetDESegmentation(detElemId, warn);
fb921a27 247}
248
249//_____________________________________________________________________________
250const AliMpVSegmentation*
251AliMUONSegmentation::GetMpSegmentation(
252 Int_t detElemId, Int_t cathod, Bool_t warn) const
253{
254/// Return the mapping segmentation specified by detElemId/cathod
255
256
257 // Get DE segmentation
258 const AliMUONVGeometryDESegmentation* kdeSegmentation
259 = GetDESegmentation(detElemId, cathod, warn);
260
261 if ( !kdeSegmentation ) return 0;
262
263 return kdeSegmentation->GetMpSegmentation();
264}
265
266//_____________________________________________________________________________
267Bool_t
268AliMUONSegmentation::HasDE(Int_t detElemId, Int_t cathod) const
269{
f1b4bfb7 270 // Get DE segmentation
271 const AliMUONVGeometryDESegmentation* kdeSegmentation
272 = GetDESegmentation(detElemId, cathod, false);
fb921a27 273
f1b4bfb7 274 return ( kdeSegmentation != 0 );
fb921a27 275
276}
277
278//_____________________________________________________________________________
279TString
280AliMUONSegmentation::GetDEName(Int_t detElemId, Int_t cathod) const
281{
282
283 // Get geometry segmentation
284 AliMUONGeometrySegmentation* moduleSegmentation
285 = GetModuleSegmentationByDEId(detElemId, cathod, true);
286
287 return moduleSegmentation->GetDEName(detElemId);
288}
289
290