]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSegFactory.cxx
Removed option from CreateSegmentation(), no alternative options
[u/mrichter/AliRoot.git] / MUON / AliMUONSegFactory.cxx
CommitLineData
fc337f2e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
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 purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16////////////////////////////////////////////////////////////
17// Factory for muon chambers, segmentations and response //
18////////////////////////////////////////////////////////////
19
20/* $Id$ */
21
f7006443 22// --------------------------
23// Class AliMUONSegFactory
24// --------------------------
25// New factory for building segmentations at all levels
26// Authors: Ivana Hrivnacova, IPN Orsay
27
fc337f2e 28#include "AliMUONSegFactory.h"
29#include "AliMUONConstants.h"
fc337f2e 30#include "AliMUONGeometryTransformer.h"
31#include "AliMUONGeometryModule.h"
32#include "AliMUONSegmentation.h"
33#include "AliMUONGeometrySegmentation.h"
34#include "AliMUONSt12QuadrantSegmentation.h"
35#include "AliMUONSt345SlatSegmentation.h"
94d085f8 36#include "AliMUONTriggerSegmentation.h"
fc337f2e 37
38#include "AliMpDEManager.h"
39#include "AliMpDEIterator.h"
b27e9585 40#include "AliMpSegmentation.h"
fc337f2e 41
42#include "AliLog.h"
43
44#include <Riostream.h>
45#include <TSystem.h>
46#include <TObjString.h>
47#include <TMap.h>
48
5398f946 49/// \cond CLASSIMP
fc337f2e 50ClassImp(AliMUONSegFactory)
5398f946 51/// \endcond
fc337f2e 52
53//______________________________________________________________________________
54AliMUONSegFactory::AliMUONSegFactory(const AliMUONGeometryTransformer* geometry)
55 : TObject(),
fc337f2e 56 fDESegmentations(),
57 fSegmentation(0),
58 fkTransformer(geometry)
59{
60/// Standard constructor
61
62}
63
64//______________________________________________________________________________
4f27ddd4 65AliMUONSegFactory::AliMUONSegFactory(const TString& volPathsFileName,
66 const TString& transformsFileName)
fc337f2e 67 : TObject(),
fc337f2e 68 fDESegmentations(),
69 fSegmentation(0),
70 fkTransformer(0)
71{
72/// Standard constructor
73
74 // Transformer
75 AliMUONGeometryTransformer* transformer = new AliMUONGeometryTransformer(true);
4f27ddd4 76 transformer->ReadGeometryData(volPathsFileName, transformsFileName);
fc337f2e 77 fkTransformer = transformer;
78}
79
80//______________________________________________________________________________
81 AliMUONSegFactory::AliMUONSegFactory()
82 : TObject(),
fc337f2e 83 fDESegmentations(),
84 fSegmentation(0),
85 fkTransformer(0)
86{
87/// Default constructor
88}
89
fc337f2e 90//______________________________________________________________________________
91
92AliMUONSegFactory::~AliMUONSegFactory()
93{
94/// Destructor
95
96 //delete fSegmentation;
97 // The segmentation is supposed to be deleted in the client code
98}
99
fc337f2e 100//
101// Private methods
102//
103
104//______________________________________________________________________________
6080a225 105Bool_t AliMUONSegFactory::IsGeometryDefined(Int_t ichamberId)
fc337f2e 106{
5398f946 107/// Return true, if det elements for the chamber with the given ichamber Id
108/// are defined in geometry (the geometry builder for this chamber was activated)
fc337f2e 109
6080a225 110 AliMpDEIterator it;
111 it.First(ichamberId);
112 Int_t firstDE = it.CurrentDE();
113
fc337f2e 114 if ( ! fkTransformer ||
6080a225 115 ! fkTransformer->GetModuleTransformerByDEId(firstDE, false) )
fc337f2e 116
117 return kFALSE;
118
119 return kTRUE;
120}
121
122//__________________________________________________________________________
123AliMUONSegmentation* AliMUONSegFactory::Segmentation()
124{
125/// Return the segmentation container, create it if it does not yet exist
126
127 if ( ! fSegmentation )
6080a225 128 fSegmentation = new AliMUONSegmentation(AliMUONConstants::NGeomModules());
fc337f2e 129
130 return fSegmentation;
131}
132
133//
134// public methods
135//
136
fc337f2e 137//______________________________________________________________________________
138AliMUONVGeometryDESegmentation*
139AliMUONSegFactory::CreateDESegmentation(Int_t detElemId, Int_t cath)
140{
5398f946 141/// Create DE segmentation, operating in local DE reference frame
fc337f2e 142
143 // Check detElemId & cath
144 if ( ! AliMpDEManager::IsValid(detElemId, cath, true) ) return 0;
145
146 // Check if transformer is defined
147 if ( ! fkTransformer) {
148 AliErrorStream() << "Geometry transformer not defined" << endl;
149 return 0;
150 }
151
152 // Only return it, if DE segmentation for this detElemId and cath
153 // was already defined
154 //
155 const AliMUONVGeometryDESegmentation* kdeSegmentation
156 = Segmentation()->GetDESegmentation(detElemId, cath, false);
157 if ( kdeSegmentation )
158 return const_cast<AliMUONVGeometryDESegmentation*>(kdeSegmentation);
159
160 // Get module, create it if it does not exist
161 //
fc337f2e 162 AliMUONGeometrySegmentation* moduleSegmentation
6080a225 163 = Segmentation()->GetModuleSegmentationByDEId(detElemId, cath, false);
fc337f2e 164 if (! moduleSegmentation) {
6080a225 165 Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
fc337f2e 166 moduleSegmentation
167 = new AliMUONGeometrySegmentation(
168 fkTransformer->GetModuleTransformer(moduleId));
169 Segmentation()->AddModuleSegmentation(moduleId, cath, moduleSegmentation);
170 }
171
172 // Get DE segmentation for this DE type, create it if it does not exist
173 //
174 AliMUONVGeometryDESegmentation* deSegmentation = 0;
175 TString deName = AliMpDEManager::GetDEName(detElemId, cath);
176 TObject* objSegmentation = fDESegmentations.Get(deName);
177 if ( objSegmentation )
178 deSegmentation = (AliMUONVGeometryDESegmentation*)objSegmentation;
179
180 if ( !deSegmentation ) {
181
b27e9585 182
183
fc337f2e 184 // Get/Create mapping segmentation via mapping manager
b27e9585 185 const AliMpVSegmentation* kmpSegmentation
186 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, cath);
fc337f2e 187 AliMpVSegmentation* mpSegmentation
b27e9585 188 = const_cast<AliMpVSegmentation*>(kmpSegmentation);
189
fc337f2e 190 AliMpStationType stationType = AliMpDEManager::GetStationType(detElemId);
191 AliMpPlaneType planeType = AliMpDEManager::GetPlaneType(detElemId, cath);
192
193 switch (stationType) {
194
195 case kStation1:
196 case kStation2:
197 deSegmentation = new AliMUONSt12QuadrantSegmentation(
198 mpSegmentation, stationType, planeType);
199 //cout << " new AliMUONSt12QuadrantSegmentation "
200 // << StationTypeName(stationType) << " "
201 // << PlaneTypeName(planeType) << " "
202 // << deName << endl;
203
204 break;
205
206 case kStation345:
c3e6d1f3 207 deSegmentation = new AliMUONSt345SlatSegmentation(
fc337f2e 208 mpSegmentation, detElemId, planeType);
209 //cout << " new AliMUONSt345SlatSegmentationV2 "
210 // << StationTypeName(stationType) << " "
211 // << PlaneTypeName(planeType) << " "
212 // << deName << endl;
213 break;
214
215 case kStationTrigger:
94d085f8 216 deSegmentation = new AliMUONTriggerSegmentation(
fc337f2e 217 mpSegmentation, detElemId, planeType);
94d085f8 218 //cout << " new AliMUONTriggerSegmentation "
fc337f2e 219 // << StationTypeName(stationType) << " "
220 // << PlaneTypeName(planeType) << " "
221 // << deName << endl;
222 break;
223 }
224
225 // Map new DE segmentation
226 fDESegmentations.Add(deName, deSegmentation);
227 Segmentation()->AddDESegmentation(deSegmentation);
228 }
229
230 // Add DE segmentation to module
231 //
232 moduleSegmentation->Add(detElemId, deName, deSegmentation);
233
234 return deSegmentation;
235}
236
237
238//______________________________________________________________________________
6080a225 239void
240AliMUONSegFactory::CreateModuleSegmentations(Int_t chamberId, Int_t cath)
fc337f2e 241{
6080a225 242/// Create module segmentation(s), operating in the global reference frame
5398f946 243/// Detection elements are defined via DE names map.
fc337f2e 244
245 // Check cathod & module Id
246 if ( ! AliMpDEManager::IsValidCathod(cath, true) ||
6080a225 247 ! AliMpDEManager::IsValidChamberId(chamberId, true) ) return;
fc337f2e 248
249 AliMpDEIterator it;
6080a225 250 for ( it.First(chamberId); ! it.IsDone(); it.Next() )
fc337f2e 251 CreateDESegmentation(it.CurrentDE(), cath);
fc337f2e 252}
253
254//______________________________________________________________________________
255AliMUONSegmentation*
c3e6d1f3 256AliMUONSegFactory::CreateSegmentation()
fc337f2e 257{
258/// Create segmentations on all levels and return their container.
259
6080a225 260 for (Int_t chamberId = 0; chamberId<AliMUONConstants::NCh(); chamberId++)
261 for (Int_t cath = 0; cath < 2; cath++) {
262 if ( IsGeometryDefined(chamberId) )
263 CreateModuleSegmentations( chamberId, cath);
fc337f2e 264 }
fc337f2e 265
6080a225 266 return Segmentation();
fc337f2e 267}
268