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));
145 delete fSectorSegmentation;
146 delete fSectorIterator;
153 //______________________________________________________________________________
154 void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad)
156 /// Updates current pad values.
158 fIx = pad.GetIndices().GetFirst();
159 fIy = pad.GetIndices().GetSecond();
160 fX = pad.Position().X();
161 fY = pad.Position().Y();
162 fZone = fSectorSegmentation->Zone(pad);
170 //______________________________________________________________________________
171 void AliMUONSt12QuadrantSegmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
173 /// Set pad size Dx*Dy
175 AliFatal("Not uniform pad size.");
178 //______________________________________________________________________________
179 void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
186 #include "AliMpMotifMap.h"
187 //______________________________________________________________________________
188 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
190 /// Returns true if a pad exists in the given position
192 // fSector->GetMotifMap()->Print();
194 AliMpPad pad = fSectorSegmentation
195 ->PadByPosition(TVector2(x,y), false);
197 return pad.IsValid();
201 //______________________________________________________________________________
202 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Int_t ix, Int_t iy)
204 /// Returns true if a pad with given indices exists
206 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), false);
208 return pad.IsValid();
212 //______________________________________________________________________________
213 AliMUONGeometryDirection AliMUONSt12QuadrantSegmentation::GetDirection()
215 /// Returns the direction with a constant pad size
216 /// (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 const AliMpVSegmentation*
227 AliMUONSt12QuadrantSegmentation::GetMpSegmentation() const
229 /// Returns the mapping segmentation
230 /// (provides access to electronics info)
232 return fSectorSegmentation;
235 //______________________________________________________________________________
236 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
238 /// Anod wire coordinate closest to xhit
239 /// Returns for a hit position xhit the position of the nearest anode wire
240 /// From AliMUONSegmentationV01.
242 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
243 : Int_t(xhit/fWireD) - 0.5;
248 //______________________________________________________________________________
249 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
250 Int_t& ix, Int_t& iy)
252 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
254 GetPadI(x, y, ix, iy);
257 //______________________________________________________________________________
258 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
259 Int_t& ix, Int_t& iy)
261 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
262 /// If there is no pad, ix = 0, iy = 0 are returned.
264 AliMpPad pad = fSectorSegmentation->PadByPosition(TVector2(x,y), true);
266 ix = pad.GetIndices().GetFirst();
267 iy = pad.GetIndices().GetSecond();
270 //______________________________________________________________________________
271 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
272 Float_t& x, Float_t& y, Float_t& z)
274 /// Transform from pad to real coordinates
277 GetPadC(ix, iy, x , y);
280 //______________________________________________________________________________
281 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
282 Float_t& x, Float_t& y)
284 /// Transform from pad to real coordinates
285 /// If there is no pad, x = 0., y = 0. are returned.
287 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
289 x = pad.Position().X();
290 y = pad.Position().Y();
294 //______________________________________________________________________________
295 void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
297 /// Initialize segmentation
299 // find Npx, Npy and save this info
301 // reference to chamber
302 fRmin=AliMUONConstants::Rmin(0);
303 fRmax=AliMUONConstants::Rmax(0);
308 //______________________________________________________________________________
309 Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
311 /// Get pad size in x
313 AliFatal( "Not uniform pad size.");
317 //______________________________________________________________________________
318 Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
320 /// Get pad size in y
322 AliFatal("Not uniform pad size.");
326 //______________________________________________________________________________
327 Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
329 /// Pad size in x by sector
331 return fSectorSegmentation->PadDimensions(isector).X()*2.0;
334 //______________________________________________________________________________
335 Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
337 /// Pad size in x, y by Sector
339 return fSectorSegmentation->PadDimensions(isector).Y()*2.0;
342 //______________________________________________________________________________
343 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
345 /// Maximum number of Pads in x
346 /// hard coded for the time being
348 return fSectorSegmentation->MaxPadIndexX();
351 //______________________________________________________________________________
352 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
354 /// Maximum number of Pads in y
355 /// hard coded for the time being
357 return fSectorSegmentation->MaxPadIndexY();
360 //______________________________________________________________________________
361 void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
363 /// Set pad position.
364 /// Sets virtual pad coordinates, needed for evaluating pad response
365 /// outside the tracking program.
366 /// From AliMUONSegmentationV01.
368 GetPadC(ix, iy, fX, fY);
369 fZone = Sector(ix, iy);
372 //______________________________________________________________________________
373 void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
376 /// Sets virtual hit position, needed for evaluating pad response
377 /// outside the tracking program
378 /// From AliMUONSegmentationV01.
384 //______________________________________________________________________________
385 void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
386 Float_t dx, Float_t dy)
388 /// Iterate over pads - initialiser
390 // Sets the current pad to that located in the hit position
392 SetHit(GetAnod(xhit), yhit, 0.);
394 // Enable iterating in one dimension
395 if (dx == 0.) dx = 0.01;
396 if (dy == 0.) dy = 0.01;
398 // Delete previous iterator
399 delete fSectorIterator;
402 = fSectorSegmentation
403 ->CreateIterator(AliMpArea(TVector2(fXhit,fYhit),TVector2(dx,dy)));
405 AliDebug(1,Form("CreateIterator area=%e,%e +- %e,%e %s",
406 fXhit,fYhit,dx,dy,PlaneTypeName(fPlaneType).Data()));
408 fSectorIterator->First();
410 if (! fSectorIterator->IsDone())
411 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
414 //______________________________________________________________________________
415 void AliMUONSt12QuadrantSegmentation::NextPad()
417 /// Iterate over pads - stepper
419 fSectorIterator->Next();
421 if (! fSectorIterator->IsDone())
422 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
425 //______________________________________________________________________________
426 Int_t AliMUONSt12QuadrantSegmentation::MorePads()
428 /// Iterate over pads - condition
430 if (fSectorIterator->IsDone())
436 //______________________________________________________________________________
437 Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
438 Float_t x, Float_t y, Int_t* /*dummy*/)
440 /// Returns the square of the distance between 1 pad
441 /// labelled by its channel numbers and a coordinate
443 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
446 AliFatal("Cannot locate pad.");
448 return (pad.Position() - TVector2(x, y)).Mod2();
451 //______________________________________________________________________________
452 void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
453 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
455 /// Number of pads read in parallel and offset to add to x
456 /// (specific to LYON, but mandatory for display)
458 AliFatal( "Not yet implemented.");
462 //______________________________________________________________________________
463 void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
465 Int_t Xlist[10], Int_t Ylist[10])
467 /// Get next neighbours
469 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
472 AliMpNeighboursPadIterator iter(fSectorSegmentation, pad, kFALSE);
474 for( iter.First(); !iter.IsDone() && i<10; iter.Next()) {
475 Xlist[i] = iter.CurrentItem().GetIndices().GetFirst();
476 Ylist[i] = iter.CurrentItem().GetIndices().GetSecond();
481 //______________________________________________________________________________
482 Int_t AliMUONSt12QuadrantSegmentation::Ix()
484 /// Current pad cursor during disintegration
487 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
490 //______________________________________________________________________________
491 Int_t AliMUONSt12QuadrantSegmentation::Iy()
493 /// Current pad cursor during disintegration
496 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
499 //______________________________________________________________________________
500 Int_t AliMUONSt12QuadrantSegmentation::ISector()
507 //______________________________________________________________________________
508 Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
510 /// Calculate sector from pad coordinates
512 return fSectorSegmentation
513 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
516 //______________________________________________________________________________
517 Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
519 /// Calculate sector from pad coordinates
521 return fSectorSegmentation
522 ->Zone(fSectorSegmentation
523 ->PadByPosition(TVector2(x,y)));
526 //______________________________________________________________________________
527 void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
528 Float_t& y1, Float_t& y2)
530 /// Current integration limits
532 x1 = fXhit - fX - Dpx(fZone)/2.;
533 x2 = x1 + Dpx(fZone);
535 y1 = fYhit - fY - Dpy(fZone)/2.;
536 y2 = y1 + Dpy(fZone);
539 //______________________________________________________________________________
540 Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
542 /// Signal Generation Condition during Stepping
543 /// - 0: don't generate signal
544 /// - 1: generate signal
548 /// Crossing of pad boundary and mid plane between neighbouring wires is checked.
549 /// To correctly simulate the dependence of the spatial resolution on the angle
550 /// of incidence signal must be generated for constant steps on
551 /// the projection of the trajectory along the anode wire.
553 /// Signal will be generated if particle crosses pad boundary or
554 /// boundary between two wires.
556 /// From AliMUONSegmentationV01
559 GetPadI(x, y, ixt, iyt);
560 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
562 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
570 //______________________________________________________________________________
571 void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
573 /// Initialise signal generation at coord (x,y,z)
574 /// Initialises pad and wire position during stepping.
575 /// From AliMUONSegmentationV01
579 GetPadI(x, y, fIxt, fIyt);
580 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
583 //______________________________________________________________________________
584 void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
586 /// Test points for auto calibration
587 /// Returns test point on the pad plane.
588 /// Used during determination of the segmoid correction of the COG-method
589 /// From AliMUONSegmentationV01
592 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
596 //______________________________________________________________________________
597 void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
599 /// Draw the segmentation zones.
600 /// (Called from AliMUON::BuildGeometry)
602 AliWarning("Not yet implemented.");
605 //______________________________________________________________________________
606 void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
608 /// Set the correction function.
609 /// From AliMUONSegmentationV01
611 fCorrA->AddAt(func, isec);
614 //______________________________________________________________________________
615 TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
617 /// Get the correction Function.
618 /// From AliMUONSegmentationV01
620 return (TF1*) fCorrA->At(isec);