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"
42 #include "AliMpFiles.h"
43 #include "AliMpNeighboursPadIterator.h"
46 ClassImp(AliMUONSt12QuadrantSegmentation)
48 const Float_t AliMUONSt12QuadrantSegmentation::fgkWireD = 0.20;
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 AliMpReader 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 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
258 // Anod wire coordinate closest to xhit
259 // Returns for a hit position xhit the position of the nearest anode wire
260 // From AliMUONSegmentationV01.
263 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
264 : Int_t(xhit/fWireD) - 0.5;
269 //______________________________________________________________________________
270 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
271 Int_t& ix, Int_t& iy)
273 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
276 GetPadI(x, y, ix, iy);
279 //______________________________________________________________________________
280 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
281 Int_t& ix, Int_t& iy)
283 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
284 // If there is no pad, ix = 0, iy = 0 are returned.
287 AliMpPad pad = fSectorSegmentation
288 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), true);
290 ix = pad.GetIndices().GetFirst();
291 iy = pad.GetIndices().GetSecond();
294 //______________________________________________________________________________
295 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
296 Float_t& x, Float_t& y, Float_t& z)
298 // Transform from pad to real coordinates
302 GetPadC(ix, iy, x , y);
305 //______________________________________________________________________________
306 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
307 Float_t& x, Float_t& y)
309 // Transform from pad to real coordinates
310 // If there is no pad, x = 0., y = 0. are returned.
313 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
315 x = pad.Position().X() * fgkLengthUnit;
316 y = pad.Position().Y() * fgkLengthUnit;
320 //______________________________________________________________________________
321 void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
323 // Initialize segmentation
326 // find Npx, Npy and save this info
328 // reference to chamber
329 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
330 fChamber = &(pMUON->Chamber(chamber));
331 fRmin=fChamber->RInner();
332 fRmax=fChamber->ROuter();
337 //______________________________________________________________________________
338 Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
343 AliFatal( "Not uniform pad size.");
347 //______________________________________________________________________________
348 Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
353 AliFatal("Not uniform pad size.");
357 //______________________________________________________________________________
358 Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
360 // Pad size in x by sector
363 return fSectorSegmentation->PadDimensions(isector).X()*2.*fgkLengthUnit;
366 //______________________________________________________________________________
367 Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
369 // Pad size in x, y by Sector
372 return fSectorSegmentation->PadDimensions(isector).Y()*2.*fgkLengthUnit;
375 //______________________________________________________________________________
376 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
378 // Maximum number of Pads in x
379 // hard coded for the time being
382 return fSectorSegmentation->MaxPadIndexX();
385 //______________________________________________________________________________
386 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
388 // Maximum number of Pads in y
389 // hard coded for the time being
392 return fSectorSegmentation->MaxPadIndexY();
395 //______________________________________________________________________________
396 void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
399 // Sets virtual pad coordinates, needed for evaluating pad response
400 // outside the tracking program.
401 // From AliMUONSegmentationV01.
404 GetPadC(ix, iy, fX, fY);
405 fZone = Sector(ix, iy);
408 //______________________________________________________________________________
409 void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
412 // Sets virtual hit position, needed for evaluating pad response
413 // outside the tracking program
414 // From AliMUONSegmentationV01.
420 //______________________________________________________________________________
421 void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
422 Float_t dx, Float_t dy)
424 // Iterate over pads - initialiser
427 // Sets the current pad to that located in the hit position
429 SetHit(GetAnod(xhit), yhit, 0.);
431 // Enable iterating in one dimension
432 if (dx == 0.) dx = 0.01;
433 if (dy == 0.) dy = 0.01;
436 = fSectorSegmentation
437 ->CreateIterator(AliMpArea(TVector2(fXhit/fgkLengthUnit, fYhit/fgkLengthUnit),
438 TVector2(dx/fgkLengthUnit, dy/fgkLengthUnit)));
440 fSectorIterator->First();
442 if (! fSectorIterator->IsDone())
443 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
446 //______________________________________________________________________________
447 void AliMUONSt12QuadrantSegmentation::NextPad()
449 // Iterate over pads - stepper
452 fSectorIterator->Next();
454 if (! fSectorIterator->IsDone())
455 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
458 //______________________________________________________________________________
459 Int_t AliMUONSt12QuadrantSegmentation::MorePads()
461 // Iterate over pads - condition
464 if (fSectorIterator->IsDone())
470 //______________________________________________________________________________
471 Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
472 Float_t x, Float_t y, Int_t* /*dummy*/)
474 // Returns the square of the distance between 1 pad
475 // labelled by its channel numbers and a coordinate
478 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
481 AliFatal("Cannot locate pad.");
483 return (pad.Position()*fgkLengthUnit - TVector2(x, y)).Mod2();
486 //______________________________________________________________________________
487 void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
488 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
490 // Number of pads read in parallel and offset to add to x
491 // (specific to LYON, but mandatory for display)
494 AliFatal( "Not yet implemented.");
498 //______________________________________________________________________________
499 void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
501 Int_t Xlist[10], Int_t Ylist[10])
503 // Get next neighbours
506 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
509 AliMpNeighboursPadIterator iter
510 = AliMpNeighboursPadIterator(fSectorSegmentation, pad, kFALSE);
512 for( iter.First(); !iter.IsDone() && i<10; iter.Next()) {
513 Xlist[i] = iter.CurrentItem().GetIndices().GetFirst();
514 Ylist[i] = iter.CurrentItem().GetIndices().GetSecond();
519 //______________________________________________________________________________
520 Int_t AliMUONSt12QuadrantSegmentation::Ix()
522 // Current pad cursor during disintegration
526 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
529 //______________________________________________________________________________
530 Int_t AliMUONSt12QuadrantSegmentation::Iy()
532 // Current pad cursor during disintegration
536 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
539 //______________________________________________________________________________
540 Int_t AliMUONSt12QuadrantSegmentation::ISector()
548 //______________________________________________________________________________
549 Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
551 // Calculate sector from pad coordinates
554 return fSectorSegmentation
555 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
558 //______________________________________________________________________________
559 Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
561 // Calculate sector from pad coordinates
564 return fSectorSegmentation
565 ->Zone(fSectorSegmentation
566 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit)));
569 //______________________________________________________________________________
570 void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
571 Float_t& y1, Float_t& y2)
573 // Current integration limits
576 x1 = fXhit - fX - Dpx(fZone)/2.;
577 x2 = x1 + Dpx(fZone);
579 y1 = fYhit - fY - Dpy(fZone)/2.;
580 y2 = y1 + Dpy(fZone);
583 //______________________________________________________________________________
584 Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
586 // Signal Generation Condition during Stepping
587 // 0: don't generate signal
588 // 1: generate signal
591 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
592 // To correctly simulate the dependence of the spatial resolution on the angle
593 // of incidence signal must be generated for constant steps on
594 // the projection of the trajectory along the anode wire.
596 // Signal will be generated if particle crosses pad boundary or
597 // boundary between two wires.
599 // From AliMUONSegmentationV01
603 GetPadI(x, y, ixt, iyt);
604 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
606 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
614 //______________________________________________________________________________
615 void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
617 // Initialise signal generation at coord (x,y,z)
618 // Initialises pad and wire position during stepping.
619 // From AliMUONSegmentationV01
624 GetPadI(x, y, fIxt, fIyt);
625 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
628 //______________________________________________________________________________
629 void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
631 // Test points for auto calibration
632 // Returns test point on the pad plane.
633 // Used during determination of the segmoid correction of the COG-method
634 // From AliMUONSegmentationV01
638 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
642 //______________________________________________________________________________
643 void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
645 // Draw the segmentation zones.
646 // (Called from AliMUON::BuildGeometry)
649 AliWarning("Not yet implemented.");
652 //______________________________________________________________________________
653 void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
655 // Set the correction function.
656 // From AliMUONSegmentationV01
659 fCorrA->AddAt(func, isec);
662 //______________________________________________________________________________
663 TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
665 // Get the correction Function.
666 // From AliMUONSegmentationV01
669 return (TF1*) fCorrA->At(isec);
672 //______________________________________________________________________________
673 void AliMUONSt12QuadrantSegmentation::Streamer(TBuffer &R__b)
675 // Stream an object of class AliMUONSt12QuadrantSegmentation.
677 if (R__b.IsReading()) {
678 AliMUONSt12QuadrantSegmentation::Class()->ReadBuffer(R__b, this);
682 AliMUONSt12QuadrantSegmentation::Class()->WriteBuffer(R__b, this);