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