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