]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONGeometrySegmentation.cxx
- New virtual function in AliMUONVGeometryDESegmentation and in the daughters GetDire...
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometrySegmentation.cxx
CommitLineData
e118b27e 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// Class AliMUONGeometrySegmentation
18// -------------------------------
19// New class for the module segmentation
20// composed of the segmentations of detection elements.
21// Applies transformations defined in geometry.
22//
23// Author:Ivana Hrivnacova, IPN Orsay
24
e118b27e 25#include "AliLog.h"
26
27#include "AliMUONGeometrySegmentation.h"
e0a49962 28#include "AliMUONVGeometryDESegmentation.h"
e118b27e 29#include "AliMUONGeometryModule.h"
30#include "AliMUONGeometryDetElement.h"
31#include "AliMUONGeometryStore.h"
32
33
34ClassImp(AliMUONGeometrySegmentation)
35
36
37//______________________________________________________________________________
38AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
39 AliMUONGeometryModule* geometry)
40: TObject(),
41 fCurrentDetElemId(0),
42 fCurrentDetElement(0),
43 fCurrentSegmentation(0),
44 fGeometryModule(geometry),
45 fDESegmentations(0)
46
47{
48// Normal constructor
49
50 fDESegmentations
51 = new AliMUONGeometryStore(geometry->GetDEIndexing(), false);
52}
53
54//______________________________________________________________________________
55AliMUONGeometrySegmentation::AliMUONGeometrySegmentation()
56: TObject(),
57 fCurrentDetElemId(0),
58 fCurrentDetElement(0),
59 fCurrentSegmentation(0),
60 fGeometryModule(0),
61 fDESegmentations(0)
62{
63// Default Constructor
64}
65
66//______________________________________________________________________________
67AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
68 const AliMUONGeometrySegmentation& rhs)
69 : TObject(rhs)
70{
71// Copy constructor
72 AliFatal("Copy constructor is not implemented.");
73}
74
75//______________________________________________________________________________
76AliMUONGeometrySegmentation::~AliMUONGeometrySegmentation() {
77// Destructor
78
79 delete fDESegmentations;
80}
81
82//
83// operators
84//
85
86//______________________________________________________________________________
87AliMUONGeometrySegmentation&
88AliMUONGeometrySegmentation::operator=(const AliMUONGeometrySegmentation& rhs)
89{
90// Copy operator
91
92 // check assignement to self
93 if (this == &rhs) return *this;
94
95 AliFatal("Assignment operator is not implemented.");
96
97 return *this;
98}
99
100//
101// private methods
102//
103
104//______________________________________________________________________________
105Bool_t AliMUONGeometrySegmentation::Notify(Int_t detElemId) const
106{
107// Updates current detection element and segmentation,
108// and checks if they exist.
109// Returns true if success.
110// ---
111
112 if (detElemId != fCurrentDetElemId) {
113
114 // Find detection element and its segmentation
115 AliMUONGeometryDetElement* detElement
116 = fGeometryModule->GetDetElement(detElemId);
117 if (!detElement) {
118 AliError(Form("Detection element %d not defined", detElemId));
119 return false;
120 }
121
e0a49962 122 AliMUONVGeometryDESegmentation* segmentation
123 = (AliMUONVGeometryDESegmentation*) fDESegmentations->Get(detElemId);
e118b27e 124 if (!segmentation) {
125 AliError(Form("Segmentation for detection element %d not defined",
126 detElemId));
127 return false;
128 }
129
130 fCurrentDetElemId = detElemId;
131 fCurrentDetElement = detElement;
132 fCurrentSegmentation = segmentation;
133 }
134
135 return true;
136}
137
138//
139// public methods
140//
141
142//______________________________________________________________________________
143void AliMUONGeometrySegmentation::Add(Int_t detElemId,
e0a49962 144 AliMUONVGeometryDESegmentation* segmentation)
e118b27e 145{
146// Add detection element segmentation
147// ---
148
149 fDESegmentations->Add(detElemId, segmentation);
150}
151
6b1e4b22 152//______________________________________________________________________________
153AliMUONGeometryDirection
154AliMUONGeometrySegmentation::GetDirection(Int_t detElemId) const
155{
156// Return direction with a constant pad size (Direction or coordinate where the resolution is the best)
157
158 if (!Notify(detElemId)) return kDirUndefined;
159
160 return fCurrentSegmentation->GetDirection();
161}
162
e118b27e 163//______________________________________________________________________________
164void AliMUONGeometrySegmentation::SetPadSize(Float_t p1, Float_t p2)
165{
166// Set pad size Dx*Dy to all detection element segmentations
167// ---
168
169 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
e0a49962 170 AliMUONVGeometryDESegmentation* segmentation
171 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
e118b27e 172 segmentation->SetPadSize(p1, p2);
173 }
174}
175
176//______________________________________________________________________________
177void AliMUONGeometrySegmentation::SetDAnod(Float_t d)
178{
179// Set anod pitch to all detection element segmentations
180// ---
181
182 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
e0a49962 183 AliMUONVGeometryDESegmentation* segmentation
184 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
e118b27e 185 segmentation->SetDAnod(d);
186 }
187}
188
189//______________________________________________________________________________
190Float_t AliMUONGeometrySegmentation::GetAnod(Int_t detElemId, Float_t xhit) const
191{
192// Anod wire coordinate closest to xhit
193// Returns for a hit position xhit the position of the nearest anode wire
194// !!! xhit is understand a a distance, not as a position in the space
195// CHECK
196// ---
197
198 if (!Notify(detElemId)) return 0;
199
200 return fCurrentSegmentation->GetAnod(xhit);
201}
202
203//______________________________________________________________________________
e0a49962 204Bool_t AliMUONGeometrySegmentation::GetPadI(Int_t detElemId,
e118b27e 205 Float_t xg, Float_t yg, Float_t zg,
206 Int_t& ix, Int_t& iy)
207{
208// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
209// ---
210
e0a49962 211 if (!Notify(detElemId)) return false;
212
213 if (!fCurrentSegmentation->HasPad(xg, yg, zg)) return false;
e118b27e 214
215 Float_t xl, yl, zl;
216 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
217
218 fCurrentSegmentation->GetPadI(xl, yl, zl, ix, iy);
e0a49962 219 return true;
e118b27e 220}
221
222//______________________________________________________________________________
e0a49962 223Bool_t AliMUONGeometrySegmentation::GetPadC(Int_t detElemId,
e118b27e 224 Int_t ix, Int_t iy,
225 Float_t& xg, Float_t& yg, Float_t& zg)
226{
227// Transform from pad to real coordinates
228// ---
229
e0a49962 230 if (!Notify(detElemId)) return false;
231
232 if (!fCurrentSegmentation->HasPad(ix, iy)) return false;
e118b27e 233
234 Float_t xl, yl, zl;
235 fCurrentSegmentation->GetPadC(ix, iy, xl , yl, zl);
236
237 fGeometryModule->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
e0a49962 238 return true;
e118b27e 239}
240
241
242//______________________________________________________________________________
243void AliMUONGeometrySegmentation::Init(Int_t /*chamber*/)
244{
245// Initialize segmentation.
246// Check that all detection elements have segmanetation set
247// ---
248
249 // Loop over detection elements
250 AliMUONGeometryStore* detElements = fGeometryModule->GetDetElementStore();
251
252 for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
253
254 // Get detction element Id
255 Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
256
257 // Check segmentation
258 if (! fDESegmentations->Get(detElemId) )
259 AliError(Form("Detection element %d has not a segmentation set.",
260 detElements->GetEntry(i)->GetUniqueID()));
261 }
262}
263
264//______________________________________________________________________________
265Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId) const
266{
267// Get pad size in x
268// ---
269
270 if (!Notify(detElemId)) return 0.;
271
272 return fCurrentSegmentation->Dpx();
273}
274
275//______________________________________________________________________________
276Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId) const
277{
278// Get pad size in y
279// ---
280
281 if (!Notify(detElemId)) return 0.;
282
283 return fCurrentSegmentation->Dpy();
284}
285
286//______________________________________________________________________________
287Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
288{
289// Pad size in x by sector
290// ---
291
292 if (!Notify(detElemId)) return 0.;
293
294 return fCurrentSegmentation->Dpx(isector);
295}
296
297//______________________________________________________________________________
298Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
299{
300// Pad size in x, y by Sector
301// ---
302
303 if (!Notify(detElemId)) return 0.;
304
305 return fCurrentSegmentation->Dpy(isector);
306}
307
308//______________________________________________________________________________
309Int_t AliMUONGeometrySegmentation::Npx(Int_t detElemId) const
310{
311// Maximum number of Pads in x
312// ---
313
314 if (!Notify(detElemId)) return 0;
315
316 return fCurrentSegmentation->Npx();
317}
318
319//______________________________________________________________________________
320Int_t AliMUONGeometrySegmentation::Npy(Int_t detElemId) const
321{
322// Maximum number of Pads in y
323// ---
324
325 if (!Notify(detElemId)) return 0;
326
327 return fCurrentSegmentation->Npy();
328}
329
330//______________________________________________________________________________
331void AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
332{
333// Set pad position.
334// Sets virtual pad coordinates, needed for evaluating pad response
335// outside the tracking program.
336// From AliMUONGeometrySegmentationV01.
337// ---
338
339 if (!Notify(detElemId)) return;
340
341 fCurrentSegmentation->SetPad(ix, iy);
342}
343
344//______________________________________________________________________________
345void AliMUONGeometrySegmentation::SetHit(Int_t detElemId,
346 Float_t xghit, Float_t yghit, Float_t zghit)
347{
348// Set hit position
349// Sets virtual hit position, needed for evaluating pad response
350// outside the tracking program
351// From AliMUONGeometrySegmentationV01.
352
353 if (!Notify(detElemId)) return;
354
355 Float_t xl, yl, zl;
356 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
357
358 fCurrentSegmentation->SetHit(xl, yl, zl);
359}
360
361//______________________________________________________________________________
362void AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
363 Float_t xghit, Float_t yghit, Float_t zghit,
364 Float_t dx, Float_t dy)
365{
366// Iterate over pads - initialiser
367// ---
368
369 if (!Notify(detElemId)) return;
370
371 Float_t xl, yl, zl;
372 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
373
374 fCurrentSegmentation->FirstPad(xl, yl, zl, dx, dy);
375}
376
377//______________________________________________________________________________
378void AliMUONGeometrySegmentation::NextPad(Int_t detElemId)
379{
380// Iterate over pads - stepper
381// ---
382
383 if (!Notify(detElemId)) return;
384
385 fCurrentSegmentation->NextPad();
386}
387
388//______________________________________________________________________________
389Int_t AliMUONGeometrySegmentation::MorePads(Int_t detElemId)
390{
391// Iterate over pads - condition
392// ---
393
394 if (!Notify(detElemId)) return 0;
395
396 return fCurrentSegmentation->MorePads();
397}
398
399//______________________________________________________________________________
400Float_t AliMUONGeometrySegmentation::Distance2AndOffset(Int_t detElemId,
401 Int_t ix, Int_t iy,
402 Float_t xg, Float_t yg, Float_t zg,
403 Int_t* dummy)
404{
405// Returns the square of the distance between 1 pad
406// labelled by its channel numbers and a coordinate
407// ---
408
409 if (!Notify(detElemId)) return 0.;
410
411 Float_t xl, yl, zl;
412 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
413
414 return fCurrentSegmentation->Distance2AndOffset(ix, iy, xl, yl, dummy);
415}
416
417//______________________________________________________________________________
418void AliMUONGeometrySegmentation::GetNParallelAndOffset(Int_t detElemId,
419 Int_t ix, Int_t iy,
420 Int_t* nparallel, Int_t* offset)
421{
422// Number of pads read in parallel and offset to add to x
423// (specific to LYON, but mandatory for display)
424// CHECK
425// ---
426
427 if (!Notify(detElemId)) return;
428
429 fCurrentSegmentation->GetNParallelAndOffset(ix, iy, nparallel, offset);
430}
431
432
433//______________________________________________________________________________
434void AliMUONGeometrySegmentation::Neighbours(Int_t detElemId,
435 Int_t ix, Int_t iy,
436 Int_t* nlist,
437 Int_t xlist[10], Int_t ylist[10])
438{
439// Get next neighbours
440// ---
441
442 if (!Notify(detElemId)) return;
443
444 fCurrentSegmentation->Neighbours(ix, iy, nlist, xlist, ylist);
445}
446
447//______________________________________________________________________________
448Int_t AliMUONGeometrySegmentation::Ix()
449{
450// Current pad cursor during disintegration
451// x, y-coordinate
452// ---
453
454 return fCurrentSegmentation->Ix();
455}
456
457//______________________________________________________________________________
458Int_t AliMUONGeometrySegmentation::Iy()
459{
460// Current pad cursor during disintegration
461// x, y-coordinate
462// ---
463
464 return fCurrentSegmentation->Iy();
465}
466
467//______________________________________________________________________________
468Int_t AliMUONGeometrySegmentation::DetElemId()
469{
470// Current pad cursor during disintegration
471// x, y-coordinate
472// ---
473
474 return fCurrentDetElemId;
475}
476
477//______________________________________________________________________________
478Int_t AliMUONGeometrySegmentation::ISector()
479{
480// Current sector
481// ---
482
483 return fCurrentSegmentation->ISector();
484}
485
486//______________________________________________________________________________
487Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
488{
489// Calculate sector from pad coordinates
490// ---
491
492 if (!Notify(detElemId)) return 0;
493
494 return fCurrentSegmentation->Sector(ix, iy);
495}
496
497//______________________________________________________________________________
498Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId,
499 Float_t xg, Float_t yg, Float_t zg)
500{
501// Calculate sector from pad coordinates
502// ---
503
504 if (!Notify(detElemId)) return 0;
505
506 Float_t xl, yl, zl;
507 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
508
509 return fCurrentSegmentation->Sector(xl, yl);
510}
511
512//______________________________________________________________________________
513void AliMUONGeometrySegmentation::IntegrationLimits(Int_t detElemId,
514 Float_t& x1, Float_t& x2,
515 Float_t& y1, Float_t& y2)
516{
517// Current integration limits
518// ---
519
520 if (!Notify(detElemId)) return;
521
522 return fCurrentSegmentation->IntegrationLimits(x1, x2, y1, y2);
523}
524
525//______________________________________________________________________________
526Int_t AliMUONGeometrySegmentation::SigGenCond(Int_t detElemId,
527 Float_t xg, Float_t yg, Float_t zg)
528{
529// Signal Generation Condition during Stepping
530// 0: don't generate signal
531// 1: generate signal
532// Comments:
533//
534// Crossing of pad boundary and mid plane between neighbouring wires is checked.
535// To correctly simulate the dependence of the spatial resolution on the angle
536// of incidence signal must be generated for constant steps on
537// the projection of the trajectory along the anode wire.
538//
539// Signal will be generated if particle crosses pad boundary or
540// boundary between two wires.
541// ---
542
543 if (!Notify(detElemId)) return 0;
544
545 Float_t xl, yl, zl;
546 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
547
548 return fCurrentSegmentation->SigGenCond(xl, yl, zl);
549 }
550
551
552//______________________________________________________________________________
553void AliMUONGeometrySegmentation::SigGenInit(Int_t detElemId,
554 Float_t xg, Float_t yg, Float_t zg)
555{
556// Initialise signal generation at coord (x,y,z)
557// Initialises pad and wire position during stepping.
558// From AliMUONGeometrySegmentationV01
559// ---
560
561 if (!Notify(detElemId)) return;
562
563 Float_t xl, yl, zl;
564 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
565
566 fCurrentSegmentation->SigGenInit(xl, yl, zl);
567}
568
569//______________________________________________________________________________
570void AliMUONGeometrySegmentation::GiveTestPoints(Int_t /*detElemId*/,
571 Int_t& /*n*/,
572 Float_t* /*xg*/, Float_t* /*yg*/) const
573{
574// Test points for auto calibration
575// Returns test point on the pad plane.
576// Used during determination of the segmoid correction of the COG-method
577// From AliMUONGeometrySegmentationV01
578// ---
579
580 // Requires change of interface
581 // to convert points from local to global we need z coordinate
582 AliError("Not implemented.");
583}
584
585//______________________________________________________________________________
586void AliMUONGeometrySegmentation::Draw(Int_t detElemId, const char* opt) const
587{
588// Draw the segmentation zones.
589// (Called from AliMUON::BuildGeometry)
590// ---
591
592 if (!Notify(detElemId)) return;
593
594 fCurrentSegmentation->Draw(opt);
595}
596
597//______________________________________________________________________________
598void AliMUONGeometrySegmentation::SetCorrFunc(Int_t detElemId,
599 Int_t isec, TF1* func)
600{
601// Set the correction function.
602// From AliMUONGeometrySegmentationV01
603// ---
604
605 if (!Notify(detElemId)) return;
606
607 fCurrentSegmentation->SetCorrFunc(isec, func);
608}
609
610//______________________________________________________________________________
611TF1* AliMUONGeometrySegmentation::CorrFunc(Int_t detElemId, Int_t isec) const
612{
613// Get the correction Function.
614// From AliMUONGeometrySegmentationV01
615// ---
616
617 if (!Notify(detElemId)) return 0;
618
619 return fCurrentSegmentation->CorrFunc(isec);
620}
621