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 Revision 1.1 2003/01/28 13:21:06 morsch
19 Improved response simulation for station 1.
20 (M. Mac Cormick, I. Hrivnacova, D. Guez)
24 // Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
26 // Class AliMUONSt1Segmentation
27 // ------------------------------
28 // Segmentation for MUON station 1 using the external
31 #include <Riostream.h>
33 #include <TObjArray.h>
37 #include <AliMpPlane.h>
38 #include <AliMpPlaneType.h>
39 #include <AliMpPlaneSegmentation.h>
40 #include <AliMpPlaneAreaPadIterator.h>
42 #include "AliMUONSt1Segmentation.h"
45 #include "AliMUONChamber.h"
47 ClassImp(AliMUONSt1Segmentation)
49 const Float_t AliMUONSt1Segmentation::fgkWireD = 0.20;
50 const Float_t AliMUONSt1Segmentation::fgkLengthUnit = 0.1;
52 //______________________________________________________________________________
53 AliMUONSt1Segmentation::AliMUONSt1Segmentation(const AliMpPlaneType planeType)
56 fPlaneSegmentation(0),
79 fPlane = AliMpPlane::Create(planeType);
80 fPlaneSegmentation = new AliMpPlaneSegmentation(fPlane);
82 fCorrA = new TObjArray(3);
88 //______________________________________________________________________________
89 AliMUONSt1Segmentation::AliMUONSt1Segmentation()
92 fPlaneSegmentation(0),
113 // Default Constructor
116 //______________________________________________________________________________
117 AliMUONSt1Segmentation::AliMUONSt1Segmentation(const AliMUONSt1Segmentation& rhs)
120 Fatal("Copy constructor",
121 "Copy constructor is not implemented.");
124 //______________________________________________________________________________
125 AliMUONSt1Segmentation::~AliMUONSt1Segmentation() {
129 delete fPlaneSegmentation;
130 delete fPlaneIterator;
137 //______________________________________________________________________________
138 AliMUONSt1Segmentation&
139 AliMUONSt1Segmentation::operator=(const AliMUONSt1Segmentation& rhs)
143 // check assignement to self
144 if (this == &rhs) return *this;
147 "Assignment operator is not implemented.");
156 //______________________________________________________________________________
157 void AliMUONSt1Segmentation::UpdateCurrentPadValues(const AliMpPad& pad)
159 // Updates current pad values.
162 fIx = pad.GetIndices().GetFirst();
163 fIy = pad.GetIndices().GetSecond();
164 fX = pad.Position().X() * fgkLengthUnit;
165 fY = pad.Position().Y() * fgkLengthUnit;
166 fSector = fPlaneSegmentation->Zone(pad);
173 //______________________________________________________________________________
174 void AliMUONSt1Segmentation::SetPadSize(Float_t p1, Float_t p2)
176 // Set pad size Dx*Dy
179 Fatal("SetPadSize", "Not uniform pad size.");
182 //______________________________________________________________________________
183 void AliMUONSt1Segmentation::SetDAnod(Float_t d)
191 //______________________________________________________________________________
192 Float_t AliMUONSt1Segmentation::GetAnod(Float_t xhit) const
194 // Anod wire coordinate closest to xhit
195 // Returns for a hit position xhit the position of the nearest anode wire
196 // From AliMUONSegmentationV01.
199 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
200 : Int_t(xhit/fWireD) - 0.5;
205 //______________________________________________________________________________
206 void AliMUONSt1Segmentation::GetPadI(Float_t x, Float_t y, Float_t z,
207 Int_t& ix, Int_t& iy)
209 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
212 GetPadI(x, y, ix, iy);
215 //______________________________________________________________________________
216 void AliMUONSt1Segmentation::GetPadI(Float_t x, Float_t y,
217 Int_t& ix, Int_t& iy)
219 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
220 // If there is no pad, ix = 0, iy = 0 are returned.
223 AliMpPad pad = fPlaneSegmentation
224 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), false);
226 ix = pad.GetIndices().GetFirst();
227 iy = pad.GetIndices().GetSecond();
230 //______________________________________________________________________________
231 void AliMUONSt1Segmentation::GetPadC(Int_t ix, Int_t iy,
232 Float_t& x, Float_t& y, Float_t& z)
234 // Transform from pad to real coordinates
238 GetPadC(ix, iy, x , y);
241 //______________________________________________________________________________
242 void AliMUONSt1Segmentation::GetPadC(Int_t ix, Int_t iy,
243 Float_t& x, Float_t& y)
245 // Transform from pad to real coordinates
246 // If there is no pad, x = 0., y = 0. are returned.
249 AliMpPad pad = fPlaneSegmentation->PadByIndices(AliMpIntPair(ix,iy));
251 x = pad.Position().X() * fgkLengthUnit;
252 y = pad.Position().Y() * fgkLengthUnit;
256 //______________________________________________________________________________
257 void AliMUONSt1Segmentation::Init(Int_t chamber)
259 // Initialize segmentation
262 // find Npx, Npy and save this info
264 // reference to chamber
265 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
266 fChamber = &(pMUON->Chamber(chamber));
267 fRmin=fChamber->RInner();
268 fRmax=fChamber->ROuter();
273 //______________________________________________________________________________
274 Float_t AliMUONSt1Segmentation::Dpx() const
279 Fatal("Dpx", "Not uniform pad size.");
283 //______________________________________________________________________________
284 Float_t AliMUONSt1Segmentation::Dpy() const
289 Fatal("Dpy", "Not uniform pad size.");
293 //______________________________________________________________________________
294 Float_t AliMUONSt1Segmentation::Dpx(Int_t isector) const
296 // Pad size in x by sector
299 return fPlaneSegmentation->PadDimensions(isector).X()*2.*fgkLengthUnit;
302 //______________________________________________________________________________
303 Float_t AliMUONSt1Segmentation::Dpy(Int_t isector) const
305 // Pad size in x, y by Sector
308 return fPlaneSegmentation->PadDimensions(isector).Y()*2.*fgkLengthUnit;
311 //______________________________________________________________________________
312 Int_t AliMUONSt1Segmentation::Npx() const
314 // Maximum number of Pads in x
317 //Fatal("Npx", "Not yet implemented.");
318 return 142; //hard coded for the time being
321 //______________________________________________________________________________
322 Int_t AliMUONSt1Segmentation::Npy() const
324 // Maximum number of Pads in y
327 //Fatal("Npy", "Not yet implemented.");
328 return 213; //hard coded for the time being
331 //______________________________________________________________________________
332 void AliMUONSt1Segmentation::SetPad(Int_t ix, Int_t iy)
335 // Sets virtual pad coordinates, needed for evaluating pad response
336 // outside the tracking program.
337 // From AliMUONSegmentationV01.
340 GetPadC(ix, iy, fX, fY);
341 fSector = Sector(ix, iy);
344 //______________________________________________________________________________
345 void AliMUONSt1Segmentation::SetHit(Float_t xhit, Float_t yhit, Float_t zhit)
348 // Sets virtual hit position, needed for evaluating pad response
349 // outside the tracking program
350 // From AliMUONSegmentationV01.
356 //______________________________________________________________________________
357 void AliMUONSt1Segmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t zhit,
358 Float_t dx, Float_t dy)
360 // Iterate over pads - initialiser
363 // Sets the current pad to that located in the hit position
365 SetHit(GetAnod(xhit), yhit, 0.);
367 // Enable iterating in one dimension
368 if (dx == 0.) dx = 0.01;
369 if (dy == 0.) dy = 0.01;
373 ->CreateIterator(AliMpArea(TVector2(fXhit/fgkLengthUnit, fYhit/fgkLengthUnit),
374 TVector2(dx/fgkLengthUnit, dy/fgkLengthUnit)));
376 fPlaneIterator->First();
378 if (! fPlaneIterator->IsDone())
379 UpdateCurrentPadValues(fPlaneIterator->CurrentItem());
382 //______________________________________________________________________________
383 void AliMUONSt1Segmentation::NextPad()
385 // Iterate over pads - stepper
388 fPlaneIterator->Next();
390 if (! fPlaneIterator->IsDone())
391 UpdateCurrentPadValues(fPlaneIterator->CurrentItem());
394 //______________________________________________________________________________
395 Int_t AliMUONSt1Segmentation::MorePads()
397 // Iterate over pads - condition
400 if (fPlaneIterator->IsDone())
406 //______________________________________________________________________________
407 Float_t AliMUONSt1Segmentation::Distance2AndOffset(Int_t iX, Int_t iY,
408 Float_t x, Float_t y, Int_t* dummy)
410 // Returns the square of the distance between 1 pad
411 // labelled by its channel numbers and a coordinate
414 AliMpPad pad = fPlaneSegmentation->PadByIndices(AliMpIntPair(iX, iY));
417 Fatal("Distance2AndOffset", "Cannot locate pad.");
419 return (pad.Position()*fgkLengthUnit - TVector2(x, y)).Mod2();
422 //______________________________________________________________________________
423 void AliMUONSt1Segmentation::GetNParallelAndOffset(Int_t iX, Int_t iY,
424 Int_t* Nparallel, Int_t* Offset)
426 // Number of pads read in parallel and offset to add to x
427 // (specific to LYON, but mandatory for display)
430 Fatal("GetNParallelAndOffset", "Not yet implemented.");
434 //______________________________________________________________________________
435 void AliMUONSt1Segmentation::Neighbours(Int_t iX, Int_t iY,
437 Int_t Xlist[10], Int_t Ylist[10])
439 // Get next neighbours
442 AliMpPad pad = fPlaneSegmentation->PadByIndices(AliMpIntPair(iX,iY));
445 AliMpVPadIterator* iter
447 ->CreateIterator(AliMpArea(pad.Position(),2.*pad.Dimensions()*1.1));
449 for( iter->First(); !iter->IsDone() && i<10; iter->Next()) {
450 Xlist[i] = iter->CurrentItem().GetIndices().GetFirst();
451 Ylist[i] = iter->CurrentItem().GetIndices().GetSecond();
458 //______________________________________________________________________________
459 Int_t AliMUONSt1Segmentation::Ix()
461 // Current pad cursor during disintegration
465 return fPlaneIterator->CurrentItem().GetIndices().GetFirst();
468 //______________________________________________________________________________
469 Int_t AliMUONSt1Segmentation::Iy()
471 // Current pad cursor during disintegration
475 return fPlaneIterator->CurrentItem().GetIndices().GetSecond();
478 //______________________________________________________________________________
479 Int_t AliMUONSt1Segmentation::ISector()
487 //______________________________________________________________________________
488 Int_t AliMUONSt1Segmentation::Sector(Int_t ix, Int_t iy)
490 // Calculate sector from pad coordinates
493 return fPlaneSegmentation
494 ->Zone(fPlaneSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
497 //______________________________________________________________________________
498 Int_t AliMUONSt1Segmentation::Sector(Float_t x, Float_t y)
500 // Calculate sector from pad coordinates
503 return fPlaneSegmentation
504 ->Zone(fPlaneSegmentation
505 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit)));
508 //______________________________________________________________________________
509 void AliMUONSt1Segmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
510 Float_t& y1, Float_t& y2)
512 // Current integration limits
515 x1 = fXhit - fX - Dpx(fSector)/2.;
516 x2 = x1 + Dpx(fSector);
518 y1 = fYhit - fY - Dpy(fSector)/2.;
519 y2 = y1 + Dpy(fSector);
522 //______________________________________________________________________________
523 Int_t AliMUONSt1Segmentation::SigGenCond(Float_t x, Float_t y, Float_t z)
525 // Signal Generation Condition during Stepping
526 // 0: don't generate signal
527 // 1: generate signal
530 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
531 // To correctly simulate the dependence of the spatial resolution on the angle
532 // of incidence signal must be generated for constant steps on
533 // the projection of the trajectory along the anode wire.
535 // Signal will be generated if particle crosses pad boundary or
536 // boundary between two wires.
538 // From AliMUONSegmentationV01
542 GetPadI(x, y, ixt, iyt);
543 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
545 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
554 //______________________________________________________________________________
555 void AliMUONSt1Segmentation::SigGenInit(Float_t x, Float_t y, Float_t z)
557 // Initialise signal generation at coord (x,y,z)
558 // Initialises pad and wire position during stepping.
559 // From AliMUONSegmentationV01
564 GetPadI(x, y, fIxt, fIyt);
565 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
568 //______________________________________________________________________________
569 void AliMUONSt1Segmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
571 // Test points for auto calibration
572 // Returns test point on the pad plane.
573 // Used during determination of the segmoid correction of the COG-method
574 // From AliMUONSegmentationV01
578 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
582 //______________________________________________________________________________
583 void AliMUONSt1Segmentation::Draw(const char *opt) const
585 // Draw the segmentation zones.
586 // (Called from AliMUON::BuildGeometry)
589 Warning("Draw", "Not yet implemented.");
592 //______________________________________________________________________________
593 void AliMUONSt1Segmentation::SetCorrFunc(Int_t isec, TF1* func)
595 // Set the correction function.
596 // From AliMUONSegmentationV01
599 fCorrA->AddAt(func, isec);
602 //______________________________________________________________________________
603 TF1* AliMUONSt1Segmentation::CorrFunc(Int_t isec) const
605 // Get the correction Function.
606 // From AliMUONSegmentationV01
609 return (TF1*) fCorrA->At(isec);