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 AliMUONGeometryDirection AliMUONSt12QuadrantSegmentation::GetDirection()
216 // Returns the direction with a constant pad size (Direction or coordinate where the resolution is the best)
218 switch ( fSector->GetDirection() ) {
219 case kX: return kDirX;
220 case kY: return kDirY;
221 default: return kDirUndefined;
225 //______________________________________________________________________________
226 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
228 // Anod wire coordinate closest to xhit
229 // Returns for a hit position xhit the position of the nearest anode wire
230 // From AliMUONSegmentationV01.
233 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
234 : Int_t(xhit/fWireD) - 0.5;
239 //______________________________________________________________________________
240 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
241 Int_t& ix, Int_t& iy)
243 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
246 GetPadI(x, y, ix, iy);
249 //______________________________________________________________________________
250 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
251 Int_t& ix, Int_t& iy)
253 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
254 // If there is no pad, ix = 0, iy = 0 are returned.
257 AliMpPad pad = fSectorSegmentation
258 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), true);
260 ix = pad.GetIndices().GetFirst();
261 iy = pad.GetIndices().GetSecond();
264 //______________________________________________________________________________
265 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
266 Float_t& x, Float_t& y, Float_t& z)
268 // Transform from pad to real coordinates
272 GetPadC(ix, iy, x , y);
275 //______________________________________________________________________________
276 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
277 Float_t& x, Float_t& y)
279 // Transform from pad to real coordinates
280 // If there is no pad, x = 0., y = 0. are returned.
283 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
285 x = pad.Position().X() * fgkLengthUnit;
286 y = pad.Position().Y() * fgkLengthUnit;
290 //______________________________________________________________________________
291 void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
293 // Initialize segmentation
296 // find Npx, Npy and save this info
298 // reference to chamber
299 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
300 fChamber = &(pMUON->Chamber(chamber));
301 fRmin=fChamber->RInner();
302 fRmax=fChamber->ROuter();
307 //______________________________________________________________________________
308 Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
313 AliFatal( "Not uniform pad size.");
317 //______________________________________________________________________________
318 Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
323 AliFatal("Not uniform pad size.");
327 //______________________________________________________________________________
328 Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
330 // Pad size in x by sector
333 return fSectorSegmentation->PadDimensions(isector).X()*2.*fgkLengthUnit;
336 //______________________________________________________________________________
337 Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
339 // Pad size in x, y by Sector
342 return fSectorSegmentation->PadDimensions(isector).Y()*2.*fgkLengthUnit;
345 //______________________________________________________________________________
346 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
348 // Maximum number of Pads in x
349 // hard coded for the time being
352 //Fatal("Npx", "Not yet implemented.");
353 switch (fSector->GetDirection()) {
359 AliError("Unknown sector direction");
364 //______________________________________________________________________________
365 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
367 // Maximum number of Pads in y
368 // hard coded for the time being
371 //Fatal("Npy", "Not yet implemented.");
372 switch (fSector->GetDirection()) {
378 AliError("Unknown sector direction");
383 //______________________________________________________________________________
384 void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
387 // Sets virtual pad coordinates, needed for evaluating pad response
388 // outside the tracking program.
389 // From AliMUONSegmentationV01.
392 GetPadC(ix, iy, fX, fY);
393 fZone = Sector(ix, iy);
396 //______________________________________________________________________________
397 void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
400 // Sets virtual hit position, needed for evaluating pad response
401 // outside the tracking program
402 // From AliMUONSegmentationV01.
408 //______________________________________________________________________________
409 void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
410 Float_t dx, Float_t dy)
412 // Iterate over pads - initialiser
415 // Sets the current pad to that located in the hit position
417 SetHit(GetAnod(xhit), yhit, 0.);
419 // Enable iterating in one dimension
420 if (dx == 0.) dx = 0.01;
421 if (dy == 0.) dy = 0.01;
424 = fSectorSegmentation
425 ->CreateIterator(AliMpArea(TVector2(fXhit/fgkLengthUnit, fYhit/fgkLengthUnit),
426 TVector2(dx/fgkLengthUnit, dy/fgkLengthUnit)));
428 fSectorIterator->First();
430 if (! fSectorIterator->IsDone())
431 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
434 //______________________________________________________________________________
435 void AliMUONSt12QuadrantSegmentation::NextPad()
437 // Iterate over pads - stepper
440 fSectorIterator->Next();
442 if (! fSectorIterator->IsDone())
443 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
446 //______________________________________________________________________________
447 Int_t AliMUONSt12QuadrantSegmentation::MorePads()
449 // Iterate over pads - condition
452 if (fSectorIterator->IsDone())
458 //______________________________________________________________________________
459 Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
460 Float_t x, Float_t y, Int_t* /*dummy*/)
462 // Returns the square of the distance between 1 pad
463 // labelled by its channel numbers and a coordinate
466 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
469 AliFatal("Cannot locate pad.");
471 return (pad.Position()*fgkLengthUnit - TVector2(x, y)).Mod2();
474 //______________________________________________________________________________
475 void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
476 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
478 // Number of pads read in parallel and offset to add to x
479 // (specific to LYON, but mandatory for display)
482 AliFatal( "Not yet implemented.");
486 //______________________________________________________________________________
487 void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
489 Int_t Xlist[10], Int_t Ylist[10])
491 // Get next neighbours
494 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
497 AliMpVPadIterator* iter
498 = fSectorSegmentation
499 ->CreateIterator(AliMpArea(pad.Position(),2.*pad.Dimensions()*1.1));
501 for( iter->First(); !iter->IsDone() && i<10; iter->Next()) {
502 Xlist[i] = iter->CurrentItem().GetIndices().GetFirst();
503 Ylist[i] = iter->CurrentItem().GetIndices().GetSecond();
510 //______________________________________________________________________________
511 Int_t AliMUONSt12QuadrantSegmentation::Ix()
513 // Current pad cursor during disintegration
517 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
520 //______________________________________________________________________________
521 Int_t AliMUONSt12QuadrantSegmentation::Iy()
523 // Current pad cursor during disintegration
527 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
530 //______________________________________________________________________________
531 Int_t AliMUONSt12QuadrantSegmentation::ISector()
539 //______________________________________________________________________________
540 Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
542 // Calculate sector from pad coordinates
545 return fSectorSegmentation
546 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
549 //______________________________________________________________________________
550 Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
552 // Calculate sector from pad coordinates
555 return fSectorSegmentation
556 ->Zone(fSectorSegmentation
557 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit)));
560 //______________________________________________________________________________
561 void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
562 Float_t& y1, Float_t& y2)
564 // Current integration limits
567 x1 = fXhit - fX - Dpx(fZone)/2.;
568 x2 = x1 + Dpx(fZone);
570 y1 = fYhit - fY - Dpy(fZone)/2.;
571 y2 = y1 + Dpy(fZone);
574 //______________________________________________________________________________
575 Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
577 // Signal Generation Condition during Stepping
578 // 0: don't generate signal
579 // 1: generate signal
582 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
583 // To correctly simulate the dependence of the spatial resolution on the angle
584 // of incidence signal must be generated for constant steps on
585 // the projection of the trajectory along the anode wire.
587 // Signal will be generated if particle crosses pad boundary or
588 // boundary between two wires.
590 // From AliMUONSegmentationV01
594 GetPadI(x, y, ixt, iyt);
595 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
597 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
606 //______________________________________________________________________________
607 void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
609 // Initialise signal generation at coord (x,y,z)
610 // Initialises pad and wire position during stepping.
611 // From AliMUONSegmentationV01
616 GetPadI(x, y, fIxt, fIyt);
617 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
620 //______________________________________________________________________________
621 void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
623 // Test points for auto calibration
624 // Returns test point on the pad plane.
625 // Used during determination of the segmoid correction of the COG-method
626 // From AliMUONSegmentationV01
630 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
634 //______________________________________________________________________________
635 void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
637 // Draw the segmentation zones.
638 // (Called from AliMUON::BuildGeometry)
641 AliWarning("Not yet implemented.");
644 //______________________________________________________________________________
645 void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
647 // Set the correction function.
648 // From AliMUONSegmentationV01
651 fCorrA->AddAt(func, isec);
654 //______________________________________________________________________________
655 TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
657 // Get the correction Function.
658 // From AliMUONSegmentationV01
661 return (TF1*) fCorrA->At(isec);