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 <Riostream.h>
31 #include "AliMUONGeometrySegmentation.h"
32 #include "AliMUONVGeometryDESegmentation.h"
33 #include "AliMUONGeometryModule.h"
34 #include "AliMUONGeometryDetElement.h"
35 #include "AliMUONGeometryStore.h"
38 ClassImp(AliMUONGeometrySegmentation)
40 //______________________________________________________________________________
41 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
42 AliMUONGeometryModule* geometry)
45 fCurrentDetElement(0),
46 fCurrentSegmentation(0),
47 fGeometryModule(geometry),
54 = new AliMUONGeometryStore(geometry->GetDEIndexing(), false);
57 //______________________________________________________________________________
58 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation()
61 fCurrentDetElement(0),
62 fCurrentSegmentation(0),
66 // Default Constructor
69 //______________________________________________________________________________
70 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
71 const AliMUONGeometrySegmentation& rhs)
75 AliFatal("Copy constructor is not implemented.");
78 //______________________________________________________________________________
79 AliMUONGeometrySegmentation::~AliMUONGeometrySegmentation() {
82 delete fDESegmentations;
89 //______________________________________________________________________________
90 AliMUONGeometrySegmentation&
91 AliMUONGeometrySegmentation::operator=(const AliMUONGeometrySegmentation& rhs)
95 // check assignement to self
96 if (this == &rhs) return *this;
98 AliFatal("Assignment operator is not implemented.");
107 //______________________________________________________________________________
108 Bool_t AliMUONGeometrySegmentation::Notify(Int_t detElemId) const
110 // Updates current detection element and segmentation,
111 // and checks if they exist.
112 // Returns true if success.
115 if (detElemId != fCurrentDetElemId) {
117 // Find detection element and its segmentation
118 AliMUONGeometryDetElement* detElement
119 = fGeometryModule->GetDetElement(detElemId);
121 AliError(Form("Detection element %d not defined", detElemId));
125 AliMUONVGeometryDESegmentation* segmentation
126 = (AliMUONVGeometryDESegmentation*) fDESegmentations->Get(detElemId);
128 AliError(Form("Segmentation for detection element %d not defined",
133 fCurrentDetElemId = detElemId;
134 fCurrentDetElement = detElement;
135 fCurrentSegmentation = segmentation;
145 //______________________________________________________________________________
146 void AliMUONGeometrySegmentation::Add(Int_t detElemId,
147 AliMUONVGeometryDESegmentation* segmentation)
149 // Add detection element segmentation
152 fDESegmentations->Add(detElemId, segmentation);
155 //______________________________________________________________________________
156 AliMUONGeometryDirection
157 AliMUONGeometrySegmentation::GetDirection(Int_t detElemId) const
159 // Return direction with a constant pad size
160 // (Direction or coordinate where the resolution is the best)
162 if (!Notify(detElemId)) return kDirUndefined;
164 return fCurrentSegmentation->GetDirection();
167 //______________________________________________________________________________
168 void AliMUONGeometrySegmentation::SetPadSize(Float_t p1, Float_t p2)
170 // Set pad size Dx*Dy to all detection element segmentations
173 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
174 AliMUONVGeometryDESegmentation* segmentation
175 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
176 segmentation->SetPadSize(p1, p2);
180 //______________________________________________________________________________
181 void AliMUONGeometrySegmentation::SetDAnod(Float_t d)
183 // Set anod pitch to all detection element segmentations
186 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
187 AliMUONVGeometryDESegmentation* segmentation
188 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
189 segmentation->SetDAnod(d);
193 //______________________________________________________________________________
194 Float_t AliMUONGeometrySegmentation::GetAnod(Int_t detElemId, Float_t xhit) const
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
202 if (!Notify(detElemId)) return 0;
204 return fCurrentSegmentation->GetAnod(xhit);
207 //______________________________________________________________________________
208 Bool_t AliMUONGeometrySegmentation::GetPadI(Int_t detElemId,
209 Float_t xg, Float_t yg, Float_t zg,
210 Int_t& ix, Int_t& iy)
212 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
215 if (!Notify(detElemId)) return false;
218 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
220 if (!fCurrentSegmentation->HasPad(xl, yl, zl)) return false;
222 fCurrentSegmentation->GetPadI(xl, yl, zl, ix, iy);
226 //______________________________________________________________________________
227 Bool_t AliMUONGeometrySegmentation::GetPadC(Int_t detElemId,
229 Float_t& xg, Float_t& yg, Float_t& zg)
231 // Transform from pad to real coordinates
234 if (!Notify(detElemId)) return false;
236 if (!fCurrentSegmentation->HasPad(ix, iy)) return false;
239 fCurrentSegmentation->GetPadC(ix, iy, xl , yl, zl);
241 fGeometryModule->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
246 //______________________________________________________________________________
247 void AliMUONGeometrySegmentation::Init(Int_t chamber)
249 // Initialize segmentation.
250 // Check that all detection elements have segmanetation set
253 // Loop over detection elements
254 AliMUONGeometryStore* detElements = fGeometryModule->GetDetElementStore();
256 for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
258 // Get detction element Id
259 Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
261 // Check segmentation
262 if (! fDESegmentations->Get(detElemId) ) {
263 AliError(Form("Detection element %d has not a segmentation set.",
264 detElements->GetEntry(i)->GetUniqueID()));
267 // Initialize DE Segmentation
268 ((AliSegmentation*)fDESegmentations->Get(detElemId))->Init(chamber);
273 //______________________________________________________________________________
274 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId) const
279 if (!Notify(detElemId)) return 0.;
281 return fCurrentSegmentation->Dpx();
284 //______________________________________________________________________________
285 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId) const
290 if (!Notify(detElemId)) return 0.;
292 return fCurrentSegmentation->Dpy();
295 //______________________________________________________________________________
296 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
298 // Pad size in x by sector
301 if (!Notify(detElemId)) return 0.;
303 return fCurrentSegmentation->Dpx(isector);
306 //______________________________________________________________________________
307 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
309 // Pad size in x, y by Sector
312 if (!Notify(detElemId)) return 0.;
314 return fCurrentSegmentation->Dpy(isector);
317 //______________________________________________________________________________
318 Int_t AliMUONGeometrySegmentation::Npx(Int_t detElemId) const
320 // Maximum number of Pads in x
323 if (!Notify(detElemId)) return 0;
325 return fCurrentSegmentation->Npx();
328 //______________________________________________________________________________
329 Int_t AliMUONGeometrySegmentation::Npy(Int_t detElemId) const
331 // Maximum number of Pads in y
334 if (!Notify(detElemId)) return 0;
336 return fCurrentSegmentation->Npy();
339 //______________________________________________________________________________
340 void AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
343 // Sets virtual pad coordinates, needed for evaluating pad response
344 // outside the tracking program.
345 // From AliMUONGeometrySegmentationV01.
348 if (!Notify(detElemId)) return;
350 fCurrentSegmentation->SetPad(ix, iy);
353 //______________________________________________________________________________
354 void AliMUONGeometrySegmentation::SetHit(Int_t detElemId,
355 Float_t xghit, Float_t yghit, Float_t zghit)
358 // Sets virtual hit position, needed for evaluating pad response
359 // outside the tracking program
360 // From AliMUONGeometrySegmentationV01.
362 if (!Notify(detElemId)) return;
365 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
367 fCurrentSegmentation->SetHit(xl, yl, zl);
370 //______________________________________________________________________________
371 void AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
372 Float_t xghit, Float_t yghit, Float_t zghit,
373 Float_t dx, Float_t dy)
375 // Iterate over pads - initialiser
378 if (!Notify(detElemId)) return;
381 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
383 fCurrentSegmentation->FirstPad(xl, yl, zl, dx, dy);
386 //______________________________________________________________________________
387 void AliMUONGeometrySegmentation::NextPad(Int_t detElemId)
389 // Iterate over pads - stepper
392 if (!Notify(detElemId)) return;
394 fCurrentSegmentation->NextPad();
397 //______________________________________________________________________________
398 Int_t AliMUONGeometrySegmentation::MorePads(Int_t detElemId)
400 // Iterate over pads - condition
403 if (!Notify(detElemId)) return 0;
405 return fCurrentSegmentation->MorePads();
408 //______________________________________________________________________________
409 Float_t AliMUONGeometrySegmentation::Distance2AndOffset(Int_t detElemId,
411 Float_t xg, Float_t yg, Float_t zg,
414 // Returns the square of the distance between 1 pad
415 // labelled by its channel numbers and a coordinate
418 if (!Notify(detElemId)) return 0.;
421 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
423 return fCurrentSegmentation->Distance2AndOffset(ix, iy, xl, yl, dummy);
426 //______________________________________________________________________________
427 void AliMUONGeometrySegmentation::GetNParallelAndOffset(Int_t detElemId,
429 Int_t* nparallel, Int_t* offset)
431 // Number of pads read in parallel and offset to add to x
432 // (specific to LYON, but mandatory for display)
436 if (!Notify(detElemId)) return;
438 fCurrentSegmentation->GetNParallelAndOffset(ix, iy, nparallel, offset);
442 //______________________________________________________________________________
443 void AliMUONGeometrySegmentation::Neighbours(Int_t detElemId,
446 Int_t xlist[10], Int_t ylist[10])
448 // Get next neighbours
451 if (!Notify(detElemId)) return;
453 fCurrentSegmentation->Neighbours(ix, iy, nlist, xlist, ylist);
456 //______________________________________________________________________________
457 Int_t AliMUONGeometrySegmentation::Ix()
459 // Current pad cursor during disintegration
463 return fCurrentSegmentation->Ix();
466 //______________________________________________________________________________
467 Int_t AliMUONGeometrySegmentation::Iy()
469 // Current pad cursor during disintegration
473 return fCurrentSegmentation->Iy();
476 //______________________________________________________________________________
477 Int_t AliMUONGeometrySegmentation::DetElemId()
479 // Current pad cursor during disintegration
483 return fCurrentDetElemId;
486 //______________________________________________________________________________
487 Int_t AliMUONGeometrySegmentation::ISector()
492 return fCurrentSegmentation->ISector();
495 //______________________________________________________________________________
496 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
498 // Calculate sector from pad coordinates
501 if (!Notify(detElemId)) return 0;
503 return fCurrentSegmentation->Sector(ix, iy);
506 //______________________________________________________________________________
507 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId,
508 Float_t xg, Float_t yg, Float_t zg)
510 // Calculate sector from pad coordinates
513 if (!Notify(detElemId)) return 0;
516 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
518 return fCurrentSegmentation->Sector(xl, yl);
521 //______________________________________________________________________________
522 void AliMUONGeometrySegmentation::IntegrationLimits(Int_t detElemId,
523 Float_t& x1, Float_t& x2,
524 Float_t& y1, Float_t& y2)
526 // Current integration limits
529 if (!Notify(detElemId)) return;
531 fCurrentSegmentation->IntegrationLimits(x1, x2, y1, y2);
534 //______________________________________________________________________________
535 Int_t AliMUONGeometrySegmentation::SigGenCond(Int_t detElemId,
536 Float_t xg, Float_t yg, Float_t zg)
538 // Signal Generation Condition during Stepping
539 // 0: don't generate signal
540 // 1: generate signal
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.
548 // Signal will be generated if particle crosses pad boundary or
549 // boundary between two wires.
552 if (!Notify(detElemId)) return 0;
555 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
557 return fCurrentSegmentation->SigGenCond(xl, yl, zl);
560 //______________________________________________________________________________
561 void AliMUONGeometrySegmentation::SigGenInit(Int_t detElemId,
562 Float_t xg, Float_t yg, Float_t zg)
564 // Initialise signal generation at coord (x,y,z)
565 // Initialises pad and wire position during stepping.
566 // From AliMUONGeometrySegmentationV01
569 if (!Notify(detElemId)) return;
572 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
574 if (!fCurrentSegmentation->HasPad(xl, yl, zl)) {
576 << "No pad at " << detElemId
577 << " global position: " << xg << " " << yg << " " << zg
578 << " local position: " << xl << " " << yl << " " << zl << endl;
582 fCurrentSegmentation->SigGenInit(xl, yl, zl);
585 //______________________________________________________________________________
586 void AliMUONGeometrySegmentation::GiveTestPoints(Int_t /*detElemId*/,
588 Float_t* /*xg*/, Float_t* /*yg*/) const
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
596 // Requires change of interface
597 // to convert points from local to global we need z coordinate
598 AliError("Not implemented.");
601 //______________________________________________________________________________
602 void AliMUONGeometrySegmentation::Draw(Int_t detElemId, const char* opt) const
604 // Draw the segmentation zones.
605 // (Called from AliMUON::BuildGeometry)
608 if (!Notify(detElemId)) return;
610 fCurrentSegmentation->Draw(opt);
613 //______________________________________________________________________________
614 void AliMUONGeometrySegmentation::SetCorrFunc(Int_t detElemId,
615 Int_t isec, TF1* func)
617 // Set the correction function.
618 // From AliMUONGeometrySegmentationV01
621 if (!Notify(detElemId)) return;
623 fCurrentSegmentation->SetCorrFunc(isec, func);
626 //______________________________________________________________________________
627 TF1* AliMUONGeometrySegmentation::CorrFunc(Int_t detElemId, Int_t isec) const
629 // Get the correction Function.
630 // From AliMUONGeometrySegmentationV01
633 if (!Notify(detElemId)) return 0;
635 return fCurrentSegmentation->CorrFunc(isec);