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);
156 //______________________________________________________________________________
157 const AliMUONVGeometryDESegmentation*
158 AliMUONGeometrySegmentation::GetDESegmentation(Int_t detElemId) const
160 // Return the DE segmentation
162 if (!OwnNotify(detElemId)) return 0;
164 return fCurrentSegmentation;
167 //______________________________________________________________________________
168 AliMUONGeometryDirection
169 AliMUONGeometrySegmentation::GetDirection(Int_t detElemId) const
171 // Return direction with a constant pad size
172 // (Direction or coordinate where the resolution is the best)
174 if (!OwnNotify(detElemId)) return kDirUndefined;
176 return fCurrentSegmentation->GetDirection();
179 //______________________________________________________________________________
180 void AliMUONGeometrySegmentation::SetPadSize(Float_t p1, Float_t p2)
182 // Set pad size Dx*Dy to all detection element segmentations
185 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
186 AliMUONVGeometryDESegmentation* segmentation
187 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
188 segmentation->SetPadSize(p1, p2);
192 //______________________________________________________________________________
193 void AliMUONGeometrySegmentation::SetDAnod(Float_t d)
195 // Set anod pitch to all detection element segmentations
198 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
199 AliMUONVGeometryDESegmentation* segmentation
200 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
201 segmentation->SetDAnod(d);
205 //______________________________________________________________________________
206 Float_t AliMUONGeometrySegmentation::GetAnod(Int_t detElemId, Float_t xhit) const
208 // Anod wire coordinate closest to xhit
209 // Returns for a hit position xhit the position of the nearest anode wire
210 // !!! xhit is understand a a distance, not as a position in the space
214 if (!OwnNotify(detElemId)) return 0;
216 return fCurrentSegmentation->GetAnod(xhit);
219 //______________________________________________________________________________
220 Bool_t AliMUONGeometrySegmentation::GetPadI(Int_t detElemId,
221 Float_t xg, Float_t yg, Float_t zg,
222 Int_t& ix, Int_t& iy)
224 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
227 if (!OwnNotify(detElemId)) return false;
230 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
232 if (!fCurrentSegmentation->HasPad(xl, yl, zl)) return false;
234 fCurrentSegmentation->GetPadI(xl, yl, zl, ix, iy);
238 //______________________________________________________________________________
239 Bool_t AliMUONGeometrySegmentation::GetPadC(Int_t detElemId,
241 Float_t& xg, Float_t& yg, Float_t& zg)
243 // Transform from pad to real coordinates
246 if (!OwnNotify(detElemId)) return false;
248 if (!fCurrentSegmentation->HasPad(ix, iy)) return false;
251 fCurrentSegmentation->GetPadC(ix, iy, xl , yl, zl);
253 fGeometryModule->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
257 //______________________________________________________________________________
258 Bool_t AliMUONGeometrySegmentation::GetPadE(Int_t detElemId,
259 Int_t &ix, Int_t &iy,
260 AliMUONSegmentManuIndex* connect)
262 // Get pads for a given electronic connection
265 if (!OwnNotify(detElemId)) return false;
267 if (!fCurrentSegmentation->HasPad(ix, iy)) return false;
269 fCurrentSegmentation->GetPadE(ix, iy, connect);
273 //______________________________________________________________________________
274 AliMUONSegmentManuIndex* AliMUONGeometrySegmentation:: GetMpConnection(Int_t detElemId,
277 // Get electronic connection for given pads
280 if (!OwnNotify(detElemId)) return 0x0;
282 AliMUONSegmentManuIndex* connect;
284 connect = fCurrentSegmentation->GetMpConnection(ix, iy);
285 if (connect == 0x0) return 0x0;
287 Int_t busPatchId = connect->GetBusPatchId();
290 // not very clean way, to be changed (Ch.F.)
292 if (detElemId/100 > 4 && detElemId/100 < 11)
294 else if (detElemId/100 < 5)
297 if (detElemId % 100 < 50)
298 busPatchId+= (detElemId/100 - 1)*100 + (detElemId % 100)*dBusPatch;
300 busPatchId+= (detElemId/100 - 1)*100 + ((detElemId-50) % 100)*dBusPatch + 50;
302 connect->SetBusPatchId(busPatchId);
307 //______________________________________________________________________________
308 void AliMUONGeometrySegmentation::Init(Int_t chamber)
310 // Initialize segmentation.
311 // Check that all detection elements have segmanetation set
314 // Loop over detection elements
315 AliMUONGeometryStore* detElements = fGeometryModule->GetDetElementStore();
317 for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
319 // Get detction element Id
320 Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
322 // Check segmentation
323 if (! fDESegmentations->Get(detElemId) ) {
324 AliError(Form("Detection element %d has not a segmentation set.",
325 detElements->GetEntry(i)->GetUniqueID()));
328 // Initialize DE Segmentation
329 ((AliSegmentation*)fDESegmentations->Get(detElemId))->Init(chamber);
334 //______________________________________________________________________________
335 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId) const
340 if (!OwnNotify(detElemId)) return 0.;
342 return fCurrentSegmentation->Dpx();
345 //______________________________________________________________________________
346 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId) const
351 if (!OwnNotify(detElemId)) return 0.;
353 return fCurrentSegmentation->Dpy();
356 //______________________________________________________________________________
357 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
359 // Pad size in x by sector
362 if (!OwnNotify(detElemId)) return 0.;
364 return fCurrentSegmentation->Dpx(isector);
367 //______________________________________________________________________________
368 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
370 // Pad size in x, y by Sector
373 if (!OwnNotify(detElemId)) return 0.;
375 return fCurrentSegmentation->Dpy(isector);
378 //______________________________________________________________________________
379 Int_t AliMUONGeometrySegmentation::Npx(Int_t detElemId) const
381 // Maximum number of Pads in x
384 if (!OwnNotify(detElemId)) return 0;
386 return fCurrentSegmentation->Npx();
389 //______________________________________________________________________________
390 Int_t AliMUONGeometrySegmentation::Npy(Int_t detElemId) const
392 // Maximum number of Pads in y
395 if (!OwnNotify(detElemId)) return 0;
397 return fCurrentSegmentation->Npy();
400 //______________________________________________________________________________
401 void AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
404 // Sets virtual pad coordinates, needed for evaluating pad response
405 // outside the tracking program.
406 // From AliMUONGeometrySegmentationV01.
409 if (!OwnNotify(detElemId)) return;
411 fCurrentSegmentation->SetPad(ix, iy);
414 //______________________________________________________________________________
415 void AliMUONGeometrySegmentation::SetHit(Int_t detElemId,
416 Float_t xghit, Float_t yghit, Float_t zghit)
419 // Sets virtual hit position, needed for evaluating pad response
420 // outside the tracking program
421 // From AliMUONGeometrySegmentationV01.
423 if (!OwnNotify(detElemId)) return;
426 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
428 fCurrentSegmentation->SetHit(xl, yl, zl);
431 //______________________________________________________________________________
432 void AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
433 Float_t xghit, Float_t yghit, Float_t zghit,
434 Float_t dx, Float_t dy)
436 // Iterate over pads - initialiser
439 if (!OwnNotify(detElemId)) return;
442 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
444 fCurrentSegmentation->FirstPad(xl, yl, zl, dx, dy);
447 //______________________________________________________________________________
448 void AliMUONGeometrySegmentation::NextPad(Int_t detElemId)
450 // Iterate over pads - stepper
453 if (!OwnNotify(detElemId)) return;
455 fCurrentSegmentation->NextPad();
458 //______________________________________________________________________________
459 Int_t AliMUONGeometrySegmentation::MorePads(Int_t detElemId)
461 // Iterate over pads - condition
464 if (!OwnNotify(detElemId)) return 0;
466 return fCurrentSegmentation->MorePads();
469 //______________________________________________________________________________
470 Float_t AliMUONGeometrySegmentation::Distance2AndOffset(Int_t detElemId,
472 Float_t xg, Float_t yg, Float_t zg,
475 // Returns the square of the distance between 1 pad
476 // labelled by its channel numbers and a coordinate
479 if (!OwnNotify(detElemId)) return 0.;
482 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
484 return fCurrentSegmentation->Distance2AndOffset(ix, iy, xl, yl, dummy);
487 //______________________________________________________________________________
488 void AliMUONGeometrySegmentation::GetNParallelAndOffset(Int_t detElemId,
490 Int_t* nparallel, Int_t* offset)
492 // Number of pads read in parallel and offset to add to x
493 // (specific to LYON, but mandatory for display)
497 if (!OwnNotify(detElemId)) return;
499 fCurrentSegmentation->GetNParallelAndOffset(ix, iy, nparallel, offset);
503 //______________________________________________________________________________
504 void AliMUONGeometrySegmentation::Neighbours(Int_t detElemId,
507 Int_t xlist[10], Int_t ylist[10])
509 // Get next neighbours
512 if (!OwnNotify(detElemId)) return;
514 fCurrentSegmentation->Neighbours(ix, iy, nlist, xlist, ylist);
517 //______________________________________________________________________________
518 Int_t AliMUONGeometrySegmentation::Ix()
520 // Current pad cursor during disintegration
524 return fCurrentSegmentation->Ix();
527 //______________________________________________________________________________
528 Int_t AliMUONGeometrySegmentation::Iy()
530 // Current pad cursor during disintegration
534 return fCurrentSegmentation->Iy();
537 //______________________________________________________________________________
538 Int_t AliMUONGeometrySegmentation::DetElemId()
540 // Current pad cursor during disintegration
544 return fCurrentDetElemId;
547 //______________________________________________________________________________
548 Int_t AliMUONGeometrySegmentation::ISector()
553 return fCurrentSegmentation->ISector();
556 //______________________________________________________________________________
557 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
559 // Calculate sector from pad coordinates
562 if (!OwnNotify(detElemId)) return 0;
564 return fCurrentSegmentation->Sector(ix, iy);
567 //______________________________________________________________________________
568 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId,
569 Float_t xg, Float_t yg, Float_t zg)
571 // Calculate sector from pad coordinates
574 if (!OwnNotify(detElemId)) return 0;
577 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
579 return fCurrentSegmentation->Sector(xl, yl);
582 //______________________________________________________________________________
583 void AliMUONGeometrySegmentation::IntegrationLimits(Int_t detElemId,
584 Float_t& x1, Float_t& x2,
585 Float_t& y1, Float_t& y2)
587 // Current integration limits
590 if (!OwnNotify(detElemId)) return;
592 fCurrentSegmentation->IntegrationLimits(x1, x2, y1, y2);
595 //______________________________________________________________________________
596 Int_t AliMUONGeometrySegmentation::SigGenCond(Int_t detElemId,
597 Float_t xg, Float_t yg, Float_t zg)
599 // Signal Generation Condition during Stepping
600 // 0: don't generate signal
601 // 1: generate signal
604 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
605 // To correctly simulate the dependence of the spatial resolution on the angle
606 // of incidence signal must be generated for constant steps on
607 // the projection of the trajectory along the anode wire.
609 // Signal will be generated if particle crosses pad boundary or
610 // boundary between two wires.
613 if (!OwnNotify(detElemId)) return 0;
616 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
618 return fCurrentSegmentation->SigGenCond(xl, yl, zl);
621 //______________________________________________________________________________
622 void AliMUONGeometrySegmentation::SigGenInit(Int_t detElemId,
623 Float_t xg, Float_t yg, Float_t zg)
625 // Initialise signal generation at coord (x,y,z)
626 // Initialises pad and wire position during stepping.
627 // From AliMUONGeometrySegmentationV01
630 if (!OwnNotify(detElemId)) return;
633 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
635 if (!fCurrentSegmentation->HasPad(xl, yl, zl)) {
637 << "No pad at " << detElemId
638 << " global position: " << xg << " " << yg << " " << zg
639 << " local position: " << xl << " " << yl << " " << zl << endl;
643 fCurrentSegmentation->SigGenInit(xl, yl, zl);
646 //______________________________________________________________________________
647 void AliMUONGeometrySegmentation::GiveTestPoints(Int_t /*detElemId*/,
649 Float_t* /*xg*/, Float_t* /*yg*/) const
651 // Test points for auto calibration
652 // Returns test point on the pad plane.
653 // Used during determination of the segmoid correction of the COG-method
654 // From AliMUONGeometrySegmentationV01
657 // Requires change of interface
658 // to convert points from local to global we need z coordinate
659 AliError("Not implemented.");
662 //______________________________________________________________________________
663 void AliMUONGeometrySegmentation::Draw(const char* opt)
665 // Draws the segmentation zones for all detElemId
668 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
669 AliMUONVGeometryDESegmentation* segmentation
670 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
671 segmentation->Draw(opt);
675 //______________________________________________________________________________
676 void AliMUONGeometrySegmentation::Draw(Int_t detElemId, const char* opt)
678 // Draw the segmentation zones for a given detElemId.
681 if (!OwnNotify(detElemId)) return;
683 fCurrentSegmentation->Draw(opt);
686 //______________________________________________________________________________
687 void AliMUONGeometrySegmentation::SetCorrFunc(Int_t detElemId,
688 Int_t isec, TF1* func)
690 // Set the correction function.
691 // From AliMUONGeometrySegmentationV01
694 if (!OwnNotify(detElemId)) return;
696 fCurrentSegmentation->SetCorrFunc(isec, func);
699 //______________________________________________________________________________
700 TF1* AliMUONGeometrySegmentation::CorrFunc(Int_t detElemId, Int_t isec) const
702 // Get the correction Function.
703 // From AliMUONGeometrySegmentationV01
706 if (!OwnNotify(detElemId)) return 0;
708 return fCurrentSegmentation->CorrFunc(isec);