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>
32 #include "AliMUONGeometrySegmentation.h"
33 #include "AliMUONVGeometryDESegmentation.h"
34 #include "AliMUONGeometryModule.h"
35 #include "AliMUONGeometryDetElement.h"
36 #include "AliMUONGeometryStore.h"
37 #include "AliMUONSegmentManuIndex.h"
39 ClassImp(AliMUONGeometrySegmentation)
41 //______________________________________________________________________________
42 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
43 AliMUONGeometryModule* geometry)
46 fCurrentDetElement(0),
47 fCurrentSegmentation(0),
48 fGeometryModule(geometry),
52 /// Standard constructor
55 = new AliMUONGeometryStore(geometry->GetDEIndexing(), false);
58 //______________________________________________________________________________
59 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation()
62 fCurrentDetElement(0),
63 fCurrentSegmentation(0),
67 /// Default Constructor
70 //______________________________________________________________________________
71 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
72 const AliMUONGeometrySegmentation& rhs)
75 /// Protected copy constructor
77 AliFatal("Copy constructor is not implemented.");
80 //______________________________________________________________________________
81 AliMUONGeometrySegmentation::~AliMUONGeometrySegmentation()
85 delete fDESegmentations;
92 //______________________________________________________________________________
93 AliMUONGeometrySegmentation&
94 AliMUONGeometrySegmentation::operator=(const AliMUONGeometrySegmentation& rhs)
96 /// Protected assignment operator
98 // check assignement to self
99 if (this == &rhs) return *this;
101 AliFatal("Assignment operator is not implemented.");
110 //______________________________________________________________________________
111 Bool_t AliMUONGeometrySegmentation::OwnNotify(Int_t detElemId) const
113 /// Update current detection element and segmentation,
114 /// and checks if they exist.
115 /// Return true if success.
117 if (detElemId != fCurrentDetElemId) {
119 // Find detection element and its segmentation
120 AliMUONGeometryDetElement* detElement
121 = fGeometryModule->GetDetElement(detElemId);
123 AliError(Form("Detection element %d not defined", detElemId));
127 AliMUONVGeometryDESegmentation* segmentation
128 = (AliMUONVGeometryDESegmentation*) fDESegmentations->Get(detElemId);
130 AliError(Form("Segmentation for detection element %d not defined",
135 fCurrentDetElemId = detElemId;
136 fCurrentDetElement = detElement;
137 fCurrentSegmentation = segmentation;
147 //______________________________________________________________________________
148 void AliMUONGeometrySegmentation::Add(Int_t detElemId,
149 AliMUONVGeometryDESegmentation* segmentation)
151 /// Add detection element segmentation
153 fDESegmentations->Add(detElemId, segmentation);
157 //______________________________________________________________________________
158 const AliMUONVGeometryDESegmentation*
159 AliMUONGeometrySegmentation::GetDESegmentation(Int_t detElemId) const
161 /// Return the DE segmentation
163 if (!OwnNotify(detElemId)) return 0;
165 return fCurrentSegmentation;
168 //______________________________________________________________________________
169 AliMUONGeometryDirection
170 AliMUONGeometrySegmentation::GetDirection(Int_t detElemId) const
172 /// Return direction with a constant pad size
173 /// (Direction or coordinate where the resolution is the best)
175 if (!OwnNotify(detElemId)) return kDirUndefined;
177 return fCurrentSegmentation->GetDirection();
180 //______________________________________________________________________________
181 void AliMUONGeometrySegmentation::Print(Option_t* opt) const
183 // Print DE segmentations
185 std::cout << "fDESegmentations (class "
186 << fDESegmentations->Class()->GetName() << ") entries="
187 << fDESegmentations->GetNofEntries()
189 fDESegmentations->Print(opt);
192 //______________________________________________________________________________
193 void AliMUONGeometrySegmentation::SetPadSize(Float_t p1, Float_t p2)
195 /// Set pad size Dx*Dy to all detection element segmentations
197 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
198 AliMUONVGeometryDESegmentation* segmentation
199 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
200 segmentation->SetPadSize(p1, p2);
204 //______________________________________________________________________________
205 void AliMUONGeometrySegmentation::SetDAnod(Float_t d)
207 /// Set anod pitch to all detection element segmentations
209 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
210 AliMUONVGeometryDESegmentation* segmentation
211 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
212 segmentation->SetDAnod(d);
216 //______________________________________________________________________________
217 Float_t AliMUONGeometrySegmentation::GetAnod(Int_t detElemId, Float_t xhit) const
219 /// Anod wire coordinate closest to xhit
220 /// Returns for a hit position xhit the position of the nearest anode wire
221 /// !!! xhit is understand a a distance, not as a position in the space
224 if (!OwnNotify(detElemId)) return 0;
226 return fCurrentSegmentation->GetAnod(xhit);
229 //______________________________________________________________________________
230 Bool_t AliMUONGeometrySegmentation::GetPadI(Int_t detElemId,
231 Float_t xg, Float_t yg, Float_t zg,
232 Int_t& ix, Int_t& iy)
234 /// Return pad coordinates (ix,iy) for given real coordinates (x,y)
236 if (!OwnNotify(detElemId)) return false;
239 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
241 if (!fCurrentSegmentation->HasPad(xl, yl, zl)) return false;
243 fCurrentSegmentation->GetPadI(xl, yl, zl, ix, iy);
247 //______________________________________________________________________________
249 AliMUONGeometrySegmentation::HasPad(Int_t detElemId, Int_t ix, Int_t iy)
251 // Tells if a given pad exists in a given detector element
253 if (!OwnNotify(detElemId) ) return false;
255 return fCurrentSegmentation->HasPad(ix,iy);
258 //______________________________________________________________________________
259 Bool_t AliMUONGeometrySegmentation::GetPadC(Int_t detElemId,
261 Float_t& xg, Float_t& yg, Float_t& zg)
263 /// Transform from pad to real coordinates
265 if (!OwnNotify(detElemId)) return false;
267 if (!fCurrentSegmentation->HasPad(ix, iy)) return false;
270 fCurrentSegmentation->GetPadC(ix, iy, xl , yl, zl);
272 fGeometryModule->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
276 //______________________________________________________________________________
277 Bool_t AliMUONGeometrySegmentation::GetPadE(Int_t detElemId,
278 Int_t &ix, Int_t &iy,
279 AliMUONSegmentManuIndex* connect)
281 /// Get pads for a given electronic connection
283 if (!OwnNotify(detElemId)) return false;
285 if (!fCurrentSegmentation->HasPad(ix, iy)) return false;
287 fCurrentSegmentation->GetPadE(ix, iy, connect);
291 //______________________________________________________________________________
292 AliMUONSegmentManuIndex* AliMUONGeometrySegmentation:: GetMpConnection(Int_t detElemId,
295 /// Get electronic connection for given pads
297 if (!OwnNotify(detElemId)) return 0x0;
299 AliMUONSegmentManuIndex* connect;
301 connect = fCurrentSegmentation->GetMpConnection(ix, iy);
302 if (connect == 0x0) return 0x0;
304 Int_t busPatchId = connect->GetBusPatchId();
307 // not very clean way, to be changed (Ch.F.)
309 if (detElemId/100 > 4 && detElemId/100 < 11)
311 else if (detElemId/100 < 5)
314 if (detElemId % 100 < 50)
315 busPatchId+= (detElemId/100 - 1)*100 + (detElemId % 100)*dBusPatch;
317 busPatchId+= (detElemId/100 - 1)*100 + ((detElemId-50) % 100)*dBusPatch + 50;
319 connect->SetBusPatchId(busPatchId);
324 //______________________________________________________________________________
325 void AliMUONGeometrySegmentation::Init(Int_t chamber)
327 /// Initialize segmentation.
328 /// Check that all detection elements have segmanetation set
330 // Loop over detection elements
331 AliMUONGeometryStore* detElements = fGeometryModule->GetDetElementStore();
333 for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
335 // Get detction element Id
336 Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
338 // Check segmentation
339 if (! fDESegmentations->Get(detElemId) ) {
340 AliError(Form("Detection element %d has not a segmentation set.",
341 detElements->GetEntry(i)->GetUniqueID()));
344 // Initialize DE Segmentation
345 ((AliSegmentation*)fDESegmentations->Get(detElemId))->Init(chamber);
350 //______________________________________________________________________________
351 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId) const
353 /// Get pad size in x
355 if (!OwnNotify(detElemId)) return 0.;
357 return fCurrentSegmentation->Dpx();
360 //______________________________________________________________________________
361 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId) const
363 /// Get pad size in y
365 if (!OwnNotify(detElemId)) return 0.;
367 return fCurrentSegmentation->Dpy();
370 //______________________________________________________________________________
371 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
373 /// Pad size in x by sector
375 if (!OwnNotify(detElemId)) return 0.;
377 return fCurrentSegmentation->Dpx(isector);
380 //______________________________________________________________________________
381 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
383 /// Pad size in x, y by Sector
385 if (!OwnNotify(detElemId)) return 0.;
387 return fCurrentSegmentation->Dpy(isector);
390 //______________________________________________________________________________
391 Int_t AliMUONGeometrySegmentation::Npx(Int_t detElemId) const
393 /// Maximum number of Pads in x
395 if (!OwnNotify(detElemId)) return 0;
397 return fCurrentSegmentation->Npx();
400 //______________________________________________________________________________
401 Int_t AliMUONGeometrySegmentation::Npy(Int_t detElemId) const
403 /// Maximum number of Pads in y
405 if (!OwnNotify(detElemId)) return 0;
407 return fCurrentSegmentation->Npy();
410 //______________________________________________________________________________
411 void AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
413 /// Set pad position.
414 /// Sets virtual pad coordinates, needed for evaluating pad response
415 /// outside the tracking program.
416 /// From AliMUONGeometrySegmentationV01.
418 if (!OwnNotify(detElemId)) return;
420 fCurrentSegmentation->SetPad(ix, iy);
423 //______________________________________________________________________________
424 void AliMUONGeometrySegmentation::SetHit(Int_t detElemId,
425 Float_t xghit, Float_t yghit, Float_t zghit)
428 /// Sets virtual hit position, needed for evaluating pad response
429 /// outside the tracking program
430 /// From AliMUONGeometrySegmentationV01.
432 if (!OwnNotify(detElemId)) return;
435 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
437 fCurrentSegmentation->SetHit(xl, yl, zl);
440 //______________________________________________________________________________
441 void AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
442 Float_t xghit, Float_t yghit, Float_t zghit,
443 Float_t dx, Float_t dy)
445 /// Iterate over pads - initialiser
447 if (!OwnNotify(detElemId)) return;
450 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
452 fCurrentSegmentation->FirstPad(xl, yl, zl, dx, dy);
455 //______________________________________________________________________________
456 void AliMUONGeometrySegmentation::NextPad(Int_t detElemId)
458 /// Iterate over pads - stepper
460 if (!OwnNotify(detElemId)) return;
462 fCurrentSegmentation->NextPad();
465 //______________________________________________________________________________
466 Int_t AliMUONGeometrySegmentation::MorePads(Int_t detElemId)
468 /// Iterate over pads - condition
470 if (!OwnNotify(detElemId)) return 0;
472 return fCurrentSegmentation->MorePads();
475 //______________________________________________________________________________
476 Float_t AliMUONGeometrySegmentation::Distance2AndOffset(Int_t detElemId,
478 Float_t xg, Float_t yg, Float_t zg,
481 /// Return the square of the distance between 1 pad
482 /// labelled by its channel numbers and a coordinate
484 if (!OwnNotify(detElemId)) return 0.;
487 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
489 return fCurrentSegmentation->Distance2AndOffset(ix, iy, xl, yl, dummy);
492 //______________________________________________________________________________
493 void AliMUONGeometrySegmentation::GetNParallelAndOffset(Int_t detElemId,
495 Int_t* nparallel, Int_t* offset)
497 /// Number of pads read in parallel and offset to add to x
498 /// (specific to LYON, but mandatory for display)
501 if (!OwnNotify(detElemId)) return;
503 fCurrentSegmentation->GetNParallelAndOffset(ix, iy, nparallel, offset);
507 //______________________________________________________________________________
508 void AliMUONGeometrySegmentation::Neighbours(Int_t detElemId,
511 Int_t xlist[10], Int_t ylist[10])
513 /// Get next neighbours
515 if (!OwnNotify(detElemId)) return;
517 fCurrentSegmentation->Neighbours(ix, iy, nlist, xlist, ylist);
520 //______________________________________________________________________________
521 Int_t AliMUONGeometrySegmentation::Ix()
523 /// Current pad cursor during disintegration
526 return fCurrentSegmentation->Ix();
529 //______________________________________________________________________________
530 Int_t AliMUONGeometrySegmentation::Iy()
532 /// Current pad cursor during disintegration
535 return fCurrentSegmentation->Iy();
538 //______________________________________________________________________________
539 Int_t AliMUONGeometrySegmentation::DetElemId()
541 /// Current pad cursor during disintegration
544 return fCurrentDetElemId;
547 //______________________________________________________________________________
548 Int_t AliMUONGeometrySegmentation::ISector()
552 return fCurrentSegmentation->ISector();
555 //______________________________________________________________________________
556 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
558 /// Calculate sector from pad coordinates
560 if (!OwnNotify(detElemId)) return 0;
562 return fCurrentSegmentation->Sector(ix, iy);
565 //______________________________________________________________________________
566 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId,
567 Float_t xg, Float_t yg, Float_t zg)
569 /// Calculate sector from pad coordinates
571 if (!OwnNotify(detElemId)) return 0;
574 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
576 return fCurrentSegmentation->Sector(xl, yl);
579 //______________________________________________________________________________
580 void AliMUONGeometrySegmentation::IntegrationLimits(Int_t detElemId,
581 Float_t& x1, Float_t& x2,
582 Float_t& y1, Float_t& y2)
584 /// Current integration limits
586 if (!OwnNotify(detElemId)) return;
588 fCurrentSegmentation->IntegrationLimits(x1, x2, y1, y2);
591 //______________________________________________________________________________
592 Int_t AliMUONGeometrySegmentation::SigGenCond(Int_t detElemId,
593 Float_t xg, Float_t yg, Float_t zg)
595 /// Signal Generation Condition during Stepping
596 /// 0: don't generate signal \n
597 /// 1: generate signal \n
600 /// Crossing of pad boundary and mid plane between neighbouring wires is checked.
601 /// To correctly simulate the dependence of the spatial resolution on the angle
602 /// of incidence signal must be generated for constant steps on
603 /// the projection of the trajectory along the anode wire.
605 /// Signal will be generated if particle crosses pad boundary or
606 /// boundary between two wires.
608 if (!OwnNotify(detElemId)) return 0;
611 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
613 return fCurrentSegmentation->SigGenCond(xl, yl, zl);
616 //______________________________________________________________________________
617 void AliMUONGeometrySegmentation::SigGenInit(Int_t detElemId,
618 Float_t xg, Float_t yg, Float_t zg)
620 /// Initialise signal generation at coord (x,y,z)
621 /// Initialise pad and wire position during stepping.
622 /// From AliMUONGeometrySegmentationV01
624 if (!OwnNotify(detElemId)) return;
627 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
629 if (!fCurrentSegmentation->HasPad(xl, yl, zl)) {
631 << "No pad at " << detElemId
632 << " global position: " << xg << " " << yg << " " << zg
633 << " local position: " << xl << " " << yl << " " << zl << endl;
637 fCurrentSegmentation->SigGenInit(xl, yl, zl);
640 //______________________________________________________________________________
641 void AliMUONGeometrySegmentation::GiveTestPoints(Int_t /*detElemId*/,
643 Float_t* /*xg*/, Float_t* /*yg*/) const
645 /// Test points for auto calibration
646 /// Return test point on the pad plane.
647 /// Used during determination of the segmoid correction of the COG-method
648 /// From AliMUONGeometrySegmentationV01
650 // Requires change of interface
651 // to convert points from local to global we need z coordinate
652 AliError("Not implemented.");
655 //______________________________________________________________________________
656 void AliMUONGeometrySegmentation::Draw(const char* opt)
658 /// Draw the segmentation zones for all detElemId
660 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
661 AliMUONVGeometryDESegmentation* segmentation
662 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
663 segmentation->Draw(opt);
667 //______________________________________________________________________________
668 void AliMUONGeometrySegmentation::Draw(Int_t detElemId, const char* opt)
670 /// Draw the segmentation zones for a given detElemId.
672 if (!OwnNotify(detElemId)) return;
674 fCurrentSegmentation->Draw(opt);
677 //______________________________________________________________________________
678 void AliMUONGeometrySegmentation::SetCorrFunc(Int_t detElemId,
679 Int_t isec, TF1* func)
681 /// Set the correction function.
682 /// From AliMUONGeometrySegmentationV01
684 if (!OwnNotify(detElemId)) return;
686 fCurrentSegmentation->SetCorrFunc(isec, func);
689 //______________________________________________________________________________
690 TF1* AliMUONGeometrySegmentation::CorrFunc(Int_t detElemId, Int_t isec) const
692 /// Get the correction Function.
693 /// From AliMUONGeometrySegmentationV01
695 if (!OwnNotify(detElemId)) return 0;
697 return fCurrentSegmentation->CorrFunc(isec);