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 // -------------------------------------
19 // Class AliMUONTriggerSegmentation
20 // -------------------------------------
21 // Segmentation for MUON trigger stations using
22 // the mapping package
24 #include "AliMUONTriggerSegmentationV2.h"
27 #include "AliMpTrigger.h"
28 #include "AliMpTriggerSegmentation.h"
29 #include "AliMpSlat.h"
33 #include "Riostream.h"
37 ClassImp(AliMUONTriggerSegmentationV2)
41 // Int_t SPECIAL_SECTOR = 8;
44 Int_t CODEMAKER(1000);
46 Int_t Code(Int_t ixLA, Int_t iyLA)
48 return iyLA*CODEMAKER + ixLA;
51 void Decode(Int_t code, Int_t& ixLA, Int_t& iyLA)
53 iyLA = code/CODEMAKER;
54 ixLA = code - iyLA*CODEMAKER;
58 //_____________________________________________________________________________
59 AliMUONTriggerSegmentationV2::AliMUONTriggerSegmentationV2()
60 : AliMUONVGeometryDESegmentation(),
62 fPlaneType(kNonBendingPlane),
70 // Default ctor (empty).
72 AliDebug(1,Form("this=%p default (empty) ctor",this));
75 //_____________________________________________________________________________
76 AliMUONTriggerSegmentationV2::AliMUONTriggerSegmentationV2(
77 AliMpVSegmentation* segmentation,
78 Int_t detElemId, AliMpPlaneType bendingOrNonBending)
79 : AliMUONVGeometryDESegmentation(),
80 fDetElemId(detElemId),
81 fPlaneType(bendingOrNonBending),
92 fSlatSegmentation = dynamic_cast<AliMpTriggerSegmentation*>(segmentation);
93 if (fSlatSegmentation)
94 fSlat = fSlatSegmentation->Slat();
96 AliFatal("Wrong mapping segmentation type");
98 TString id(fSlat->GetID());
99 Ssiz_t pos = id.Last('L');
102 AliFatal(Form("Cannot infer line number for slat %s",id.Data()));
104 fLineNumber = TString(id(pos+1),1).Atoi();
106 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
107 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
111 //_____________________________________________________________________________
112 AliMUONTriggerSegmentationV2::AliMUONTriggerSegmentationV2(const AliMUONTriggerSegmentationV2& rhs) : AliMUONVGeometryDESegmentation(rhs)
115 AliFatal("Not implemented.");
118 //_____________________________________________________________________________
119 AliMUONTriggerSegmentationV2::~AliMUONTriggerSegmentationV2()
122 AliDebug(1,Form("this=%p",this));
125 //_____________________________________________________________________________
126 AliMUONTriggerSegmentationV2& AliMUONTriggerSegmentationV2::operator=(const AliMUONTriggerSegmentationV2& rhs)
128 // Protected assignement operator
129 if (this == &rhs) return *this;
130 AliFatal("Not implemented.");
134 //_____________________________________________________________________________
136 AliMUONTriggerSegmentationV2::CorrFunc(Int_t) const
140 AliFatal("Not implemented");
144 //_____________________________________________________________________________
146 AliMUONTriggerSegmentationV2::Distance2AndOffset(Int_t, Int_t,
147 Float_t, Float_t, Int_t*)
151 AliFatal("Not implemented");
155 //_____________________________________________________________________________
157 AliMUONTriggerSegmentationV2::Draw(Option_t*)
161 AliFatal("Not Implemented");
164 //_____________________________________________________________________________
166 AliMUONTriggerSegmentationV2::Dpx() const
170 AliFatal("Not Implemented");
174 //_____________________________________________________________________________
176 AliMUONTriggerSegmentationV2::Dpy() const
180 AliFatal("Not Implemented");
184 //_____________________________________________________________________________
186 AliMUONTriggerSegmentationV2::Dpx(int sectorCode) const
191 Decode(sectorCode,ixLA,iyLA);
192 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
193 if ( !pad.IsValid() ) return 0.0;
194 return pad.Dimensions().X()*2.0;
197 //_____________________________________________________________________________
199 AliMUONTriggerSegmentationV2::Dpy(int sectorCode) const
204 Decode(sectorCode,ixLA,iyLA);
205 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
206 if ( !pad.IsValid() ) return 0.0;
207 return pad.Dimensions().Y()*2.0;
210 //_____________________________________________________________________________
212 AliMUONTriggerSegmentationV2::FirstPad(Float_t /*xhit*/, Float_t /*yhit*/, Float_t /*zhit*/,
213 Float_t /*dx*/, Float_t /*dy*/)
217 AliFatal("Not implemented");
220 //_____________________________________________________________________________
222 AliMUONTriggerSegmentationV2::GetAnod(Float_t) const
226 AliFatal("Not implemented");
230 //_____________________________________________________________________________
231 AliMUONGeometryDirection
232 AliMUONTriggerSegmentationV2::GetDirection()
236 //AliWarning("Not Implemented");
237 return kDirUndefined;
240 //______________________________________________________________________________
241 const AliMpVSegmentation*
242 AliMUONTriggerSegmentationV2::GetMpSegmentation() const
244 // Returns the mapping segmentation
245 // (provides access to electronics info)
247 return fSlatSegmentation;
250 //_____________________________________________________________________________
252 AliMUONTriggerSegmentationV2::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
256 AliFatal("Not Implemented");
259 //_____________________________________________________________________________
261 AliMUONTriggerSegmentationV2::GetPadC(Int_t ix, Int_t iy,
262 Float_t& x, Float_t& y, Float_t& z)
264 // Transform from pad to real coordinates
270 //_____________________________________________________________________________
272 AliMUONTriggerSegmentationV2::GetPadC(Int_t ixGlo, Int_t iyGlo,
273 Float_t& x, Float_t& y)
275 // Transform from pad to real coordinates
278 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
279 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
280 x = pad.Position().X();
281 y = pad.Position().Y();
284 //_____________________________________________________________________________
286 AliMUONTriggerSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t,
287 Int_t& ix, Int_t& iy)
289 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
294 //_____________________________________________________________________________
296 AliMUONTriggerSegmentationV2::GetPadI(Float_t x, Float_t y,
297 Int_t& ixGlo, Int_t& iyGlo)
299 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
301 AliDebug(2,Form("%s x=%e y=%e ixGlo,iyGlo=%d,%d\n",
302 fSlatSegmentation->GetName(),
306 fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
308 if ( pad != AliMpPad::Invalid() )
310 Int_t ix = pad.GetIndices().GetFirst();
311 Int_t iy = pad.GetIndices().GetSecond();
312 ILoc2IGlo(ix,iy,ixGlo,iyGlo);
318 AliDebug(2,Form("ixGlo,iyGlo=%d,%d\n",ixGlo,iyGlo));
321 //_____________________________________________________________________________
323 AliMUONTriggerSegmentationV2::GetPadLoc2Glo(Int_t ix, Int_t iy,
324 Int_t& ixGlo, Int_t& iyGlo) const
327 // Converts from local (in PC convention) to (ix,iy) to global (ix,iy)
330 ixGlo=iyGlo=-1; // starts with invalid values
332 if ( fPlaneType == kBendingPlane )
334 ixGlo = 10*LineNumber() + ix;
335 iyGlo = iy - fgIntOffset;
337 else if ( fPlaneType == kNonBendingPlane )
339 Int_t i = fSlat->GetLayer(0)->FindPCBIndex(ix-fgIntOffset);
342 AliError(Form("Invalid local (ix=%d,iy=%d) ?",ix,iy));
345 AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ix-fgIntOffset);
346 iyGlo = ix - pcb->Ixmin() - fgIntOffset;
347 if ( LineNumber() == 5 ) ++i;
348 ixGlo = 10*LineNumber() + i + fgIntOffset;
352 //_____________________________________________________________________________
354 AliMUONTriggerSegmentationV2::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
355 Int_t& ix, Int_t& iy) const
358 // Converts from global (ix,iy) to local (ix,iy) (in PC convention)
361 ix=iy=-1; // starts with invalid values
363 if ( abs(ixGlo) == 51 ) return;
365 Int_t column = ModuleColNum(ixGlo);
367 if ( fPlaneType == kBendingPlane )
369 ix = column + fgIntOffset;
370 iy = iyGlo + fgIntOffset;
372 else if ( fPlaneType == kNonBendingPlane )
374 if ( LineNumber()==5 ) --column;
375 AliMpPCB* pcb = fSlat->GetLayer(0)->GetPCB(column);
378 AliError(Form("Invalid global (ix=%d,iy=%d)",ixGlo,iyGlo));
381 ix = pcb->Ixmin() + iyGlo + fgIntOffset;
386 //_____________________________________________________________________________
388 AliMUONTriggerSegmentationV2::GiveTestPoints(Int_t& /*n*/,
389 Float_t* /*x*/, Float_t*/*y*/) const
393 AliFatal("Not Implemented");
396 //_____________________________________________________________________________
398 AliMUONTriggerSegmentationV2::HasPad(Float_t x, Float_t y, Float_t /*z*/)
400 // Returns true if a pad exists in the given position
403 // Well, 2 implementations are possible here
404 // Either reuse HasPad(int,int), or get it from scratch using
405 // underlying fSlatSegmentation.
406 // Took second option, but w/o checking whether this is the faster.
407 // The second option is commented out below, for the record.
410 // GetPadI(x,y,z,ix,iy);
412 // IGlo2ILoc(ix,iy,ixLA,iyLA);
414 // LA2PC(ixLA,iyLA,ixPC,iyPC);
415 // Bool_t ok1 = HasPad(ixPC,iyPC);
418 fSlatSegmentation->PadByPosition(TVector2(x,y),kFALSE);
419 return pad.IsValid();
422 //_____________________________________________________________________________
424 AliMUONTriggerSegmentationV2::HasPad(Int_t ixGlo, Int_t iyGlo)
426 // Returns true if a pad with given indices exists
429 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
430 return fSlatSegmentation->HasPad(AliMpIntPair(ixLA,iyLA));
433 //_____________________________________________________________________________
435 AliMUONTriggerSegmentationV2::IGlo2ILoc(Int_t ixGlo, Int_t iyGlo,
436 Int_t& ixLA, Int_t& iyLA) const
438 // FIXME: add comment
441 GetPadGlo2Loc(ixGlo,iyGlo,ixPC,iyPC);
442 PC2LA(ixPC,iyPC,ixLA,iyLA);
445 //_____________________________________________________________________________
447 AliMUONTriggerSegmentationV2::ILoc2IGlo(Int_t ixLA, Int_t iyLA,
448 Int_t& ixGlo, Int_t& iyGlo) const
450 // FIXME: add comment
453 LA2PC(ixLA,iyLA,ixPC,iyPC);
454 GetPadLoc2Glo(ixPC,iyPC,ixGlo,iyGlo);
457 //_____________________________________________________________________________
459 AliMUONTriggerSegmentationV2::ISector()
461 // FIXME: remove the usage of ISector from all the code.
465 //_____________________________________________________________________________
466 void AliMUONTriggerSegmentationV2::IntegrationLimits(Float_t& x1,
471 // x1 : hit x(y) position
472 // x2 : x(y) coordinate of the main strip
473 // x3 : current strip real x(y) coordinate
474 // x4 : dist. between x(y) hit pos. and the closest border of the current strip
476 // Note : need to return (only) x4.
478 AliFatal("Check me before usage. ResponseTrigger does not use me, while"
479 "ResponseTriggerV1 does ?");
482 fSlatSegmentation->PadByPosition(TVector2(fXhit,fYhit),kFALSE);
483 if ( !strip.IsValid() )
485 AliWarning(Form("%s got invalid fXhit,fYhit=%e,%e\n",
486 fSlatSegmentation->GetName(),fXhit,fYhit));
491 Double_t xstrip = strip.Position().X();
492 Double_t ystrip = strip.Position().Y();
493 AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
494 fXhit,fYhit,xstrip,ystrip));
495 x1 = (fPlaneType==kBendingPlane) ? fYhit : fXhit;
496 x2 = (fPlaneType==kBendingPlane) ? ystrip : xstrip;
497 x3 = (fPlaneType==kBendingPlane) ?
498 fCurrentPad.Position().Y() : fCurrentPad.Position().X();
501 if (fPlaneType==kBendingPlane)
503 xmin = x3 - fCurrentPad.Dimensions().X();
504 xmax = x3 + fCurrentPad.Dimensions().X();
508 xmin = x3 - fCurrentPad.Dimensions().Y();
509 xmax = x3 + fCurrentPad.Dimensions().Y();
511 // dist. between the hit and the closest border of the current strip
512 x4 = (TMath::Abs(xmax-x1) > TMath::Abs(xmin-x1)) ?
513 TMath::Abs(xmin-x1):TMath::Abs(xmax-x1);
515 AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
516 fPlaneType,x1,x2,x3,x4,xmin,xmax));
521 //_____________________________________________________________________________
523 AliMUONTriggerSegmentationV2::Ix()
525 // Current pad cursor during disintegration
528 if ( fCurrentPad.IsValid() )
531 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
532 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
538 //_____________________________________________________________________________
540 AliMUONTriggerSegmentationV2::Iy()
542 // Current pad cursor during disintegration
545 if ( fCurrentPad.IsValid() )
548 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
549 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
556 //_____________________________________________________________________________
558 AliMUONTriggerSegmentationV2::LA2PC(Int_t ixLA, Int_t iyLA,
559 Int_t& ixPC, Int_t& iyPC) const
562 // From LA to PC conventions for integers indices.
566 if ( ixLA<0 || iyLA<0 ) return;
571 if ( fPlaneType == kBendingPlane )
573 if ( LineNumber()==5 )
577 if ( LineNumber()==4 && ixLA==0 )
583 AliDebug(3,Form("ix,iy LA (%d,%d) -> PC (%d,%d)",ixLA,iyLA,ixPC,iyPC));
587 //_____________________________________________________________________________
589 AliMUONTriggerSegmentationV2::LineNumber() const
591 // FIXME: add comment
593 return 10-fLineNumber;
596 //_____________________________________________________________________________
598 AliMUONTriggerSegmentationV2::ModuleColNum(Int_t ixGlo) const
600 // returns column number (from 0 to 6) in which the (global) module
601 // ix is sitting (could return 7 if ix=isec)
602 return TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10-1;
605 //_____________________________________________________________________________
607 AliMUONTriggerSegmentationV2::MorePads()
611 AliFatal("Not implemented");
615 //_____________________________________________________________________________
616 void AliMUONTriggerSegmentationV2::Neighbours(Int_t /*iX*/, Int_t /*iY*/,
621 //-----------------BENDING-----------------------------------------
622 // Returns list of 10 next neighbours for given X strip (ix, iy)
623 // neighbour number 4 in the list -
624 // neighbour number 3 in the list |
625 // neighbour number 2 in the list |_ Upper part
626 // neighbour number 1 in the list |
627 // neighbour number 0 in the list -
629 // neighbour number 5 in the list -
630 // neighbour number 6 in the list | _ Lower part
631 // neighbour number 7 in the list |
632 // neighbour number 8 in the list |
633 // neighbour number 9 in the list -
635 //-----------------NON-BENDING-------------------------------------
636 // Returns list of 10 next neighbours for given Y strip (ix, iy)
637 // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
638 // \_______/ \_______/
640 AliFatal("Please implement me");
643 //_____________________________________________________________________________
645 AliMUONTriggerSegmentationV2::NextPad()
649 AliFatal("Not implemented");
652 //_____________________________________________________________________________
654 AliMUONTriggerSegmentationV2::Npx() const
656 // Maximum number of Pads in x
657 // hard coded for the time being
659 return 124;// FIXME: this should not have to be done, if only we'd stick
660 // to a local (ix,iy) convention !!!
661 // return fSlatSegmentation->MaxPadIndexX()+1;
664 //_____________________________________________________________________________
666 AliMUONTriggerSegmentationV2::Npy() const
668 // Maximum number of Pads in y
669 // hard coded for the time being
672 // return fSlatSegmentation->MaxPadIndexY()+1;
675 //_____________________________________________________________________________
677 AliMUONTriggerSegmentationV2::PC2LA(Int_t ixPC, Int_t iyPC,
678 Int_t& ixLA, Int_t& iyLA) const
681 // From PC to LA conventions for integers indices.
685 if ( ixPC<0 || iyPC<0 ) return;
690 if ( fPlaneType == kBendingPlane )
692 if ( LineNumber()==5 )
696 if ( LineNumber()==4 && ixLA==0 )
702 AliDebug(3,Form("ix,iy PC (%d,%d) -> LA (%d,%d)",ixPC,iyPC,ixLA,iyLA));
705 //_____________________________________________________________________________
707 AliMUONTriggerSegmentationV2::Print(Option_t* opt) const
713 cout << "DetElemId=" << fDetElemId << " PlaneType="
714 << fPlaneType << " Npx=" << Npx() << " Npy=" << Npy() << endl;
715 if ( ( sopt.Contains("SEG") || sopt.Contains("ALL") ) && fSlatSegmentation )
717 fSlatSegmentation->Print();
719 if ( sopt.Contains("ALL") && fSlat )
725 //_____________________________________________________________________________
727 AliMUONTriggerSegmentationV2::Sector(Int_t ix, Int_t iy)
729 // Calculate sector from pad coordinates
732 IGlo2ILoc(ix,iy,ixLA,iyLA);
733 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
734 if ( !pad.IsValid() ) return -1;
735 return Code(ixLA,iyLA);
737 // AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ixLA);
740 // AliError(Form("Could not find a pcb at (%d,%d) for slat %s",
741 // ix,iy,fSlat->GetName()));
744 // if ( pcb->PadSizeX()==-1.0 )
746 // // special case of column 7 non-bending.
747 // return SPECIAL_SECTOR;
749 // return fSlat->GetLayer(0)->FindPCBIndex(ixLA);
752 //_____________________________________________________________________________
754 AliMUONTriggerSegmentationV2::Sector(Float_t, Float_t)
758 AliFatal("Not implemented");
762 //_____________________________________________________________________________
764 AliMUONTriggerSegmentationV2::SetCorrFunc(Int_t,TF1*)
768 AliFatal("Not Implemented");
771 //_____________________________________________________________________________
773 AliMUONTriggerSegmentationV2::SetDAnod(float)
777 AliFatal("Not Implemented");
780 //_____________________________________________________________________________
782 AliMUONTriggerSegmentationV2::SetHit(Float_t x, Float_t y)
785 // Sets virtual hit position, needed for evaluating pad response
786 // outside the tracking program
792 // insure we're within the slat limits. If not, issue an error and sets
793 // the current hit to slat center.
794 // FIXME: this should probably a) not happen at all b) be a fatal error
796 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
797 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
799 AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
800 " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
807 //_____________________________________________________________________________
809 AliMUONTriggerSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
812 // Sets virtual hit position, needed for evaluating pad response
813 // outside the tracking program
818 //_____________________________________________________________________________
820 AliMUONTriggerSegmentationV2::SetPad(Int_t ix, Int_t iy)
823 // Sets virtual pad coordinates, needed for evaluating pad response
824 // outside the tracking program.
827 IGlo2ILoc(ix,iy,ixLA,iyLA);
828 fCurrentPad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
829 if ( !fCurrentPad.IsValid() )
831 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
835 //_____________________________________________________________________________
837 AliMUONTriggerSegmentationV2::SetPadSize(float,float)
841 AliFatal("Not Implemented");
844 //_____________________________________________________________________________
846 AliMUONTriggerSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
850 AliFatal("Not Implemented");
854 //_____________________________________________________________________________
856 AliMUONTriggerSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
860 AliFatal("Not Implemented");