]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSegmentation.cxx
EMCAL geometry can be created independently form anything now
[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//
490da820 18// ----------------------------
fb921a27 19// Class AliMUONSegmentation
20// ----------------------------
21// Manager class for geometry construction via geometry builders.
fb921a27 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"
283cfce0 31\
e81a0d4f 32#include "AliMpVSegmentation.h"
283cfce0 33#include "AliMpDEManager.h"
e81a0d4f 34
fb921a27 35#include "AliLog.h"
36
a9aad96e 37/// \cond CLASSIMP
fb921a27 38ClassImp(AliMUONSegmentation)
a9aad96e 39/// \endcond
fb921a27 40
41//______________________________________________________________________________
42AliMUONSegmentation::AliMUONSegmentation(Int_t nofModules)
43 : TObject(),
44 fDESegmentations(0)
45{
46/// Standard constructor
47
48 // Create array for DE segmentations
49 fDESegmentations = new TObjArray();
50 fDESegmentations->SetOwner(kTRUE);
51
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);
56
57 for (Int_t i=0; i<nofModules; i++)
58 fModuleSegmentations[cathod]->AddAt(0, i);
59 }
60
61 AliDebug(1, Form("ctor this = %p", this) );
62}
63
64//______________________________________________________________________________
65AliMUONSegmentation::AliMUONSegmentation()
66 : TObject(),
67 fDESegmentations(0)
68{
69/// Default constructor
70
71 fModuleSegmentations[0] = 0;
72 fModuleSegmentations[1] = 0;
73
74 AliDebug(1, Form("default (empty) ctor this = %p", this));
75}
76
fb921a27 77//______________________________________________________________________________
78AliMUONSegmentation::~AliMUONSegmentation()
79{
80/// Destructor
81
82 AliDebug(1, Form("dtor this = %p", this));
83
84 delete fDESegmentations;
85 delete fModuleSegmentations[0];
86 delete fModuleSegmentations[1];
87}
88
283cfce0 89//
90// private functions
91//
92
93//_____________________________________________________________________________
94AliMUONGeometrySegmentation*
95AliMUONSegmentation::GetModuleSegmentation(
96 Int_t moduleId, Int_t cathod, Bool_t warn) const
97{
98/// Return the geometry module segmentation specified by moduleId
99
100 if (cathod < 0 || cathod >= 2) {
101 if (warn) {
102 AliWarningStream()
103 << "Cathod: " << cathod << " outside limits" << std::endl;
104 }
105 return 0;
106 }
107
108 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
109 if (warn) {
110 AliWarningStream()
111 << "Index: " << moduleId << " outside limits" << std::endl;
112 }
113 return 0;
114 }
115
116 return (AliMUONGeometrySegmentation*)
117 fModuleSegmentations[cathod]->At(moduleId);
118}
119
fb921a27 120//
121// public functions
122//
123
124//_____________________________________________________________________________
125void AliMUONSegmentation::AddDESegmentation(
e81a0d4f 126 AliMUONVGeometryDESegmentation* segmentation)
fb921a27 127{
128/// Add the DE segmentation to the array
129
130 fDESegmentations->Add(segmentation);
131}
132
133//_____________________________________________________________________________
134void AliMUONSegmentation::AddModuleSegmentation(Int_t moduleId, Int_t cathod,
135 AliMUONGeometrySegmentation* segmentation)
136{
137/// Add the module segmentation to the array
138
139 if (cathod < 0 || cathod >= 2) {
140 AliErrorStream()
141 << "Cathod: " << cathod << " outside limits" << std::endl;
142 return;
143 }
144
145 if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
146 AliErrorStream()
147 << "Module Id: " << moduleId << " outside limits" << std::endl;
148 return;
149 }
150
151 fModuleSegmentations[cathod]->AddAt(segmentation, moduleId);
152}
153
154//_____________________________________________________________________________
155void AliMUONSegmentation::Init()
156{
157/// Initialize all segmentations
158
159 for (Int_t cathod = 0; cathod < 2; cathod++) {
160 for (Int_t i = 0; i < fModuleSegmentations[cathod]->GetEntriesFast(); i++) {
161
162 AliMUONGeometrySegmentation* moduleSegmentation
163 = (AliMUONGeometrySegmentation*)fModuleSegmentations[cathod]->At(i);
164
165 if (moduleSegmentation) moduleSegmentation->Init(i);
166 }
167 }
168}
169
fb921a27 170//_____________________________________________________________________________
171AliMUONGeometrySegmentation*
172AliMUONSegmentation::GetModuleSegmentationByDEId(
173 Int_t detElemId, Int_t cathod, Bool_t warn) const
174{
175/// Return the geometry module specified by detElemId/cathod
176
177 // Get moduleId
283cfce0 178 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
fb921a27 179
180 return GetModuleSegmentation(moduleId, cathod, warn);
181}
182
183//_____________________________________________________________________________
184const AliMUONVGeometryDESegmentation*
185AliMUONSegmentation::GetDESegmentation(
186 Int_t detElemId, Int_t cathod, Bool_t warn) const
187{
188/// Return the DE segmentation specified by detElemId/cathod
189
190 // Get geometry segmentation
191 AliMUONGeometrySegmentation* moduleSegmentation
192 = GetModuleSegmentationByDEId(detElemId, cathod, warn);
193
194 if ( !moduleSegmentation ) return 0;
195
f1b4bfb7 196 return moduleSegmentation->GetDESegmentation(detElemId, warn);
fb921a27 197}
198
fb921a27 199//_____________________________________________________________________________
200Bool_t
201AliMUONSegmentation::HasDE(Int_t detElemId, Int_t cathod) const
202{
a9aad96e 203/// Return true if segmentation for detElemId and cathod is defined.
204
f1b4bfb7 205 const AliMUONVGeometryDESegmentation* kdeSegmentation
206 = GetDESegmentation(detElemId, cathod, false);
fb921a27 207
f1b4bfb7 208 return ( kdeSegmentation != 0 );
fb921a27 209
210}
211
212//_____________________________________________________________________________
213TString
214AliMUONSegmentation::GetDEName(Int_t detElemId, Int_t cathod) const
215{
a9aad96e 216/// Get detection element name
fb921a27 217
fb921a27 218 AliMUONGeometrySegmentation* moduleSegmentation
219 = GetModuleSegmentationByDEId(detElemId, cathod, true);
220
221 return moduleSegmentation->GetDEName(detElemId);
222}
223
224