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"
45 ClassImp(AliMUONSt12QuadrantSegmentation)
47 const Float_t AliMUONSt12QuadrantSegmentation::fgkWireD = 0.20;
48 const Float_t AliMUONSt12QuadrantSegmentation::fgkLengthUnit = 0.1;
50 //______________________________________________________________________________
51 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
52 AliMpStationType stationType,
53 AliMpPlaneType planeType)
54 : AliMUONVGeometryDESegmentation(),
55 fStationType(stationType),
56 fPlaneType(planeType),
58 fSectorSegmentation(0),
84 fCorrA = new TObjArray(3);
90 //______________________________________________________________________________
91 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation()
92 : AliMUONVGeometryDESegmentation(),
93 fStationType(kStation1),
94 fPlaneType(kBendingPlane),
96 fSectorSegmentation(0),
117 // Default Constructor
120 //______________________________________________________________________________
121 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(const AliMUONSt12QuadrantSegmentation& rhs)
122 : AliMUONVGeometryDESegmentation(rhs)
125 AliFatal("Copy constructor is not implemented.");
128 //______________________________________________________________________________
129 AliMUONSt12QuadrantSegmentation::~AliMUONSt12QuadrantSegmentation() {
133 delete fSectorSegmentation;
134 delete fSectorIterator;
141 //______________________________________________________________________________
142 AliMUONSt12QuadrantSegmentation&
143 AliMUONSt12QuadrantSegmentation::operator=(const AliMUONSt12QuadrantSegmentation& rhs)
147 // check assignement to self
148 if (this == &rhs) return *this;
150 AliFatal("Assignment operator is not implemented.");
159 //______________________________________________________________________________
160 void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad)
162 // Updates current pad values.
165 fIx = pad.GetIndices().GetFirst();
166 fIy = pad.GetIndices().GetSecond();
167 fX = pad.Position().X() * fgkLengthUnit;
168 fY = pad.Position().Y() * fgkLengthUnit;
169 fZone = fSectorSegmentation->Zone(pad);
173 //______________________________________________________________________________
174 void AliMUONSt12QuadrantSegmentation::ReadMappingData()
176 // Reads mapping data
179 // set path to mapping data files
180 if (!gSystem->Getenv("MINSTALL")) {
181 TString dirPath = gSystem->Getenv("ALICE_ROOT");
182 dirPath += "/MUON/mapping";
183 AliMpFiles::Instance()->SetTopPath(dirPath);
184 gSystem->Setenv("MINSTALL", dirPath.Data());
185 //cout << "AliMpFiles top path set to " << dirPath << endl;
188 AliMpReader r(fStationType, fPlaneType);
189 fSector = r.BuildSector();
190 fSectorSegmentation = new AliMpSectorSegmentation(fSector);
197 //______________________________________________________________________________
198 void AliMUONSt12QuadrantSegmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
200 // Set pad size Dx*Dy
203 AliFatal("Not uniform pad size.");
206 //______________________________________________________________________________
207 void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
215 #include "AliMpMotifMap.h"
216 //______________________________________________________________________________
217 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
219 // Returns true if a pad exists in the given position
221 // fSector->GetMotifMap()->Print();
223 AliMpPad pad = fSectorSegmentation
224 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), false);
226 return pad.IsValid();
230 //______________________________________________________________________________
231 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Int_t ix, Int_t iy)
233 // Returns true if a pad with given indices exists
235 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), false);
237 return pad.IsValid();
241 //______________________________________________________________________________
242 AliMUONGeometryDirection AliMUONSt12QuadrantSegmentation::GetDirection()
244 // Returns the direction with a constant pad size
245 // (Direction or coordinate where the resolution is the best)
247 switch ( fSector->GetDirection() ) {
248 case kX: return kDirX;
249 case kY: return kDirY;
250 default: return kDirUndefined;
254 //______________________________________________________________________________
255 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
257 // Anod wire coordinate closest to xhit
258 // Returns for a hit position xhit the position of the nearest anode wire
259 // From AliMUONSegmentationV01.
262 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
263 : Int_t(xhit/fWireD) - 0.5;
268 //______________________________________________________________________________
269 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
270 Int_t& ix, Int_t& iy)
272 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
275 GetPadI(x, y, ix, iy);
278 //______________________________________________________________________________
279 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
280 Int_t& ix, Int_t& iy)
282 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
283 // If there is no pad, ix = 0, iy = 0 are returned.
286 AliMpPad pad = fSectorSegmentation
287 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), true);
289 ix = pad.GetIndices().GetFirst();
290 iy = pad.GetIndices().GetSecond();
293 //______________________________________________________________________________
294 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
295 Float_t& x, Float_t& y, Float_t& z)
297 // Transform from pad to real coordinates
301 GetPadC(ix, iy, x , y);
304 //______________________________________________________________________________
305 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
306 Float_t& x, Float_t& y)
308 // Transform from pad to real coordinates
309 // If there is no pad, x = 0., y = 0. are returned.
312 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
314 x = pad.Position().X() * fgkLengthUnit;
315 y = pad.Position().Y() * fgkLengthUnit;
319 //______________________________________________________________________________
320 void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
322 // Initialize segmentation
325 // find Npx, Npy and save this info
327 // reference to chamber
328 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
329 fChamber = &(pMUON->Chamber(chamber));
330 fRmin=fChamber->RInner();
331 fRmax=fChamber->ROuter();
336 //______________________________________________________________________________
337 Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
342 AliFatal( "Not uniform pad size.");
346 //______________________________________________________________________________
347 Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
352 AliFatal("Not uniform pad size.");
356 //______________________________________________________________________________
357 Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
359 // Pad size in x by sector
362 return fSectorSegmentation->PadDimensions(isector).X()*2.*fgkLengthUnit;
365 //______________________________________________________________________________
366 Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
368 // Pad size in x, y by Sector
371 return fSectorSegmentation->PadDimensions(isector).Y()*2.*fgkLengthUnit;
374 //______________________________________________________________________________
375 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
377 // Maximum number of Pads in x
378 // hard coded for the time being
381 //Fatal("Npx", "Not yet implemented.");
382 switch (fSector->GetDirection()) {
388 AliError("Unknown sector direction");
393 //______________________________________________________________________________
394 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
396 // Maximum number of Pads in y
397 // hard coded for the time being
400 //Fatal("Npy", "Not yet implemented.");
401 switch (fSector->GetDirection()) {
407 AliError("Unknown sector direction");
412 //______________________________________________________________________________
413 void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
416 // Sets virtual pad coordinates, needed for evaluating pad response
417 // outside the tracking program.
418 // From AliMUONSegmentationV01.
421 GetPadC(ix, iy, fX, fY);
422 fZone = Sector(ix, iy);
425 //______________________________________________________________________________
426 void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
429 // Sets virtual hit position, needed for evaluating pad response
430 // outside the tracking program
431 // From AliMUONSegmentationV01.
437 //______________________________________________________________________________
438 void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
439 Float_t dx, Float_t dy)
441 // Iterate over pads - initialiser
444 // Sets the current pad to that located in the hit position
446 SetHit(GetAnod(xhit), yhit, 0.);
448 // Enable iterating in one dimension
449 if (dx == 0.) dx = 0.01;
450 if (dy == 0.) dy = 0.01;
453 = fSectorSegmentation
454 ->CreateIterator(AliMpArea(TVector2(fXhit/fgkLengthUnit, fYhit/fgkLengthUnit),
455 TVector2(dx/fgkLengthUnit, dy/fgkLengthUnit)));
457 fSectorIterator->First();
459 if (! fSectorIterator->IsDone())
460 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
463 //______________________________________________________________________________
464 void AliMUONSt12QuadrantSegmentation::NextPad()
466 // Iterate over pads - stepper
469 fSectorIterator->Next();
471 if (! fSectorIterator->IsDone())
472 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
475 //______________________________________________________________________________
476 Int_t AliMUONSt12QuadrantSegmentation::MorePads()
478 // Iterate over pads - condition
481 if (fSectorIterator->IsDone())
487 //______________________________________________________________________________
488 Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
489 Float_t x, Float_t y, Int_t* /*dummy*/)
491 // Returns the square of the distance between 1 pad
492 // labelled by its channel numbers and a coordinate
495 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
498 AliFatal("Cannot locate pad.");
500 return (pad.Position()*fgkLengthUnit - TVector2(x, y)).Mod2();
503 //______________________________________________________________________________
504 void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
505 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
507 // Number of pads read in parallel and offset to add to x
508 // (specific to LYON, but mandatory for display)
511 AliFatal( "Not yet implemented.");
515 //______________________________________________________________________________
516 void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
518 Int_t Xlist[10], Int_t Ylist[10])
520 // Get next neighbours
523 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
526 AliMpVPadIterator* iter
527 = fSectorSegmentation
528 ->CreateIterator(AliMpArea(pad.Position(),2.*pad.Dimensions()*1.1));
530 for( iter->First(); !iter->IsDone() && i<10; iter->Next()) {
531 Xlist[i] = iter->CurrentItem().GetIndices().GetFirst();
532 Ylist[i] = iter->CurrentItem().GetIndices().GetSecond();
539 //______________________________________________________________________________
540 Int_t AliMUONSt12QuadrantSegmentation::Ix()
542 // Current pad cursor during disintegration
546 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
549 //______________________________________________________________________________
550 Int_t AliMUONSt12QuadrantSegmentation::Iy()
552 // Current pad cursor during disintegration
556 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
559 //______________________________________________________________________________
560 Int_t AliMUONSt12QuadrantSegmentation::ISector()
568 //______________________________________________________________________________
569 Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
571 // Calculate sector from pad coordinates
574 return fSectorSegmentation
575 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
578 //______________________________________________________________________________
579 Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
581 // Calculate sector from pad coordinates
584 return fSectorSegmentation
585 ->Zone(fSectorSegmentation
586 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit)));
589 //______________________________________________________________________________
590 void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
591 Float_t& y1, Float_t& y2)
593 // Current integration limits
596 x1 = fXhit - fX - Dpx(fZone)/2.;
597 x2 = x1 + Dpx(fZone);
599 y1 = fYhit - fY - Dpy(fZone)/2.;
600 y2 = y1 + Dpy(fZone);
603 //______________________________________________________________________________
604 Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
606 // Signal Generation Condition during Stepping
607 // 0: don't generate signal
608 // 1: generate signal
611 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
612 // To correctly simulate the dependence of the spatial resolution on the angle
613 // of incidence signal must be generated for constant steps on
614 // the projection of the trajectory along the anode wire.
616 // Signal will be generated if particle crosses pad boundary or
617 // boundary between two wires.
619 // From AliMUONSegmentationV01
623 GetPadI(x, y, ixt, iyt);
624 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
626 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
634 //______________________________________________________________________________
635 void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
637 // Initialise signal generation at coord (x,y,z)
638 // Initialises pad and wire position during stepping.
639 // From AliMUONSegmentationV01
644 GetPadI(x, y, fIxt, fIyt);
645 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
648 //______________________________________________________________________________
649 void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
651 // Test points for auto calibration
652 // Returns test point on the pad plane.
653 // Used during determination of the segmoid correction of the COG-method
654 // From AliMUONSegmentationV01
658 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
662 //______________________________________________________________________________
663 void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
665 // Draw the segmentation zones.
666 // (Called from AliMUON::BuildGeometry)
669 AliWarning("Not yet implemented.");
672 //______________________________________________________________________________
673 void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
675 // Set the correction function.
676 // From AliMUONSegmentationV01
679 fCorrA->AddAt(func, isec);
682 //______________________________________________________________________________
683 TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
685 // Get the correction Function.
686 // From AliMUONSegmentationV01
689 return (TF1*) fCorrA->At(isec);
692 //______________________________________________________________________________
693 void AliMUONSt12QuadrantSegmentation::Streamer(TBuffer &R__b)
695 // Stream an object of class AliMUONSt12QuadrantSegmentation.
697 if (R__b.IsReading()) {
698 AliMUONSt12QuadrantSegmentation::Class()->ReadBuffer(R__b, this);
702 AliMUONSt12QuadrantSegmentation::Class()->WriteBuffer(R__b, this);