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"
36 #include "AliMUONSegmentManuIndex.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::OwnNotify(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 (!OwnNotify(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 (!OwnNotify(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 (!OwnNotify(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 (!OwnNotify(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);
245 //______________________________________________________________________________
246 Bool_t AliMUONGeometrySegmentation::GetPadE(Int_t detElemId,
247 Int_t &ix, Int_t &iy,
248 AliMUONSegmentManuIndex* connect)
250 // Get pads for a given electronic connection
253 if (!OwnNotify(detElemId)) return false;
255 if (!fCurrentSegmentation->HasPad(ix, iy)) return false;
257 fCurrentSegmentation->GetPadE(ix, iy, connect);
261 //______________________________________________________________________________
262 AliMUONSegmentManuIndex* AliMUONGeometrySegmentation:: GetMpConnection(Int_t detElemId,
265 // Get electronic connection for given pads
268 if (!OwnNotify(detElemId)) return 0x0;
270 AliMUONSegmentManuIndex* connect;
272 connect = fCurrentSegmentation->GetMpConnection(ix, iy);
273 if (connect == 0x0) return 0x0;
275 Int_t busPatchId = connect->GetBusPatchId();
278 // not very clean way, to be changed (Ch.F.)
280 if (detElemId/100 > 4 && detElemId/100 < 11)
282 else if (detElemId/100 < 5)
285 if (detElemId % 100 < 50)
286 busPatchId+= (detElemId/100 - 1)*100 + (detElemId % 100)*dBusPatch;
288 busPatchId+= (detElemId/100 - 1)*100 + ((detElemId-50) % 100)*dBusPatch + 50;
290 connect->SetBusPatchId(busPatchId);
295 //______________________________________________________________________________
296 void AliMUONGeometrySegmentation::Init(Int_t chamber)
298 // Initialize segmentation.
299 // Check that all detection elements have segmanetation set
302 // Loop over detection elements
303 AliMUONGeometryStore* detElements = fGeometryModule->GetDetElementStore();
305 for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
307 // Get detction element Id
308 Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
310 // Check segmentation
311 if (! fDESegmentations->Get(detElemId) ) {
312 AliError(Form("Detection element %d has not a segmentation set.",
313 detElements->GetEntry(i)->GetUniqueID()));
316 // Initialize DE Segmentation
317 ((AliSegmentation*)fDESegmentations->Get(detElemId))->Init(chamber);
322 //______________________________________________________________________________
323 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId) const
328 if (!OwnNotify(detElemId)) return 0.;
330 return fCurrentSegmentation->Dpx();
333 //______________________________________________________________________________
334 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId) const
339 if (!OwnNotify(detElemId)) return 0.;
341 return fCurrentSegmentation->Dpy();
344 //______________________________________________________________________________
345 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
347 // Pad size in x by sector
350 if (!OwnNotify(detElemId)) return 0.;
352 return fCurrentSegmentation->Dpx(isector);
355 //______________________________________________________________________________
356 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
358 // Pad size in x, y by Sector
361 if (!OwnNotify(detElemId)) return 0.;
363 return fCurrentSegmentation->Dpy(isector);
366 //______________________________________________________________________________
367 Int_t AliMUONGeometrySegmentation::Npx(Int_t detElemId) const
369 // Maximum number of Pads in x
372 if (!OwnNotify(detElemId)) return 0;
374 return fCurrentSegmentation->Npx();
377 //______________________________________________________________________________
378 Int_t AliMUONGeometrySegmentation::Npy(Int_t detElemId) const
380 // Maximum number of Pads in y
383 if (!OwnNotify(detElemId)) return 0;
385 return fCurrentSegmentation->Npy();
388 //______________________________________________________________________________
389 void AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
392 // Sets virtual pad coordinates, needed for evaluating pad response
393 // outside the tracking program.
394 // From AliMUONGeometrySegmentationV01.
397 if (!OwnNotify(detElemId)) return;
399 fCurrentSegmentation->SetPad(ix, iy);
402 //______________________________________________________________________________
403 void AliMUONGeometrySegmentation::SetHit(Int_t detElemId,
404 Float_t xghit, Float_t yghit, Float_t zghit)
407 // Sets virtual hit position, needed for evaluating pad response
408 // outside the tracking program
409 // From AliMUONGeometrySegmentationV01.
411 if (!OwnNotify(detElemId)) return;
414 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
416 fCurrentSegmentation->SetHit(xl, yl, zl);
419 //______________________________________________________________________________
420 void AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
421 Float_t xghit, Float_t yghit, Float_t zghit,
422 Float_t dx, Float_t dy)
424 // Iterate over pads - initialiser
427 if (!OwnNotify(detElemId)) return;
430 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
432 fCurrentSegmentation->FirstPad(xl, yl, zl, dx, dy);
435 //______________________________________________________________________________
436 void AliMUONGeometrySegmentation::NextPad(Int_t detElemId)
438 // Iterate over pads - stepper
441 if (!OwnNotify(detElemId)) return;
443 fCurrentSegmentation->NextPad();
446 //______________________________________________________________________________
447 Int_t AliMUONGeometrySegmentation::MorePads(Int_t detElemId)
449 // Iterate over pads - condition
452 if (!OwnNotify(detElemId)) return 0;
454 return fCurrentSegmentation->MorePads();
457 //______________________________________________________________________________
458 Float_t AliMUONGeometrySegmentation::Distance2AndOffset(Int_t detElemId,
460 Float_t xg, Float_t yg, Float_t zg,
463 // Returns the square of the distance between 1 pad
464 // labelled by its channel numbers and a coordinate
467 if (!OwnNotify(detElemId)) return 0.;
470 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
472 return fCurrentSegmentation->Distance2AndOffset(ix, iy, xl, yl, dummy);
475 //______________________________________________________________________________
476 void AliMUONGeometrySegmentation::GetNParallelAndOffset(Int_t detElemId,
478 Int_t* nparallel, Int_t* offset)
480 // Number of pads read in parallel and offset to add to x
481 // (specific to LYON, but mandatory for display)
485 if (!OwnNotify(detElemId)) return;
487 fCurrentSegmentation->GetNParallelAndOffset(ix, iy, nparallel, offset);
491 //______________________________________________________________________________
492 void AliMUONGeometrySegmentation::Neighbours(Int_t detElemId,
495 Int_t xlist[10], Int_t ylist[10])
497 // Get next neighbours
500 if (!OwnNotify(detElemId)) return;
502 fCurrentSegmentation->Neighbours(ix, iy, nlist, xlist, ylist);
505 //______________________________________________________________________________
506 Int_t AliMUONGeometrySegmentation::Ix()
508 // Current pad cursor during disintegration
512 return fCurrentSegmentation->Ix();
515 //______________________________________________________________________________
516 Int_t AliMUONGeometrySegmentation::Iy()
518 // Current pad cursor during disintegration
522 return fCurrentSegmentation->Iy();
525 //______________________________________________________________________________
526 Int_t AliMUONGeometrySegmentation::DetElemId()
528 // Current pad cursor during disintegration
532 return fCurrentDetElemId;
535 //______________________________________________________________________________
536 Int_t AliMUONGeometrySegmentation::ISector()
541 return fCurrentSegmentation->ISector();
544 //______________________________________________________________________________
545 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
547 // Calculate sector from pad coordinates
550 if (!OwnNotify(detElemId)) return 0;
552 return fCurrentSegmentation->Sector(ix, iy);
555 //______________________________________________________________________________
556 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId,
557 Float_t xg, Float_t yg, Float_t zg)
559 // Calculate sector from pad coordinates
562 if (!OwnNotify(detElemId)) return 0;
565 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
567 return fCurrentSegmentation->Sector(xl, yl);
570 //______________________________________________________________________________
571 void AliMUONGeometrySegmentation::IntegrationLimits(Int_t detElemId,
572 Float_t& x1, Float_t& x2,
573 Float_t& y1, Float_t& y2)
575 // Current integration limits
578 if (!OwnNotify(detElemId)) return;
580 fCurrentSegmentation->IntegrationLimits(x1, x2, y1, y2);
583 //______________________________________________________________________________
584 Int_t AliMUONGeometrySegmentation::SigGenCond(Int_t detElemId,
585 Float_t xg, Float_t yg, Float_t zg)
587 // Signal Generation Condition during Stepping
588 // 0: don't generate signal
589 // 1: generate signal
592 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
593 // To correctly simulate the dependence of the spatial resolution on the angle
594 // of incidence signal must be generated for constant steps on
595 // the projection of the trajectory along the anode wire.
597 // Signal will be generated if particle crosses pad boundary or
598 // boundary between two wires.
601 if (!OwnNotify(detElemId)) return 0;
604 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
606 return fCurrentSegmentation->SigGenCond(xl, yl, zl);
609 //______________________________________________________________________________
610 void AliMUONGeometrySegmentation::SigGenInit(Int_t detElemId,
611 Float_t xg, Float_t yg, Float_t zg)
613 // Initialise signal generation at coord (x,y,z)
614 // Initialises pad and wire position during stepping.
615 // From AliMUONGeometrySegmentationV01
618 if (!OwnNotify(detElemId)) return;
621 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
623 if (!fCurrentSegmentation->HasPad(xl, yl, zl)) {
625 << "No pad at " << detElemId
626 << " global position: " << xg << " " << yg << " " << zg
627 << " local position: " << xl << " " << yl << " " << zl << endl;
631 fCurrentSegmentation->SigGenInit(xl, yl, zl);
634 //______________________________________________________________________________
635 void AliMUONGeometrySegmentation::GiveTestPoints(Int_t /*detElemId*/,
637 Float_t* /*xg*/, Float_t* /*yg*/) const
639 // Test points for auto calibration
640 // Returns test point on the pad plane.
641 // Used during determination of the segmoid correction of the COG-method
642 // From AliMUONGeometrySegmentationV01
645 // Requires change of interface
646 // to convert points from local to global we need z coordinate
647 AliError("Not implemented.");
650 //______________________________________________________________________________
651 void AliMUONGeometrySegmentation::Draw(const char* opt)
653 // Draws the segmentation zones for all detElemId
656 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
657 AliMUONVGeometryDESegmentation* segmentation
658 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
659 segmentation->Draw(opt);
663 //______________________________________________________________________________
664 void AliMUONGeometrySegmentation::Draw(Int_t detElemId, const char* opt)
666 // Draw the segmentation zones for a given detElemId.
669 if (!OwnNotify(detElemId)) return;
671 fCurrentSegmentation->Draw(opt);
674 //______________________________________________________________________________
675 void AliMUONGeometrySegmentation::SetCorrFunc(Int_t detElemId,
676 Int_t isec, TF1* func)
678 // Set the correction function.
679 // From AliMUONGeometrySegmentationV01
682 if (!OwnNotify(detElemId)) return;
684 fCurrentSegmentation->SetCorrFunc(isec, func);
687 //______________________________________________________________________________
688 TF1* AliMUONGeometrySegmentation::CorrFunc(Int_t detElemId, Int_t isec) const
690 // Get the correction Function.
691 // From AliMUONGeometrySegmentationV01
694 if (!OwnNotify(detElemId)) return 0;
696 return fCurrentSegmentation->CorrFunc(isec);