]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONGeometrySegmentation.cxx
remove obsolete flange (Pascal)
[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"
36
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
245
246//______________________________________________________________________________
75b9419c 247void AliMUONGeometrySegmentation::Init(Int_t chamber)
e118b27e 248{
249// Initialize segmentation.
250// Check that all detection elements have segmanetation set
251// ---
252
253 // Loop over detection elements
254 AliMUONGeometryStore* detElements = fGeometryModule->GetDetElementStore();
255
256 for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
257
258 // Get detction element Id
259 Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
260
261 // Check segmentation
75b9419c 262 if (! fDESegmentations->Get(detElemId) ) {
e118b27e 263 AliError(Form("Detection element %d has not a segmentation set.",
75b9419c 264 detElements->GetEntry(i)->GetUniqueID()));
265 }
266 else {
267 // Initialize DE Segmentation
268 ((AliSegmentation*)fDESegmentations->Get(detElemId))->Init(chamber);
269 }
e118b27e 270 }
271}
272
273//______________________________________________________________________________
274Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId) const
275{
276// Get pad size in x
277// ---
278
4ebc2323 279 if (!OwnNotify(detElemId)) return 0.;
e118b27e 280
281 return fCurrentSegmentation->Dpx();
282}
283
284//______________________________________________________________________________
285Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId) const
286{
287// Get pad size in y
288// ---
289
4ebc2323 290 if (!OwnNotify(detElemId)) return 0.;
e118b27e 291
292 return fCurrentSegmentation->Dpy();
293}
294
295//______________________________________________________________________________
296Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
297{
298// Pad size in x by sector
299// ---
300
4ebc2323 301 if (!OwnNotify(detElemId)) return 0.;
e118b27e 302
303 return fCurrentSegmentation->Dpx(isector);
304}
305
306//______________________________________________________________________________
307Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
308{
309// Pad size in x, y by Sector
310// ---
311
4ebc2323 312 if (!OwnNotify(detElemId)) return 0.;
e118b27e 313
314 return fCurrentSegmentation->Dpy(isector);
315}
316
317//______________________________________________________________________________
318Int_t AliMUONGeometrySegmentation::Npx(Int_t detElemId) const
319{
320// Maximum number of Pads in x
321// ---
322
4ebc2323 323 if (!OwnNotify(detElemId)) return 0;
e118b27e 324
325 return fCurrentSegmentation->Npx();
326}
327
328//______________________________________________________________________________
329Int_t AliMUONGeometrySegmentation::Npy(Int_t detElemId) const
330{
331// Maximum number of Pads in y
332// ---
333
4ebc2323 334 if (!OwnNotify(detElemId)) return 0;
e118b27e 335
336 return fCurrentSegmentation->Npy();
337}
338
339//______________________________________________________________________________
340void AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
341{
342// Set pad position.
343// Sets virtual pad coordinates, needed for evaluating pad response
344// outside the tracking program.
345// From AliMUONGeometrySegmentationV01.
346// ---
347
4ebc2323 348 if (!OwnNotify(detElemId)) return;
e118b27e 349
350 fCurrentSegmentation->SetPad(ix, iy);
351}
352
353//______________________________________________________________________________
354void AliMUONGeometrySegmentation::SetHit(Int_t detElemId,
355 Float_t xghit, Float_t yghit, Float_t zghit)
356{
357// Set hit position
358// Sets virtual hit position, needed for evaluating pad response
359// outside the tracking program
360// From AliMUONGeometrySegmentationV01.
361
4ebc2323 362 if (!OwnNotify(detElemId)) return;
e118b27e 363
364 Float_t xl, yl, zl;
365 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
366
367 fCurrentSegmentation->SetHit(xl, yl, zl);
368}
369
370//______________________________________________________________________________
371void AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
372 Float_t xghit, Float_t yghit, Float_t zghit,
373 Float_t dx, Float_t dy)
374{
375// Iterate over pads - initialiser
376// ---
377
4ebc2323 378 if (!OwnNotify(detElemId)) return;
e118b27e 379
380 Float_t xl, yl, zl;
381 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
382
383 fCurrentSegmentation->FirstPad(xl, yl, zl, dx, dy);
384}
385
386//______________________________________________________________________________
387void AliMUONGeometrySegmentation::NextPad(Int_t detElemId)
388{
389// Iterate over pads - stepper
390// ---
391
4ebc2323 392 if (!OwnNotify(detElemId)) return;
e118b27e 393
394 fCurrentSegmentation->NextPad();
395}
396
397//______________________________________________________________________________
398Int_t AliMUONGeometrySegmentation::MorePads(Int_t detElemId)
399{
400// Iterate over pads - condition
401// ---
402
4ebc2323 403 if (!OwnNotify(detElemId)) return 0;
e118b27e 404
405 return fCurrentSegmentation->MorePads();
406}
407
408//______________________________________________________________________________
409Float_t AliMUONGeometrySegmentation::Distance2AndOffset(Int_t detElemId,
410 Int_t ix, Int_t iy,
411 Float_t xg, Float_t yg, Float_t zg,
412 Int_t* dummy)
413{
414// Returns the square of the distance between 1 pad
415// labelled by its channel numbers and a coordinate
416// ---
417
4ebc2323 418 if (!OwnNotify(detElemId)) return 0.;
e118b27e 419
420 Float_t xl, yl, zl;
421 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
422
423 return fCurrentSegmentation->Distance2AndOffset(ix, iy, xl, yl, dummy);
424}
425
426//______________________________________________________________________________
427void AliMUONGeometrySegmentation::GetNParallelAndOffset(Int_t detElemId,
428 Int_t ix, Int_t iy,
429 Int_t* nparallel, Int_t* offset)
430{
431// Number of pads read in parallel and offset to add to x
432// (specific to LYON, but mandatory for display)
433// CHECK
434// ---
435
4ebc2323 436 if (!OwnNotify(detElemId)) return;
e118b27e 437
438 fCurrentSegmentation->GetNParallelAndOffset(ix, iy, nparallel, offset);
439}
440
441
442//______________________________________________________________________________
443void AliMUONGeometrySegmentation::Neighbours(Int_t detElemId,
444 Int_t ix, Int_t iy,
445 Int_t* nlist,
446 Int_t xlist[10], Int_t ylist[10])
447{
448// Get next neighbours
449// ---
450
4ebc2323 451 if (!OwnNotify(detElemId)) return;
e118b27e 452
453 fCurrentSegmentation->Neighbours(ix, iy, nlist, xlist, ylist);
454}
455
456//______________________________________________________________________________
457Int_t AliMUONGeometrySegmentation::Ix()
458{
459// Current pad cursor during disintegration
460// x, y-coordinate
461// ---
462
463 return fCurrentSegmentation->Ix();
464}
465
466//______________________________________________________________________________
467Int_t AliMUONGeometrySegmentation::Iy()
468{
469// Current pad cursor during disintegration
470// x, y-coordinate
471// ---
472
473 return fCurrentSegmentation->Iy();
474}
475
476//______________________________________________________________________________
477Int_t AliMUONGeometrySegmentation::DetElemId()
478{
479// Current pad cursor during disintegration
480// x, y-coordinate
481// ---
482
483 return fCurrentDetElemId;
484}
485
486//______________________________________________________________________________
487Int_t AliMUONGeometrySegmentation::ISector()
488{
489// Current sector
490// ---
491
492 return fCurrentSegmentation->ISector();
493}
494
495//______________________________________________________________________________
496Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
497{
498// Calculate sector from pad coordinates
499// ---
500
4ebc2323 501 if (!OwnNotify(detElemId)) return 0;
e118b27e 502
503 return fCurrentSegmentation->Sector(ix, iy);
504}
505
506//______________________________________________________________________________
507Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId,
508 Float_t xg, Float_t yg, Float_t zg)
509{
510// Calculate sector from pad coordinates
511// ---
512
4ebc2323 513 if (!OwnNotify(detElemId)) return 0;
e118b27e 514
515 Float_t xl, yl, zl;
516 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
517
518 return fCurrentSegmentation->Sector(xl, yl);
519}
520
521//______________________________________________________________________________
522void AliMUONGeometrySegmentation::IntegrationLimits(Int_t detElemId,
523 Float_t& x1, Float_t& x2,
524 Float_t& y1, Float_t& y2)
525{
526// Current integration limits
527// ---
528
4ebc2323 529 if (!OwnNotify(detElemId)) return;
e118b27e 530
7d54fd29 531 fCurrentSegmentation->IntegrationLimits(x1, x2, y1, y2);
e118b27e 532}
533
534//______________________________________________________________________________
535Int_t AliMUONGeometrySegmentation::SigGenCond(Int_t detElemId,
536 Float_t xg, Float_t yg, Float_t zg)
537{
538// Signal Generation Condition during Stepping
539// 0: don't generate signal
540// 1: generate signal
541// Comments:
542//
543// Crossing of pad boundary and mid plane between neighbouring wires is checked.
544// To correctly simulate the dependence of the spatial resolution on the angle
545// of incidence signal must be generated for constant steps on
546// the projection of the trajectory along the anode wire.
547//
548// Signal will be generated if particle crosses pad boundary or
549// boundary between two wires.
550// ---
551
4ebc2323 552 if (!OwnNotify(detElemId)) return 0;
e118b27e 553
554 Float_t xl, yl, zl;
555 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
556
557 return fCurrentSegmentation->SigGenCond(xl, yl, zl);
558 }
559
e118b27e 560//______________________________________________________________________________
561void AliMUONGeometrySegmentation::SigGenInit(Int_t detElemId,
562 Float_t xg, Float_t yg, Float_t zg)
563{
564// Initialise signal generation at coord (x,y,z)
565// Initialises pad and wire position during stepping.
566// From AliMUONGeometrySegmentationV01
567// ---
568
4ebc2323 569 if (!OwnNotify(detElemId)) return;
e118b27e 570
571 Float_t xl, yl, zl;
572 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
573
75b9419c 574 if (!fCurrentSegmentation->HasPad(xl, yl, zl)) {
575 AliWarningStream()
576 << "No pad at " << detElemId
577 << " global position: " << xg << " " << yg << " " << zg
578 << " local position: " << xl << " " << yl << " " << zl << endl;
579 return ;
580 }
581
e118b27e 582 fCurrentSegmentation->SigGenInit(xl, yl, zl);
583}
584
585//______________________________________________________________________________
586void AliMUONGeometrySegmentation::GiveTestPoints(Int_t /*detElemId*/,
587 Int_t& /*n*/,
588 Float_t* /*xg*/, Float_t* /*yg*/) const
589{
590// Test points for auto calibration
591// Returns test point on the pad plane.
592// Used during determination of the segmoid correction of the COG-method
593// From AliMUONGeometrySegmentationV01
594// ---
595
596 // Requires change of interface
597 // to convert points from local to global we need z coordinate
598 AliError("Not implemented.");
599}
600
601//______________________________________________________________________________
4ebc2323 602void AliMUONGeometrySegmentation::Draw(const char* opt)
603{
604// Draws the segmentation zones for all detElemId
605// ---
606
607 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
608 AliMUONVGeometryDESegmentation* segmentation
609 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
610 segmentation->Draw(opt);
611 }
612}
613
614//______________________________________________________________________________
615void AliMUONGeometrySegmentation::Draw(Int_t detElemId, const char* opt)
e118b27e 616{
4ebc2323 617// Draw the segmentation zones for a given detElemId.
e118b27e 618// ---
619
4ebc2323 620 if (!OwnNotify(detElemId)) return;
e118b27e 621
622 fCurrentSegmentation->Draw(opt);
623}
624
625//______________________________________________________________________________
626void AliMUONGeometrySegmentation::SetCorrFunc(Int_t detElemId,
627 Int_t isec, TF1* func)
628{
629// Set the correction function.
630// From AliMUONGeometrySegmentationV01
631// ---
632
4ebc2323 633 if (!OwnNotify(detElemId)) return;
e118b27e 634
635 fCurrentSegmentation->SetCorrFunc(isec, func);
636}
637
638//______________________________________________________________________________
639TF1* AliMUONGeometrySegmentation::CorrFunc(Int_t detElemId, Int_t isec) const
640{
641// Get the correction Function.
642// From AliMUONGeometrySegmentationV01
643// ---
644
4ebc2323 645 if (!OwnNotify(detElemId)) return 0;
e118b27e 646
647 return fCurrentSegmentation->CorrFunc(isec);
648}
649