]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONGeometrySegmentation.cxx
math.h declares fmod (Alpha)
[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{
e9981d13 156// Return direction with a constant pad size
157// (Direction or coordinate where the resolution is the best)
6b1e4b22 158
159 if (!Notify(detElemId)) return kDirUndefined;
160
161 return fCurrentSegmentation->GetDirection();
162}
163
e118b27e 164//______________________________________________________________________________
165void AliMUONGeometrySegmentation::SetPadSize(Float_t p1, Float_t p2)
166{
167// Set pad size Dx*Dy to all detection element segmentations
168// ---
169
170 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
e0a49962 171 AliMUONVGeometryDESegmentation* segmentation
172 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
e118b27e 173 segmentation->SetPadSize(p1, p2);
174 }
175}
176
177//______________________________________________________________________________
178void AliMUONGeometrySegmentation::SetDAnod(Float_t d)
179{
180// Set anod pitch to all detection element segmentations
181// ---
182
183 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
e0a49962 184 AliMUONVGeometryDESegmentation* segmentation
185 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
e118b27e 186 segmentation->SetDAnod(d);
187 }
188}
189
190//______________________________________________________________________________
191Float_t AliMUONGeometrySegmentation::GetAnod(Int_t detElemId, Float_t xhit) const
192{
193// Anod wire coordinate closest to xhit
194// Returns for a hit position xhit the position of the nearest anode wire
195// !!! xhit is understand a a distance, not as a position in the space
196// CHECK
197// ---
198
199 if (!Notify(detElemId)) return 0;
200
201 return fCurrentSegmentation->GetAnod(xhit);
202}
203
204//______________________________________________________________________________
e0a49962 205Bool_t AliMUONGeometrySegmentation::GetPadI(Int_t detElemId,
e118b27e 206 Float_t xg, Float_t yg, Float_t zg,
207 Int_t& ix, Int_t& iy)
208{
209// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
210// ---
211
e0a49962 212 if (!Notify(detElemId)) return false;
213
214 if (!fCurrentSegmentation->HasPad(xg, yg, zg)) return false;
e118b27e 215
216 Float_t xl, yl, zl;
217 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
218
219 fCurrentSegmentation->GetPadI(xl, yl, zl, ix, iy);
e0a49962 220 return true;
e118b27e 221}
222
223//______________________________________________________________________________
e0a49962 224Bool_t AliMUONGeometrySegmentation::GetPadC(Int_t detElemId,
e118b27e 225 Int_t ix, Int_t iy,
226 Float_t& xg, Float_t& yg, Float_t& zg)
227{
228// Transform from pad to real coordinates
229// ---
230
e0a49962 231 if (!Notify(detElemId)) return false;
232
233 if (!fCurrentSegmentation->HasPad(ix, iy)) return false;
e118b27e 234
235 Float_t xl, yl, zl;
236 fCurrentSegmentation->GetPadC(ix, iy, xl , yl, zl);
237
238 fGeometryModule->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
e0a49962 239 return true;
e118b27e 240}
241
242
243//______________________________________________________________________________
244void AliMUONGeometrySegmentation::Init(Int_t /*chamber*/)
245{
246// Initialize segmentation.
247// Check that all detection elements have segmanetation set
248// ---
249
250 // Loop over detection elements
251 AliMUONGeometryStore* detElements = fGeometryModule->GetDetElementStore();
252
253 for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
254
255 // Get detction element Id
256 Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
257
258 // Check segmentation
259 if (! fDESegmentations->Get(detElemId) )
260 AliError(Form("Detection element %d has not a segmentation set.",
261 detElements->GetEntry(i)->GetUniqueID()));
262 }
263}
264
265//______________________________________________________________________________
266Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId) const
267{
268// Get pad size in x
269// ---
270
271 if (!Notify(detElemId)) return 0.;
272
273 return fCurrentSegmentation->Dpx();
274}
275
276//______________________________________________________________________________
277Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId) const
278{
279// Get pad size in y
280// ---
281
282 if (!Notify(detElemId)) return 0.;
283
284 return fCurrentSegmentation->Dpy();
285}
286
287//______________________________________________________________________________
288Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
289{
290// Pad size in x by sector
291// ---
292
293 if (!Notify(detElemId)) return 0.;
294
295 return fCurrentSegmentation->Dpx(isector);
296}
297
298//______________________________________________________________________________
299Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
300{
301// Pad size in x, y by Sector
302// ---
303
304 if (!Notify(detElemId)) return 0.;
305
306 return fCurrentSegmentation->Dpy(isector);
307}
308
309//______________________________________________________________________________
310Int_t AliMUONGeometrySegmentation::Npx(Int_t detElemId) const
311{
312// Maximum number of Pads in x
313// ---
314
315 if (!Notify(detElemId)) return 0;
316
317 return fCurrentSegmentation->Npx();
318}
319
320//______________________________________________________________________________
321Int_t AliMUONGeometrySegmentation::Npy(Int_t detElemId) const
322{
323// Maximum number of Pads in y
324// ---
325
326 if (!Notify(detElemId)) return 0;
327
328 return fCurrentSegmentation->Npy();
329}
330
331//______________________________________________________________________________
332void AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
333{
334// Set pad position.
335// Sets virtual pad coordinates, needed for evaluating pad response
336// outside the tracking program.
337// From AliMUONGeometrySegmentationV01.
338// ---
339
340 if (!Notify(detElemId)) return;
341
342 fCurrentSegmentation->SetPad(ix, iy);
343}
344
345//______________________________________________________________________________
346void AliMUONGeometrySegmentation::SetHit(Int_t detElemId,
347 Float_t xghit, Float_t yghit, Float_t zghit)
348{
349// Set hit position
350// Sets virtual hit position, needed for evaluating pad response
351// outside the tracking program
352// From AliMUONGeometrySegmentationV01.
353
354 if (!Notify(detElemId)) return;
355
356 Float_t xl, yl, zl;
357 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
358
359 fCurrentSegmentation->SetHit(xl, yl, zl);
360}
361
362//______________________________________________________________________________
363void AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
364 Float_t xghit, Float_t yghit, Float_t zghit,
365 Float_t dx, Float_t dy)
366{
367// Iterate over pads - initialiser
368// ---
369
370 if (!Notify(detElemId)) return;
371
372 Float_t xl, yl, zl;
373 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
374
375 fCurrentSegmentation->FirstPad(xl, yl, zl, dx, dy);
376}
377
378//______________________________________________________________________________
379void AliMUONGeometrySegmentation::NextPad(Int_t detElemId)
380{
381// Iterate over pads - stepper
382// ---
383
384 if (!Notify(detElemId)) return;
385
386 fCurrentSegmentation->NextPad();
387}
388
389//______________________________________________________________________________
390Int_t AliMUONGeometrySegmentation::MorePads(Int_t detElemId)
391{
392// Iterate over pads - condition
393// ---
394
395 if (!Notify(detElemId)) return 0;
396
397 return fCurrentSegmentation->MorePads();
398}
399
400//______________________________________________________________________________
401Float_t AliMUONGeometrySegmentation::Distance2AndOffset(Int_t detElemId,
402 Int_t ix, Int_t iy,
403 Float_t xg, Float_t yg, Float_t zg,
404 Int_t* dummy)
405{
406// Returns the square of the distance between 1 pad
407// labelled by its channel numbers and a coordinate
408// ---
409
410 if (!Notify(detElemId)) return 0.;
411
412 Float_t xl, yl, zl;
413 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
414
415 return fCurrentSegmentation->Distance2AndOffset(ix, iy, xl, yl, dummy);
416}
417
418//______________________________________________________________________________
419void AliMUONGeometrySegmentation::GetNParallelAndOffset(Int_t detElemId,
420 Int_t ix, Int_t iy,
421 Int_t* nparallel, Int_t* offset)
422{
423// Number of pads read in parallel and offset to add to x
424// (specific to LYON, but mandatory for display)
425// CHECK
426// ---
427
428 if (!Notify(detElemId)) return;
429
430 fCurrentSegmentation->GetNParallelAndOffset(ix, iy, nparallel, offset);
431}
432
433
434//______________________________________________________________________________
435void AliMUONGeometrySegmentation::Neighbours(Int_t detElemId,
436 Int_t ix, Int_t iy,
437 Int_t* nlist,
438 Int_t xlist[10], Int_t ylist[10])
439{
440// Get next neighbours
441// ---
442
443 if (!Notify(detElemId)) return;
444
445 fCurrentSegmentation->Neighbours(ix, iy, nlist, xlist, ylist);
446}
447
448//______________________________________________________________________________
449Int_t AliMUONGeometrySegmentation::Ix()
450{
451// Current pad cursor during disintegration
452// x, y-coordinate
453// ---
454
455 return fCurrentSegmentation->Ix();
456}
457
458//______________________________________________________________________________
459Int_t AliMUONGeometrySegmentation::Iy()
460{
461// Current pad cursor during disintegration
462// x, y-coordinate
463// ---
464
465 return fCurrentSegmentation->Iy();
466}
467
468//______________________________________________________________________________
469Int_t AliMUONGeometrySegmentation::DetElemId()
470{
471// Current pad cursor during disintegration
472// x, y-coordinate
473// ---
474
475 return fCurrentDetElemId;
476}
477
478//______________________________________________________________________________
479Int_t AliMUONGeometrySegmentation::ISector()
480{
481// Current sector
482// ---
483
484 return fCurrentSegmentation->ISector();
485}
486
487//______________________________________________________________________________
488Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
489{
490// Calculate sector from pad coordinates
491// ---
492
493 if (!Notify(detElemId)) return 0;
494
495 return fCurrentSegmentation->Sector(ix, iy);
496}
497
498//______________________________________________________________________________
499Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId,
500 Float_t xg, Float_t yg, Float_t zg)
501{
502// Calculate sector from pad coordinates
503// ---
504
505 if (!Notify(detElemId)) return 0;
506
507 Float_t xl, yl, zl;
508 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
509
510 return fCurrentSegmentation->Sector(xl, yl);
511}
512
513//______________________________________________________________________________
514void AliMUONGeometrySegmentation::IntegrationLimits(Int_t detElemId,
515 Float_t& x1, Float_t& x2,
516 Float_t& y1, Float_t& y2)
517{
518// Current integration limits
519// ---
520
521 if (!Notify(detElemId)) return;
522
523 return fCurrentSegmentation->IntegrationLimits(x1, x2, y1, y2);
524}
525
526//______________________________________________________________________________
527Int_t AliMUONGeometrySegmentation::SigGenCond(Int_t detElemId,
528 Float_t xg, Float_t yg, Float_t zg)
529{
530// Signal Generation Condition during Stepping
531// 0: don't generate signal
532// 1: generate signal
533// Comments:
534//
535// Crossing of pad boundary and mid plane between neighbouring wires is checked.
536// To correctly simulate the dependence of the spatial resolution on the angle
537// of incidence signal must be generated for constant steps on
538// the projection of the trajectory along the anode wire.
539//
540// Signal will be generated if particle crosses pad boundary or
541// boundary between two wires.
542// ---
543
544 if (!Notify(detElemId)) return 0;
545
546 Float_t xl, yl, zl;
547 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
548
549 return fCurrentSegmentation->SigGenCond(xl, yl, zl);
550 }
551
552
553//______________________________________________________________________________
554void AliMUONGeometrySegmentation::SigGenInit(Int_t detElemId,
555 Float_t xg, Float_t yg, Float_t zg)
556{
557// Initialise signal generation at coord (x,y,z)
558// Initialises pad and wire position during stepping.
559// From AliMUONGeometrySegmentationV01
560// ---
561
562 if (!Notify(detElemId)) return;
563
564 Float_t xl, yl, zl;
565 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
566
567 fCurrentSegmentation->SigGenInit(xl, yl, zl);
568}
569
570//______________________________________________________________________________
571void AliMUONGeometrySegmentation::GiveTestPoints(Int_t /*detElemId*/,
572 Int_t& /*n*/,
573 Float_t* /*xg*/, Float_t* /*yg*/) const
574{
575// Test points for auto calibration
576// Returns test point on the pad plane.
577// Used during determination of the segmoid correction of the COG-method
578// From AliMUONGeometrySegmentationV01
579// ---
580
581 // Requires change of interface
582 // to convert points from local to global we need z coordinate
583 AliError("Not implemented.");
584}
585
586//______________________________________________________________________________
587void AliMUONGeometrySegmentation::Draw(Int_t detElemId, const char* opt) const
588{
589// Draw the segmentation zones.
590// (Called from AliMUON::BuildGeometry)
591// ---
592
593 if (!Notify(detElemId)) return;
594
595 fCurrentSegmentation->Draw(opt);
596}
597
598//______________________________________________________________________________
599void AliMUONGeometrySegmentation::SetCorrFunc(Int_t detElemId,
600 Int_t isec, TF1* func)
601{
602// Set the correction function.
603// From AliMUONGeometrySegmentationV01
604// ---
605
606 if (!Notify(detElemId)) return;
607
608 fCurrentSegmentation->SetCorrFunc(isec, func);
609}
610
611//______________________________________________________________________________
612TF1* AliMUONGeometrySegmentation::CorrFunc(Int_t detElemId, Int_t isec) const
613{
614// Get the correction Function.
615// From AliMUONGeometrySegmentationV01
616// ---
617
618 if (!Notify(detElemId)) return 0;
619
620 return fCurrentSegmentation->CorrFunc(isec);
621}
622