1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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.
23 // Author:Ivana Hrivnacova, IPN Orsay
27 #include "AliMUONGeometrySegmentation.h"
28 #include "AliMUONVGeometryDESegmentation.h"
29 #include "AliMUONGeometryModule.h"
30 #include "AliMUONGeometryDetElement.h"
31 #include "AliMUONGeometryStore.h"
34 ClassImp(AliMUONGeometrySegmentation)
37 //______________________________________________________________________________
38 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
39 AliMUONGeometryModule* geometry)
42 fCurrentDetElement(0),
43 fCurrentSegmentation(0),
44 fGeometryModule(geometry),
51 = new AliMUONGeometryStore(geometry->GetDEIndexing(), false);
54 //______________________________________________________________________________
55 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation()
58 fCurrentDetElement(0),
59 fCurrentSegmentation(0),
63 // Default Constructor
66 //______________________________________________________________________________
67 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
68 const AliMUONGeometrySegmentation& rhs)
72 AliFatal("Copy constructor is not implemented.");
75 //______________________________________________________________________________
76 AliMUONGeometrySegmentation::~AliMUONGeometrySegmentation() {
79 delete fDESegmentations;
86 //______________________________________________________________________________
87 AliMUONGeometrySegmentation&
88 AliMUONGeometrySegmentation::operator=(const AliMUONGeometrySegmentation& rhs)
92 // check assignement to self
93 if (this == &rhs) return *this;
95 AliFatal("Assignment operator is not implemented.");
104 //______________________________________________________________________________
105 Bool_t AliMUONGeometrySegmentation::Notify(Int_t detElemId) const
107 // Updates current detection element and segmentation,
108 // and checks if they exist.
109 // Returns true if success.
112 if (detElemId != fCurrentDetElemId) {
114 // Find detection element and its segmentation
115 AliMUONGeometryDetElement* detElement
116 = fGeometryModule->GetDetElement(detElemId);
118 AliError(Form("Detection element %d not defined", detElemId));
122 AliMUONVGeometryDESegmentation* segmentation
123 = (AliMUONVGeometryDESegmentation*) fDESegmentations->Get(detElemId);
125 AliError(Form("Segmentation for detection element %d not defined",
130 fCurrentDetElemId = detElemId;
131 fCurrentDetElement = detElement;
132 fCurrentSegmentation = segmentation;
142 //______________________________________________________________________________
143 void AliMUONGeometrySegmentation::Add(Int_t detElemId,
144 AliMUONVGeometryDESegmentation* segmentation)
146 // Add detection element segmentation
149 fDESegmentations->Add(detElemId, segmentation);
152 //______________________________________________________________________________
153 AliMUONGeometryDirection
154 AliMUONGeometrySegmentation::GetDirection(Int_t detElemId) const
156 // Return direction with a constant pad size
157 // (Direction or coordinate where the resolution is the best)
159 if (!Notify(detElemId)) return kDirUndefined;
161 return fCurrentSegmentation->GetDirection();
164 //______________________________________________________________________________
165 void AliMUONGeometrySegmentation::SetPadSize(Float_t p1, Float_t p2)
167 // Set pad size Dx*Dy to all detection element segmentations
170 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
171 AliMUONVGeometryDESegmentation* segmentation
172 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
173 segmentation->SetPadSize(p1, p2);
177 //______________________________________________________________________________
178 void AliMUONGeometrySegmentation::SetDAnod(Float_t d)
180 // Set anod pitch to all detection element segmentations
183 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
184 AliMUONVGeometryDESegmentation* segmentation
185 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
186 segmentation->SetDAnod(d);
190 //______________________________________________________________________________
191 Float_t AliMUONGeometrySegmentation::GetAnod(Int_t detElemId, Float_t xhit) const
193 // Anod wire coordinate closest to xhit
194 // Returns for a hit position xhit the position of the nearest anode wire
195 // !!! xhit is understand a a distance, not as a position in the space
199 if (!Notify(detElemId)) return 0;
201 return fCurrentSegmentation->GetAnod(xhit);
204 //______________________________________________________________________________
205 Bool_t AliMUONGeometrySegmentation::GetPadI(Int_t detElemId,
206 Float_t xg, Float_t yg, Float_t zg,
207 Int_t& ix, Int_t& iy)
209 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
212 if (!Notify(detElemId)) return false;
214 if (!fCurrentSegmentation->HasPad(xg, yg, zg)) return false;
217 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
219 fCurrentSegmentation->GetPadI(xl, yl, zl, ix, iy);
223 //______________________________________________________________________________
224 Bool_t AliMUONGeometrySegmentation::GetPadC(Int_t detElemId,
226 Float_t& xg, Float_t& yg, Float_t& zg)
228 // Transform from pad to real coordinates
231 if (!Notify(detElemId)) return false;
233 if (!fCurrentSegmentation->HasPad(ix, iy)) return false;
236 fCurrentSegmentation->GetPadC(ix, iy, xl , yl, zl);
238 fGeometryModule->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
243 //______________________________________________________________________________
244 void AliMUONGeometrySegmentation::Init(Int_t /*chamber*/)
246 // Initialize segmentation.
247 // Check that all detection elements have segmanetation set
250 // Loop over detection elements
251 AliMUONGeometryStore* detElements = fGeometryModule->GetDetElementStore();
253 for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
255 // Get detction element Id
256 Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
258 // Check segmentation
259 if (! fDESegmentations->Get(detElemId) )
260 AliError(Form("Detection element %d has not a segmentation set.",
261 detElements->GetEntry(i)->GetUniqueID()));
265 //______________________________________________________________________________
266 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId) const
271 if (!Notify(detElemId)) return 0.;
273 return fCurrentSegmentation->Dpx();
276 //______________________________________________________________________________
277 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId) const
282 if (!Notify(detElemId)) return 0.;
284 return fCurrentSegmentation->Dpy();
287 //______________________________________________________________________________
288 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
290 // Pad size in x by sector
293 if (!Notify(detElemId)) return 0.;
295 return fCurrentSegmentation->Dpx(isector);
298 //______________________________________________________________________________
299 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
301 // Pad size in x, y by Sector
304 if (!Notify(detElemId)) return 0.;
306 return fCurrentSegmentation->Dpy(isector);
309 //______________________________________________________________________________
310 Int_t AliMUONGeometrySegmentation::Npx(Int_t detElemId) const
312 // Maximum number of Pads in x
315 if (!Notify(detElemId)) return 0;
317 return fCurrentSegmentation->Npx();
320 //______________________________________________________________________________
321 Int_t AliMUONGeometrySegmentation::Npy(Int_t detElemId) const
323 // Maximum number of Pads in y
326 if (!Notify(detElemId)) return 0;
328 return fCurrentSegmentation->Npy();
331 //______________________________________________________________________________
332 void AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
335 // Sets virtual pad coordinates, needed for evaluating pad response
336 // outside the tracking program.
337 // From AliMUONGeometrySegmentationV01.
340 if (!Notify(detElemId)) return;
342 fCurrentSegmentation->SetPad(ix, iy);
345 //______________________________________________________________________________
346 void AliMUONGeometrySegmentation::SetHit(Int_t detElemId,
347 Float_t xghit, Float_t yghit, Float_t zghit)
350 // Sets virtual hit position, needed for evaluating pad response
351 // outside the tracking program
352 // From AliMUONGeometrySegmentationV01.
354 if (!Notify(detElemId)) return;
357 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
359 fCurrentSegmentation->SetHit(xl, yl, zl);
362 //______________________________________________________________________________
363 void AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
364 Float_t xghit, Float_t yghit, Float_t zghit,
365 Float_t dx, Float_t dy)
367 // Iterate over pads - initialiser
370 if (!Notify(detElemId)) return;
373 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
375 fCurrentSegmentation->FirstPad(xl, yl, zl, dx, dy);
378 //______________________________________________________________________________
379 void AliMUONGeometrySegmentation::NextPad(Int_t detElemId)
381 // Iterate over pads - stepper
384 if (!Notify(detElemId)) return;
386 fCurrentSegmentation->NextPad();
389 //______________________________________________________________________________
390 Int_t AliMUONGeometrySegmentation::MorePads(Int_t detElemId)
392 // Iterate over pads - condition
395 if (!Notify(detElemId)) return 0;
397 return fCurrentSegmentation->MorePads();
400 //______________________________________________________________________________
401 Float_t AliMUONGeometrySegmentation::Distance2AndOffset(Int_t detElemId,
403 Float_t xg, Float_t yg, Float_t zg,
406 // Returns the square of the distance between 1 pad
407 // labelled by its channel numbers and a coordinate
410 if (!Notify(detElemId)) return 0.;
413 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
415 return fCurrentSegmentation->Distance2AndOffset(ix, iy, xl, yl, dummy);
418 //______________________________________________________________________________
419 void AliMUONGeometrySegmentation::GetNParallelAndOffset(Int_t detElemId,
421 Int_t* nparallel, Int_t* offset)
423 // Number of pads read in parallel and offset to add to x
424 // (specific to LYON, but mandatory for display)
428 if (!Notify(detElemId)) return;
430 fCurrentSegmentation->GetNParallelAndOffset(ix, iy, nparallel, offset);
434 //______________________________________________________________________________
435 void AliMUONGeometrySegmentation::Neighbours(Int_t detElemId,
438 Int_t xlist[10], Int_t ylist[10])
440 // Get next neighbours
443 if (!Notify(detElemId)) return;
445 fCurrentSegmentation->Neighbours(ix, iy, nlist, xlist, ylist);
448 //______________________________________________________________________________
449 Int_t AliMUONGeometrySegmentation::Ix()
451 // Current pad cursor during disintegration
455 return fCurrentSegmentation->Ix();
458 //______________________________________________________________________________
459 Int_t AliMUONGeometrySegmentation::Iy()
461 // Current pad cursor during disintegration
465 return fCurrentSegmentation->Iy();
468 //______________________________________________________________________________
469 Int_t AliMUONGeometrySegmentation::DetElemId()
471 // Current pad cursor during disintegration
475 return fCurrentDetElemId;
478 //______________________________________________________________________________
479 Int_t AliMUONGeometrySegmentation::ISector()
484 return fCurrentSegmentation->ISector();
487 //______________________________________________________________________________
488 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
490 // Calculate sector from pad coordinates
493 if (!Notify(detElemId)) return 0;
495 return fCurrentSegmentation->Sector(ix, iy);
498 //______________________________________________________________________________
499 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId,
500 Float_t xg, Float_t yg, Float_t zg)
502 // Calculate sector from pad coordinates
505 if (!Notify(detElemId)) return 0;
508 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
510 return fCurrentSegmentation->Sector(xl, yl);
513 //______________________________________________________________________________
514 void AliMUONGeometrySegmentation::IntegrationLimits(Int_t detElemId,
515 Float_t& x1, Float_t& x2,
516 Float_t& y1, Float_t& y2)
518 // Current integration limits
521 if (!Notify(detElemId)) return;
523 return fCurrentSegmentation->IntegrationLimits(x1, x2, y1, y2);
526 //______________________________________________________________________________
527 Int_t AliMUONGeometrySegmentation::SigGenCond(Int_t detElemId,
528 Float_t xg, Float_t yg, Float_t zg)
530 // Signal Generation Condition during Stepping
531 // 0: don't generate signal
532 // 1: generate signal
535 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
536 // To correctly simulate the dependence of the spatial resolution on the angle
537 // of incidence signal must be generated for constant steps on
538 // the projection of the trajectory along the anode wire.
540 // Signal will be generated if particle crosses pad boundary or
541 // boundary between two wires.
544 if (!Notify(detElemId)) return 0;
547 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
549 return fCurrentSegmentation->SigGenCond(xl, yl, zl);
553 //______________________________________________________________________________
554 void AliMUONGeometrySegmentation::SigGenInit(Int_t detElemId,
555 Float_t xg, Float_t yg, Float_t zg)
557 // Initialise signal generation at coord (x,y,z)
558 // Initialises pad and wire position during stepping.
559 // From AliMUONGeometrySegmentationV01
562 if (!Notify(detElemId)) return;
565 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
567 fCurrentSegmentation->SigGenInit(xl, yl, zl);
570 //______________________________________________________________________________
571 void AliMUONGeometrySegmentation::GiveTestPoints(Int_t /*detElemId*/,
573 Float_t* /*xg*/, Float_t* /*yg*/) const
575 // Test points for auto calibration
576 // Returns test point on the pad plane.
577 // Used during determination of the segmoid correction of the COG-method
578 // From AliMUONGeometrySegmentationV01
581 // Requires change of interface
582 // to convert points from local to global we need z coordinate
583 AliError("Not implemented.");
586 //______________________________________________________________________________
587 void AliMUONGeometrySegmentation::Draw(Int_t detElemId, const char* opt) const
589 // Draw the segmentation zones.
590 // (Called from AliMUON::BuildGeometry)
593 if (!Notify(detElemId)) return;
595 fCurrentSegmentation->Draw(opt);
598 //______________________________________________________________________________
599 void AliMUONGeometrySegmentation::SetCorrFunc(Int_t detElemId,
600 Int_t isec, TF1* func)
602 // Set the correction function.
603 // From AliMUONGeometrySegmentationV01
606 if (!Notify(detElemId)) return;
608 fCurrentSegmentation->SetCorrFunc(isec, func);
611 //______________________________________________________________________________
612 TF1* AliMUONGeometrySegmentation::CorrFunc(Int_t detElemId, Int_t isec) const
614 // Get the correction Function.
615 // From AliMUONGeometrySegmentationV01
618 if (!Notify(detElemId)) return 0;
620 return fCurrentSegmentation->CorrFunc(isec);