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