]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSegmentation.cxx
- Added function:
[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"
31#include "AliMUONGeometryDEIndexing.h"
32#include "AliLog.h"
33
34
35ClassImp(AliMUONSegmentation)
36
37//______________________________________________________________________________
38AliMUONSegmentation::AliMUONSegmentation(Int_t nofModules)
39 : TObject(),
40 fDESegmentations(0)
41{
42/// Standard constructor
43
44 // Create array for DE segmentations
45 fDESegmentations = new TObjArray();
46 fDESegmentations->SetOwner(kTRUE);
47
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);
52
53 for (Int_t i=0; i<nofModules; i++)
54 fModuleSegmentations[cathod]->AddAt(0, i);
55 }
56
57 AliDebug(1, Form("ctor this = %p", this) );
58}
59
60//______________________________________________________________________________
61AliMUONSegmentation::AliMUONSegmentation()
62 : TObject(),
63 fDESegmentations(0)
64{
65/// Default constructor
66
67 fModuleSegmentations[0] = 0;
68 fModuleSegmentations[1] = 0;
69
70 AliDebug(1, Form("default (empty) ctor this = %p", this));
71}
72
73//______________________________________________________________________________
74AliMUONSegmentation::AliMUONSegmentation(const AliMUONSegmentation& right)
75 : TObject(right)
76{
77/// Copy constructor (not implemented)
78
79 AliFatal("Copy constructor not provided.");
80}
81
82//______________________________________________________________________________
83AliMUONSegmentation::~AliMUONSegmentation()
84{
85/// Destructor
86
87 AliDebug(1, Form("dtor this = %p", this));
88
89 delete fDESegmentations;
90 delete fModuleSegmentations[0];
91 delete fModuleSegmentations[1];
92}
93
94//______________________________________________________________________________
95AliMUONSegmentation&
96AliMUONSegmentation::operator=(const AliMUONSegmentation& right)
97{
98/// Assignement operator (not implemented)
99
100 // check assignement to self
101 if (this == &right) return *this;
102
103 AliFatal("Assignement operator not provided.");
104
105 return *this;
106}
107
108//
109// public functions
110//
111
112//_____________________________________________________________________________
113void AliMUONSegmentation::AddDESegmentation(
114 AliMUONVGeometryDESegmentation* segmentation)
115{
116/// Add the DE segmentation to the array
117
118 fDESegmentations->Add(segmentation);
119}
120
121//_____________________________________________________________________________
122void AliMUONSegmentation::AddModuleSegmentation(Int_t moduleId, Int_t cathod,
123 AliMUONGeometrySegmentation* segmentation)
124{
125/// Add the module segmentation to the array
126
127 if (cathod < 0 || cathod >= 2) {
128 AliErrorStream()
129 << "Cathod: " << cathod << " outside limits" << std::endl;
130 return;
131 }
132
133 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
134 AliErrorStream()
135 << "Module Id: " << moduleId << " outside limits" << std::endl;
136 return;
137 }
138
139 fModuleSegmentations[cathod]->AddAt(segmentation, moduleId);
140}
141
142//_____________________________________________________________________________
143void AliMUONSegmentation::Init()
144{
145/// Initialize all segmentations
146
147 for (Int_t cathod = 0; cathod < 2; cathod++) {
148 for (Int_t i = 0; i < fModuleSegmentations[cathod]->GetEntriesFast(); i++) {
149
150 AliMUONGeometrySegmentation* moduleSegmentation
151 = (AliMUONGeometrySegmentation*)fModuleSegmentations[cathod]->At(i);
152
153 if (moduleSegmentation) moduleSegmentation->Init(i);
154 }
155 }
156}
157
158//_____________________________________________________________________________
159AliMUONGeometrySegmentation*
160AliMUONSegmentation::GetModuleSegmentation(
161 Int_t moduleId, Int_t cathod, Bool_t warn) const
162{
163/// Return the geometry module specified by moduleId
164
165 if (cathod < 0 || cathod >= 2) {
166 if (warn) {
167 AliWarningStream()
168 << "Cathod: " << cathod << " outside limits" << std::endl;
169 }
170 return 0;
171 }
172
173 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
174 if (warn) {
175 AliWarningStream()
176 << "Index: " << moduleId << " outside limits" << std::endl;
177 }
178 return 0;
179 }
180
181 return (AliMUONGeometrySegmentation*)
182 fModuleSegmentations[cathod]->At(moduleId);
183}
184
185//_____________________________________________________________________________
186AliMUONGeometrySegmentation*
187AliMUONSegmentation::GetModuleSegmentationByDEId(
188 Int_t detElemId, Int_t cathod, Bool_t warn) const
189{
190/// Return the geometry module specified by detElemId/cathod
191
192 // Get moduleId
193 Int_t moduleId = AliMUONGeometryDEIndexing::GetModuleId(detElemId);
194
195 return GetModuleSegmentation(moduleId, cathod, warn);
196}
197
198//_____________________________________________________________________________
199const AliMUONVGeometryDESegmentation*
200AliMUONSegmentation::GetDESegmentation(
201 Int_t detElemId, Int_t cathod, Bool_t warn) const
202{
203/// Return the DE segmentation specified by detElemId/cathod
204
205 // Get geometry segmentation
206 AliMUONGeometrySegmentation* moduleSegmentation
207 = GetModuleSegmentationByDEId(detElemId, cathod, warn);
208
209 if ( !moduleSegmentation ) return 0;
210
f1b4bfb7 211 return moduleSegmentation->GetDESegmentation(detElemId, warn);
fb921a27 212}
213
214//_____________________________________________________________________________
215const AliMpVSegmentation*
216AliMUONSegmentation::GetMpSegmentation(
217 Int_t detElemId, Int_t cathod, Bool_t warn) const
218{
219/// Return the mapping segmentation specified by detElemId/cathod
220
221
222 // Get DE segmentation
223 const AliMUONVGeometryDESegmentation* kdeSegmentation
224 = GetDESegmentation(detElemId, cathod, warn);
225
226 if ( !kdeSegmentation ) return 0;
227
228 return kdeSegmentation->GetMpSegmentation();
229}
230
231//_____________________________________________________________________________
232Bool_t
233AliMUONSegmentation::HasDE(Int_t detElemId, Int_t cathod) const
234{
f1b4bfb7 235 // Get DE segmentation
236 const AliMUONVGeometryDESegmentation* kdeSegmentation
237 = GetDESegmentation(detElemId, cathod, false);
fb921a27 238
f1b4bfb7 239 return ( kdeSegmentation != 0 );
fb921a27 240
241}
242
243//_____________________________________________________________________________
244TString
245AliMUONSegmentation::GetDEName(Int_t detElemId, Int_t cathod) const
246{
247
248 // Get geometry segmentation
249 AliMUONGeometrySegmentation* moduleSegmentation
250 = GetModuleSegmentationByDEId(detElemId, cathod, true);
251
252 return moduleSegmentation->GetDEName(detElemId);
253}
254
255