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
25 #include "AliMUONSt12QuadrantSegmentation.h"
26 #include "AliMUONConstants.h"
29 #include "AliMpArea.h"
30 #include "AliMpSectorReader.h"
31 #include "AliMpSector.h"
32 #include "AliMpVPadIterator.h"
33 #include "AliMpSectorSegmentation.h"
34 #include "AliMpFiles.h"
35 #include "AliMpNeighboursPadIterator.h"
42 #include <TObjArray.h>
47 ClassImp(AliMUONSt12QuadrantSegmentation)
50 //______________________________________________________________________________
51 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
52 AliMpVSegmentation* segmentation,
53 AliMp::StationType stationType,
54 AliMp::PlaneType planeType)
55 : AliMUONVGeometryDESegmentation(),
56 fStationType(stationType),
57 fPlaneType(planeType),
59 fSectorSegmentation(0),
81 /// Standard constructor
83 fSectorSegmentation = dynamic_cast<AliMpSectorSegmentation*>(segmentation);
84 if (fSectorSegmentation)
85 fSector = fSectorSegmentation->GetSector();
87 AliFatal("Wrong mapping segmentation type");
90 if ( stationType == AliMp::kStation1 )
91 fWireD = AliMUONConstants::PitchSt1();
92 else if ( stationType == AliMp::kStation2 )
93 fWireD = AliMUONConstants::Pitch();
95 AliFatal("Wrong station type");
97 fCorrA = new TObjArray(3);
102 AliDebug(1, Form("ctor this = %p", this) );
105 //______________________________________________________________________________
106 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation()
107 : AliMUONVGeometryDESegmentation(),
108 fStationType(AliMp::kStation1),
109 fPlaneType(AliMp::kBendingPlane),
111 fSectorSegmentation(0),
133 /// Default Constructor
135 AliDebug(1, Form("default (empty) ctor this = %p", this));
138 //______________________________________________________________________________
139 AliMUONSt12QuadrantSegmentation::~AliMUONSt12QuadrantSegmentation()
143 AliDebug(1, Form("dtor this = %p", this));
145 delete fSectorIterator;
152 //______________________________________________________________________________
153 void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad)
155 /// Updates current pad values.
157 fIx = pad.GetIndices().GetFirst();
158 fIy = pad.GetIndices().GetSecond();
159 fX = pad.Position().X();
160 fY = pad.Position().Y();
161 fZone = fSectorSegmentation->Zone(pad);
169 //______________________________________________________________________________
170 void AliMUONSt12QuadrantSegmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
172 /// Set pad size Dx*Dy
174 AliFatal("Not uniform pad size.");
177 //______________________________________________________________________________
178 void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
185 #include "AliMpMotifMap.h"
186 //______________________________________________________________________________
187 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
189 /// Returns true if a pad exists in the given position
191 // fSector->GetMotifMap()->Print();
193 AliMpPad pad = fSectorSegmentation
194 ->PadByPosition(TVector2(x,y), false);
196 return pad.IsValid();
200 //______________________________________________________________________________
201 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Int_t ix, Int_t iy)
203 /// Returns true if a pad with given indices exists
205 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), false);
207 return pad.IsValid();
211 //______________________________________________________________________________
212 AliMUONGeometryDirection AliMUONSt12QuadrantSegmentation::GetDirection()
214 /// Returns the direction with a constant pad size
215 /// (Direction or coordinate where the resolution is the best)
217 switch ( fSector->GetDirection() ) {
218 case AliMp::kX: return kDirX;
219 case AliMp::kY: return kDirY;
220 default: return kDirUndefined;
224 //______________________________________________________________________________
225 const AliMpVSegmentation*
226 AliMUONSt12QuadrantSegmentation::GetMpSegmentation() const
228 /// Returns the mapping segmentation
229 /// (provides access to electronics info)
231 return fSectorSegmentation;
234 //______________________________________________________________________________
235 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
237 /// Anod wire coordinate closest to xhit
238 /// Returns for a hit position xhit the position of the nearest anode wire
239 /// From AliMUONSegmentationV01.
241 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
242 : Int_t(xhit/fWireD) - 0.5;
247 //______________________________________________________________________________
248 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
249 Int_t& ix, Int_t& iy)
251 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
253 GetPadI(x, y, ix, iy);
256 //______________________________________________________________________________
257 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
258 Int_t& ix, Int_t& iy)
260 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
261 /// If there is no pad, ix = 0, iy = 0 are returned.
263 AliMpPad pad = fSectorSegmentation->PadByPosition(TVector2(x,y), true);
265 ix = pad.GetIndices().GetFirst();
266 iy = pad.GetIndices().GetSecond();
269 //______________________________________________________________________________
270 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
271 Float_t& x, Float_t& y, Float_t& z)
273 /// Transform from pad to real coordinates
276 GetPadC(ix, iy, x , y);
279 //______________________________________________________________________________
280 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
281 Float_t& x, Float_t& y)
283 /// Transform from pad to real coordinates
284 /// If there is no pad, x = 0., y = 0. are returned.
286 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
288 x = pad.Position().X();
289 y = pad.Position().Y();
293 //______________________________________________________________________________
294 void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
296 /// Initialize segmentation
298 // find Npx, Npy and save this info
300 // reference to chamber
301 fRmin=AliMUONConstants::Rmin(0);
302 fRmax=AliMUONConstants::Rmax(0);
307 //______________________________________________________________________________
308 Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
310 /// Get pad size in x
312 AliFatal( "Not uniform pad size.");
316 //______________________________________________________________________________
317 Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
319 /// Get pad size in y
321 AliFatal("Not uniform pad size.");
325 //______________________________________________________________________________
326 Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
328 /// Pad size in x by sector
330 return fSectorSegmentation->PadDimensions(isector).X()*2.0;
333 //______________________________________________________________________________
334 Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
336 /// Pad size in x, y by Sector
338 return fSectorSegmentation->PadDimensions(isector).Y()*2.0;
341 //______________________________________________________________________________
342 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
344 /// Maximum number of Pads in x
345 /// hard coded for the time being
347 return fSectorSegmentation->MaxPadIndexX();
350 //______________________________________________________________________________
351 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
353 /// Maximum number of Pads in y
354 /// hard coded for the time being
356 return fSectorSegmentation->MaxPadIndexY();
359 //______________________________________________________________________________
360 void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
362 /// Set pad position.
363 /// Sets virtual pad coordinates, needed for evaluating pad response
364 /// outside the tracking program.
365 /// From AliMUONSegmentationV01.
367 GetPadC(ix, iy, fX, fY);
368 fZone = Sector(ix, iy);
371 //______________________________________________________________________________
372 void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
375 /// Sets virtual hit position, needed for evaluating pad response
376 /// outside the tracking program
377 /// From AliMUONSegmentationV01.
383 //______________________________________________________________________________
384 void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
385 Float_t dx, Float_t dy)
387 /// Iterate over pads - initialiser
389 // Sets the current pad to that located in the hit position
391 SetHit(GetAnod(xhit), yhit, 0.);
393 // Enable iterating in one dimension
394 if (dx == 0.) dx = 0.01;
395 if (dy == 0.) dy = 0.01;
397 // Delete previous iterator
398 delete fSectorIterator;
401 = fSectorSegmentation
402 ->CreateIterator(AliMpArea(TVector2(fXhit,fYhit),TVector2(dx,dy)));
404 AliDebug(1,Form("CreateIterator area=%e,%e +- %e,%e %s",
405 fXhit,fYhit,dx,dy,PlaneTypeName(fPlaneType).Data()));
407 fSectorIterator->First();
409 if (! fSectorIterator->IsDone())
410 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
413 //______________________________________________________________________________
414 void AliMUONSt12QuadrantSegmentation::NextPad()
416 /// Iterate over pads - stepper
418 fSectorIterator->Next();
420 if (! fSectorIterator->IsDone())
421 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
424 //______________________________________________________________________________
425 Int_t AliMUONSt12QuadrantSegmentation::MorePads()
427 /// Iterate over pads - condition
429 if (fSectorIterator->IsDone())
435 //______________________________________________________________________________
436 Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
437 Float_t x, Float_t y, Int_t* /*dummy*/)
439 /// Returns the square of the distance between 1 pad
440 /// labelled by its channel numbers and a coordinate
442 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
445 AliFatal("Cannot locate pad.");
447 return (pad.Position() - TVector2(x, y)).Mod2();
450 //______________________________________________________________________________
451 void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
452 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
454 /// Number of pads read in parallel and offset to add to x
455 /// (specific to LYON, but mandatory for display)
457 AliFatal( "Not yet implemented.");
461 //______________________________________________________________________________
462 void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
464 Int_t Xlist[10], Int_t Ylist[10])
466 /// Get next neighbours
468 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
471 AliMpNeighboursPadIterator iter(fSectorSegmentation, pad, kFALSE);
473 for( iter.First(); !iter.IsDone() && i<10; iter.Next()) {
474 Xlist[i] = iter.CurrentItem().GetIndices().GetFirst();
475 Ylist[i] = iter.CurrentItem().GetIndices().GetSecond();
480 //______________________________________________________________________________
481 Int_t AliMUONSt12QuadrantSegmentation::Ix()
483 /// Current pad cursor during disintegration
486 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
489 //______________________________________________________________________________
490 Int_t AliMUONSt12QuadrantSegmentation::Iy()
492 /// Current pad cursor during disintegration
495 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
498 //______________________________________________________________________________
499 Int_t AliMUONSt12QuadrantSegmentation::ISector()
506 //______________________________________________________________________________
507 Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
509 /// Calculate sector from pad coordinates
511 return fSectorSegmentation
512 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
515 //______________________________________________________________________________
516 Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
518 /// Calculate sector from pad coordinates
520 return fSectorSegmentation
521 ->Zone(fSectorSegmentation
522 ->PadByPosition(TVector2(x,y)));
525 //______________________________________________________________________________
526 void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
527 Float_t& y1, Float_t& y2)
529 /// Current integration limits
531 x1 = fXhit - fX - Dpx(fZone)/2.;
532 x2 = x1 + Dpx(fZone);
534 y1 = fYhit - fY - Dpy(fZone)/2.;
535 y2 = y1 + Dpy(fZone);
538 //______________________________________________________________________________
539 Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
541 /// Signal Generation Condition during Stepping
542 /// - 0: don't generate signal
543 /// - 1: generate signal
547 /// Crossing of pad boundary and mid plane between neighbouring wires is checked.
548 /// To correctly simulate the dependence of the spatial resolution on the angle
549 /// of incidence signal must be generated for constant steps on
550 /// the projection of the trajectory along the anode wire.
552 /// Signal will be generated if particle crosses pad boundary or
553 /// boundary between two wires.
555 /// From AliMUONSegmentationV01
558 GetPadI(x, y, ixt, iyt);
559 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
561 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
569 //______________________________________________________________________________
570 void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
572 /// Initialise signal generation at coord (x,y,z)
573 /// Initialises pad and wire position during stepping.
574 /// From AliMUONSegmentationV01
578 GetPadI(x, y, fIxt, fIyt);
579 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
582 //______________________________________________________________________________
583 void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
585 /// Test points for auto calibration
586 /// Returns test point on the pad plane.
587 /// Used during determination of the segmoid correction of the COG-method
588 /// From AliMUONSegmentationV01
591 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
595 //______________________________________________________________________________
596 void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
598 /// Draw the segmentation zones.
599 /// (Called from AliMUON::BuildGeometry)
601 AliWarning("Not yet implemented.");
604 //______________________________________________________________________________
605 void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
607 /// Set the correction function.
608 /// From AliMUONSegmentationV01
610 fCorrA->AddAt(func, isec);
613 //______________________________________________________________________________
614 TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
616 /// Get the correction Function.
617 /// From AliMUONSegmentationV01
619 return (TF1*) fCorrA->At(isec);