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