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