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 "AliMpSectorReader.h"
33 #include "AliMpSector.h"
34 #include "AliMpVPadIterator.h"
35 #include "AliMpSectorSegmentation.h"
37 #include "AliMUONSt12QuadrantSegmentation.h"
40 #include "AliMUONChamber.h"
42 #include "AliMpFiles.h"
43 #include "AliMpNeighboursPadIterator.h"
46 ClassImp(AliMUONSt12QuadrantSegmentation)
48 const Float_t AliMUONSt12QuadrantSegmentation::fgkWireD = 0.21;
49 const Float_t AliMUONSt12QuadrantSegmentation::fgkLengthUnit = 0.1;
51 //______________________________________________________________________________
52 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
53 AliMpStationType stationType,
54 AliMpPlaneType planeType)
55 : AliMUONVGeometryDESegmentation(),
56 fStationType(stationType),
57 fPlaneType(planeType),
59 fSectorSegmentation(0),
85 fCorrA = new TObjArray(3);
91 //______________________________________________________________________________
92 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation()
93 : AliMUONVGeometryDESegmentation(),
94 fStationType(kStation1),
95 fPlaneType(kBendingPlane),
97 fSectorSegmentation(0),
118 // Default Constructor
121 //______________________________________________________________________________
122 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(const AliMUONSt12QuadrantSegmentation& rhs)
123 : AliMUONVGeometryDESegmentation(rhs)
126 AliFatal("Copy constructor is not implemented.");
129 //______________________________________________________________________________
130 AliMUONSt12QuadrantSegmentation::~AliMUONSt12QuadrantSegmentation() {
134 delete fSectorSegmentation;
135 delete fSectorIterator;
142 //______________________________________________________________________________
143 AliMUONSt12QuadrantSegmentation&
144 AliMUONSt12QuadrantSegmentation::operator=(const AliMUONSt12QuadrantSegmentation& rhs)
148 // check assignement to self
149 if (this == &rhs) return *this;
151 AliFatal("Assignment operator is not implemented.");
160 //______________________________________________________________________________
161 void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad)
163 // Updates current pad values.
166 fIx = pad.GetIndices().GetFirst();
167 fIy = pad.GetIndices().GetSecond();
168 fX = pad.Position().X() * fgkLengthUnit;
169 fY = pad.Position().Y() * fgkLengthUnit;
170 fZone = fSectorSegmentation->Zone(pad);
174 //______________________________________________________________________________
175 void AliMUONSt12QuadrantSegmentation::ReadMappingData()
177 // Reads mapping data
180 // set path to mapping data files
181 if (!gSystem->Getenv("MINSTALL")) {
182 TString dirPath = gSystem->Getenv("ALICE_ROOT");
183 dirPath += "/MUON/mapping";
184 AliMpFiles::Instance()->SetTopPath(dirPath);
185 gSystem->Setenv("MINSTALL", dirPath.Data());
186 //cout << "AliMpFiles top path set to " << dirPath << endl;
189 AliMpSectorReader r(fStationType, fPlaneType);
190 fSector = r.BuildSector();
191 fSectorSegmentation = new AliMpSectorSegmentation(fSector);
198 //______________________________________________________________________________
199 void AliMUONSt12QuadrantSegmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
201 // Set pad size Dx*Dy
204 AliFatal("Not uniform pad size.");
207 //______________________________________________________________________________
208 void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
216 #include "AliMpMotifMap.h"
217 //______________________________________________________________________________
218 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
220 // Returns true if a pad exists in the given position
222 // fSector->GetMotifMap()->Print();
224 AliMpPad pad = fSectorSegmentation
225 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), false);
227 return pad.IsValid();
231 //______________________________________________________________________________
232 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Int_t ix, Int_t iy)
234 // Returns true if a pad with given indices exists
236 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), false);
238 return pad.IsValid();
242 //______________________________________________________________________________
243 AliMUONGeometryDirection AliMUONSt12QuadrantSegmentation::GetDirection()
245 // Returns the direction with a constant pad size
246 // (Direction or coordinate where the resolution is the best)
248 switch ( fSector->GetDirection() ) {
249 case kX: return kDirX;
250 case kY: return kDirY;
251 default: return kDirUndefined;
255 //______________________________________________________________________________
256 const AliMpSectorSegmentation*
257 AliMUONSt12QuadrantSegmentation::GetMpSegmentation() const
259 // Returns the mapping segmentation
260 // (provides access to electronics info)
262 return fSectorSegmentation;
265 //______________________________________________________________________________
266 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
268 // Anod wire coordinate closest to xhit
269 // Returns for a hit position xhit the position of the nearest anode wire
270 // From AliMUONSegmentationV01.
273 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
274 : Int_t(xhit/fWireD) - 0.5;
279 //______________________________________________________________________________
280 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
281 Int_t& ix, Int_t& iy)
283 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
286 GetPadI(x, y, ix, iy);
289 //______________________________________________________________________________
290 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
291 Int_t& ix, Int_t& iy)
293 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
294 // If there is no pad, ix = 0, iy = 0 are returned.
297 AliMpPad pad = fSectorSegmentation
298 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), true);
300 ix = pad.GetIndices().GetFirst();
301 iy = pad.GetIndices().GetSecond();
304 //______________________________________________________________________________
305 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
306 Float_t& x, Float_t& y, Float_t& z)
308 // Transform from pad to real coordinates
312 GetPadC(ix, iy, x , y);
315 //______________________________________________________________________________
316 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
317 Float_t& x, Float_t& y)
319 // Transform from pad to real coordinates
320 // If there is no pad, x = 0., y = 0. are returned.
323 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
325 x = pad.Position().X() * fgkLengthUnit;
326 y = pad.Position().Y() * fgkLengthUnit;
330 //______________________________________________________________________________
331 void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
333 // Initialize segmentation
336 // find Npx, Npy and save this info
338 // reference to chamber
339 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
340 fChamber = &(pMUON->Chamber(chamber));
341 fRmin=fChamber->RInner();
342 fRmax=fChamber->ROuter();
347 //______________________________________________________________________________
348 Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
353 AliFatal( "Not uniform pad size.");
357 //______________________________________________________________________________
358 Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
363 AliFatal("Not uniform pad size.");
367 //______________________________________________________________________________
368 Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
370 // Pad size in x by sector
373 return fSectorSegmentation->PadDimensions(isector).X()*2.*fgkLengthUnit;
376 //______________________________________________________________________________
377 Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
379 // Pad size in x, y by Sector
382 return fSectorSegmentation->PadDimensions(isector).Y()*2.*fgkLengthUnit;
385 //______________________________________________________________________________
386 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
388 // Maximum number of Pads in x
389 // hard coded for the time being
392 return fSectorSegmentation->MaxPadIndexX();
395 //______________________________________________________________________________
396 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
398 // Maximum number of Pads in y
399 // hard coded for the time being
402 return fSectorSegmentation->MaxPadIndexY();
405 //______________________________________________________________________________
406 void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
409 // Sets virtual pad coordinates, needed for evaluating pad response
410 // outside the tracking program.
411 // From AliMUONSegmentationV01.
414 GetPadC(ix, iy, fX, fY);
415 fZone = Sector(ix, iy);
418 //______________________________________________________________________________
419 void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
422 // Sets virtual hit position, needed for evaluating pad response
423 // outside the tracking program
424 // From AliMUONSegmentationV01.
430 //______________________________________________________________________________
431 void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
432 Float_t dx, Float_t dy)
434 // Iterate over pads - initialiser
437 // Sets the current pad to that located in the hit position
439 SetHit(GetAnod(xhit), yhit, 0.);
441 // Enable iterating in one dimension
442 if (dx == 0.) dx = 0.01;
443 if (dy == 0.) dy = 0.01;
446 = fSectorSegmentation
447 ->CreateIterator(AliMpArea(TVector2(fXhit/fgkLengthUnit, fYhit/fgkLengthUnit),
448 TVector2(dx/fgkLengthUnit, dy/fgkLengthUnit)));
450 fSectorIterator->First();
452 if (! fSectorIterator->IsDone())
453 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
456 //______________________________________________________________________________
457 void AliMUONSt12QuadrantSegmentation::NextPad()
459 // Iterate over pads - stepper
462 fSectorIterator->Next();
464 if (! fSectorIterator->IsDone())
465 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
468 //______________________________________________________________________________
469 Int_t AliMUONSt12QuadrantSegmentation::MorePads()
471 // Iterate over pads - condition
474 if (fSectorIterator->IsDone())
480 //______________________________________________________________________________
481 Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
482 Float_t x, Float_t y, Int_t* /*dummy*/)
484 // Returns the square of the distance between 1 pad
485 // labelled by its channel numbers and a coordinate
488 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
491 AliFatal("Cannot locate pad.");
493 return (pad.Position()*fgkLengthUnit - TVector2(x, y)).Mod2();
496 //______________________________________________________________________________
497 void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
498 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
500 // Number of pads read in parallel and offset to add to x
501 // (specific to LYON, but mandatory for display)
504 AliFatal( "Not yet implemented.");
508 //______________________________________________________________________________
509 void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
511 Int_t Xlist[10], Int_t Ylist[10])
513 // Get next neighbours
516 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
519 AliMpNeighboursPadIterator iter
520 = AliMpNeighboursPadIterator(fSectorSegmentation, pad, kFALSE);
522 for( iter.First(); !iter.IsDone() && i<10; iter.Next()) {
523 Xlist[i] = iter.CurrentItem().GetIndices().GetFirst();
524 Ylist[i] = iter.CurrentItem().GetIndices().GetSecond();
529 //______________________________________________________________________________
530 Int_t AliMUONSt12QuadrantSegmentation::Ix()
532 // Current pad cursor during disintegration
536 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
539 //______________________________________________________________________________
540 Int_t AliMUONSt12QuadrantSegmentation::Iy()
542 // Current pad cursor during disintegration
546 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
549 //______________________________________________________________________________
550 Int_t AliMUONSt12QuadrantSegmentation::ISector()
558 //______________________________________________________________________________
559 Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
561 // Calculate sector from pad coordinates
564 return fSectorSegmentation
565 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
568 //______________________________________________________________________________
569 Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
571 // Calculate sector from pad coordinates
574 return fSectorSegmentation
575 ->Zone(fSectorSegmentation
576 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit)));
579 //______________________________________________________________________________
580 void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
581 Float_t& y1, Float_t& y2)
583 // Current integration limits
586 x1 = fXhit - fX - Dpx(fZone)/2.;
587 x2 = x1 + Dpx(fZone);
589 y1 = fYhit - fY - Dpy(fZone)/2.;
590 y2 = y1 + Dpy(fZone);
593 //______________________________________________________________________________
594 Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
596 // Signal Generation Condition during Stepping
597 // 0: don't generate signal
598 // 1: generate signal
601 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
602 // To correctly simulate the dependence of the spatial resolution on the angle
603 // of incidence signal must be generated for constant steps on
604 // the projection of the trajectory along the anode wire.
606 // Signal will be generated if particle crosses pad boundary or
607 // boundary between two wires.
609 // From AliMUONSegmentationV01
613 GetPadI(x, y, ixt, iyt);
614 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
616 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
624 //______________________________________________________________________________
625 void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
627 // Initialise signal generation at coord (x,y,z)
628 // Initialises pad and wire position during stepping.
629 // From AliMUONSegmentationV01
634 GetPadI(x, y, fIxt, fIyt);
635 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
638 //______________________________________________________________________________
639 void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
641 // Test points for auto calibration
642 // Returns test point on the pad plane.
643 // Used during determination of the segmoid correction of the COG-method
644 // From AliMUONSegmentationV01
648 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
652 //______________________________________________________________________________
653 void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
655 // Draw the segmentation zones.
656 // (Called from AliMUON::BuildGeometry)
659 AliWarning("Not yet implemented.");
662 //______________________________________________________________________________
663 void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
665 // Set the correction function.
666 // From AliMUONSegmentationV01
669 fCorrA->AddAt(func, isec);
672 //______________________________________________________________________________
673 TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
675 // Get the correction Function.
676 // From AliMUONSegmentationV01
679 return (TF1*) fCorrA->At(isec);
682 //______________________________________________________________________________
683 void AliMUONSt12QuadrantSegmentation::Streamer(TBuffer &R__b)
685 // Stream an object of class AliMUONSt12QuadrantSegmentation.
687 if (R__b.IsReading()) {
688 AliMUONSt12QuadrantSegmentation::Class()->ReadBuffer(R__b, this);
692 AliMUONSt12QuadrantSegmentation::Class()->WriteBuffer(R__b, this);