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 // -------------------------------------
19 // Class AliMUONSt12QuadrantSegmentation
20 // -------------------------------------
21 // Segmentation for MUON quadrants of stations 1 and 2 using
22 // the mapping package
23 // Author: Ivana Hrivnacova, IPN Orsay
27 #include <TObjArray.h>
34 #include "AliMpArea.h"
35 #include "AliMpSectorReader.h"
36 #include "AliMpSector.h"
37 #include "AliMpVPadIterator.h"
38 #include "AliMpSectorSegmentation.h"
39 #include "AliMpFiles.h"
40 #include "AliMpNeighboursPadIterator.h"
42 #include "AliMUONSt12QuadrantSegmentation.h"
43 #include "AliMUONConstants.h"
45 ClassImp(AliMUONSt12QuadrantSegmentation)
47 //______________________________________________________________________________
48 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
49 AliMpVSegmentation* segmentation,
50 AliMpStationType stationType,
51 AliMpPlaneType planeType)
52 : AliMUONVGeometryDESegmentation(),
53 fStationType(stationType),
54 fPlaneType(planeType),
56 fSectorSegmentation(0),
80 fSectorSegmentation = dynamic_cast<AliMpSectorSegmentation*>(segmentation);
81 if (fSectorSegmentation)
82 fSector = fSectorSegmentation->GetSector();
84 AliFatal("Wrong mapping segmentation type");
87 if ( stationType == kStation1 )
88 fWireD = AliMUONConstants::PitchSt1();
89 else if ( stationType == kStation2 )
90 fWireD = AliMUONConstants::Pitch();
92 AliFatal("Wrong station type");
94 fCorrA = new TObjArray(3);
99 AliDebug(1, Form("ctor this = %p", this) );
102 //______________________________________________________________________________
103 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation()
104 : AliMUONVGeometryDESegmentation(),
105 fStationType(kStation1),
106 fPlaneType(kBendingPlane),
108 fSectorSegmentation(0),
129 // Default Constructor
131 AliDebug(1, Form("default (empty) ctor this = %p", this));
134 //______________________________________________________________________________
135 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(const AliMUONSt12QuadrantSegmentation& rhs)
136 : AliMUONVGeometryDESegmentation(rhs)
139 AliFatal("Copy constructor is not implemented.");
142 //______________________________________________________________________________
143 AliMUONSt12QuadrantSegmentation::~AliMUONSt12QuadrantSegmentation() {
146 AliDebug(1, Form("dtor this = %p", this));
149 delete fSectorSegmentation;
150 delete fSectorIterator;
157 //______________________________________________________________________________
158 AliMUONSt12QuadrantSegmentation&
159 AliMUONSt12QuadrantSegmentation::operator=(const AliMUONSt12QuadrantSegmentation& rhs)
163 // check assignement to self
164 if (this == &rhs) return *this;
166 AliFatal("Assignment operator is not implemented.");
175 //______________________________________________________________________________
176 void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad)
178 // Updates current pad values.
181 fIx = pad.GetIndices().GetFirst();
182 fIy = pad.GetIndices().GetSecond();
183 fX = pad.Position().X();
184 fY = pad.Position().Y();
185 fZone = fSectorSegmentation->Zone(pad);
193 //______________________________________________________________________________
194 void AliMUONSt12QuadrantSegmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
196 // Set pad size Dx*Dy
199 AliFatal("Not uniform pad size.");
202 //______________________________________________________________________________
203 void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
211 #include "AliMpMotifMap.h"
212 //______________________________________________________________________________
213 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
215 // Returns true if a pad exists in the given position
217 // fSector->GetMotifMap()->Print();
219 AliMpPad pad = fSectorSegmentation
220 ->PadByPosition(TVector2(x,y), false);
222 return pad.IsValid();
226 //______________________________________________________________________________
227 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Int_t ix, Int_t iy)
229 // Returns true if a pad with given indices exists
231 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), false);
233 return pad.IsValid();
237 //______________________________________________________________________________
238 AliMUONGeometryDirection AliMUONSt12QuadrantSegmentation::GetDirection()
240 // Returns the direction with a constant pad size
241 // (Direction or coordinate where the resolution is the best)
243 switch ( fSector->GetDirection() ) {
244 case kX: return kDirX;
245 case kY: return kDirY;
246 default: return kDirUndefined;
250 //______________________________________________________________________________
251 const AliMpVSegmentation*
252 AliMUONSt12QuadrantSegmentation::GetMpSegmentation() const
254 // Returns the mapping segmentation
255 // (provides access to electronics info)
257 return fSectorSegmentation;
260 //______________________________________________________________________________
261 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
263 // Anod wire coordinate closest to xhit
264 // Returns for a hit position xhit the position of the nearest anode wire
265 // From AliMUONSegmentationV01.
268 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
269 : Int_t(xhit/fWireD) - 0.5;
274 //______________________________________________________________________________
275 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
276 Int_t& ix, Int_t& iy)
278 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
281 GetPadI(x, y, ix, iy);
284 //______________________________________________________________________________
285 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
286 Int_t& ix, Int_t& iy)
288 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
289 // If there is no pad, ix = 0, iy = 0 are returned.
292 AliMpPad pad = fSectorSegmentation->PadByPosition(TVector2(x,y), true);
294 ix = pad.GetIndices().GetFirst();
295 iy = pad.GetIndices().GetSecond();
298 //______________________________________________________________________________
299 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
300 Float_t& x, Float_t& y, Float_t& z)
302 // Transform from pad to real coordinates
306 GetPadC(ix, iy, x , y);
309 //______________________________________________________________________________
310 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
311 Float_t& x, Float_t& y)
313 // Transform from pad to real coordinates
314 // If there is no pad, x = 0., y = 0. are returned.
317 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
319 x = pad.Position().X();
320 y = pad.Position().Y();
324 //______________________________________________________________________________
325 void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
327 // Initialize segmentation
330 // find Npx, Npy and save this info
332 // reference to chamber
333 fRmin=AliMUONConstants::Rmin(0);
334 fRmax=AliMUONConstants::Rmax(0);
339 //______________________________________________________________________________
340 Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
345 AliFatal( "Not uniform pad size.");
349 //______________________________________________________________________________
350 Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
355 AliFatal("Not uniform pad size.");
359 //______________________________________________________________________________
360 Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
362 // Pad size in x by sector
365 return fSectorSegmentation->PadDimensions(isector).X()*2.0;
368 //______________________________________________________________________________
369 Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
371 // Pad size in x, y by Sector
374 return fSectorSegmentation->PadDimensions(isector).Y()*2.0;
377 //______________________________________________________________________________
378 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
380 // Maximum number of Pads in x
381 // hard coded for the time being
384 return fSectorSegmentation->MaxPadIndexX();
387 //______________________________________________________________________________
388 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
390 // Maximum number of Pads in y
391 // hard coded for the time being
394 return fSectorSegmentation->MaxPadIndexY();
397 //______________________________________________________________________________
398 void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
401 // Sets virtual pad coordinates, needed for evaluating pad response
402 // outside the tracking program.
403 // From AliMUONSegmentationV01.
406 GetPadC(ix, iy, fX, fY);
407 fZone = Sector(ix, iy);
410 //______________________________________________________________________________
411 void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
414 // Sets virtual hit position, needed for evaluating pad response
415 // outside the tracking program
416 // From AliMUONSegmentationV01.
422 //______________________________________________________________________________
423 void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
424 Float_t dx, Float_t dy)
426 // Iterate over pads - initialiser
429 // Sets the current pad to that located in the hit position
431 SetHit(GetAnod(xhit), yhit, 0.);
433 // Enable iterating in one dimension
434 if (dx == 0.) dx = 0.01;
435 if (dy == 0.) dy = 0.01;
437 // Delete previous iterator
438 delete fSectorIterator;
441 = fSectorSegmentation
442 ->CreateIterator(AliMpArea(TVector2(fXhit,fYhit),TVector2(dx,dy)));
444 AliDebug(1,Form("CreateIterator area=%e,%e +- %e,%e %s",
445 fXhit,fYhit,dx,dy,PlaneTypeName(fPlaneType).Data()));
447 fSectorIterator->First();
449 if (! fSectorIterator->IsDone())
450 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
453 //______________________________________________________________________________
454 void AliMUONSt12QuadrantSegmentation::NextPad()
456 // Iterate over pads - stepper
459 fSectorIterator->Next();
461 if (! fSectorIterator->IsDone())
462 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
465 //______________________________________________________________________________
466 Int_t AliMUONSt12QuadrantSegmentation::MorePads()
468 // Iterate over pads - condition
471 if (fSectorIterator->IsDone())
477 //______________________________________________________________________________
478 Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
479 Float_t x, Float_t y, Int_t* /*dummy*/)
481 // Returns the square of the distance between 1 pad
482 // labelled by its channel numbers and a coordinate
485 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
488 AliFatal("Cannot locate pad.");
490 return (pad.Position() - TVector2(x, y)).Mod2();
493 //______________________________________________________________________________
494 void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
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 AliFatal( "Not yet implemented.");
505 //______________________________________________________________________________
506 void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
508 Int_t Xlist[10], Int_t Ylist[10])
510 // Get next neighbours
513 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
516 AliMpNeighboursPadIterator iter(fSectorSegmentation, pad, kFALSE);
518 for( iter.First(); !iter.IsDone() && i<10; iter.Next()) {
519 Xlist[i] = iter.CurrentItem().GetIndices().GetFirst();
520 Ylist[i] = iter.CurrentItem().GetIndices().GetSecond();
525 //______________________________________________________________________________
526 Int_t AliMUONSt12QuadrantSegmentation::Ix()
528 // Current pad cursor during disintegration
532 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
535 //______________________________________________________________________________
536 Int_t AliMUONSt12QuadrantSegmentation::Iy()
538 // Current pad cursor during disintegration
542 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
545 //______________________________________________________________________________
546 Int_t AliMUONSt12QuadrantSegmentation::ISector()
554 //______________________________________________________________________________
555 Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
557 // Calculate sector from pad coordinates
560 return fSectorSegmentation
561 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
564 //______________________________________________________________________________
565 Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
567 // Calculate sector from pad coordinates
570 return fSectorSegmentation
571 ->Zone(fSectorSegmentation
572 ->PadByPosition(TVector2(x,y)));
575 //______________________________________________________________________________
576 void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
577 Float_t& y1, Float_t& y2)
579 // Current integration limits
582 x1 = fXhit - fX - Dpx(fZone)/2.;
583 x2 = x1 + Dpx(fZone);
585 y1 = fYhit - fY - Dpy(fZone)/2.;
586 y2 = y1 + Dpy(fZone);
589 //______________________________________________________________________________
590 Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
592 // Signal Generation Condition during Stepping
593 // 0: don't generate signal
594 // 1: generate signal
597 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
598 // To correctly simulate the dependence of the spatial resolution on the angle
599 // of incidence signal must be generated for constant steps on
600 // the projection of the trajectory along the anode wire.
602 // Signal will be generated if particle crosses pad boundary or
603 // boundary between two wires.
605 // From AliMUONSegmentationV01
609 GetPadI(x, y, ixt, iyt);
610 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
612 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
620 //______________________________________________________________________________
621 void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
623 // Initialise signal generation at coord (x,y,z)
624 // Initialises pad and wire position during stepping.
625 // From AliMUONSegmentationV01
630 GetPadI(x, y, fIxt, fIyt);
631 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
634 //______________________________________________________________________________
635 void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
637 // Test points for auto calibration
638 // Returns test point on the pad plane.
639 // Used during determination of the segmoid correction of the COG-method
640 // From AliMUONSegmentationV01
644 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
648 //______________________________________________________________________________
649 void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
651 // Draw the segmentation zones.
652 // (Called from AliMUON::BuildGeometry)
655 AliWarning("Not yet implemented.");
658 //______________________________________________________________________________
659 void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
661 // Set the correction function.
662 // From AliMUONSegmentationV01
665 fCorrA->AddAt(func, isec);
668 //______________________________________________________________________________
669 TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
671 // Get the correction Function.
672 // From AliMUONSegmentationV01
675 return (TF1*) fCorrA->At(isec);