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>
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 const Float_t AliMUONSt12QuadrantSegmentation::fgkWireD = 0.21;
49 //______________________________________________________________________________
50 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
51 AliMpVSegmentation* segmentation,
52 AliMpStationType stationType,
53 AliMpPlaneType planeType)
54 : AliMUONVGeometryDESegmentation(),
55 fStationType(stationType),
56 fPlaneType(planeType),
58 fSectorSegmentation(0),
82 fSectorSegmentation = dynamic_cast<AliMpSectorSegmentation*>(segmentation);
83 if (fSectorSegmentation)
84 fSector = fSectorSegmentation->GetSector();
86 AliFatal("Wrong mapping segmentation type");
88 fCorrA = new TObjArray(3);
93 AliDebug(1, Form("ctor this = %p", this) );
96 //______________________________________________________________________________
97 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation()
98 : AliMUONVGeometryDESegmentation(),
99 fStationType(kStation1),
100 fPlaneType(kBendingPlane),
102 fSectorSegmentation(0),
123 // Default Constructor
125 AliDebug(1, Form("default (empty) ctor this = %p", this));
128 //______________________________________________________________________________
129 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(const AliMUONSt12QuadrantSegmentation& rhs)
130 : AliMUONVGeometryDESegmentation(rhs)
133 AliFatal("Copy constructor is not implemented.");
136 //______________________________________________________________________________
137 AliMUONSt12QuadrantSegmentation::~AliMUONSt12QuadrantSegmentation() {
140 AliDebug(1, Form("dtor this = %p", this));
143 delete fSectorSegmentation;
144 delete fSectorIterator;
151 //______________________________________________________________________________
152 AliMUONSt12QuadrantSegmentation&
153 AliMUONSt12QuadrantSegmentation::operator=(const AliMUONSt12QuadrantSegmentation& rhs)
157 // check assignement to self
158 if (this == &rhs) return *this;
160 AliFatal("Assignment operator is not implemented.");
169 //______________________________________________________________________________
170 void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad)
172 // Updates current pad values.
175 fIx = pad.GetIndices().GetFirst();
176 fIy = pad.GetIndices().GetSecond();
177 fX = pad.Position().X();
178 fY = pad.Position().Y();
179 fZone = fSectorSegmentation->Zone(pad);
187 //______________________________________________________________________________
188 void AliMUONSt12QuadrantSegmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
190 // Set pad size Dx*Dy
193 AliFatal("Not uniform pad size.");
196 //______________________________________________________________________________
197 void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
205 #include "AliMpMotifMap.h"
206 //______________________________________________________________________________
207 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
209 // Returns true if a pad exists in the given position
211 // fSector->GetMotifMap()->Print();
213 AliMpPad pad = fSectorSegmentation
214 ->PadByPosition(TVector2(x,y), false);
216 return pad.IsValid();
220 //______________________________________________________________________________
221 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Int_t ix, Int_t iy)
223 // Returns true if a pad with given indices exists
225 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), false);
227 return pad.IsValid();
231 //______________________________________________________________________________
232 AliMUONGeometryDirection AliMUONSt12QuadrantSegmentation::GetDirection()
234 // Returns the direction with a constant pad size
235 // (Direction or coordinate where the resolution is the best)
237 switch ( fSector->GetDirection() ) {
238 case kX: return kDirX;
239 case kY: return kDirY;
240 default: return kDirUndefined;
244 //______________________________________________________________________________
245 const AliMpVSegmentation*
246 AliMUONSt12QuadrantSegmentation::GetMpSegmentation() const
248 // Returns the mapping segmentation
249 // (provides access to electronics info)
251 return fSectorSegmentation;
254 //______________________________________________________________________________
255 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
257 // Anod wire coordinate closest to xhit
258 // Returns for a hit position xhit the position of the nearest anode wire
259 // From AliMUONSegmentationV01.
262 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
263 : Int_t(xhit/fWireD) - 0.5;
268 //______________________________________________________________________________
269 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
270 Int_t& ix, Int_t& iy)
272 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
275 GetPadI(x, y, ix, iy);
278 //______________________________________________________________________________
279 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
280 Int_t& ix, Int_t& iy)
282 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
283 // If there is no pad, ix = 0, iy = 0 are returned.
286 AliMpPad pad = fSectorSegmentation->PadByPosition(TVector2(x,y), true);
288 ix = pad.GetIndices().GetFirst();
289 iy = pad.GetIndices().GetSecond();
292 //______________________________________________________________________________
293 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
294 Float_t& x, Float_t& y, Float_t& z)
296 // Transform from pad to real coordinates
300 GetPadC(ix, iy, x , y);
303 //______________________________________________________________________________
304 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
305 Float_t& x, Float_t& y)
307 // Transform from pad to real coordinates
308 // If there is no pad, x = 0., y = 0. are returned.
311 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
313 x = pad.Position().X();
314 y = pad.Position().Y();
318 //______________________________________________________________________________
319 void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
321 // Initialize segmentation
324 // find Npx, Npy and save this info
326 // reference to chamber
327 fRmin=AliMUONConstants::Rmin(0);
328 fRmax=AliMUONConstants::Rmax(0);
333 //______________________________________________________________________________
334 Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
339 AliFatal( "Not uniform pad size.");
343 //______________________________________________________________________________
344 Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
349 AliFatal("Not uniform pad size.");
353 //______________________________________________________________________________
354 Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
356 // Pad size in x by sector
359 return fSectorSegmentation->PadDimensions(isector).X()*2.0;
362 //______________________________________________________________________________
363 Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
365 // Pad size in x, y by Sector
368 return fSectorSegmentation->PadDimensions(isector).Y()*2.0;
371 //______________________________________________________________________________
372 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
374 // Maximum number of Pads in x
375 // hard coded for the time being
378 return fSectorSegmentation->MaxPadIndexX();
381 //______________________________________________________________________________
382 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
384 // Maximum number of Pads in y
385 // hard coded for the time being
388 return fSectorSegmentation->MaxPadIndexY();
391 //______________________________________________________________________________
392 void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
395 // Sets virtual pad coordinates, needed for evaluating pad response
396 // outside the tracking program.
397 // From AliMUONSegmentationV01.
400 GetPadC(ix, iy, fX, fY);
401 fZone = Sector(ix, iy);
404 //______________________________________________________________________________
405 void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
408 // Sets virtual hit position, needed for evaluating pad response
409 // outside the tracking program
410 // From AliMUONSegmentationV01.
416 //______________________________________________________________________________
417 void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
418 Float_t dx, Float_t dy)
420 // Iterate over pads - initialiser
423 // Sets the current pad to that located in the hit position
425 SetHit(GetAnod(xhit), yhit, 0.);
427 // Enable iterating in one dimension
428 if (dx == 0.) dx = 0.01;
429 if (dy == 0.) dy = 0.01;
431 // Delete previous iterator
432 delete fSectorIterator;
435 = fSectorSegmentation
436 ->CreateIterator(AliMpArea(TVector2(fXhit,fYhit),TVector2(dx,dy)));
438 AliDebug(1,Form("CreateIterator area=%e,%e +- %e,%e %s",
439 fXhit,fYhit,dx,dy,PlaneTypeName(fPlaneType).Data()));
441 fSectorIterator->First();
443 if (! fSectorIterator->IsDone())
444 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
447 //______________________________________________________________________________
448 void AliMUONSt12QuadrantSegmentation::NextPad()
450 // Iterate over pads - stepper
453 fSectorIterator->Next();
455 if (! fSectorIterator->IsDone())
456 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
459 //______________________________________________________________________________
460 Int_t AliMUONSt12QuadrantSegmentation::MorePads()
462 // Iterate over pads - condition
465 if (fSectorIterator->IsDone())
471 //______________________________________________________________________________
472 Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
473 Float_t x, Float_t y, Int_t* /*dummy*/)
475 // Returns the square of the distance between 1 pad
476 // labelled by its channel numbers and a coordinate
479 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
482 AliFatal("Cannot locate pad.");
484 return (pad.Position() - TVector2(x, y)).Mod2();
487 //______________________________________________________________________________
488 void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
489 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
491 // Number of pads read in parallel and offset to add to x
492 // (specific to LYON, but mandatory for display)
495 AliFatal( "Not yet implemented.");
499 //______________________________________________________________________________
500 void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
502 Int_t Xlist[10], Int_t Ylist[10])
504 // Get next neighbours
507 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
510 AliMpNeighboursPadIterator iter
511 = AliMpNeighboursPadIterator(fSectorSegmentation, pad, kFALSE);
513 for( iter.First(); !iter.IsDone() && i<10; iter.Next()) {
514 Xlist[i] = iter.CurrentItem().GetIndices().GetFirst();
515 Ylist[i] = iter.CurrentItem().GetIndices().GetSecond();
520 //______________________________________________________________________________
521 Int_t AliMUONSt12QuadrantSegmentation::Ix()
523 // Current pad cursor during disintegration
527 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
530 //______________________________________________________________________________
531 Int_t AliMUONSt12QuadrantSegmentation::Iy()
533 // Current pad cursor during disintegration
537 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
540 //______________________________________________________________________________
541 Int_t AliMUONSt12QuadrantSegmentation::ISector()
549 //______________________________________________________________________________
550 Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
552 // Calculate sector from pad coordinates
555 return fSectorSegmentation
556 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
559 //______________________________________________________________________________
560 Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
562 // Calculate sector from pad coordinates
565 return fSectorSegmentation
566 ->Zone(fSectorSegmentation
567 ->PadByPosition(TVector2(x,y)));
570 //______________________________________________________________________________
571 void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
572 Float_t& y1, Float_t& y2)
574 // Current integration limits
577 x1 = fXhit - fX - Dpx(fZone)/2.;
578 x2 = x1 + Dpx(fZone);
580 y1 = fYhit - fY - Dpy(fZone)/2.;
581 y2 = y1 + Dpy(fZone);
584 //______________________________________________________________________________
585 Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
587 // Signal Generation Condition during Stepping
588 // 0: don't generate signal
589 // 1: generate signal
592 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
593 // To correctly simulate the dependence of the spatial resolution on the angle
594 // of incidence signal must be generated for constant steps on
595 // the projection of the trajectory along the anode wire.
597 // Signal will be generated if particle crosses pad boundary or
598 // boundary between two wires.
600 // From AliMUONSegmentationV01
604 GetPadI(x, y, ixt, iyt);
605 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
607 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
615 //______________________________________________________________________________
616 void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
618 // Initialise signal generation at coord (x,y,z)
619 // Initialises pad and wire position during stepping.
620 // From AliMUONSegmentationV01
625 GetPadI(x, y, fIxt, fIyt);
626 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
629 //______________________________________________________________________________
630 void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
632 // Test points for auto calibration
633 // Returns test point on the pad plane.
634 // Used during determination of the segmoid correction of the COG-method
635 // From AliMUONSegmentationV01
639 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
643 //______________________________________________________________________________
644 void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
646 // Draw the segmentation zones.
647 // (Called from AliMUON::BuildGeometry)
650 AliWarning("Not yet implemented.");
653 //______________________________________________________________________________
654 void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
656 // Set the correction function.
657 // From AliMUONSegmentationV01
660 fCorrA->AddAt(func, isec);
663 //______________________________________________________________________________
664 TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
666 // Get the correction Function.
667 // From AliMUONSegmentationV01
670 return (TF1*) fCorrA->At(isec);