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 **************************************************************************/
18 // Class AliMUONSt12QuadrantSegmentation
19 // -------------------------------------
20 // Segmentation for MUON quadrants of stations 1 and 2 using
21 // the mapping package
23 // Author: Ivana Hrivnacova, IPN Orsay
27 #include <TObjArray.h>
31 #include "AliMpArea.h"
32 #include "AliMpReader.h"
33 #include "AliMpSector.h"
34 #include "AliMpVPadIterator.h"
35 #include "AliMpSectorSegmentation.h"
37 #include "AliMUONSt12QuadrantSegmentation.h"
40 #include "AliMUONChamber.h"
43 ClassImp(AliMUONSt12QuadrantSegmentation)
45 const Float_t AliMUONSt12QuadrantSegmentation::fgkWireD = 0.20;
46 const Float_t AliMUONSt12QuadrantSegmentation::fgkLengthUnit = 0.1;
48 //______________________________________________________________________________
49 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
50 AliMpStationType stationType,
51 AliMpPlaneType planeType)
52 : AliMUONVGeometryDESegmentation(),
54 fSectorSegmentation(0),
78 AliMpReader r(stationType, planeType);
79 fSector = r.BuildSector();
80 fSectorSegmentation = new AliMpSectorSegmentation(fSector);
82 fCorrA = new TObjArray(3);
88 //______________________________________________________________________________
89 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation()
90 : AliMUONVGeometryDESegmentation(),
92 fSectorSegmentation(0),
113 // Default Constructor
116 //______________________________________________________________________________
117 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(const AliMUONSt12QuadrantSegmentation& rhs)
118 : AliMUONVGeometryDESegmentation(rhs)
121 AliFatal("Copy constructor is not implemented.");
124 //______________________________________________________________________________
125 AliMUONSt12QuadrantSegmentation::~AliMUONSt12QuadrantSegmentation() {
129 delete fSectorSegmentation;
130 delete fSectorIterator;
137 //______________________________________________________________________________
138 AliMUONSt12QuadrantSegmentation&
139 AliMUONSt12QuadrantSegmentation::operator=(const AliMUONSt12QuadrantSegmentation& rhs)
143 // check assignement to self
144 if (this == &rhs) return *this;
146 AliFatal("Assignment operator is not implemented.");
155 //______________________________________________________________________________
156 void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad)
158 // Updates current pad values.
161 fIx = pad.GetIndices().GetFirst();
162 fIy = pad.GetIndices().GetSecond();
163 fX = pad.Position().X() * fgkLengthUnit;
164 fY = pad.Position().Y() * fgkLengthUnit;
165 fZone = fSectorSegmentation->Zone(pad);
172 //______________________________________________________________________________
173 void AliMUONSt12QuadrantSegmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
175 // Set pad size Dx*Dy
178 AliFatal("Not uniform pad size.");
181 //______________________________________________________________________________
182 void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
190 //______________________________________________________________________________
191 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
193 // Returns true if a pad exists in the given position
195 AliMpPad pad = fSectorSegmentation
196 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), false);
198 return pad.IsValid();
202 //______________________________________________________________________________
203 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Int_t ix, Int_t iy)
205 // Returns true if a pad with given indices exists
207 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), false);
209 return pad.IsValid();
213 //______________________________________________________________________________
214 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
216 // Anod wire coordinate closest to xhit
217 // Returns for a hit position xhit the position of the nearest anode wire
218 // From AliMUONSegmentationV01.
221 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
222 : Int_t(xhit/fWireD) - 0.5;
227 //______________________________________________________________________________
228 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
229 Int_t& ix, Int_t& iy)
231 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
234 GetPadI(x, y, ix, iy);
237 //______________________________________________________________________________
238 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
239 Int_t& ix, Int_t& iy)
241 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
242 // If there is no pad, ix = 0, iy = 0 are returned.
245 AliMpPad pad = fSectorSegmentation
246 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), true);
248 ix = pad.GetIndices().GetFirst();
249 iy = pad.GetIndices().GetSecond();
252 //______________________________________________________________________________
253 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
254 Float_t& x, Float_t& y, Float_t& z)
256 // Transform from pad to real coordinates
260 GetPadC(ix, iy, x , y);
263 //______________________________________________________________________________
264 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
265 Float_t& x, Float_t& y)
267 // Transform from pad to real coordinates
268 // If there is no pad, x = 0., y = 0. are returned.
271 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
273 x = pad.Position().X() * fgkLengthUnit;
274 y = pad.Position().Y() * fgkLengthUnit;
278 //______________________________________________________________________________
279 void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
281 // Initialize segmentation
284 // find Npx, Npy and save this info
286 // reference to chamber
287 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
288 fChamber = &(pMUON->Chamber(chamber));
289 fRmin=fChamber->RInner();
290 fRmax=fChamber->ROuter();
295 //______________________________________________________________________________
296 Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
301 AliFatal( "Not uniform pad size.");
305 //______________________________________________________________________________
306 Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
311 AliFatal("Not uniform pad size.");
315 //______________________________________________________________________________
316 Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
318 // Pad size in x by sector
321 return fSectorSegmentation->PadDimensions(isector).X()*2.*fgkLengthUnit;
324 //______________________________________________________________________________
325 Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
327 // Pad size in x, y by Sector
330 return fSectorSegmentation->PadDimensions(isector).Y()*2.*fgkLengthUnit;
333 //______________________________________________________________________________
334 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
336 // Maximum number of Pads in x
337 // hard coded for the time being
340 //Fatal("Npx", "Not yet implemented.");
341 switch (fSector->GetDirection()) {
347 AliError("Unknown sector direction");
352 //______________________________________________________________________________
353 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
355 // Maximum number of Pads in y
356 // hard coded for the time being
359 //Fatal("Npy", "Not yet implemented.");
360 switch (fSector->GetDirection()) {
366 AliError("Unknown sector direction");
371 //______________________________________________________________________________
372 void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
375 // Sets virtual pad coordinates, needed for evaluating pad response
376 // outside the tracking program.
377 // From AliMUONSegmentationV01.
380 GetPadC(ix, iy, fX, fY);
381 fZone = Sector(ix, iy);
384 //______________________________________________________________________________
385 void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
388 // Sets virtual hit position, needed for evaluating pad response
389 // outside the tracking program
390 // From AliMUONSegmentationV01.
396 //______________________________________________________________________________
397 void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
398 Float_t dx, Float_t dy)
400 // Iterate over pads - initialiser
403 // Sets the current pad to that located in the hit position
405 SetHit(GetAnod(xhit), yhit, 0.);
407 // Enable iterating in one dimension
408 if (dx == 0.) dx = 0.01;
409 if (dy == 0.) dy = 0.01;
412 = fSectorSegmentation
413 ->CreateIterator(AliMpArea(TVector2(fXhit/fgkLengthUnit, fYhit/fgkLengthUnit),
414 TVector2(dx/fgkLengthUnit, dy/fgkLengthUnit)));
416 fSectorIterator->First();
418 if (! fSectorIterator->IsDone())
419 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
422 //______________________________________________________________________________
423 void AliMUONSt12QuadrantSegmentation::NextPad()
425 // Iterate over pads - stepper
428 fSectorIterator->Next();
430 if (! fSectorIterator->IsDone())
431 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
434 //______________________________________________________________________________
435 Int_t AliMUONSt12QuadrantSegmentation::MorePads()
437 // Iterate over pads - condition
440 if (fSectorIterator->IsDone())
446 //______________________________________________________________________________
447 Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
448 Float_t x, Float_t y, Int_t* /*dummy*/)
450 // Returns the square of the distance between 1 pad
451 // labelled by its channel numbers and a coordinate
454 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
457 AliFatal("Cannot locate pad.");
459 return (pad.Position()*fgkLengthUnit - TVector2(x, y)).Mod2();
462 //______________________________________________________________________________
463 void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
464 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
466 // Number of pads read in parallel and offset to add to x
467 // (specific to LYON, but mandatory for display)
470 AliFatal( "Not yet implemented.");
474 //______________________________________________________________________________
475 void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
477 Int_t Xlist[10], Int_t Ylist[10])
479 // Get next neighbours
482 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
485 AliMpVPadIterator* iter
486 = fSectorSegmentation
487 ->CreateIterator(AliMpArea(pad.Position(),2.*pad.Dimensions()*1.1));
489 for( iter->First(); !iter->IsDone() && i<10; iter->Next()) {
490 Xlist[i] = iter->CurrentItem().GetIndices().GetFirst();
491 Ylist[i] = iter->CurrentItem().GetIndices().GetSecond();
498 //______________________________________________________________________________
499 Int_t AliMUONSt12QuadrantSegmentation::Ix()
501 // Current pad cursor during disintegration
505 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
508 //______________________________________________________________________________
509 Int_t AliMUONSt12QuadrantSegmentation::Iy()
511 // Current pad cursor during disintegration
515 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
518 //______________________________________________________________________________
519 Int_t AliMUONSt12QuadrantSegmentation::ISector()
527 //______________________________________________________________________________
528 Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
530 // Calculate sector from pad coordinates
533 return fSectorSegmentation
534 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
537 //______________________________________________________________________________
538 Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
540 // Calculate sector from pad coordinates
543 return fSectorSegmentation
544 ->Zone(fSectorSegmentation
545 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit)));
548 //______________________________________________________________________________
549 void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
550 Float_t& y1, Float_t& y2)
552 // Current integration limits
555 x1 = fXhit - fX - Dpx(fZone)/2.;
556 x2 = x1 + Dpx(fZone);
558 y1 = fYhit - fY - Dpy(fZone)/2.;
559 y2 = y1 + Dpy(fZone);
562 //______________________________________________________________________________
563 Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
565 // Signal Generation Condition during Stepping
566 // 0: don't generate signal
567 // 1: generate signal
570 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
571 // To correctly simulate the dependence of the spatial resolution on the angle
572 // of incidence signal must be generated for constant steps on
573 // the projection of the trajectory along the anode wire.
575 // Signal will be generated if particle crosses pad boundary or
576 // boundary between two wires.
578 // From AliMUONSegmentationV01
582 GetPadI(x, y, ixt, iyt);
583 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
585 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
594 //______________________________________________________________________________
595 void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
597 // Initialise signal generation at coord (x,y,z)
598 // Initialises pad and wire position during stepping.
599 // From AliMUONSegmentationV01
604 GetPadI(x, y, fIxt, fIyt);
605 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
608 //______________________________________________________________________________
609 void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
611 // Test points for auto calibration
612 // Returns test point on the pad plane.
613 // Used during determination of the segmoid correction of the COG-method
614 // From AliMUONSegmentationV01
618 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
622 //______________________________________________________________________________
623 void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
625 // Draw the segmentation zones.
626 // (Called from AliMUON::BuildGeometry)
629 AliWarning("Not yet implemented.");
632 //______________________________________________________________________________
633 void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
635 // Set the correction function.
636 // From AliMUONSegmentationV01
639 fCorrA->AddAt(func, isec);
642 //______________________________________________________________________________
643 TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
645 // Get the correction Function.
646 // From AliMUONSegmentationV01
649 return (TF1*) fCorrA->At(isec);