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 #include "AliMUONTriggerSegmentationV2.h"
21 #include "AliMpTrigger.h"
22 #include "AliMpTriggerSegmentation.h"
23 #include "AliMpSlat.h"
27 #include "Riostream.h"
31 ClassImp(AliMUONTriggerSegmentationV2)
35 // Int_t SPECIAL_SECTOR = 8;
38 Int_t CODEMAKER(1000);
40 Int_t Code(Int_t ixLA, Int_t iyLA)
42 return iyLA*CODEMAKER + ixLA;
45 void Decode(Int_t code, Int_t& ixLA, Int_t& iyLA)
47 iyLA = code/CODEMAKER;
48 ixLA = code - iyLA*CODEMAKER;
52 //_____________________________________________________________________________
53 AliMUONTriggerSegmentationV2::AliMUONTriggerSegmentationV2()
54 : AliMUONVGeometryDESegmentation(),
56 fPlaneType(kNonBendingPlane),
64 // Default ctor (empty).
66 AliDebug(1,Form("this=%p default (empty) ctor",this));
69 //_____________________________________________________________________________
70 AliMUONTriggerSegmentationV2::AliMUONTriggerSegmentationV2(
71 AliMpVSegmentation* segmentation,
72 Int_t detElemId, AliMpPlaneType bendingOrNonBending)
73 : AliMUONVGeometryDESegmentation(),
74 fDetElemId(detElemId),
75 fPlaneType(bendingOrNonBending),
86 fSlatSegmentation = dynamic_cast<AliMpTriggerSegmentation*>(segmentation);
87 if (fSlatSegmentation)
88 fSlat = fSlatSegmentation->Slat();
90 AliFatal("Wrong mapping segmentation type");
92 TString id(fSlat->GetID());
93 Ssiz_t pos = id.Last('L');
96 AliFatal(Form("Cannot infer line number for slat %s",id.Data()));
98 fLineNumber = TString(id(pos+1),1).Atoi();
100 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
101 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
105 //_____________________________________________________________________________
106 AliMUONTriggerSegmentationV2::AliMUONTriggerSegmentationV2(const AliMUONTriggerSegmentationV2& rhs) : AliMUONVGeometryDESegmentation(rhs)
108 AliFatal("Not implemented.");
111 //_____________________________________________________________________________
112 AliMUONTriggerSegmentationV2::~AliMUONTriggerSegmentationV2()
114 AliDebug(1,Form("this=%p",this));
118 //_____________________________________________________________________________
119 AliMUONTriggerSegmentationV2& AliMUONTriggerSegmentationV2::operator=(const AliMUONTriggerSegmentationV2& rhs)
121 // Protected assignement operator
122 if (this == &rhs) return *this;
123 AliFatal("Not implemented.");
127 //_____________________________________________________________________________
129 AliMUONTriggerSegmentationV2::CorrFunc(Int_t) const
131 AliFatal("Not implemented");
135 //_____________________________________________________________________________
137 AliMUONTriggerSegmentationV2::Distance2AndOffset(Int_t, Int_t,
138 Float_t, Float_t, Int_t*)
140 AliFatal("Not implemented");
144 //_____________________________________________________________________________
146 AliMUONTriggerSegmentationV2::Draw(Option_t*)
148 AliFatal("Not Implemented");
151 //_____________________________________________________________________________
153 AliMUONTriggerSegmentationV2::Dpx() const
155 AliFatal("Not Implemented");
159 //_____________________________________________________________________________
161 AliMUONTriggerSegmentationV2::Dpy() const
163 AliFatal("Not Implemented");
167 //_____________________________________________________________________________
169 AliMUONTriggerSegmentationV2::Dpx(int sectorCode) const
172 Decode(sectorCode,ixLA,iyLA);
173 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
174 if ( !pad.IsValid() ) return 0.0;
175 return pad.Dimensions().X()*2.0;
178 //_____________________________________________________________________________
180 AliMUONTriggerSegmentationV2::Dpy(int sectorCode) const
183 Decode(sectorCode,ixLA,iyLA);
184 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
185 if ( !pad.IsValid() ) return 0.0;
186 return pad.Dimensions().Y()*2.0;
189 //_____________________________________________________________________________
191 AliMUONTriggerSegmentationV2::FirstPad(Float_t /*xhit*/, Float_t /*yhit*/,
193 Float_t /*dx*/, Float_t /*dy*/)
195 AliFatal("Not implemented");
198 //_____________________________________________________________________________
200 AliMUONTriggerSegmentationV2::GetAnod(Float_t) const
202 AliFatal("Not implemented");
206 //_____________________________________________________________________________
207 AliMUONGeometryDirection
208 AliMUONTriggerSegmentationV2::GetDirection()
210 //AliWarning("Not Implemented");
211 return kDirUndefined;
214 //______________________________________________________________________________
215 const AliMpVSegmentation*
216 AliMUONTriggerSegmentationV2::GetMpSegmentation() const
218 // Returns the mapping segmentation
219 // (provides access to electronics info)
221 return fSlatSegmentation;
224 //_____________________________________________________________________________
226 AliMUONTriggerSegmentationV2::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
228 AliFatal("Not Implemented");
231 //_____________________________________________________________________________
233 AliMUONTriggerSegmentationV2::GetPadC(Int_t ix, Int_t iy,
234 Float_t& x, Float_t& y, Float_t& z)
240 //_____________________________________________________________________________
242 AliMUONTriggerSegmentationV2::GetPadC(Int_t ixGlo, Int_t iyGlo,
243 Float_t& x, Float_t& y)
246 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
247 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
248 x = pad.Position().X();
249 y = pad.Position().Y();
252 //_____________________________________________________________________________
254 AliMUONTriggerSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t,
255 Int_t& ix, Int_t& iy)
260 //_____________________________________________________________________________
262 AliMUONTriggerSegmentationV2::GetPadI(Float_t x, Float_t y,
263 Int_t& ixGlo, Int_t& iyGlo)
265 AliDebug(2,Form("%s x=%e y=%e ixGlo,iyGlo=%d,%d\n",
266 fSlatSegmentation->GetName(),
270 fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
272 if ( pad != AliMpPad::Invalid() )
274 Int_t ix = pad.GetIndices().GetFirst();
275 Int_t iy = pad.GetIndices().GetSecond();
276 ILoc2IGlo(ix,iy,ixGlo,iyGlo);
282 AliDebug(2,Form("ixGlo,iyGlo=%d,%d\n",ixGlo,iyGlo));
285 //_____________________________________________________________________________
287 AliMUONTriggerSegmentationV2::GetPadLoc2Glo(Int_t ix, Int_t iy,
288 Int_t& ixGlo, Int_t& iyGlo) const
291 // Converts from local (in PC convention) to (ix,iy) to global (ix,iy)
294 ixGlo=iyGlo=-1; // starts with invalid values
296 if ( fPlaneType == kBendingPlane )
298 ixGlo = 10*LineNumber() + ix;
299 iyGlo = iy - fgIntOffset;
301 else if ( fPlaneType == kNonBendingPlane )
303 Int_t i = fSlat->GetLayer(0)->FindPCBIndex(ix-fgIntOffset);
306 AliError(Form("Invalid local (ix=%d,iy=%d) ?",ix,iy));
309 AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ix-fgIntOffset);
310 iyGlo = ix - pcb->Ixmin() - fgIntOffset;
311 if ( LineNumber() == 5 ) ++i;
312 ixGlo = 10*LineNumber() + i + fgIntOffset;
316 //_____________________________________________________________________________
318 AliMUONTriggerSegmentationV2::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
319 Int_t& ix, Int_t& iy) const
322 // Converts from global (ix,iy) to local (ix,iy) (in PC convention)
325 ix=iy=-1; // starts with invalid values
327 if ( abs(ixGlo) == 51 ) return;
329 Int_t column = ModuleColNum(ixGlo);
331 if ( fPlaneType == kBendingPlane )
333 ix = column + fgIntOffset;
334 iy = iyGlo + fgIntOffset;
336 else if ( fPlaneType == kNonBendingPlane )
338 if ( LineNumber()==5 ) --column;
339 AliMpPCB* pcb = fSlat->GetLayer(0)->GetPCB(column);
342 AliError(Form("Invalid global (ix=%d,iy=%d)",ixGlo,iyGlo));
345 ix = pcb->Ixmin() + iyGlo + fgIntOffset;
350 //_____________________________________________________________________________
352 AliMUONTriggerSegmentationV2::GiveTestPoints(Int_t&,Float_t*,Float_t*) const
354 AliFatal("Not Implemented");
357 //_____________________________________________________________________________
359 AliMUONTriggerSegmentationV2::HasPad(Float_t x, Float_t y, Float_t)
362 // Well, 2 implementations are possible here
363 // Either reuse HasPad(int,int), or get it from scratch using
364 // underlying fSlatSegmentation.
365 // Took second option, but w/o checking whether this is the faster.
366 // The second option is commented out below, for the record.
369 // GetPadI(x,y,z,ix,iy);
371 // IGlo2ILoc(ix,iy,ixLA,iyLA);
373 // LA2PC(ixLA,iyLA,ixPC,iyPC);
374 // Bool_t ok1 = HasPad(ixPC,iyPC);
377 fSlatSegmentation->PadByPosition(TVector2(x,y),kFALSE);
378 return pad.IsValid();
381 //_____________________________________________________________________________
383 AliMUONTriggerSegmentationV2::HasPad(Int_t ixGlo, Int_t iyGlo)
386 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
387 return fSlatSegmentation->HasPad(AliMpIntPair(ixLA,iyLA));
390 //_____________________________________________________________________________
392 AliMUONTriggerSegmentationV2::IGlo2ILoc(Int_t ixGlo, Int_t iyGlo,
393 Int_t& ixLA, Int_t& iyLA) const
396 GetPadGlo2Loc(ixGlo,iyGlo,ixPC,iyPC);
397 PC2LA(ixPC,iyPC,ixLA,iyLA);
400 //_____________________________________________________________________________
402 AliMUONTriggerSegmentationV2::ILoc2IGlo(Int_t ixLA, Int_t iyLA,
403 Int_t& ixGlo, Int_t& iyGlo) const
406 LA2PC(ixLA,iyLA,ixPC,iyPC);
407 GetPadLoc2Glo(ixPC,iyPC,ixGlo,iyGlo);
410 //_____________________________________________________________________________
412 AliMUONTriggerSegmentationV2::Init(int)
414 AliWarning("Not Implemented because not needed ;-)");
417 //_____________________________________________________________________________
419 AliMUONTriggerSegmentationV2::ISector()
421 // FIXME: remove the usage of ISector from all the code.
425 //_____________________________________________________________________________
426 void AliMUONTriggerSegmentationV2::IntegrationLimits(Float_t& x1,
431 // x1 : hit x(y) position
432 // x2 : x(y) coordinate of the main strip
433 // x3 : current strip real x(y) coordinate
434 // x4 : dist. between x(y) hit pos. and the closest border of the current strip
436 // Note : need to return (only) x4.
438 AliFatal("Check me before usage. ResponseTrigger does not use me, while"
439 "ResponseTriggerV1 does ?");
442 fSlatSegmentation->PadByPosition(TVector2(fXhit,fYhit),kFALSE);
443 if ( !strip.IsValid() )
445 AliWarning(Form("%s got invalid fXhit,fYhit=%e,%e\n",
446 fSlatSegmentation->GetName(),fXhit,fYhit));
451 Double_t xstrip = strip.Position().X();
452 Double_t ystrip = strip.Position().Y();
453 AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
454 fXhit,fYhit,xstrip,ystrip));
455 x1 = (fPlaneType==kBendingPlane) ? fYhit : fXhit;
456 x2 = (fPlaneType==kBendingPlane) ? ystrip : xstrip;
457 x3 = (fPlaneType==kBendingPlane) ?
458 fCurrentPad.Position().Y() : fCurrentPad.Position().X();
461 if (fPlaneType==kBendingPlane)
463 xmin = x3 - fCurrentPad.Dimensions().X();
464 xmax = x3 + fCurrentPad.Dimensions().X();
468 xmin = x3 - fCurrentPad.Dimensions().Y();
469 xmax = x3 + fCurrentPad.Dimensions().Y();
471 // dist. between the hit and the closest border of the current strip
472 x4 = (TMath::Abs(xmax-x1) > TMath::Abs(xmin-x1)) ?
473 TMath::Abs(xmin-x1):TMath::Abs(xmax-x1);
475 AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
476 fPlaneType,x1,x2,x3,x4,xmin,xmax));
481 //_____________________________________________________________________________
483 AliMUONTriggerSegmentationV2::Ix()
485 if ( fCurrentPad.IsValid() )
488 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
489 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
495 //_____________________________________________________________________________
497 AliMUONTriggerSegmentationV2::Iy()
499 if ( fCurrentPad.IsValid() )
502 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
503 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
510 //_____________________________________________________________________________
512 AliMUONTriggerSegmentationV2::LA2PC(Int_t ixLA, Int_t iyLA,
513 Int_t& ixPC, Int_t& iyPC) const
516 // From LA to PC conventions for integers indices.
520 if ( ixLA<0 || iyLA<0 ) return;
525 if ( fPlaneType == kBendingPlane )
527 if ( LineNumber()==5 )
531 if ( LineNumber()==4 && ixLA==0 )
537 AliDebug(3,Form("ix,iy LA (%d,%d) -> PC (%d,%d)",ixLA,iyLA,ixPC,iyPC));
541 //_____________________________________________________________________________
543 AliMUONTriggerSegmentationV2::LineNumber() const
545 return 10-fLineNumber;
548 //_____________________________________________________________________________
550 AliMUONTriggerSegmentationV2::ModuleColNum(Int_t ixGlo) const
552 // returns column number (from 0 to 6) in which the (global) module
553 // ix is sitting (could return 7 if ix=isec)
554 return TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10-1;
557 //_____________________________________________________________________________
559 AliMUONTriggerSegmentationV2::MorePads()
561 AliFatal("Not implemented");
565 //_____________________________________________________________________________
566 void AliMUONTriggerSegmentationV2::Neighbours(Int_t /*iX*/, Int_t /*iY*/,
571 //-----------------BENDING-----------------------------------------
572 // Returns list of 10 next neighbours for given X strip (ix, iy)
573 // neighbour number 4 in the list -
574 // neighbour number 3 in the list |
575 // neighbour number 2 in the list |_ Upper part
576 // neighbour number 1 in the list |
577 // neighbour number 0 in the list -
579 // neighbour number 5 in the list -
580 // neighbour number 6 in the list | _ Lower part
581 // neighbour number 7 in the list |
582 // neighbour number 8 in the list |
583 // neighbour number 9 in the list -
585 //-----------------NON-BENDING-------------------------------------
586 // Returns list of 10 next neighbours for given Y strip (ix, iy)
587 // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
588 // \_______/ \_______/
590 AliFatal("Please implement me");
593 //_____________________________________________________________________________
595 AliMUONTriggerSegmentationV2::NextPad()
597 AliFatal("Not implemented");
600 //_____________________________________________________________________________
602 AliMUONTriggerSegmentationV2::Npx() const
604 return 124;// FIXME: this should not have to be done, if only we'd stick
605 // to a local (ix,iy) convention !!!
606 // return fSlatSegmentation->MaxPadIndexX()+1;
609 //_____________________________________________________________________________
611 AliMUONTriggerSegmentationV2::Npy() const
614 // return fSlatSegmentation->MaxPadIndexY()+1;
617 //_____________________________________________________________________________
619 AliMUONTriggerSegmentationV2::PC2LA(Int_t ixPC, Int_t iyPC,
620 Int_t& ixLA, Int_t& iyLA) const
623 // From PC to LA conventions for integers indices.
627 if ( ixPC<0 || iyPC<0 ) return;
632 if ( fPlaneType == kBendingPlane )
634 if ( LineNumber()==5 )
638 if ( LineNumber()==4 && ixLA==0 )
644 AliDebug(3,Form("ix,iy PC (%d,%d) -> LA (%d,%d)",ixPC,iyPC,ixLA,iyLA));
647 //_____________________________________________________________________________
649 AliMUONTriggerSegmentationV2::Print(Option_t* opt) const
653 cout << "DetElemId=" << fDetElemId << " PlaneType="
654 << fPlaneType << " Npx=" << Npx() << " Npy=" << Npy() << endl;
655 if ( ( sopt.Contains("SEG") || sopt.Contains("ALL") ) && fSlatSegmentation )
657 fSlatSegmentation->Print();
659 if ( sopt.Contains("ALL") && fSlat )
665 //_____________________________________________________________________________
667 AliMUONTriggerSegmentationV2::Sector(Int_t ix, Int_t iy)
670 IGlo2ILoc(ix,iy,ixLA,iyLA);
671 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
672 if ( !pad.IsValid() ) return -1;
673 return Code(ixLA,iyLA);
675 // AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ixLA);
678 // AliError(Form("Could not find a pcb at (%d,%d) for slat %s",
679 // ix,iy,fSlat->GetName()));
682 // if ( pcb->PadSizeX()==-1.0 )
684 // // special case of column 7 non-bending.
685 // return SPECIAL_SECTOR;
687 // return fSlat->GetLayer(0)->FindPCBIndex(ixLA);
690 //_____________________________________________________________________________
692 AliMUONTriggerSegmentationV2::Sector(Float_t, Float_t)
694 AliFatal("Not implemented");
698 //_____________________________________________________________________________
700 AliMUONTriggerSegmentationV2::SetCorrFunc(Int_t,TF1*)
702 AliFatal("Not Implemented");
705 //_____________________________________________________________________________
707 AliMUONTriggerSegmentationV2::SetDAnod(float)
709 AliFatal("Not Implemented");
712 //_____________________________________________________________________________
714 AliMUONTriggerSegmentationV2::SetHit(Float_t x, Float_t y)
720 // insure we're within the slat limits. If not, issue an error and sets
721 // the current hit to slat center.
722 // FIXME: this should probably a) not happen at all b) be a fatal error
724 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
725 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
727 AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
728 " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
735 //_____________________________________________________________________________
737 AliMUONTriggerSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
742 //_____________________________________________________________________________
744 AliMUONTriggerSegmentationV2::SetPad(Int_t ix, Int_t iy)
747 IGlo2ILoc(ix,iy,ixLA,iyLA);
748 fCurrentPad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
749 if ( !fCurrentPad.IsValid() )
751 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
755 //_____________________________________________________________________________
757 AliMUONTriggerSegmentationV2::SetPadSize(float,float)
759 AliFatal("Not Implemented");
762 //_____________________________________________________________________________
764 AliMUONTriggerSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
766 AliFatal("Not Implemented");
770 //_____________________________________________________________________________
772 AliMUONTriggerSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
774 AliFatal("Not Implemented");