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"
38 ClassImp(AliMUONTriggerSegmentationV2)
43 // Int_t SPECIAL_SECTOR = 8;
46 Int_t CODEMAKER(1000);
48 Int_t Code(Int_t ixLA, Int_t iyLA)
50 return iyLA*CODEMAKER + ixLA;
53 void Decode(Int_t code, Int_t& ixLA, Int_t& iyLA)
55 iyLA = code/CODEMAKER;
56 ixLA = code - iyLA*CODEMAKER;
60 //_____________________________________________________________________________
61 AliMUONTriggerSegmentationV2::AliMUONTriggerSegmentationV2()
62 : AliMUONVGeometryDESegmentation(),
64 fPlaneType(kNonBendingPlane),
71 /// Default ctor (empty).
73 AliDebug(1,Form("this=%p default (empty) ctor",this));
76 //_____________________________________________________________________________
77 AliMUONTriggerSegmentationV2::AliMUONTriggerSegmentationV2(
78 AliMpVSegmentation* segmentation,
79 Int_t detElemId, AliMpPlaneType bendingOrNonBending)
80 : AliMUONVGeometryDESegmentation(),
81 fDetElemId(detElemId),
82 fPlaneType(bendingOrNonBending),
91 fSlatSegmentation = dynamic_cast<AliMpTriggerSegmentation*>(segmentation);
92 if (fSlatSegmentation)
93 fSlat = fSlatSegmentation->Slat();
95 AliFatal("Wrong mapping segmentation type");
97 TString id(fSlat->GetID());
98 Ssiz_t pos = id.Last('L');
101 AliFatal(Form("Cannot infer line number for slat %s",id.Data()));
103 fLineNumber = TString(id(pos+1),1).Atoi();
105 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
106 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
110 //_____________________________________________________________________________
111 AliMUONTriggerSegmentationV2::~AliMUONTriggerSegmentationV2()
115 AliDebug(1,Form("this=%p",this));
118 //_____________________________________________________________________________
120 AliMUONTriggerSegmentationV2::CorrFunc(Int_t) const
124 AliFatal("Not implemented");
128 //_____________________________________________________________________________
130 AliMUONTriggerSegmentationV2::Distance2AndOffset(Int_t, Int_t,
131 Float_t, Float_t, Int_t*)
135 AliFatal("Not implemented");
139 //_____________________________________________________________________________
141 AliMUONTriggerSegmentationV2::Draw(Option_t*)
145 AliFatal("Not Implemented");
148 //_____________________________________________________________________________
150 AliMUONTriggerSegmentationV2::Dpx() const
154 AliFatal("Not Implemented");
158 //_____________________________________________________________________________
160 AliMUONTriggerSegmentationV2::Dpy() const
164 AliFatal("Not Implemented");
168 //_____________________________________________________________________________
170 AliMUONTriggerSegmentationV2::Dpx(Int_t sectorCode) const
172 /// Get pad size in x
175 Decode(sectorCode,ixLA,iyLA);
176 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
177 if ( !pad.IsValid() ) return 0.0;
178 return pad.Dimensions().X()*2.0;
181 //_____________________________________________________________________________
183 AliMUONTriggerSegmentationV2::Dpy(Int_t sectorCode) const
185 /// Get pad size in y
188 Decode(sectorCode,ixLA,iyLA);
189 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
190 if ( !pad.IsValid() ) return 0.0;
191 return pad.Dimensions().Y()*2.0;
194 //_____________________________________________________________________________
196 AliMUONTriggerSegmentationV2::FirstPad(Float_t /*xhit*/, Float_t /*yhit*/, Float_t /*zhit*/,
197 Float_t /*dx*/, Float_t /*dy*/)
201 AliFatal("Not implemented");
204 //_____________________________________________________________________________
206 AliMUONTriggerSegmentationV2::GetAnod(Float_t) const
210 AliFatal("Not implemented");
214 //_____________________________________________________________________________
215 AliMUONGeometryDirection
216 AliMUONTriggerSegmentationV2::GetDirection()
220 //AliWarning("Not Implemented");
221 return kDirUndefined;
224 //______________________________________________________________________________
225 const AliMpVSegmentation*
226 AliMUONTriggerSegmentationV2::GetMpSegmentation() const
228 /// Returns the mapping segmentation
229 /// (provides access to electronics info)
231 return fSlatSegmentation;
234 //_____________________________________________________________________________
236 AliMUONTriggerSegmentationV2::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
240 AliFatal("Not Implemented");
243 //_____________________________________________________________________________
245 AliMUONTriggerSegmentationV2::GetPadC(Int_t ix, Int_t iy,
246 Float_t& x, Float_t& y, Float_t& z)
248 /// Transform from pad to real coordinates
254 //_____________________________________________________________________________
256 AliMUONTriggerSegmentationV2::GetPadC(Int_t ixGlo, Int_t iyGlo,
257 Float_t& x, Float_t& y)
259 /// Transform from pad to real coordinates
262 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
263 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
264 x = pad.Position().X();
265 y = pad.Position().Y();
268 //_____________________________________________________________________________
270 AliMUONTriggerSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t,
271 Int_t& ix, Int_t& iy)
273 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
278 //_____________________________________________________________________________
280 AliMUONTriggerSegmentationV2::GetPadI(Float_t x, Float_t y,
281 Int_t& ixGlo, Int_t& iyGlo)
283 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
285 AliDebug(2,Form("%s x=%e y=%e ixGlo,iyGlo=%d,%d\n",
286 fSlatSegmentation->GetName(),
290 fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
292 if ( pad != AliMpPad::Invalid() )
294 Int_t ix = pad.GetIndices().GetFirst();
295 Int_t iy = pad.GetIndices().GetSecond();
296 ILoc2IGlo(ix,iy,ixGlo,iyGlo);
302 AliDebug(2,Form("ixGlo,iyGlo=%d,%d\n",ixGlo,iyGlo));
305 //_____________________________________________________________________________
307 AliMUONTriggerSegmentationV2::GetPadLoc2Glo(Int_t ix, Int_t iy,
308 Int_t& ixGlo, Int_t& iyGlo) const
310 /// Converts from local (in PC convention) to (ix,iy) to global (ix,iy)
312 ixGlo=iyGlo=-1; // starts with invalid values
314 if ( fPlaneType == kBendingPlane )
316 ixGlo = 10*LineNumber() + ix;
317 iyGlo = iy - fgIntOffset;
319 else if ( fPlaneType == kNonBendingPlane )
321 Int_t i = fSlat->GetLayer(0)->FindPCBIndex(ix-fgIntOffset);
324 AliError(Form("Invalid local (ix=%d,iy=%d) ?",ix,iy));
327 AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ix-fgIntOffset);
328 iyGlo = ix - pcb->Ixmin() - fgIntOffset;
329 if ( LineNumber() == 5 ) ++i;
330 ixGlo = 10*LineNumber() + i + fgIntOffset;
334 //_____________________________________________________________________________
336 AliMUONTriggerSegmentationV2::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
337 Int_t& ix, Int_t& iy) const
339 /// Converts from global (ix,iy) to local (ix,iy) (in PC convention)
341 ix=iy=-1; // starts with invalid values
343 if ( abs(ixGlo) == 51 ) return;
345 Int_t column = ModuleColNum(ixGlo);
347 if ( fPlaneType == kBendingPlane )
349 ix = column + fgIntOffset;
350 iy = iyGlo + fgIntOffset;
352 else if ( fPlaneType == kNonBendingPlane )
354 if ( LineNumber()==5 ) --column;
355 AliMpPCB* pcb = fSlat->GetLayer(0)->GetPCB(column);
358 AliError(Form("Invalid global (ix=%d,iy=%d)",ixGlo,iyGlo));
361 ix = pcb->Ixmin() + iyGlo + fgIntOffset;
366 //_____________________________________________________________________________
368 AliMUONTriggerSegmentationV2::GiveTestPoints(Int_t& /*n*/,
369 Float_t* /*x*/, Float_t*/*y*/) const
373 AliFatal("Not Implemented");
376 //_____________________________________________________________________________
378 AliMUONTriggerSegmentationV2::HasPad(Float_t x, Float_t y, Float_t /*z*/)
380 /// Returns true if a pad exists in the given position
382 /// Well, 2 implementations are possible here
383 /// Either reuse HasPad(int,int), or get it from scratch using
384 /// underlying fSlatSegmentation.
385 /// Took second option, but w/o checking whether this is the faster.
386 /// The second option is commented out below, for the record.
389 // GetPadI(x,y,z,ix,iy);
391 // IGlo2ILoc(ix,iy,ixLA,iyLA);
393 // LA2PC(ixLA,iyLA,ixPC,iyPC);
394 // Bool_t ok1 = HasPad(ixPC,iyPC);
397 fSlatSegmentation->PadByPosition(TVector2(x,y),kFALSE);
398 return pad.IsValid();
401 //_____________________________________________________________________________
403 AliMUONTriggerSegmentationV2::HasPad(Int_t ixGlo, Int_t iyGlo)
405 /// Returns true if a pad with given indices exists
408 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
409 return fSlatSegmentation->HasPad(AliMpIntPair(ixLA,iyLA));
412 //_____________________________________________________________________________
414 AliMUONTriggerSegmentationV2::IGlo2ILoc(Int_t ixGlo, Int_t iyGlo,
415 Int_t& ixLA, Int_t& iyLA) const
417 /// \todo FIXME: add comment
420 GetPadGlo2Loc(ixGlo,iyGlo,ixPC,iyPC);
421 PC2LA(ixPC,iyPC,ixLA,iyLA);
424 //_____________________________________________________________________________
426 AliMUONTriggerSegmentationV2::ILoc2IGlo(Int_t ixLA, Int_t iyLA,
427 Int_t& ixGlo, Int_t& iyGlo) const
429 /// \todo FIXME: add comment
432 LA2PC(ixLA,iyLA,ixPC,iyPC);
433 GetPadLoc2Glo(ixPC,iyPC,ixGlo,iyGlo);
436 //_____________________________________________________________________________
438 AliMUONTriggerSegmentationV2::ISector()
440 /// \todo FIXME: remove the usage of ISector from all the code.
445 //_____________________________________________________________________________
446 void AliMUONTriggerSegmentationV2::IntegrationLimits(Float_t& x1,
451 /// \param x1 : hit x(y) position
452 /// \param x2 : x(y) coordinate of the main strip
453 /// \param x3 : current strip real x(y) coordinate
454 /// \param x4 : dist. between x(y) hit pos. and the closest border of the current strip
456 /// Note : need to return (only) x4.
458 AliFatal("Check me before usage. ResponseTrigger does not use me, while"
459 "ResponseTriggerV1 does ?");
462 fSlatSegmentation->PadByPosition(TVector2(fXhit,fYhit),kFALSE);
463 if ( !strip.IsValid() )
465 AliWarning(Form("%s got invalid fXhit,fYhit=%e,%e\n",
466 fSlatSegmentation->GetName(),fXhit,fYhit));
471 Double_t xstrip = strip.Position().X();
472 Double_t ystrip = strip.Position().Y();
473 AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
474 fXhit,fYhit,xstrip,ystrip));
475 x1 = (fPlaneType==kBendingPlane) ? fYhit : fXhit;
476 x2 = (fPlaneType==kBendingPlane) ? ystrip : xstrip;
477 x3 = (fPlaneType==kBendingPlane) ?
478 fCurrentPad.Position().Y() : fCurrentPad.Position().X();
481 if (fPlaneType==kBendingPlane)
483 xmin = x3 - fCurrentPad.Dimensions().X();
484 xmax = x3 + fCurrentPad.Dimensions().X();
488 xmin = x3 - fCurrentPad.Dimensions().Y();
489 xmax = x3 + fCurrentPad.Dimensions().Y();
491 // dist. between the hit and the closest border of the current strip
492 x4 = (TMath::Abs(xmax-x1) > TMath::Abs(xmin-x1)) ?
493 TMath::Abs(xmin-x1):TMath::Abs(xmax-x1);
495 AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
496 fPlaneType,x1,x2,x3,x4,xmin,xmax));
501 //_____________________________________________________________________________
503 AliMUONTriggerSegmentationV2::Ix()
505 /// Current pad cursor during disintegration
508 if ( fCurrentPad.IsValid() )
511 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
512 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
518 //_____________________________________________________________________________
520 AliMUONTriggerSegmentationV2::Iy()
522 /// Current pad cursor during disintegration
525 if ( fCurrentPad.IsValid() )
528 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
529 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
536 //_____________________________________________________________________________
538 AliMUONTriggerSegmentationV2::LA2PC(Int_t ixLA, Int_t iyLA,
539 Int_t& ixPC, Int_t& iyPC) const
541 /// From LA to PC conventions for integers indices.
545 if ( ixLA<0 || iyLA<0 ) return;
550 if ( fPlaneType == kBendingPlane )
552 if ( LineNumber()==5 )
556 if ( LineNumber()==4 && ixLA==0 )
562 AliDebug(3,Form("ix,iy LA (%d,%d) -> PC (%d,%d)",ixLA,iyLA,ixPC,iyPC));
566 //_____________________________________________________________________________
568 AliMUONTriggerSegmentationV2::LineNumber() const
570 /// \todo FIXME: add comment
572 return 10-fLineNumber;
575 //_____________________________________________________________________________
577 AliMUONTriggerSegmentationV2::ModuleColNum(Int_t ixGlo) const
579 /// returns column number (from 0 to 6) in which the (global) module
580 /// ix is sitting (could return 7 if ix=isec)
582 return TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10-1;
585 //_____________________________________________________________________________
587 AliMUONTriggerSegmentationV2::MorePads()
591 AliFatal("Not implemented");
595 //_____________________________________________________________________________
596 void AliMUONTriggerSegmentationV2::Neighbours(Int_t /*iX*/, Int_t /*iY*/,
603 //-----------------BENDING-----------------------------------------
604 // Returns list of 10 next neighbours for given X strip (ix, iy)
605 // neighbour number 4 in the list -
606 // neighbour number 3 in the list |
607 // neighbour number 2 in the list |_ Upper part
608 // neighbour number 1 in the list |
609 // neighbour number 0 in the list -
611 // neighbour number 5 in the list -
612 // neighbour number 6 in the list | _ Lower part
613 // neighbour number 7 in the list |
614 // neighbour number 8 in the list |
615 // neighbour number 9 in the list -
617 //-----------------NON-BENDING-------------------------------------
618 // Returns list of 10 next neighbours for given Y strip (ix, iy)
619 // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
620 // \_______/ \_______/
622 AliFatal("Please implement me");
625 //_____________________________________________________________________________
627 AliMUONTriggerSegmentationV2::NextPad()
631 AliFatal("Not implemented");
634 //_____________________________________________________________________________
636 AliMUONTriggerSegmentationV2::Npx() const
638 /// Maximum number of Pads in x
639 /// hard coded for the time being
641 return 124;// FIXME: this should not have to be done, if only we'd stick
642 // to a local (ix,iy) convention !!!
643 // return fSlatSegmentation->MaxPadIndexX()+1;
646 //_____________________________________________________________________________
648 AliMUONTriggerSegmentationV2::Npy() const
650 /// Maximum number of Pads in y
651 /// hard coded for the time being
654 // return fSlatSegmentation->MaxPadIndexY()+1;
657 //_____________________________________________________________________________
659 AliMUONTriggerSegmentationV2::PC2LA(Int_t ixPC, Int_t iyPC,
660 Int_t& ixLA, Int_t& iyLA) const
662 /// From PC to LA conventions for integers indices.
666 if ( ixPC<0 || iyPC<0 ) return;
671 if ( fPlaneType == kBendingPlane )
673 if ( LineNumber()==5 )
677 if ( LineNumber()==4 && ixLA==0 )
683 AliDebug(3,Form("ix,iy PC (%d,%d) -> LA (%d,%d)",ixPC,iyPC,ixLA,iyLA));
686 //_____________________________________________________________________________
688 AliMUONTriggerSegmentationV2::Print(Option_t* opt) const
694 cout << "DetElemId=" << fDetElemId << " PlaneType="
695 << fPlaneType << " Npx=" << Npx() << " Npy=" << Npy() << endl;
696 if ( ( sopt.Contains("SEG") || sopt.Contains("ALL") ) && fSlatSegmentation )
698 fSlatSegmentation->Print();
700 if ( sopt.Contains("ALL") && fSlat )
706 //_____________________________________________________________________________
708 AliMUONTriggerSegmentationV2::Sector(Int_t ix, Int_t iy)
710 /// Calculate sector from pad coordinates
713 IGlo2ILoc(ix,iy,ixLA,iyLA);
714 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
715 if ( !pad.IsValid() ) return -1;
716 return Code(ixLA,iyLA);
718 // AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ixLA);
721 // AliError(Form("Could not find a pcb at (%d,%d) for slat %s",
722 // ix,iy,fSlat->GetName()));
725 // if ( pcb->PadSizeX()==-1.0 )
727 // // special case of column 7 non-bending.
728 // return SPECIAL_SECTOR;
730 // return fSlat->GetLayer(0)->FindPCBIndex(ixLA);
733 //_____________________________________________________________________________
735 AliMUONTriggerSegmentationV2::Sector(Float_t, Float_t)
739 AliFatal("Not implemented");
743 //_____________________________________________________________________________
745 AliMUONTriggerSegmentationV2::SetCorrFunc(Int_t,TF1*)
749 AliFatal("Not Implemented");
752 //_____________________________________________________________________________
754 AliMUONTriggerSegmentationV2::SetDAnod(Float_t)
758 AliFatal("Not Implemented");
761 //_____________________________________________________________________________
763 AliMUONTriggerSegmentationV2::SetHit(Float_t x, Float_t y)
766 /// Sets virtual hit position, needed for evaluating pad response
767 /// outside the tracking program
773 // insure we're within the slat limits. If not, issue an error and sets
774 // the current hit to slat center.
775 // FIXME: this should probably a) not happen at all b) be a fatal error
777 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
778 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
780 AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
781 " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
788 //_____________________________________________________________________________
790 AliMUONTriggerSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
793 /// Sets virtual hit position, needed for evaluating pad response
794 /// outside the tracking program
799 //_____________________________________________________________________________
801 AliMUONTriggerSegmentationV2::SetPad(Int_t ix, Int_t iy)
803 /// Set pad position.
804 /// Sets virtual pad coordinates, needed for evaluating pad response
805 /// outside the tracking program.
808 IGlo2ILoc(ix,iy,ixLA,iyLA);
809 fCurrentPad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
810 if ( !fCurrentPad.IsValid() )
812 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
816 //_____________________________________________________________________________
818 AliMUONTriggerSegmentationV2::SetPadSize(Float_t,Float_t)
822 AliFatal("Not Implemented");
825 //_____________________________________________________________________________
827 AliMUONTriggerSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
831 AliFatal("Not Implemented");
835 //_____________________________________________________________________________
837 AliMUONTriggerSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
841 AliFatal("Not Implemented");