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
25 #include "AliSegmentation.h"
28 #include "AliMUONGeometrySegmentation.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 AliSegmentation* segmentation
123 = (AliSegmentation*) 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 AliSegmentation* segmentation)
146 // Add detection element segmentation
149 fDESegmentations->Add(detElemId, segmentation);
152 //______________________________________________________________________________
153 void AliMUONGeometrySegmentation::SetPadSize(Float_t p1, Float_t p2)
155 // Set pad size Dx*Dy to all detection element segmentations
158 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
159 AliSegmentation* segmentation
160 = (AliSegmentation*)fDESegmentations->GetEntry(i);
161 segmentation->SetPadSize(p1, p2);
165 //______________________________________________________________________________
166 void AliMUONGeometrySegmentation::SetDAnod(Float_t d)
168 // Set anod pitch to all detection element segmentations
171 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
172 AliSegmentation* segmentation
173 = (AliSegmentation*)fDESegmentations->GetEntry(i);
174 segmentation->SetDAnod(d);
178 //______________________________________________________________________________
179 Float_t AliMUONGeometrySegmentation::GetAnod(Int_t detElemId, Float_t xhit) const
181 // Anod wire coordinate closest to xhit
182 // Returns for a hit position xhit the position of the nearest anode wire
183 // !!! xhit is understand a a distance, not as a position in the space
187 if (!Notify(detElemId)) return 0;
189 return fCurrentSegmentation->GetAnod(xhit);
192 //______________________________________________________________________________
193 void AliMUONGeometrySegmentation::GetPadI(Int_t detElemId,
194 Float_t xg, Float_t yg, Float_t zg,
195 Int_t& ix, Int_t& iy)
197 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
200 if (!Notify(detElemId)) return;
203 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
205 fCurrentSegmentation->GetPadI(xl, yl, zl, ix, iy);
208 //______________________________________________________________________________
209 void AliMUONGeometrySegmentation::GetPadC(Int_t detElemId,
211 Float_t& xg, Float_t& yg, Float_t& zg)
213 // Transform from pad to real coordinates
216 if (!Notify(detElemId)) return;
219 fCurrentSegmentation->GetPadC(ix, iy, xl , yl, zl);
221 fGeometryModule->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
225 //______________________________________________________________________________
226 void AliMUONGeometrySegmentation::Init(Int_t /*chamber*/)
228 // Initialize segmentation.
229 // Check that all detection elements have segmanetation set
232 // Loop over detection elements
233 AliMUONGeometryStore* detElements = fGeometryModule->GetDetElementStore();
235 for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
237 // Get detction element Id
238 Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
240 // Check segmentation
241 if (! fDESegmentations->Get(detElemId) )
242 AliError(Form("Detection element %d has not a segmentation set.",
243 detElements->GetEntry(i)->GetUniqueID()));
247 //______________________________________________________________________________
248 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId) const
253 if (!Notify(detElemId)) return 0.;
255 return fCurrentSegmentation->Dpx();
258 //______________________________________________________________________________
259 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId) const
264 if (!Notify(detElemId)) return 0.;
266 return fCurrentSegmentation->Dpy();
269 //______________________________________________________________________________
270 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
272 // Pad size in x by sector
275 if (!Notify(detElemId)) return 0.;
277 return fCurrentSegmentation->Dpx(isector);
280 //______________________________________________________________________________
281 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
283 // Pad size in x, y by Sector
286 if (!Notify(detElemId)) return 0.;
288 return fCurrentSegmentation->Dpy(isector);
291 //______________________________________________________________________________
292 Int_t AliMUONGeometrySegmentation::Npx(Int_t detElemId) const
294 // Maximum number of Pads in x
297 if (!Notify(detElemId)) return 0;
299 return fCurrentSegmentation->Npx();
302 //______________________________________________________________________________
303 Int_t AliMUONGeometrySegmentation::Npy(Int_t detElemId) const
305 // Maximum number of Pads in y
308 if (!Notify(detElemId)) return 0;
310 return fCurrentSegmentation->Npy();
313 //______________________________________________________________________________
314 void AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
317 // Sets virtual pad coordinates, needed for evaluating pad response
318 // outside the tracking program.
319 // From AliMUONGeometrySegmentationV01.
322 if (!Notify(detElemId)) return;
324 fCurrentSegmentation->SetPad(ix, iy);
327 //______________________________________________________________________________
328 void AliMUONGeometrySegmentation::SetHit(Int_t detElemId,
329 Float_t xghit, Float_t yghit, Float_t zghit)
332 // Sets virtual hit position, needed for evaluating pad response
333 // outside the tracking program
334 // From AliMUONGeometrySegmentationV01.
336 if (!Notify(detElemId)) return;
339 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
341 fCurrentSegmentation->SetHit(xl, yl, zl);
344 //______________________________________________________________________________
345 void AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
346 Float_t xghit, Float_t yghit, Float_t zghit,
347 Float_t dx, Float_t dy)
349 // Iterate over pads - initialiser
352 if (!Notify(detElemId)) return;
355 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
357 fCurrentSegmentation->FirstPad(xl, yl, zl, dx, dy);
360 //______________________________________________________________________________
361 void AliMUONGeometrySegmentation::NextPad(Int_t detElemId)
363 // Iterate over pads - stepper
366 if (!Notify(detElemId)) return;
368 fCurrentSegmentation->NextPad();
371 //______________________________________________________________________________
372 Int_t AliMUONGeometrySegmentation::MorePads(Int_t detElemId)
374 // Iterate over pads - condition
377 if (!Notify(detElemId)) return 0;
379 return fCurrentSegmentation->MorePads();
382 //______________________________________________________________________________
383 Float_t AliMUONGeometrySegmentation::Distance2AndOffset(Int_t detElemId,
385 Float_t xg, Float_t yg, Float_t zg,
388 // Returns the square of the distance between 1 pad
389 // labelled by its channel numbers and a coordinate
392 if (!Notify(detElemId)) return 0.;
395 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
397 return fCurrentSegmentation->Distance2AndOffset(ix, iy, xl, yl, dummy);
400 //______________________________________________________________________________
401 void AliMUONGeometrySegmentation::GetNParallelAndOffset(Int_t detElemId,
403 Int_t* nparallel, Int_t* offset)
405 // Number of pads read in parallel and offset to add to x
406 // (specific to LYON, but mandatory for display)
410 if (!Notify(detElemId)) return;
412 fCurrentSegmentation->GetNParallelAndOffset(ix, iy, nparallel, offset);
416 //______________________________________________________________________________
417 void AliMUONGeometrySegmentation::Neighbours(Int_t detElemId,
420 Int_t xlist[10], Int_t ylist[10])
422 // Get next neighbours
425 if (!Notify(detElemId)) return;
427 fCurrentSegmentation->Neighbours(ix, iy, nlist, xlist, ylist);
430 //______________________________________________________________________________
431 Int_t AliMUONGeometrySegmentation::Ix()
433 // Current pad cursor during disintegration
437 return fCurrentSegmentation->Ix();
440 //______________________________________________________________________________
441 Int_t AliMUONGeometrySegmentation::Iy()
443 // Current pad cursor during disintegration
447 return fCurrentSegmentation->Iy();
450 //______________________________________________________________________________
451 Int_t AliMUONGeometrySegmentation::DetElemId()
453 // Current pad cursor during disintegration
457 return fCurrentDetElemId;
460 //______________________________________________________________________________
461 Int_t AliMUONGeometrySegmentation::ISector()
466 return fCurrentSegmentation->ISector();
469 //______________________________________________________________________________
470 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
472 // Calculate sector from pad coordinates
475 if (!Notify(detElemId)) return 0;
477 return fCurrentSegmentation->Sector(ix, iy);
480 //______________________________________________________________________________
481 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId,
482 Float_t xg, Float_t yg, Float_t zg)
484 // Calculate sector from pad coordinates
487 if (!Notify(detElemId)) return 0;
490 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
492 return fCurrentSegmentation->Sector(xl, yl);
495 //______________________________________________________________________________
496 void AliMUONGeometrySegmentation::IntegrationLimits(Int_t detElemId,
497 Float_t& x1, Float_t& x2,
498 Float_t& y1, Float_t& y2)
500 // Current integration limits
503 if (!Notify(detElemId)) return;
505 return fCurrentSegmentation->IntegrationLimits(x1, x2, y1, y2);
508 //______________________________________________________________________________
509 Int_t AliMUONGeometrySegmentation::SigGenCond(Int_t detElemId,
510 Float_t xg, Float_t yg, Float_t zg)
512 // Signal Generation Condition during Stepping
513 // 0: don't generate signal
514 // 1: generate signal
517 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
518 // To correctly simulate the dependence of the spatial resolution on the angle
519 // of incidence signal must be generated for constant steps on
520 // the projection of the trajectory along the anode wire.
522 // Signal will be generated if particle crosses pad boundary or
523 // boundary between two wires.
526 if (!Notify(detElemId)) return 0;
529 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
531 return fCurrentSegmentation->SigGenCond(xl, yl, zl);
535 //______________________________________________________________________________
536 void AliMUONGeometrySegmentation::SigGenInit(Int_t detElemId,
537 Float_t xg, Float_t yg, Float_t zg)
539 // Initialise signal generation at coord (x,y,z)
540 // Initialises pad and wire position during stepping.
541 // From AliMUONGeometrySegmentationV01
544 if (!Notify(detElemId)) return;
547 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
549 fCurrentSegmentation->SigGenInit(xl, yl, zl);
552 //______________________________________________________________________________
553 void AliMUONGeometrySegmentation::GiveTestPoints(Int_t /*detElemId*/,
555 Float_t* /*xg*/, Float_t* /*yg*/) const
557 // Test points for auto calibration
558 // Returns test point on the pad plane.
559 // Used during determination of the segmoid correction of the COG-method
560 // From AliMUONGeometrySegmentationV01
563 // Requires change of interface
564 // to convert points from local to global we need z coordinate
565 AliError("Not implemented.");
568 //______________________________________________________________________________
569 void AliMUONGeometrySegmentation::Draw(Int_t detElemId, const char* opt) const
571 // Draw the segmentation zones.
572 // (Called from AliMUON::BuildGeometry)
575 if (!Notify(detElemId)) return;
577 fCurrentSegmentation->Draw(opt);
580 //______________________________________________________________________________
581 void AliMUONGeometrySegmentation::SetCorrFunc(Int_t detElemId,
582 Int_t isec, TF1* func)
584 // Set the correction function.
585 // From AliMUONGeometrySegmentationV01
588 if (!Notify(detElemId)) return;
590 fCurrentSegmentation->SetCorrFunc(isec, func);
593 //______________________________________________________________________________
594 TF1* AliMUONGeometrySegmentation::CorrFunc(Int_t detElemId, Int_t isec) const
596 // Get the correction Function.
597 // From AliMUONGeometrySegmentationV01
600 if (!Notify(detElemId)) return 0;
602 return fCurrentSegmentation->CorrFunc(isec);