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"
38 ClassImp(AliMUONGeometrySegmentation)
40 const Float_t AliMUONGeometrySegmentation::fgkMaxDistance = 1.0e11;
42 //______________________________________________________________________________
43 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
44 AliMUONGeometryModule* geometry)
47 fCurrentDetElement(0),
48 fCurrentSegmentation(0),
49 fGeometryModule(geometry),
53 /// Standard constructor
56 = new AliMUONGeometryStore(geometry->GetDEIndexing(), false);
59 //______________________________________________________________________________
60 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation()
63 fCurrentDetElement(0),
64 fCurrentSegmentation(0),
68 /// Default Constructor
71 //______________________________________________________________________________
72 AliMUONGeometrySegmentation::AliMUONGeometrySegmentation(
73 const AliMUONGeometrySegmentation& rhs)
76 /// Protected copy constructor
78 AliFatal("Copy constructor is not implemented.");
81 //______________________________________________________________________________
82 AliMUONGeometrySegmentation::~AliMUONGeometrySegmentation()
86 delete fDESegmentations;
93 //______________________________________________________________________________
94 AliMUONGeometrySegmentation&
95 AliMUONGeometrySegmentation::operator=(const AliMUONGeometrySegmentation& rhs)
97 /// Protected assignment operator
99 // check assignement to self
100 if (this == &rhs) return *this;
102 AliFatal("Assignment operator is not implemented.");
111 //______________________________________________________________________________
112 Bool_t AliMUONGeometrySegmentation::OwnNotify(Int_t detElemId) const
114 /// Update current detection element and segmentation,
115 /// and checks if they exist.
116 /// Return true if success.
118 if (detElemId != fCurrentDetElemId) {
120 // Find detection element and its segmentation
121 AliMUONGeometryDetElement* detElement
122 = fGeometryModule->GetDetElement(detElemId);
124 AliError(Form("Detection element %d not defined", detElemId));
128 AliMUONVGeometryDESegmentation* segmentation
129 = (AliMUONVGeometryDESegmentation*) fDESegmentations->Get(detElemId);
131 AliError(Form("Segmentation for detection element %d not defined",
136 fCurrentDetElemId = detElemId;
137 fCurrentDetElement = detElement;
138 fCurrentSegmentation = segmentation;
148 //______________________________________________________________________________
149 void AliMUONGeometrySegmentation::Add(Int_t detElemId,
150 AliMUONVGeometryDESegmentation* segmentation)
152 /// Add detection element segmentation
154 fDESegmentations->Add(detElemId, segmentation);
158 //______________________________________________________________________________
159 const AliMUONVGeometryDESegmentation*
160 AliMUONGeometrySegmentation::GetDESegmentation(Int_t detElemId) const
162 /// Return the DE segmentation
164 if (!OwnNotify(detElemId)) return 0;
166 return fCurrentSegmentation;
169 //______________________________________________________________________________
170 AliMUONGeometryDirection
171 AliMUONGeometrySegmentation::GetDirection(Int_t detElemId) const
173 /// Return direction with a constant pad size
174 /// (Direction or coordinate where the resolution is the best)
176 if (!OwnNotify(detElemId)) return kDirUndefined;
178 return fCurrentSegmentation->GetDirection();
181 //______________________________________________________________________________
182 void AliMUONGeometrySegmentation::Print(Option_t* opt) const
184 // Print DE segmentations
186 std::cout << "fDESegmentations (class "
187 << fDESegmentations->Class()->GetName() << ") entries="
188 << fDESegmentations->GetNofEntries()
190 fDESegmentations->Print(opt);
193 //______________________________________________________________________________
194 void AliMUONGeometrySegmentation::SetPadSize(Float_t p1, Float_t p2)
196 /// Set pad size Dx*Dy 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->SetPadSize(p1, p2);
205 //______________________________________________________________________________
206 void AliMUONGeometrySegmentation::SetDAnod(Float_t d)
208 /// Set anod pitch to all detection element segmentations
210 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
211 AliMUONVGeometryDESegmentation* segmentation
212 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
213 segmentation->SetDAnod(d);
217 //______________________________________________________________________________
218 Float_t AliMUONGeometrySegmentation::GetAnod(Int_t detElemId, Float_t xhit) const
220 /// Anod wire coordinate closest to xhit
221 /// Returns for a hit position xhit the position of the nearest anode wire
222 /// !!! xhit is understand a a distance, not as a position in the space
225 if (!OwnNotify(detElemId)) return 0;
227 return fCurrentSegmentation->GetAnod(xhit);
230 //______________________________________________________________________________
231 Bool_t AliMUONGeometrySegmentation::GetPadI(Int_t detElemId,
232 Float_t xg, Float_t yg, Float_t zg,
233 Int_t& ix, Int_t& iy)
235 /// Return pad coordinates (ix,iy) for given real coordinates (x,y)
237 if (!OwnNotify(detElemId)) return false;
240 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
242 if (!fCurrentSegmentation->HasPad(xl, yl, zl)) return false;
244 fCurrentSegmentation->GetPadI(xl, yl, zl, ix, iy);
248 //______________________________________________________________________________
250 AliMUONGeometrySegmentation::HasPad(Int_t detElemId, Int_t ix, Int_t iy)
252 // Tells if a given pad exists in a given detector element
254 if (!OwnNotify(detElemId)) return false;
256 return fCurrentSegmentation->HasPad(ix,iy);
259 //______________________________________________________________________________
261 AliMUONGeometrySegmentation::GetPadC(Int_t detElemId,
263 Float_t& xg, Float_t& yg, Float_t& zg)
265 /// Transform from pad to real coordinates
267 if (!OwnNotify(detElemId)) return false;
269 if (!fCurrentSegmentation->HasPad(ix, iy)) {
270 xg = yg = zg = fgkMaxDistance;
275 fCurrentSegmentation->GetPadC(ix, iy, xl , yl, zl);
277 fGeometryModule->Local2Global(detElemId, xl, yl, zl, xg, yg, zg);
281 //______________________________________________________________________________
282 void AliMUONGeometrySegmentation::Init(Int_t chamber)
284 /// Initialize segmentation.
285 /// Check that all detection elements have segmanetation set
287 // Loop over detection elements
288 AliMUONGeometryStore* detElements = fGeometryModule->GetDetElementStore();
290 for (Int_t i=0; i<detElements->GetNofEntries(); i++) {
292 // Get detction element Id
293 Int_t detElemId = detElements->GetEntry(i)->GetUniqueID();
295 // Check segmentation
296 if (! fDESegmentations->Get(detElemId) ) {
297 AliError(Form("Detection element %d has not a segmentation set.",
298 detElements->GetEntry(i)->GetUniqueID()));
301 // Initialize DE Segmentation
302 ((AliSegmentation*)fDESegmentations->Get(detElemId))->Init(chamber);
307 //______________________________________________________________________________
308 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId) const
310 /// Get pad size in x
312 if (!OwnNotify(detElemId)) return 0.;
314 return fCurrentSegmentation->Dpx();
317 //______________________________________________________________________________
318 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId) const
320 /// Get pad size in y
322 if (!OwnNotify(detElemId)) return 0.;
324 return fCurrentSegmentation->Dpy();
327 //______________________________________________________________________________
328 Float_t AliMUONGeometrySegmentation::Dpx(Int_t detElemId, Int_t isector) const
330 /// Pad size in x by sector
332 if (!OwnNotify(detElemId)) return 0.;
334 return fCurrentSegmentation->Dpx(isector);
337 //______________________________________________________________________________
338 Float_t AliMUONGeometrySegmentation::Dpy(Int_t detElemId, Int_t isector) const
340 /// Pad size in x, y by Sector
342 if (!OwnNotify(detElemId)) return 0.;
344 return fCurrentSegmentation->Dpy(isector);
347 //______________________________________________________________________________
348 Int_t AliMUONGeometrySegmentation::Npx(Int_t detElemId) const
350 /// Maximum number of Pads in x
352 if (!OwnNotify(detElemId)) return 0;
354 return fCurrentSegmentation->Npx();
357 //______________________________________________________________________________
358 Int_t AliMUONGeometrySegmentation::Npy(Int_t detElemId) const
360 /// Maximum number of Pads in y
362 if (!OwnNotify(detElemId)) return 0;
364 return fCurrentSegmentation->Npy();
367 //______________________________________________________________________________
368 void AliMUONGeometrySegmentation::SetPad(Int_t detElemId, Int_t ix, Int_t iy)
370 /// Set pad position.
371 /// Sets virtual pad coordinates, needed for evaluating pad response
372 /// outside the tracking program.
373 /// From AliMUONGeometrySegmentationV01.
375 if (!OwnNotify(detElemId)) return;
377 fCurrentSegmentation->SetPad(ix, iy);
380 //______________________________________________________________________________
381 void AliMUONGeometrySegmentation::SetHit(Int_t detElemId,
382 Float_t xghit, Float_t yghit, Float_t zghit)
385 /// Sets virtual hit position, needed for evaluating pad response
386 /// outside the tracking program
387 /// From AliMUONGeometrySegmentationV01.
389 if (!OwnNotify(detElemId)) return;
392 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
394 fCurrentSegmentation->SetHit(xl, yl, zl);
397 //______________________________________________________________________________
398 void AliMUONGeometrySegmentation::FirstPad(Int_t detElemId,
399 Float_t xghit, Float_t yghit, Float_t zghit,
400 Float_t dx, Float_t dy)
402 /// Iterate over pads - initialiser
404 if (!OwnNotify(detElemId)) return;
407 fCurrentDetElement->Global2Local(xghit, yghit, zghit, xl, yl, zl);
409 fCurrentSegmentation->FirstPad(xl, yl, zl, dx, dy);
412 //______________________________________________________________________________
413 void AliMUONGeometrySegmentation::NextPad(Int_t detElemId)
415 /// Iterate over pads - stepper
417 if (!OwnNotify(detElemId)) return;
419 fCurrentSegmentation->NextPad();
422 //______________________________________________________________________________
423 Int_t AliMUONGeometrySegmentation::MorePads(Int_t detElemId)
425 /// Iterate over pads - condition
427 if (!OwnNotify(detElemId)) return 0;
429 return fCurrentSegmentation->MorePads();
432 //______________________________________________________________________________
433 Float_t AliMUONGeometrySegmentation::Distance2AndOffset(Int_t detElemId,
435 Float_t xg, Float_t yg, Float_t zg,
438 /// Return the square of the distance between 1 pad
439 /// labelled by its channel numbers and a coordinate
441 if (!OwnNotify(detElemId)) return 0.;
444 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
446 return fCurrentSegmentation->Distance2AndOffset(ix, iy, xl, yl, dummy);
449 //______________________________________________________________________________
450 void AliMUONGeometrySegmentation::GetNParallelAndOffset(Int_t detElemId,
452 Int_t* nparallel, Int_t* offset)
454 /// Number of pads read in parallel and offset to add to x
455 /// (specific to LYON, but mandatory for display)
458 if (!OwnNotify(detElemId)) return;
460 fCurrentSegmentation->GetNParallelAndOffset(ix, iy, nparallel, offset);
464 //______________________________________________________________________________
465 void AliMUONGeometrySegmentation::Neighbours(Int_t detElemId,
468 Int_t xlist[10], Int_t ylist[10])
470 /// Get next neighbours
472 if (!OwnNotify(detElemId)) return;
474 fCurrentSegmentation->Neighbours(ix, iy, nlist, xlist, ylist);
477 //______________________________________________________________________________
478 Int_t AliMUONGeometrySegmentation::Ix()
480 /// Current pad cursor during disintegration
483 return fCurrentSegmentation->Ix();
486 //______________________________________________________________________________
487 Int_t AliMUONGeometrySegmentation::Iy()
489 /// Current pad cursor during disintegration
492 return fCurrentSegmentation->Iy();
495 //______________________________________________________________________________
496 Int_t AliMUONGeometrySegmentation::DetElemId()
498 /// Current pad cursor during disintegration
501 return fCurrentDetElemId;
504 //______________________________________________________________________________
505 Int_t AliMUONGeometrySegmentation::ISector()
509 return fCurrentSegmentation->ISector();
512 //______________________________________________________________________________
513 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId, Int_t ix, Int_t iy)
515 /// Calculate sector from pad coordinates
517 if (!OwnNotify(detElemId)) return 0;
519 return fCurrentSegmentation->Sector(ix, iy);
522 //______________________________________________________________________________
523 Int_t AliMUONGeometrySegmentation::Sector(Int_t detElemId,
524 Float_t xg, Float_t yg, Float_t zg)
526 /// Calculate sector from pad coordinates
528 if (!OwnNotify(detElemId)) return 0;
531 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
533 return fCurrentSegmentation->Sector(xl, yl);
536 //______________________________________________________________________________
537 void AliMUONGeometrySegmentation::IntegrationLimits(Int_t detElemId,
538 Float_t& x1, Float_t& x2,
539 Float_t& y1, Float_t& y2)
541 /// Current integration limits
543 if (!OwnNotify(detElemId)) return;
545 fCurrentSegmentation->IntegrationLimits(x1, x2, y1, y2);
548 //______________________________________________________________________________
549 Int_t AliMUONGeometrySegmentation::SigGenCond(Int_t detElemId,
550 Float_t xg, Float_t yg, Float_t zg)
552 /// Signal Generation Condition during Stepping
553 /// 0: don't generate signal \n
554 /// 1: generate signal \n
557 /// Crossing of pad boundary and mid plane between neighbouring wires is checked.
558 /// To correctly simulate the dependence of the spatial resolution on the angle
559 /// of incidence signal must be generated for constant steps on
560 /// the projection of the trajectory along the anode wire.
562 /// Signal will be generated if particle crosses pad boundary or
563 /// boundary between two wires.
565 if (!OwnNotify(detElemId)) return 0;
568 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
570 return fCurrentSegmentation->SigGenCond(xl, yl, zl);
573 //______________________________________________________________________________
574 void AliMUONGeometrySegmentation::SigGenInit(Int_t detElemId,
575 Float_t xg, Float_t yg, Float_t zg)
577 /// Initialise signal generation at coord (x,y,z)
578 /// Initialise pad and wire position during stepping.
579 /// From AliMUONGeometrySegmentationV01
581 if (!OwnNotify(detElemId)) return;
584 fCurrentDetElement->Global2Local(xg, yg, zg, xl, yl, zl);
586 if (!fCurrentSegmentation->HasPad(xl, yl, zl)) {
588 << "No pad at " << detElemId
589 << " global position: " << xg << " " << yg << " " << zg
590 << " local position: " << xl << " " << yl << " " << zl << endl;
594 fCurrentSegmentation->SigGenInit(xl, yl, zl);
597 //______________________________________________________________________________
598 void AliMUONGeometrySegmentation::GiveTestPoints(Int_t /*detElemId*/,
600 Float_t* /*xg*/, Float_t* /*yg*/) const
602 /// Test points for auto calibration
603 /// Return test point on the pad plane.
604 /// Used during determination of the segmoid correction of the COG-method
605 /// From AliMUONGeometrySegmentationV01
607 // Requires change of interface
608 // to convert points from local to global we need z coordinate
609 AliError("Not implemented.");
612 //______________________________________________________________________________
613 void AliMUONGeometrySegmentation::Draw(const char* opt)
615 /// Draw the segmentation zones for all detElemId
617 for (Int_t i=0; i<fDESegmentations->GetNofEntries(); i++) {
618 AliMUONVGeometryDESegmentation* segmentation
619 = (AliMUONVGeometryDESegmentation*)fDESegmentations->GetEntry(i);
620 segmentation->Draw(opt);
624 //______________________________________________________________________________
625 void AliMUONGeometrySegmentation::Draw(Int_t detElemId, const char* opt)
627 /// Draw the segmentation zones for a given detElemId.
629 if (!OwnNotify(detElemId)) return;
631 fCurrentSegmentation->Draw(opt);
634 //______________________________________________________________________________
635 void AliMUONGeometrySegmentation::SetCorrFunc(Int_t detElemId,
636 Int_t isec, TF1* func)
638 /// Set the correction function.
639 /// From AliMUONGeometrySegmentationV01
641 if (!OwnNotify(detElemId)) return;
643 fCurrentSegmentation->SetCorrFunc(isec, func);
646 //______________________________________________________________________________
647 TF1* AliMUONGeometrySegmentation::CorrFunc(Int_t detElemId, Int_t isec) const
649 /// Get the correction Function.
650 /// From AliMUONGeometrySegmentationV01
652 if (!OwnNotify(detElemId)) return 0;
654 return fCurrentSegmentation->CorrFunc(isec);