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>
31 #include "AliMpArea.h"
32 #include "AliMpReader.h"
33 #include "AliMpSector.h"
34 #include "AliMpVPadIterator.h"
35 #include "AliMpSectorSegmentation.h"
37 #include "AliMUONSt12QuadrantSegmentation.h"
40 #include "AliMUONChamber.h"
43 ClassImp(AliMUONSt12QuadrantSegmentation)
45 const Float_t AliMUONSt12QuadrantSegmentation::fgkWireD = 0.20;
46 const Float_t AliMUONSt12QuadrantSegmentation::fgkLengthUnit = 0.1;
48 //______________________________________________________________________________
49 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
50 AliMpStationType stationType,
51 AliMpPlaneType planeType)
54 fSectorSegmentation(0),
78 AliMpReader r(stationType, planeType);
79 fSector = r.BuildSector();
80 fSectorSegmentation = new AliMpSectorSegmentation(fSector);
82 fCorrA = new TObjArray(3);
88 //______________________________________________________________________________
89 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation()
92 fSectorSegmentation(0),
113 // Default Constructor
116 //______________________________________________________________________________
117 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(const AliMUONSt12QuadrantSegmentation& rhs)
118 : AliSegmentation(rhs)
121 AliFatal("Copy constructor is not implemented.");
124 //______________________________________________________________________________
125 AliMUONSt12QuadrantSegmentation::~AliMUONSt12QuadrantSegmentation() {
129 delete fSectorSegmentation;
130 delete fSectorIterator;
137 //______________________________________________________________________________
138 AliMUONSt12QuadrantSegmentation&
139 AliMUONSt12QuadrantSegmentation::operator=(const AliMUONSt12QuadrantSegmentation& rhs)
143 // check assignement to self
144 if (this == &rhs) return *this;
146 AliFatal("Assignment operator is not implemented.");
155 //______________________________________________________________________________
156 void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad)
158 // Updates current pad values.
161 fIx = pad.GetIndices().GetFirst();
162 fIy = pad.GetIndices().GetSecond();
163 fX = pad.Position().X() * fgkLengthUnit;
164 fY = pad.Position().Y() * fgkLengthUnit;
165 fZone = fSectorSegmentation->Zone(pad);
172 //______________________________________________________________________________
173 void AliMUONSt12QuadrantSegmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
175 // Set pad size Dx*Dy
178 AliFatal("Not uniform pad size.");
181 //______________________________________________________________________________
182 void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
190 //______________________________________________________________________________
191 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
193 // Anod wire coordinate closest to xhit
194 // Returns for a hit position xhit the position of the nearest anode wire
195 // From AliMUONSegmentationV01.
198 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
199 : Int_t(xhit/fWireD) - 0.5;
204 //______________________________________________________________________________
205 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
206 Int_t& ix, Int_t& iy)
208 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
211 GetPadI(x, y, ix, iy);
214 //______________________________________________________________________________
215 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
216 Int_t& ix, Int_t& iy)
218 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
219 // If there is no pad, ix = 0, iy = 0 are returned.
222 AliMpPad pad = fSectorSegmentation
223 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), false);
225 ix = pad.GetIndices().GetFirst();
226 iy = pad.GetIndices().GetSecond();
229 //______________________________________________________________________________
230 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
231 Float_t& x, Float_t& y, Float_t& z)
233 // Transform from pad to real coordinates
237 GetPadC(ix, iy, x , y);
240 //______________________________________________________________________________
241 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
242 Float_t& x, Float_t& y)
244 // Transform from pad to real coordinates
245 // If there is no pad, x = 0., y = 0. are returned.
248 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy));
250 x = pad.Position().X() * fgkLengthUnit;
251 y = pad.Position().Y() * fgkLengthUnit;
255 //______________________________________________________________________________
256 void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
258 // Initialize segmentation
261 // find Npx, Npy and save this info
263 // reference to chamber
264 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
265 fChamber = &(pMUON->Chamber(chamber));
266 fRmin=fChamber->RInner();
267 fRmax=fChamber->ROuter();
272 //______________________________________________________________________________
273 Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
278 AliFatal( "Not uniform pad size.");
282 //______________________________________________________________________________
283 Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
288 AliFatal("Not uniform pad size.");
292 //______________________________________________________________________________
293 Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
295 // Pad size in x by sector
298 return fSectorSegmentation->PadDimensions(isector).X()*2.*fgkLengthUnit;
301 //______________________________________________________________________________
302 Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
304 // Pad size in x, y by Sector
307 return fSectorSegmentation->PadDimensions(isector).Y()*2.*fgkLengthUnit;
310 //______________________________________________________________________________
311 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
313 // Maximum number of Pads in x
316 //Fatal("Npx", "Not yet implemented.");
317 return 142; //hard coded for the time being
320 //______________________________________________________________________________
321 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
323 // Maximum number of Pads in y
326 //Fatal("Npy", "Not yet implemented.");
327 return 213; //hard coded for the time being
330 //______________________________________________________________________________
331 void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
334 // Sets virtual pad coordinates, needed for evaluating pad response
335 // outside the tracking program.
336 // From AliMUONSegmentationV01.
339 GetPadC(ix, iy, fX, fY);
340 fZone = Sector(ix, iy);
343 //______________________________________________________________________________
344 void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
347 // Sets virtual hit position, needed for evaluating pad response
348 // outside the tracking program
349 // From AliMUONSegmentationV01.
355 //______________________________________________________________________________
356 void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
357 Float_t dx, Float_t dy)
359 // Iterate over pads - initialiser
362 // Sets the current pad to that located in the hit position
364 SetHit(GetAnod(xhit), yhit, 0.);
366 // Enable iterating in one dimension
367 if (dx == 0.) dx = 0.01;
368 if (dy == 0.) dy = 0.01;
371 = fSectorSegmentation
372 ->CreateIterator(AliMpArea(TVector2(fXhit/fgkLengthUnit, fYhit/fgkLengthUnit),
373 TVector2(dx/fgkLengthUnit, dy/fgkLengthUnit)));
375 fSectorIterator->First();
377 if (! fSectorIterator->IsDone())
378 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
381 //______________________________________________________________________________
382 void AliMUONSt12QuadrantSegmentation::NextPad()
384 // Iterate over pads - stepper
387 fSectorIterator->Next();
389 if (! fSectorIterator->IsDone())
390 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
393 //______________________________________________________________________________
394 Int_t AliMUONSt12QuadrantSegmentation::MorePads()
396 // Iterate over pads - condition
399 if (fSectorIterator->IsDone())
405 //______________________________________________________________________________
406 Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
407 Float_t x, Float_t y, Int_t* /*dummy*/)
409 // Returns the square of the distance between 1 pad
410 // labelled by its channel numbers and a coordinate
413 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
416 AliFatal("Cannot locate pad.");
418 return (pad.Position()*fgkLengthUnit - TVector2(x, y)).Mod2();
421 //______________________________________________________________________________
422 void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
423 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
425 // Number of pads read in parallel and offset to add to x
426 // (specific to LYON, but mandatory for display)
429 AliFatal( "Not yet implemented.");
433 //______________________________________________________________________________
434 void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
436 Int_t Xlist[10], Int_t Ylist[10])
438 // Get next neighbours
441 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
444 AliMpVPadIterator* iter
445 = fSectorSegmentation
446 ->CreateIterator(AliMpArea(pad.Position(),2.*pad.Dimensions()*1.1));
448 for( iter->First(); !iter->IsDone() && i<10; iter->Next()) {
449 Xlist[i] = iter->CurrentItem().GetIndices().GetFirst();
450 Ylist[i] = iter->CurrentItem().GetIndices().GetSecond();
457 //______________________________________________________________________________
458 Int_t AliMUONSt12QuadrantSegmentation::Ix()
460 // Current pad cursor during disintegration
464 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
467 //______________________________________________________________________________
468 Int_t AliMUONSt12QuadrantSegmentation::Iy()
470 // Current pad cursor during disintegration
474 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
477 //______________________________________________________________________________
478 Int_t AliMUONSt12QuadrantSegmentation::ISector()
486 //______________________________________________________________________________
487 Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
489 // Calculate sector from pad coordinates
492 return fSectorSegmentation
493 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
496 //______________________________________________________________________________
497 Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
499 // Calculate sector from pad coordinates
502 return fSectorSegmentation
503 ->Zone(fSectorSegmentation
504 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit)));
507 //______________________________________________________________________________
508 void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
509 Float_t& y1, Float_t& y2)
511 // Current integration limits
514 x1 = fXhit - fX - Dpx(fZone)/2.;
515 x2 = x1 + Dpx(fZone);
517 y1 = fYhit - fY - Dpy(fZone)/2.;
518 y2 = y1 + Dpy(fZone);
521 //______________________________________________________________________________
522 Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
524 // Signal Generation Condition during Stepping
525 // 0: don't generate signal
526 // 1: generate signal
529 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
530 // To correctly simulate the dependence of the spatial resolution on the angle
531 // of incidence signal must be generated for constant steps on
532 // the projection of the trajectory along the anode wire.
534 // Signal will be generated if particle crosses pad boundary or
535 // boundary between two wires.
537 // From AliMUONSegmentationV01
541 GetPadI(x, y, ixt, iyt);
542 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
544 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
553 //______________________________________________________________________________
554 void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
556 // Initialise signal generation at coord (x,y,z)
557 // Initialises pad and wire position during stepping.
558 // From AliMUONSegmentationV01
563 GetPadI(x, y, fIxt, fIyt);
564 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
567 //______________________________________________________________________________
568 void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
570 // Test points for auto calibration
571 // Returns test point on the pad plane.
572 // Used during determination of the segmoid correction of the COG-method
573 // From AliMUONSegmentationV01
577 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
581 //______________________________________________________________________________
582 void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
584 // Draw the segmentation zones.
585 // (Called from AliMUON::BuildGeometry)
588 AliWarning("Not yet implemented.");
591 //______________________________________________________________________________
592 void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
594 // Set the correction function.
595 // From AliMUONSegmentationV01
598 fCorrA->AddAt(func, isec);
601 //______________________________________________________________________________
602 TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
604 // Get the correction Function.
605 // From AliMUONSegmentationV01
608 return (TF1*) fCorrA->At(isec);