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"
46 ClassImp(AliMUONSt12QuadrantSegmentation)
49 //______________________________________________________________________________
50 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
51 AliMpVSegmentation* segmentation,
52 AliMpStationType stationType,
53 AliMpPlaneType planeType)
54 : AliMUONVGeometryDESegmentation(),
55 fStationType(stationType),
56 fPlaneType(planeType),
58 fSectorSegmentation(0),
80 /// Standard constructor
82 fSectorSegmentation = dynamic_cast<AliMpSectorSegmentation*>(segmentation);
83 if (fSectorSegmentation)
84 fSector = fSectorSegmentation->GetSector();
86 AliFatal("Wrong mapping segmentation type");
89 if ( stationType == kStation1 )
90 fWireD = AliMUONConstants::PitchSt1();
91 else if ( stationType == kStation2 )
92 fWireD = AliMUONConstants::Pitch();
94 AliFatal("Wrong station type");
96 fCorrA = new TObjArray(3);
101 AliDebug(1, Form("ctor this = %p", this) );
104 //______________________________________________________________________________
105 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation()
106 : AliMUONVGeometryDESegmentation(),
107 fStationType(kStation1),
108 fPlaneType(kBendingPlane),
110 fSectorSegmentation(0),
132 /// Default Constructor
134 AliDebug(1, Form("default (empty) ctor this = %p", this));
137 //______________________________________________________________________________
138 AliMUONSt12QuadrantSegmentation::~AliMUONSt12QuadrantSegmentation()
142 AliDebug(1, Form("dtor this = %p", this));
144 delete fSectorIterator;
151 //______________________________________________________________________________
152 void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad)
154 /// Updates current pad values.
156 fIx = pad.GetIndices().GetFirst();
157 fIy = pad.GetIndices().GetSecond();
158 fX = pad.Position().X();
159 fY = pad.Position().Y();
160 fZone = fSectorSegmentation->Zone(pad);
168 //______________________________________________________________________________
169 void AliMUONSt12QuadrantSegmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
171 /// Set pad size Dx*Dy
173 AliFatal("Not uniform pad size.");
176 //______________________________________________________________________________
177 void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
184 #include "AliMpMotifMap.h"
185 //______________________________________________________________________________
186 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
188 /// Returns true if a pad exists in the given position
190 // fSector->GetMotifMap()->Print();
192 AliMpPad pad = fSectorSegmentation
193 ->PadByPosition(TVector2(x,y), false);
195 return pad.IsValid();
199 //______________________________________________________________________________
200 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Int_t ix, Int_t iy)
202 /// Returns true if a pad with given indices exists
204 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), false);
206 return pad.IsValid();
210 //______________________________________________________________________________
211 AliMUONGeometryDirection AliMUONSt12QuadrantSegmentation::GetDirection()
213 /// Returns the direction with a constant pad size
214 /// (Direction or coordinate where the resolution is the best)
216 switch ( fSector->GetDirection() ) {
217 case kX: return kDirX;
218 case kY: return kDirY;
219 default: return kDirUndefined;
223 //______________________________________________________________________________
224 const AliMpVSegmentation*
225 AliMUONSt12QuadrantSegmentation::GetMpSegmentation() const
227 /// Returns the mapping segmentation
228 /// (provides access to electronics info)
230 return fSectorSegmentation;
233 //______________________________________________________________________________
234 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
236 /// Anod wire coordinate closest to xhit
237 /// Returns for a hit position xhit the position of the nearest anode wire
238 /// From AliMUONSegmentationV01.
240 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
241 : Int_t(xhit/fWireD) - 0.5;
246 //______________________________________________________________________________
247 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
248 Int_t& ix, Int_t& iy)
250 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
252 GetPadI(x, y, ix, iy);
255 //______________________________________________________________________________
256 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
257 Int_t& ix, Int_t& iy)
259 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
260 /// If there is no pad, ix = 0, iy = 0 are returned.
262 AliMpPad pad = fSectorSegmentation->PadByPosition(TVector2(x,y), true);
264 ix = pad.GetIndices().GetFirst();
265 iy = pad.GetIndices().GetSecond();
268 //______________________________________________________________________________
269 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
270 Float_t& x, Float_t& y, Float_t& z)
272 /// Transform from pad to real coordinates
275 GetPadC(ix, iy, x , y);
278 //______________________________________________________________________________
279 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
280 Float_t& x, Float_t& y)
282 /// Transform from pad to real coordinates
283 /// If there is no pad, x = 0., y = 0. are returned.
285 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
287 x = pad.Position().X();
288 y = pad.Position().Y();
292 //______________________________________________________________________________
293 void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
295 /// Initialize segmentation
297 // find Npx, Npy and save this info
299 // reference to chamber
300 fRmin=AliMUONConstants::Rmin(0);
301 fRmax=AliMUONConstants::Rmax(0);
306 //______________________________________________________________________________
307 Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
309 /// Get pad size in x
311 AliFatal( "Not uniform pad size.");
315 //______________________________________________________________________________
316 Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
318 /// Get pad size in y
320 AliFatal("Not uniform pad size.");
324 //______________________________________________________________________________
325 Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
327 /// Pad size in x by sector
329 return fSectorSegmentation->PadDimensions(isector).X()*2.0;
332 //______________________________________________________________________________
333 Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
335 /// Pad size in x, y by Sector
337 return fSectorSegmentation->PadDimensions(isector).Y()*2.0;
340 //______________________________________________________________________________
341 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
343 /// Maximum number of Pads in x
344 /// hard coded for the time being
346 return fSectorSegmentation->MaxPadIndexX();
349 //______________________________________________________________________________
350 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
352 /// Maximum number of Pads in y
353 /// hard coded for the time being
355 return fSectorSegmentation->MaxPadIndexY();
358 //______________________________________________________________________________
359 void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
361 /// Set pad position.
362 /// Sets virtual pad coordinates, needed for evaluating pad response
363 /// outside the tracking program.
364 /// From AliMUONSegmentationV01.
366 GetPadC(ix, iy, fX, fY);
367 fZone = Sector(ix, iy);
370 //______________________________________________________________________________
371 void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
374 /// Sets virtual hit position, needed for evaluating pad response
375 /// outside the tracking program
376 /// From AliMUONSegmentationV01.
382 //______________________________________________________________________________
383 void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
384 Float_t dx, Float_t dy)
386 /// Iterate over pads - initialiser
388 // Sets the current pad to that located in the hit position
390 SetHit(GetAnod(xhit), yhit, 0.);
392 // Enable iterating in one dimension
393 if (dx == 0.) dx = 0.01;
394 if (dy == 0.) dy = 0.01;
396 // Delete previous iterator
397 delete fSectorIterator;
400 = fSectorSegmentation
401 ->CreateIterator(AliMpArea(TVector2(fXhit,fYhit),TVector2(dx,dy)));
403 AliDebug(1,Form("CreateIterator area=%e,%e +- %e,%e %s",
404 fXhit,fYhit,dx,dy,PlaneTypeName(fPlaneType).Data()));
406 fSectorIterator->First();
408 if (! fSectorIterator->IsDone())
409 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
412 //______________________________________________________________________________
413 void AliMUONSt12QuadrantSegmentation::NextPad()
415 /// Iterate over pads - stepper
417 fSectorIterator->Next();
419 if (! fSectorIterator->IsDone())
420 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
423 //______________________________________________________________________________
424 Int_t AliMUONSt12QuadrantSegmentation::MorePads()
426 /// Iterate over pads - condition
428 if (fSectorIterator->IsDone())
434 //______________________________________________________________________________
435 Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
436 Float_t x, Float_t y, Int_t* /*dummy*/)
438 /// Returns the square of the distance between 1 pad
439 /// labelled by its channel numbers and a coordinate
441 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
444 AliFatal("Cannot locate pad.");
446 return (pad.Position() - TVector2(x, y)).Mod2();
449 //______________________________________________________________________________
450 void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
451 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
453 /// Number of pads read in parallel and offset to add to x
454 /// (specific to LYON, but mandatory for display)
456 AliFatal( "Not yet implemented.");
460 //______________________________________________________________________________
461 void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
463 Int_t Xlist[10], Int_t Ylist[10])
465 /// Get next neighbours
467 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
470 AliMpNeighboursPadIterator iter(fSectorSegmentation, pad, kFALSE);
472 for( iter.First(); !iter.IsDone() && i<10; iter.Next()) {
473 Xlist[i] = iter.CurrentItem().GetIndices().GetFirst();
474 Ylist[i] = iter.CurrentItem().GetIndices().GetSecond();
479 //______________________________________________________________________________
480 Int_t AliMUONSt12QuadrantSegmentation::Ix()
482 /// Current pad cursor during disintegration
485 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
488 //______________________________________________________________________________
489 Int_t AliMUONSt12QuadrantSegmentation::Iy()
491 /// Current pad cursor during disintegration
494 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
497 //______________________________________________________________________________
498 Int_t AliMUONSt12QuadrantSegmentation::ISector()
505 //______________________________________________________________________________
506 Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
508 /// Calculate sector from pad coordinates
510 return fSectorSegmentation
511 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
514 //______________________________________________________________________________
515 Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
517 /// Calculate sector from pad coordinates
519 return fSectorSegmentation
520 ->Zone(fSectorSegmentation
521 ->PadByPosition(TVector2(x,y)));
524 //______________________________________________________________________________
525 void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
526 Float_t& y1, Float_t& y2)
528 /// Current integration limits
530 x1 = fXhit - fX - Dpx(fZone)/2.;
531 x2 = x1 + Dpx(fZone);
533 y1 = fYhit - fY - Dpy(fZone)/2.;
534 y2 = y1 + Dpy(fZone);
537 //______________________________________________________________________________
538 Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
540 /// Signal Generation Condition during Stepping
541 /// - 0: don't generate signal
542 /// - 1: generate signal
546 /// Crossing of pad boundary and mid plane between neighbouring wires is checked.
547 /// To correctly simulate the dependence of the spatial resolution on the angle
548 /// of incidence signal must be generated for constant steps on
549 /// the projection of the trajectory along the anode wire.
551 /// Signal will be generated if particle crosses pad boundary or
552 /// boundary between two wires.
554 /// From AliMUONSegmentationV01
557 GetPadI(x, y, ixt, iyt);
558 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
560 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
568 //______________________________________________________________________________
569 void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
571 /// Initialise signal generation at coord (x,y,z)
572 /// Initialises pad and wire position during stepping.
573 /// From AliMUONSegmentationV01
577 GetPadI(x, y, fIxt, fIyt);
578 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
581 //______________________________________________________________________________
582 void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
584 /// Test points for auto calibration
585 /// Returns test point on the pad plane.
586 /// Used during determination of the segmoid correction of the COG-method
587 /// From AliMUONSegmentationV01
590 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
594 //______________________________________________________________________________
595 void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
597 /// Draw the segmentation zones.
598 /// (Called from AliMUON::BuildGeometry)
600 AliWarning("Not yet implemented.");
603 //______________________________________________________________________________
604 void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
606 /// Set the correction function.
607 /// From AliMUONSegmentationV01
609 fCorrA->AddAt(func, isec);
612 //______________________________________________________________________________
613 TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
615 /// Get the correction Function.
616 /// From AliMUONSegmentationV01
618 return (TF1*) fCorrA->At(isec);