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 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 AliMUONVGeometryDESegmentation* segmentation
160 = (AliMUONVGeometryDESegmentation*)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 AliMUONVGeometryDESegmentation* segmentation
173 = (AliMUONVGeometryDESegmentation*)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 Bool_t 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 false;
202 if (!fCurrentSegmentation->HasPad(xg, yg, zg)) return false;
205 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
207 fCurrentSegmentation->GetPadI(xl, yl, zl, ix, iy);
211 //______________________________________________________________________________
212 Bool_t AliMUONGeometrySegmentation::GetPadC(Int_t detElemId,
214 Float_t& xg, Float_t& yg, Float_t& zg)
216 // Transform from pad to real coordinates
219 if (!Notify(detElemId)) return false;
221 if (!fCurrentSegmentation->HasPad(ix, iy)) return false;
224 fCurrentSegmentation->GetPadC(ix, iy, xl , yl, zl);
226 fGeometryModule->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
231 //______________________________________________________________________________
232 void AliMUONGeometrySegmentation::Init(Int_t /*chamber*/)
234 // Initialize segmentation.
235 // Check that all detection elements have segmanetation set
238 // Loop over detection elements
239 AliMUONGeometryStore* detElements = fGeometryModule->GetDetElementStore();
241 for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
243 // Get detction element Id
244 Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
246 // Check segmentation
247 if (! fDESegmentations->Get(detElemId) )
248 AliError(Form("Detection element %d has not a segmentation set.",
249 detElements->GetEntry(i)->GetUniqueID()));
253 //______________________________________________________________________________
254 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId) const
259 if (!Notify(detElemId)) return 0.;
261 return fCurrentSegmentation->Dpx();
264 //______________________________________________________________________________
265 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId) const
270 if (!Notify(detElemId)) return 0.;
272 return fCurrentSegmentation->Dpy();
275 //______________________________________________________________________________
276 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
278 // Pad size in x by sector
281 if (!Notify(detElemId)) return 0.;
283 return fCurrentSegmentation->Dpx(isector);
286 //______________________________________________________________________________
287 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
289 // Pad size in x, y by Sector
292 if (!Notify(detElemId)) return 0.;
294 return fCurrentSegmentation->Dpy(isector);
297 //______________________________________________________________________________
298 Int_t AliMUONGeometrySegmentation::Npx(Int_t detElemId) const
300 // Maximum number of Pads in x
303 if (!Notify(detElemId)) return 0;
305 return fCurrentSegmentation->Npx();
308 //______________________________________________________________________________
309 Int_t AliMUONGeometrySegmentation::Npy(Int_t detElemId) const
311 // Maximum number of Pads in y
314 if (!Notify(detElemId)) return 0;
316 return fCurrentSegmentation->Npy();
319 //______________________________________________________________________________
320 void AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
323 // Sets virtual pad coordinates, needed for evaluating pad response
324 // outside the tracking program.
325 // From AliMUONGeometrySegmentationV01.
328 if (!Notify(detElemId)) return;
330 fCurrentSegmentation->SetPad(ix, iy);
333 //______________________________________________________________________________
334 void AliMUONGeometrySegmentation::SetHit(Int_t detElemId,
335 Float_t xghit, Float_t yghit, Float_t zghit)
338 // Sets virtual hit position, needed for evaluating pad response
339 // outside the tracking program
340 // From AliMUONGeometrySegmentationV01.
342 if (!Notify(detElemId)) return;
345 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
347 fCurrentSegmentation->SetHit(xl, yl, zl);
350 //______________________________________________________________________________
351 void AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
352 Float_t xghit, Float_t yghit, Float_t zghit,
353 Float_t dx, Float_t dy)
355 // Iterate over pads - initialiser
358 if (!Notify(detElemId)) return;
361 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
363 fCurrentSegmentation->FirstPad(xl, yl, zl, dx, dy);
366 //______________________________________________________________________________
367 void AliMUONGeometrySegmentation::NextPad(Int_t detElemId)
369 // Iterate over pads - stepper
372 if (!Notify(detElemId)) return;
374 fCurrentSegmentation->NextPad();
377 //______________________________________________________________________________
378 Int_t AliMUONGeometrySegmentation::MorePads(Int_t detElemId)
380 // Iterate over pads - condition
383 if (!Notify(detElemId)) return 0;
385 return fCurrentSegmentation->MorePads();
388 //______________________________________________________________________________
389 Float_t AliMUONGeometrySegmentation::Distance2AndOffset(Int_t detElemId,
391 Float_t xg, Float_t yg, Float_t zg,
394 // Returns the square of the distance between 1 pad
395 // labelled by its channel numbers and a coordinate
398 if (!Notify(detElemId)) return 0.;
401 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
403 return fCurrentSegmentation->Distance2AndOffset(ix, iy, xl, yl, dummy);
406 //______________________________________________________________________________
407 void AliMUONGeometrySegmentation::GetNParallelAndOffset(Int_t detElemId,
409 Int_t* nparallel, Int_t* offset)
411 // Number of pads read in parallel and offset to add to x
412 // (specific to LYON, but mandatory for display)
416 if (!Notify(detElemId)) return;
418 fCurrentSegmentation->GetNParallelAndOffset(ix, iy, nparallel, offset);
422 //______________________________________________________________________________
423 void AliMUONGeometrySegmentation::Neighbours(Int_t detElemId,
426 Int_t xlist[10], Int_t ylist[10])
428 // Get next neighbours
431 if (!Notify(detElemId)) return;
433 fCurrentSegmentation->Neighbours(ix, iy, nlist, xlist, ylist);
436 //______________________________________________________________________________
437 Int_t AliMUONGeometrySegmentation::Ix()
439 // Current pad cursor during disintegration
443 return fCurrentSegmentation->Ix();
446 //______________________________________________________________________________
447 Int_t AliMUONGeometrySegmentation::Iy()
449 // Current pad cursor during disintegration
453 return fCurrentSegmentation->Iy();
456 //______________________________________________________________________________
457 Int_t AliMUONGeometrySegmentation::DetElemId()
459 // Current pad cursor during disintegration
463 return fCurrentDetElemId;
466 //______________________________________________________________________________
467 Int_t AliMUONGeometrySegmentation::ISector()
472 return fCurrentSegmentation->ISector();
475 //______________________________________________________________________________
476 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
478 // Calculate sector from pad coordinates
481 if (!Notify(detElemId)) return 0;
483 return fCurrentSegmentation->Sector(ix, iy);
486 //______________________________________________________________________________
487 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId,
488 Float_t xg, Float_t yg, Float_t zg)
490 // Calculate sector from pad coordinates
493 if (!Notify(detElemId)) return 0;
496 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
498 return fCurrentSegmentation->Sector(xl, yl);
501 //______________________________________________________________________________
502 void AliMUONGeometrySegmentation::IntegrationLimits(Int_t detElemId,
503 Float_t& x1, Float_t& x2,
504 Float_t& y1, Float_t& y2)
506 // Current integration limits
509 if (!Notify(detElemId)) return;
511 return fCurrentSegmentation->IntegrationLimits(x1, x2, y1, y2);
514 //______________________________________________________________________________
515 Int_t AliMUONGeometrySegmentation::SigGenCond(Int_t detElemId,
516 Float_t xg, Float_t yg, Float_t zg)
518 // Signal Generation Condition during Stepping
519 // 0: don't generate signal
520 // 1: generate signal
523 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
524 // To correctly simulate the dependence of the spatial resolution on the angle
525 // of incidence signal must be generated for constant steps on
526 // the projection of the trajectory along the anode wire.
528 // Signal will be generated if particle crosses pad boundary or
529 // boundary between two wires.
532 if (!Notify(detElemId)) return 0;
535 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
537 return fCurrentSegmentation->SigGenCond(xl, yl, zl);
541 //______________________________________________________________________________
542 void AliMUONGeometrySegmentation::SigGenInit(Int_t detElemId,
543 Float_t xg, Float_t yg, Float_t zg)
545 // Initialise signal generation at coord (x,y,z)
546 // Initialises pad and wire position during stepping.
547 // From AliMUONGeometrySegmentationV01
550 if (!Notify(detElemId)) return;
553 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
555 fCurrentSegmentation->SigGenInit(xl, yl, zl);
558 //______________________________________________________________________________
559 void AliMUONGeometrySegmentation::GiveTestPoints(Int_t /*detElemId*/,
561 Float_t* /*xg*/, Float_t* /*yg*/) const
563 // Test points for auto calibration
564 // Returns test point on the pad plane.
565 // Used during determination of the segmoid correction of the COG-method
566 // From AliMUONGeometrySegmentationV01
569 // Requires change of interface
570 // to convert points from local to global we need z coordinate
571 AliError("Not implemented.");
574 //______________________________________________________________________________
575 void AliMUONGeometrySegmentation::Draw(Int_t detElemId, const char* opt) const
577 // Draw the segmentation zones.
578 // (Called from AliMUON::BuildGeometry)
581 if (!Notify(detElemId)) return;
583 fCurrentSegmentation->Draw(opt);
586 //______________________________________________________________________________
587 void AliMUONGeometrySegmentation::SetCorrFunc(Int_t detElemId,
588 Int_t isec, TF1* func)
590 // Set the correction function.
591 // From AliMUONGeometrySegmentationV01
594 if (!Notify(detElemId)) return;
596 fCurrentSegmentation->SetCorrFunc(isec, func);
599 //______________________________________________________________________________
600 TF1* AliMUONGeometrySegmentation::CorrFunc(Int_t detElemId, Int_t isec) const
602 // Get the correction Function.
603 // From AliMUONGeometrySegmentationV01
606 if (!Notify(detElemId)) return 0;
608 return fCurrentSegmentation->CorrFunc(isec);