]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSegFactoryV4.cxx
Adding a paragraph on checking overlaps.
[u/mrichter/AliRoot.git] / MUON / AliMUONSegFactoryV4.cxx
CommitLineData
a4dc60c5 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#include <Riostream.h>
23#include <TObjString.h>
24
25#include "AliRun.h"
26#include "AliLog.h"
27
28#include "AliMpPlaneType.h"
29#include "AliMpExMap.h"
30
31#include "AliMUONSegFactoryV4.h"
32#include "AliMUONConstants.h"
33#include "AliMUONGeometryTransformer.h"
34#include "AliMUONGeometryModule.h"
35#include "AliMUONSegmentation.h"
36#include "AliMUONGeometrySegmentation.h"
37#include "AliMUONSegmentationManager.h"
38#include "AliMUONSt12QuadrantSegmentation.h"
39#include "AliMUONSt345SlatSegmentationV2.h"
40#include "AliMUONTriggerSegmentationV2.h"
41
42ClassImp(AliMUONSegFactoryV4)
43
44//__________________________________________________________________________
45AliMUONSegFactoryV4::AliMUONSegFactoryV4(const char* name)
46 : TNamed(name, ""),
47 fSegmentation(0),
48 fkGeomTransformer(0)
49{
50/// Standard constructor
51
52 fSegmentation = new AliMUONSegmentation(AliMUONConstants::NCh());
53}
54
55//__________________________________________________________________________
56 AliMUONSegFactoryV4::AliMUONSegFactoryV4()
57 : TNamed(),
58 fSegmentation(0),
59 fkGeomTransformer(0)
60{
61/// Default constructor
62}
63
64//__________________________________________________________________________
65AliMUONSegFactoryV4::AliMUONSegFactoryV4(const AliMUONSegFactoryV4& rhs)
66 : TNamed(rhs)
67{
68/// Protected copy constructor
69
70 AliFatal("Not implemented.");
71}
72
73//__________________________________________________________________________
74
75AliMUONSegFactoryV4::~AliMUONSegFactoryV4()
76{
77/// Destructor
78
79
80 //delete fSegmentation;
81 // The segmentation is supposed to be deleted in the client code
82}
83
84//__________________________________________________________________________
85AliMUONSegFactoryV4& AliMUONSegFactoryV4::operator=(const AliMUONSegFactoryV4& rhs)
86{
87 // Protected assignement operator
88
89 if (this == &rhs) return *this;
90
91 AliFatal("Not implemented.");
92
93 return *this;
94}
95
96//
97// Private methods
98//
99
100//__________________________________________________________________________
101Bool_t AliMUONSegFactoryV4::IsGeometryDefined(Int_t ichamber)
102{
103// Return true, if det elements for the chamber with the given ichamber Id
104// are defined in geometry (the geometry builder for this chamber was activated)
105
106 if ( ! fkGeomTransformer ||
107 ! fkGeomTransformer->GetModuleTransformer(ichamber, false) )
108
109 return kFALSE;
110
111 return kTRUE;
112}
113
114//_____________________________________________________________________________
115Bool_t
116AliMUONSegFactoryV4::ReadDENames(const TString& fileName, AliMpExMap& map)
117{
118/// Read det element names from the file specified by name
119/// and fill the map
120
121 // Open file
122 TString filePath(gSystem->ExpandPathName("${ALICE_ROOT}/MUON/data/"));
123 filePath += fileName;
124 std::ifstream in(filePath);
125 if (!in.good()) {
126 AliErrorClass(Form("Cannot read file %s", filePath.Data()));
127 return false;
128 }
129
130 // Read file and fill the map
131 char line[80];
132 while ( in.getline(line,80) )
133 {
134 if ( !isdigit(line[0]) ) continue;
135 TString sline(line);
136
137 Ssiz_t pos = sline.First(' ');
138 Int_t detelemid = TString(sline(0,pos)).Atoi();
139 TObject* o = map.GetValue(detelemid);
140 if (!o)
141 {
142 map.Add(detelemid, new TObjString(sline(pos+1,sline.Length()-pos).Data()));
143 }
144 }
145
146 // Close file
147 in.close();
148 return true;
149}
150
151//_____________________________________________________________________________
152void
153AliMUONSegFactoryV4::BuildChamber345(Int_t firstDetElemId, Int_t lastDetElemId,
154 const AliMpExMap& deNamesMap)
155{
156 // Build a single chamber for stations 345.
157 // The first and lastDetElemId must correspond to the same chamber.
158
159 Int_t ichamber = firstDetElemId/100 - 1;
160 Int_t test = lastDetElemId/100-1;
161
162 if ( test != ichamber )
163 {
164 AliFatal(Form("DetElemIds %d and %d not part of the same chamber !",
165 firstDetElemId,lastDetElemId));
166 }
167
168 const Int_t kNPLANES = 2;
169 const AliMpPlaneType kptypes[kNPLANES] = { kBendingPlane, kNonBendingPlane };
170
171 const AliMUONGeometryModuleTransformer* kModuleTransformer
172 = fkGeomTransformer->GetModuleTransformer(ichamber);
173
174 for ( Int_t iplane = 0; iplane < kNPLANES; ++iplane )
175 {
176 AliMUONGeometrySegmentation* segmentation =
177 new AliMUONGeometrySegmentation(kModuleTransformer);
178
179 for ( Int_t d = firstDetElemId; d <= lastDetElemId; ++d )
180 {
181 if ( !deNamesMap.GetValue(d) )
182 {
183 AliWarning(Form("You are requesting an invalid detElemId = %d, I am skipping it",d));
184 continue;
185 }
186
187 AliMUONVGeometryDESegmentation* slatSeg =
188 new AliMUONSt345SlatSegmentationV2(d,kptypes[iplane]);
189
190 fSegmentation->AddDESegmentation(slatSeg);
191
192 TString deName = ((TObjString*)deNamesMap.GetValue(d))->GetString();
193 segmentation->Add(d, deName, slatSeg);
194 }
195
196 fSegmentation->AddModuleSegmentation(ichamber, iplane, segmentation);
197 }
198}
199
200//_____________________________________________________________________________
201void
202AliMUONSegFactoryV4::BuildChamberTrigger(Int_t firstDetElemId, Int_t lastDetElemId,
203 const AliMpExMap& deNamesMap)
204{
205 // Build a single chamber for trigger stations.
206 // The first and lastDetElemId must correspond to the same chamber.
207
208 Int_t ichamber = firstDetElemId/100 - 1;
209 Int_t test = lastDetElemId/100-1;
210
211 if ( test != ichamber )
212 {
213 AliFatal(Form("DetElemIds %d and %d not part of the same chamber !",
214 firstDetElemId,lastDetElemId));
215 }
216
217 const Int_t kNPLANES = 2;
218 const AliMpPlaneType kptypes[kNPLANES] = { kBendingPlane, kNonBendingPlane };
219
220 const AliMUONGeometryModuleTransformer* kModuleTransformer
221 = fkGeomTransformer->GetModuleTransformer(ichamber);
222
223 for ( Int_t iplane = 0; iplane < kNPLANES; ++iplane )
224 {
225 AliMUONGeometrySegmentation* segmentation =
226 new AliMUONGeometrySegmentation(kModuleTransformer);
227
228 for ( Int_t d = firstDetElemId; d <= lastDetElemId; ++d )
229 {
230 if ( !deNamesMap.GetValue(d) )
231 {
232 AliWarning(Form("You are requesting an invalid detElemId = %d, I am skipping it",d));
233 continue;
234 }
235
236 AliMUONVGeometryDESegmentation* slatSeg =
237 new AliMUONTriggerSegmentationV2(d,kptypes[iplane]);
238
239 fSegmentation->AddDESegmentation(slatSeg);
240
241 TString deName = ((TObjString*)deNamesMap.GetValue(d))->GetString();
242 segmentation->Add(d, deName, slatSeg);
243 }
244
245 fSegmentation->AddModuleSegmentation(ichamber, iplane, segmentation);
246 }
247}
248
249//__________________________________________________________________________
250void AliMUONSegFactoryV4::BuildStation1()
251{
252/// Station 1
253
254 // Quadrant segmentations:
255 AliMUONSt12QuadrantSegmentation* bendSt1
256 = new AliMUONSt12QuadrantSegmentation(kStation1, kBendingPlane);
257 AliMUONSt12QuadrantSegmentation* nonbendSt1
258 = new AliMUONSt12QuadrantSegmentation(kStation1, kNonBendingPlane);
259
260 // Add in the array (for safe deleting)
261 fSegmentation->AddDESegmentation(bendSt1);
262 fSegmentation->AddDESegmentation(nonbendSt1);
263
264 AliMUONGeometrySegmentation* segmentation[2];
265
266 for (Int_t chamber = 0; chamber < 2; chamber++) {
267
268 const AliMUONGeometryModuleTransformer* kModuleTransformer
269 = fkGeomTransformer->GetModuleTransformer(chamber);
270
271 segmentation[0] = new AliMUONGeometrySegmentation(kModuleTransformer);
272 segmentation[1] = new AliMUONGeometrySegmentation(kModuleTransformer);
273
274 // id detection elt for chamber 1
275 Int_t id0 = (chamber+1)*100;
276
277 // cathode 0
278 segmentation[0]->Add(id0, "St1_Quadrant_I", bendSt1);
279 segmentation[0]->Add(id0 + 1, "St1_Quadrant_II", nonbendSt1);
280 segmentation[0]->Add(id0 + 2, "St1_Quadrant_III", bendSt1);
281 segmentation[0]->Add(id0 + 3, "St1_Quadrant_IV", nonbendSt1);
282 fSegmentation->AddModuleSegmentation(chamber, 0, segmentation[0]);
283
284 // cathode 1
285 segmentation[1]->Add(id0, "St1_Quadrant_I", nonbendSt1);
286 segmentation[1]->Add(id0 + 1, "St1_Quadrant_II", bendSt1);
287 segmentation[1]->Add(id0 + 2, "St1_Quadrant_III", nonbendSt1);
288 segmentation[1]->Add(id0 + 3, "St1_Quadrant_IV", bendSt1);
289 fSegmentation->AddModuleSegmentation(chamber, 1, segmentation[1]);
290 }
291}
292
293//__________________________________________________________________________
294void AliMUONSegFactoryV4::BuildStation2()
295{
296 //
297 //--------------------------------------------------------
298 // Configuration for Chamber TC3/4 (Station 2) -----------
299 ///^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
300
301 // Quadrant segmentations:
302 AliMUONSt12QuadrantSegmentation* bendSt2
303 = new AliMUONSt12QuadrantSegmentation(kStation2, kBendingPlane);
304 AliMUONSt12QuadrantSegmentation* nonbendSt2
305 = new AliMUONSt12QuadrantSegmentation(kStation2, kNonBendingPlane);
306
307 // Add in the array (for safe deleting)
308 fSegmentation->AddDESegmentation(bendSt2);
309 fSegmentation->AddDESegmentation(nonbendSt2);
310
311 AliMUONGeometrySegmentation* segmentation[2];
312
313 for (Int_t chamber = 2; chamber < 4; chamber++) {
314
315 const AliMUONGeometryModuleTransformer* kModuleTransformer
316 = fkGeomTransformer->GetModuleTransformer(chamber);
317
318 segmentation[0] = new AliMUONGeometrySegmentation(kModuleTransformer);
319 segmentation[1] = new AliMUONGeometrySegmentation(kModuleTransformer);
320
321 // id detection elt for chamber 1
322 Int_t id0 = (chamber+1)*100;
323
324 //--------------------------------------------------------
325 // Configuration for Chamber TC3/4 (Station 2) ----------
326
327
328 // cathode 0
329 segmentation[0]->Add(id0, "St2_Quadrant_I", bendSt2);
330 segmentation[0]->Add(id0 + 1, "St2_Quadrant_II", nonbendSt2);
331 segmentation[0]->Add(id0 + 2, "St2_Quadrant_III", bendSt2);
332 segmentation[0]->Add(id0 + 3, "St2_Quadrant_IV", nonbendSt2);
333 fSegmentation->AddModuleSegmentation(chamber, 0, segmentation[0]);
334
335 // cathode 1
336 segmentation[1]->Add(id0, "St2_Quadrant_I", nonbendSt2);
337 segmentation[1]->Add(id0 + 1, "St2_Quadrant_II", bendSt2);
338 segmentation[1]->Add(id0 + 2, "St2_Quadrant_III", nonbendSt2);
339 segmentation[1]->Add(id0 + 3, "St2_Quadrant_IV", bendSt2);
340 fSegmentation->AddModuleSegmentation(chamber, 1, segmentation[1]);
341 }
342}
343
344//__________________________________________________________________________
345void AliMUONSegFactoryV4::BuildStation3(const AliMpExMap& deNamesMap)
346{
347 BuildChamber345(500,517,deNamesMap);
348 BuildChamber345(600,617,deNamesMap);
349}
350
351//__________________________________________________________________________
352void AliMUONSegFactoryV4::BuildStation4(const AliMpExMap& deNamesMap)
353{
354 BuildChamber345(700,725,deNamesMap);
355 BuildChamber345(800,825,deNamesMap);
356}
357
358//__________________________________________________________________________
359void AliMUONSegFactoryV4::BuildStation5(const AliMpExMap& deNamesMap)
360{
361 BuildChamber345(900,925,deNamesMap);
362 BuildChamber345(1000,1025,deNamesMap);
363}
364
365//__________________________________________________________________________
366void AliMUONSegFactoryV4::BuildStation6(const AliMpExMap& deNamesMap)
367{
368 BuildChamberTrigger(1100,1117,deNamesMap);
369 BuildChamberTrigger(1200,1217,deNamesMap);
370 BuildChamberTrigger(1300,1317,deNamesMap);
371 BuildChamberTrigger(1400,1417,deNamesMap);
372}
373
374//__________________________________________________________________________
375void AliMUONSegFactoryV4::Build(const AliMUONGeometryTransformer* geometry)
376{
377/// Construct segmentation for all MUON stations
378//
379
380 fkGeomTransformer = geometry;
381
382 AliMpExMap map1(kTRUE);
383 ReadDENames("denames_slat.dat", map1);
384
385 AliMpExMap map2(kTRUE);
386 ReadDENames("denames_trigger.dat", map2);
387
388 // Build all stations
389 if (IsGeometryDefined(0)) BuildStation1();
390 if (IsGeometryDefined(2)) BuildStation2();
391 if (IsGeometryDefined(4)) BuildStation3(map1);
392 if (IsGeometryDefined(6)) BuildStation4(map1);
393 if (IsGeometryDefined(8)) BuildStation5(map1);
394 if (IsGeometryDefined(10)) BuildStation6(map2);
395}
396
397//__________________________________________________________________________
398void AliMUONSegFactoryV4::BuildStation(
399 const AliMUONGeometryTransformer* geometry,
400 Int_t stationNumber)
401{
402/// Construct segmentations for the given MUON station
403
404 fkGeomTransformer = geometry;
405
406 AliMpExMap map1(kTRUE);
407 ReadDENames("denames_slat.dat", map1);
408
409 AliMpExMap map2(kTRUE);
410 ReadDENames("denames_trigger.dat", map2);
411
412 switch (stationNumber) {
413 case 1: BuildStation1(); break;
414 case 2: BuildStation2(); break;
415 case 3: BuildStation3(map1); break;
416 case 4: BuildStation4(map1); break;
417 case 5: BuildStation5(map1); break;
418 case 6: BuildStation6(map2); break;
419
420 default: AliFatal("Wrong station number");
421 }
422}