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 // Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
20 // Class AliMUONSt1Segmentation
21 // ------------------------------
22 // Segmentation for MUON station 1 using the external
24 // Included in AliRoot 2003/01/28
28 #include <TObjArray.h>
32 #include "AliMpPlane.h"
33 #include "AliMpPlaneAreaPadIterator.h"
34 #include "AliMpPlaneSegmentation.h"
36 #include "AliMUONSt1Segmentation.h"
39 #include "AliMUONChamber.h"
41 ClassImp(AliMUONSt1Segmentation)
43 const Float_t AliMUONSt1Segmentation::fgkWireD = 0.20;
44 const Float_t AliMUONSt1Segmentation::fgkLengthUnit = 0.1;
46 //______________________________________________________________________________
47 AliMUONSt1Segmentation::AliMUONSt1Segmentation(const AliMpPlaneType planeType)
50 fPlaneSegmentation(0),
73 fPlane = AliMpPlane::Create(kStation1, planeType);
74 fPlaneSegmentation = new AliMpPlaneSegmentation(fPlane);
76 fCorrA = new TObjArray(3);
82 //______________________________________________________________________________
83 AliMUONSt1Segmentation::AliMUONSt1Segmentation()
86 fPlaneSegmentation(0),
107 // Default Constructor
110 //______________________________________________________________________________
111 AliMUONSt1Segmentation::AliMUONSt1Segmentation(const AliMUONSt1Segmentation& rhs)
112 : AliSegmentation(rhs)
115 Fatal("Copy constructor",
116 "Copy constructor is not implemented.");
119 //______________________________________________________________________________
120 AliMUONSt1Segmentation::~AliMUONSt1Segmentation() {
124 delete fPlaneSegmentation;
125 delete fPlaneIterator;
132 //______________________________________________________________________________
133 AliMUONSt1Segmentation&
134 AliMUONSt1Segmentation::operator=(const AliMUONSt1Segmentation& rhs)
138 // check assignement to self
139 if (this == &rhs) return *this;
142 "Assignment operator is not implemented.");
151 //______________________________________________________________________________
152 void AliMUONSt1Segmentation::UpdateCurrentPadValues(const AliMpPad& pad)
154 // Updates current pad values.
157 fIx = pad.GetIndices().GetFirst();
158 fIy = pad.GetIndices().GetSecond();
159 fX = pad.Position().X() * fgkLengthUnit;
160 fY = pad.Position().Y() * fgkLengthUnit;
161 fSector = fPlaneSegmentation->Zone(pad);
168 //______________________________________________________________________________
169 void AliMUONSt1Segmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
171 // Set pad size Dx*Dy
174 Fatal("SetPadSize", "Not uniform pad size.");
177 //______________________________________________________________________________
178 void AliMUONSt1Segmentation::SetDAnod(Float_t d)
186 //______________________________________________________________________________
187 Float_t AliMUONSt1Segmentation::GetAnod(Float_t xhit) const
189 // Anod wire coordinate closest to xhit
190 // Returns for a hit position xhit the position of the nearest anode wire
191 // From AliMUONSegmentationV01.
194 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
195 : Int_t(xhit/fWireD) - 0.5;
200 //______________________________________________________________________________
201 void AliMUONSt1Segmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
202 Int_t& ix, Int_t& iy)
204 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
207 GetPadI(x, y, ix, iy);
210 //______________________________________________________________________________
211 void AliMUONSt1Segmentation::GetPadI(Float_t x, Float_t y,
212 Int_t& ix, Int_t& iy)
214 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
215 // If there is no pad, ix = 0, iy = 0 are returned.
218 AliMpPad pad = fPlaneSegmentation
219 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), false);
221 ix = pad.GetIndices().GetFirst();
222 iy = pad.GetIndices().GetSecond();
225 //______________________________________________________________________________
226 void AliMUONSt1Segmentation::GetPadC(Int_t ix, Int_t iy,
227 Float_t& x, Float_t& y, Float_t& z)
229 // Transform from pad to real coordinates
233 GetPadC(ix, iy, x , y);
236 //______________________________________________________________________________
237 void AliMUONSt1Segmentation::GetPadC(Int_t ix, Int_t iy,
238 Float_t& x, Float_t& y)
240 // Transform from pad to real coordinates
241 // If there is no pad, x = 0., y = 0. are returned.
244 AliMpPad pad = fPlaneSegmentation->PadByIndices(AliMpIntPair(ix,iy));
246 x = pad.Position().X() * fgkLengthUnit;
247 y = pad.Position().Y() * fgkLengthUnit;
251 //______________________________________________________________________________
252 void AliMUONSt1Segmentation::Init(Int_t chamber)
254 // Initialize segmentation
257 // find Npx, Npy and save this info
259 // reference to chamber
260 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
261 fChamber = &(pMUON->Chamber(chamber));
262 fRmin=fChamber->RInner();
263 fRmax=fChamber->ROuter();
268 //______________________________________________________________________________
269 Float_t AliMUONSt1Segmentation::Dpx() const
274 Fatal("Dpx", "Not uniform pad size.");
278 //______________________________________________________________________________
279 Float_t AliMUONSt1Segmentation::Dpy() const
284 Fatal("Dpy", "Not uniform pad size.");
288 //______________________________________________________________________________
289 Float_t AliMUONSt1Segmentation::Dpx(Int_t isector) const
291 // Pad size in x by sector
294 return fPlaneSegmentation->PadDimensions(isector).X()*2.*fgkLengthUnit;
297 //______________________________________________________________________________
298 Float_t AliMUONSt1Segmentation::Dpy(Int_t isector) const
300 // Pad size in x, y by Sector
303 return fPlaneSegmentation->PadDimensions(isector).Y()*2.*fgkLengthUnit;
306 //______________________________________________________________________________
307 Int_t AliMUONSt1Segmentation::Npx() const
309 // Maximum number of Pads in x
312 //Fatal("Npx", "Not yet implemented.");
313 return 142; //hard coded for the time being
316 //______________________________________________________________________________
317 Int_t AliMUONSt1Segmentation::Npy() const
319 // Maximum number of Pads in y
322 //Fatal("Npy", "Not yet implemented.");
323 return 213; //hard coded for the time being
326 //______________________________________________________________________________
327 void AliMUONSt1Segmentation::SetPad(Int_t ix, Int_t iy)
330 // Sets virtual pad coordinates, needed for evaluating pad response
331 // outside the tracking program.
332 // From AliMUONSegmentationV01.
335 GetPadC(ix, iy, fX, fY);
336 fSector = Sector(ix, iy);
339 //______________________________________________________________________________
340 void AliMUONSt1Segmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
343 // Sets virtual hit position, needed for evaluating pad response
344 // outside the tracking program
345 // From AliMUONSegmentationV01.
351 //______________________________________________________________________________
352 void AliMUONSt1Segmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
353 Float_t dx, Float_t dy)
355 // Iterate over pads - initialiser
358 // Sets the current pad to that located in the hit position
360 SetHit(GetAnod(xhit), yhit, 0.);
362 // Enable iterating in one dimension
363 if (dx == 0.) dx = 0.01;
364 if (dy == 0.) dy = 0.01;
368 ->CreateIterator(AliMpArea(TVector2(fXhit/fgkLengthUnit, fYhit/fgkLengthUnit),
369 TVector2(dx/fgkLengthUnit, dy/fgkLengthUnit)));
371 fPlaneIterator->First();
373 if (! fPlaneIterator->IsDone())
374 UpdateCurrentPadValues(fPlaneIterator->CurrentItem());
377 //______________________________________________________________________________
378 void AliMUONSt1Segmentation::NextPad()
380 // Iterate over pads - stepper
383 fPlaneIterator->Next();
385 if (! fPlaneIterator->IsDone())
386 UpdateCurrentPadValues(fPlaneIterator->CurrentItem());
389 //______________________________________________________________________________
390 Int_t AliMUONSt1Segmentation::MorePads()
392 // Iterate over pads - condition
395 if (fPlaneIterator->IsDone())
401 //______________________________________________________________________________
402 Float_t AliMUONSt1Segmentation::Distance2AndOffset(Int_t iX, Int_t iY,
403 Float_t x, Float_t y, Int_t* /*dummy*/)
405 // Returns the square of the distance between 1 pad
406 // labelled by its channel numbers and a coordinate
409 AliMpPad pad = fPlaneSegmentation->PadByIndices(AliMpIntPair(iX, iY));
412 Fatal("Distance2AndOffset", "Cannot locate pad.");
414 return (pad.Position()*fgkLengthUnit - TVector2(x, y)).Mod2();
417 //______________________________________________________________________________
418 void AliMUONSt1Segmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
419 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
421 // Number of pads read in parallel and offset to add to x
422 // (specific to LYON, but mandatory for display)
425 Fatal("GetNParallelAndOffset", "Not yet implemented.");
429 //______________________________________________________________________________
430 void AliMUONSt1Segmentation::Neighbours(Int_t iX, Int_t iY,
432 Int_t Xlist[10], Int_t Ylist[10])
434 // Get next neighbours
437 AliMpPad pad = fPlaneSegmentation->PadByIndices(AliMpIntPair(iX,iY));
440 AliMpVPadIterator* iter
442 ->CreateIterator(AliMpArea(pad.Position(),2.*pad.Dimensions()*1.1));
444 for( iter->First(); !iter->IsDone() && i<10; iter->Next()) {
445 Xlist[i] = iter->CurrentItem().GetIndices().GetFirst();
446 Ylist[i] = iter->CurrentItem().GetIndices().GetSecond();
453 //______________________________________________________________________________
454 Int_t AliMUONSt1Segmentation::Ix()
456 // Current pad cursor during disintegration
460 return fPlaneIterator->CurrentItem().GetIndices().GetFirst();
463 //______________________________________________________________________________
464 Int_t AliMUONSt1Segmentation::Iy()
466 // Current pad cursor during disintegration
470 return fPlaneIterator->CurrentItem().GetIndices().GetSecond();
473 //______________________________________________________________________________
474 Int_t AliMUONSt1Segmentation::ISector()
482 //______________________________________________________________________________
483 Int_t AliMUONSt1Segmentation::Sector(Int_t ix, Int_t iy)
485 // Calculate sector from pad coordinates
488 return fPlaneSegmentation
489 ->Zone(fPlaneSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
492 //______________________________________________________________________________
493 Int_t AliMUONSt1Segmentation::Sector(Float_t x, Float_t y)
495 // Calculate sector from pad coordinates
498 return fPlaneSegmentation
499 ->Zone(fPlaneSegmentation
500 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit)));
503 //______________________________________________________________________________
504 void AliMUONSt1Segmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
505 Float_t& y1, Float_t& y2)
507 // Current integration limits
510 x1 = fXhit - fX - Dpx(fSector)/2.;
511 x2 = x1 + Dpx(fSector);
513 y1 = fYhit - fY - Dpy(fSector)/2.;
514 y2 = y1 + Dpy(fSector);
517 //______________________________________________________________________________
518 Int_t AliMUONSt1Segmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
520 // Signal Generation Condition during Stepping
521 // 0: don't generate signal
522 // 1: generate signal
525 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
526 // To correctly simulate the dependence of the spatial resolution on the angle
527 // of incidence signal must be generated for constant steps on
528 // the projection of the trajectory along the anode wire.
530 // Signal will be generated if particle crosses pad boundary or
531 // boundary between two wires.
533 // From AliMUONSegmentationV01
537 GetPadI(x, y, ixt, iyt);
538 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
540 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
549 //______________________________________________________________________________
550 void AliMUONSt1Segmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
552 // Initialise signal generation at coord (x,y,z)
553 // Initialises pad and wire position during stepping.
554 // From AliMUONSegmentationV01
559 GetPadI(x, y, fIxt, fIyt);
560 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
563 //______________________________________________________________________________
564 void AliMUONSt1Segmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
566 // Test points for auto calibration
567 // Returns test point on the pad plane.
568 // Used during determination of the segmoid correction of the COG-method
569 // From AliMUONSegmentationV01
573 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
577 //______________________________________________________________________________
578 void AliMUONSt1Segmentation::Draw(const char * /*opt*/) const
580 // Draw the segmentation zones.
581 // (Called from AliMUON::BuildGeometry)
584 Warning("Draw", "Not yet implemented.");
587 //______________________________________________________________________________
588 void AliMUONSt1Segmentation::SetCorrFunc(Int_t isec, TF1* func)
590 // Set the correction function.
591 // From AliMUONSegmentationV01
594 fCorrA->AddAt(func, isec);
597 //______________________________________________________________________________
598 TF1* AliMUONSt1Segmentation::CorrFunc(Int_t isec) const
600 // Get the correction Function.
601 // From AliMUONSegmentationV01
604 return (TF1*) fCorrA->At(isec);