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::ISector()
414 // FIXME: remove the usage of ISector from all the code.
418 //_____________________________________________________________________________
419 void AliMUONTriggerSegmentationV2::IntegrationLimits(Float_t& x1,
424 // x1 : hit x(y) position
425 // x2 : x(y) coordinate of the main strip
426 // x3 : current strip real x(y) coordinate
427 // x4 : dist. between x(y) hit pos. and the closest border of the current strip
429 // Note : need to return (only) x4.
431 AliFatal("Check me before usage. ResponseTrigger does not use me, while"
432 "ResponseTriggerV1 does ?");
435 fSlatSegmentation->PadByPosition(TVector2(fXhit,fYhit),kFALSE);
436 if ( !strip.IsValid() )
438 AliWarning(Form("%s got invalid fXhit,fYhit=%e,%e\n",
439 fSlatSegmentation->GetName(),fXhit,fYhit));
444 Double_t xstrip = strip.Position().X();
445 Double_t ystrip = strip.Position().Y();
446 AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
447 fXhit,fYhit,xstrip,ystrip));
448 x1 = (fPlaneType==kBendingPlane) ? fYhit : fXhit;
449 x2 = (fPlaneType==kBendingPlane) ? ystrip : xstrip;
450 x3 = (fPlaneType==kBendingPlane) ?
451 fCurrentPad.Position().Y() : fCurrentPad.Position().X();
454 if (fPlaneType==kBendingPlane)
456 xmin = x3 - fCurrentPad.Dimensions().X();
457 xmax = x3 + fCurrentPad.Dimensions().X();
461 xmin = x3 - fCurrentPad.Dimensions().Y();
462 xmax = x3 + fCurrentPad.Dimensions().Y();
464 // dist. between the hit and the closest border of the current strip
465 x4 = (TMath::Abs(xmax-x1) > TMath::Abs(xmin-x1)) ?
466 TMath::Abs(xmin-x1):TMath::Abs(xmax-x1);
468 AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
469 fPlaneType,x1,x2,x3,x4,xmin,xmax));
474 //_____________________________________________________________________________
476 AliMUONTriggerSegmentationV2::Ix()
478 if ( fCurrentPad.IsValid() )
481 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
482 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
488 //_____________________________________________________________________________
490 AliMUONTriggerSegmentationV2::Iy()
492 if ( fCurrentPad.IsValid() )
495 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
496 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
503 //_____________________________________________________________________________
505 AliMUONTriggerSegmentationV2::LA2PC(Int_t ixLA, Int_t iyLA,
506 Int_t& ixPC, Int_t& iyPC) const
509 // From LA to PC conventions for integers indices.
513 if ( ixLA<0 || iyLA<0 ) return;
518 if ( fPlaneType == kBendingPlane )
520 if ( LineNumber()==5 )
524 if ( LineNumber()==4 && ixLA==0 )
530 AliDebug(3,Form("ix,iy LA (%d,%d) -> PC (%d,%d)",ixLA,iyLA,ixPC,iyPC));
534 //_____________________________________________________________________________
536 AliMUONTriggerSegmentationV2::LineNumber() const
538 return 10-fLineNumber;
541 //_____________________________________________________________________________
543 AliMUONTriggerSegmentationV2::ModuleColNum(Int_t ixGlo) const
545 // returns column number (from 0 to 6) in which the (global) module
546 // ix is sitting (could return 7 if ix=isec)
547 return TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10-1;
550 //_____________________________________________________________________________
552 AliMUONTriggerSegmentationV2::MorePads()
554 AliFatal("Not implemented");
558 //_____________________________________________________________________________
559 void AliMUONTriggerSegmentationV2::Neighbours(Int_t /*iX*/, Int_t /*iY*/,
564 //-----------------BENDING-----------------------------------------
565 // Returns list of 10 next neighbours for given X strip (ix, iy)
566 // neighbour number 4 in the list -
567 // neighbour number 3 in the list |
568 // neighbour number 2 in the list |_ Upper part
569 // neighbour number 1 in the list |
570 // neighbour number 0 in the list -
572 // neighbour number 5 in the list -
573 // neighbour number 6 in the list | _ Lower part
574 // neighbour number 7 in the list |
575 // neighbour number 8 in the list |
576 // neighbour number 9 in the list -
578 //-----------------NON-BENDING-------------------------------------
579 // Returns list of 10 next neighbours for given Y strip (ix, iy)
580 // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
581 // \_______/ \_______/
583 AliFatal("Please implement me");
586 //_____________________________________________________________________________
588 AliMUONTriggerSegmentationV2::NextPad()
590 AliFatal("Not implemented");
593 //_____________________________________________________________________________
595 AliMUONTriggerSegmentationV2::Npx() const
597 return 124;// FIXME: this should not have to be done, if only we'd stick
598 // to a local (ix,iy) convention !!!
599 // return fSlatSegmentation->MaxPadIndexX()+1;
602 //_____________________________________________________________________________
604 AliMUONTriggerSegmentationV2::Npy() const
607 // return fSlatSegmentation->MaxPadIndexY()+1;
610 //_____________________________________________________________________________
612 AliMUONTriggerSegmentationV2::PC2LA(Int_t ixPC, Int_t iyPC,
613 Int_t& ixLA, Int_t& iyLA) const
616 // From PC to LA conventions for integers indices.
620 if ( ixPC<0 || iyPC<0 ) return;
625 if ( fPlaneType == kBendingPlane )
627 if ( LineNumber()==5 )
631 if ( LineNumber()==4 && ixLA==0 )
637 AliDebug(3,Form("ix,iy PC (%d,%d) -> LA (%d,%d)",ixPC,iyPC,ixLA,iyLA));
640 //_____________________________________________________________________________
642 AliMUONTriggerSegmentationV2::Print(Option_t* opt) const
646 cout << "DetElemId=" << fDetElemId << " PlaneType="
647 << fPlaneType << " Npx=" << Npx() << " Npy=" << Npy() << endl;
648 if ( ( sopt.Contains("SEG") || sopt.Contains("ALL") ) && fSlatSegmentation )
650 fSlatSegmentation->Print();
652 if ( sopt.Contains("ALL") && fSlat )
658 //_____________________________________________________________________________
660 AliMUONTriggerSegmentationV2::Sector(Int_t ix, Int_t iy)
663 IGlo2ILoc(ix,iy,ixLA,iyLA);
664 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
665 if ( !pad.IsValid() ) return -1;
666 return Code(ixLA,iyLA);
668 // AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ixLA);
671 // AliError(Form("Could not find a pcb at (%d,%d) for slat %s",
672 // ix,iy,fSlat->GetName()));
675 // if ( pcb->PadSizeX()==-1.0 )
677 // // special case of column 7 non-bending.
678 // return SPECIAL_SECTOR;
680 // return fSlat->GetLayer(0)->FindPCBIndex(ixLA);
683 //_____________________________________________________________________________
685 AliMUONTriggerSegmentationV2::Sector(Float_t, Float_t)
687 AliFatal("Not implemented");
691 //_____________________________________________________________________________
693 AliMUONTriggerSegmentationV2::SetCorrFunc(Int_t,TF1*)
695 AliFatal("Not Implemented");
698 //_____________________________________________________________________________
700 AliMUONTriggerSegmentationV2::SetDAnod(float)
702 AliFatal("Not Implemented");
705 //_____________________________________________________________________________
707 AliMUONTriggerSegmentationV2::SetHit(Float_t x, Float_t y)
713 // insure we're within the slat limits. If not, issue an error and sets
714 // the current hit to slat center.
715 // FIXME: this should probably a) not happen at all b) be a fatal error
717 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
718 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
720 AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
721 " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
728 //_____________________________________________________________________________
730 AliMUONTriggerSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
735 //_____________________________________________________________________________
737 AliMUONTriggerSegmentationV2::SetPad(Int_t ix, Int_t iy)
740 IGlo2ILoc(ix,iy,ixLA,iyLA);
741 fCurrentPad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
742 if ( !fCurrentPad.IsValid() )
744 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
748 //_____________________________________________________________________________
750 AliMUONTriggerSegmentationV2::SetPadSize(float,float)
752 AliFatal("Not Implemented");
755 //_____________________________________________________________________________
757 AliMUONTriggerSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
759 AliFatal("Not Implemented");
763 //_____________________________________________________________________________
765 AliMUONTriggerSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
767 AliFatal("Not Implemented");