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");
93 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
94 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
98 //_____________________________________________________________________________
99 AliMUONTriggerSegmentationV2::AliMUONTriggerSegmentationV2(const AliMUONTriggerSegmentationV2& rhs) : AliMUONVGeometryDESegmentation(rhs)
101 AliFatal("Not implemented.");
104 //_____________________________________________________________________________
105 AliMUONTriggerSegmentationV2::~AliMUONTriggerSegmentationV2()
107 AliDebug(1,Form("this=%p",this));
111 //_____________________________________________________________________________
112 AliMUONTriggerSegmentationV2& AliMUONTriggerSegmentationV2::operator=(const AliMUONTriggerSegmentationV2& rhs)
114 // Protected assignement operator
115 if (this == &rhs) return *this;
116 AliFatal("Not implemented.");
120 //_____________________________________________________________________________
122 AliMUONTriggerSegmentationV2::CorrFunc(Int_t) const
124 AliFatal("Not implemented");
128 //_____________________________________________________________________________
130 AliMUONTriggerSegmentationV2::Distance2AndOffset(Int_t, Int_t,
131 Float_t, Float_t, Int_t*)
133 AliFatal("Not implemented");
137 //_____________________________________________________________________________
139 AliMUONTriggerSegmentationV2::Draw(Option_t*)
141 AliFatal("Not Implemented");
144 //_____________________________________________________________________________
146 AliMUONTriggerSegmentationV2::Dpx() const
148 AliFatal("Not Implemented");
152 //_____________________________________________________________________________
154 AliMUONTriggerSegmentationV2::Dpy() const
156 AliFatal("Not Implemented");
160 //_____________________________________________________________________________
162 AliMUONTriggerSegmentationV2::Dpx(int sectorCode) const
165 Decode(sectorCode,ixLA,iyLA);
166 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
167 if ( !pad.IsValid() ) return 0.0;
168 return pad.Dimensions().X()*2.0;
171 //_____________________________________________________________________________
173 AliMUONTriggerSegmentationV2::Dpy(int sectorCode) const
176 Decode(sectorCode,ixLA,iyLA);
177 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
178 if ( !pad.IsValid() ) return 0.0;
179 return pad.Dimensions().Y()*2.0;
182 //_____________________________________________________________________________
184 AliMUONTriggerSegmentationV2::FirstPad(Float_t /*xhit*/, Float_t /*yhit*/,
186 Float_t /*dx*/, Float_t /*dy*/)
188 AliFatal("Not implemented");
191 //_____________________________________________________________________________
193 AliMUONTriggerSegmentationV2::GetAnod(Float_t) const
195 AliFatal("Not implemented");
199 //_____________________________________________________________________________
200 AliMUONGeometryDirection
201 AliMUONTriggerSegmentationV2::GetDirection()
203 //AliWarning("Not Implemented");
204 return kDirUndefined;
207 //______________________________________________________________________________
208 const AliMpVSegmentation*
209 AliMUONTriggerSegmentationV2::GetMpSegmentation() const
211 // Returns the mapping segmentation
212 // (provides access to electronics info)
214 return fSlatSegmentation;
217 //_____________________________________________________________________________
219 AliMUONTriggerSegmentationV2::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
221 AliFatal("Not Implemented");
224 //_____________________________________________________________________________
226 AliMUONTriggerSegmentationV2::GetPadC(Int_t ix, Int_t iy,
227 Float_t& x, Float_t& y, Float_t& z)
233 //_____________________________________________________________________________
235 AliMUONTriggerSegmentationV2::GetPadC(Int_t ixGlo, Int_t iyGlo,
236 Float_t& x, Float_t& y)
239 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
240 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
241 x = pad.Position().X();
242 y = pad.Position().Y();
245 //_____________________________________________________________________________
247 AliMUONTriggerSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t,
248 Int_t& ix, Int_t& iy)
253 //_____________________________________________________________________________
255 AliMUONTriggerSegmentationV2::GetPadI(Float_t x, Float_t y,
256 Int_t& ixGlo, Int_t& iyGlo)
258 AliDebug(2,Form("%s x=%e y=%e ixGlo,iyGlo=%d,%d\n",
259 fSlatSegmentation->GetName(),
263 fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
265 if ( pad != AliMpPad::Invalid() )
267 Int_t ix = pad.GetIndices().GetFirst();
268 Int_t iy = pad.GetIndices().GetSecond();
269 ILoc2IGlo(ix,iy,ixGlo,iyGlo);
275 AliDebug(2,Form("ixGlo,iyGlo=%d,%d\n",ixGlo,iyGlo));
278 //_____________________________________________________________________________
280 AliMUONTriggerSegmentationV2::GetPadLoc2Glo(Int_t ix, Int_t iy,
281 Int_t& ixGlo, Int_t& iyGlo) const
284 // Converts from local (in PC convention) to (ix,iy) to global (ix,iy)
287 ixGlo=iyGlo=-1; // starts with invalid values
289 if ( fPlaneType == kBendingPlane )
291 ixGlo = 10*LineNumber() + ix;
292 iyGlo = iy - fgIntOffset;
294 else if ( fPlaneType == kNonBendingPlane )
296 Int_t i = fSlat->GetLayer(0)->FindPCBIndex(ix-fgIntOffset);
299 AliError(Form("Invalid local (ix=%d,iy=%d) ?",ix,iy));
302 AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ix-fgIntOffset);
303 iyGlo = ix - pcb->Ixmin() - fgIntOffset;
304 if ( LineNumber() == 5 ) ++i;
305 ixGlo = 10*LineNumber() + i + fgIntOffset;
309 //_____________________________________________________________________________
311 AliMUONTriggerSegmentationV2::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
312 Int_t& ix, Int_t& iy) const
315 // Converts from global (ix,iy) to local (ix,iy) (in PC convention)
318 ix=iy=-1; // starts with invalid values
320 if ( abs(ixGlo) == 51 ) return;
322 Int_t column = ModuleColNum(ixGlo);
324 if ( fPlaneType == kBendingPlane )
326 ix = column + fgIntOffset;
327 iy = iyGlo + fgIntOffset;
329 else if ( fPlaneType == kNonBendingPlane )
331 if ( LineNumber()==5 ) --column;
332 AliMpPCB* pcb = fSlat->GetLayer(0)->GetPCB(column);
335 AliError(Form("Invalid global (ix=%d,iy=%d)",ixGlo,iyGlo));
338 ix = pcb->Ixmin() + iyGlo + fgIntOffset;
343 //_____________________________________________________________________________
345 AliMUONTriggerSegmentationV2::GiveTestPoints(Int_t&,Float_t*,Float_t*) const
347 AliFatal("Not Implemented");
350 //_____________________________________________________________________________
352 AliMUONTriggerSegmentationV2::HasPad(Float_t x, Float_t y, Float_t)
355 // Well, 2 implementations are possible here
356 // Either reuse HasPad(int,int), or get it from scratch using
357 // underlying fSlatSegmentation.
358 // Took second option, but w/o checking whether this is the faster.
359 // The second option is commented out below, for the record.
362 // GetPadI(x,y,z,ix,iy);
364 // IGlo2ILoc(ix,iy,ixLA,iyLA);
366 // LA2PC(ixLA,iyLA,ixPC,iyPC);
367 // Bool_t ok1 = HasPad(ixPC,iyPC);
370 fSlatSegmentation->PadByPosition(TVector2(x,y),kFALSE);
371 return pad.IsValid();
374 //_____________________________________________________________________________
376 AliMUONTriggerSegmentationV2::HasPad(Int_t ixGlo, Int_t iyGlo)
379 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
380 return fSlatSegmentation->HasPad(AliMpIntPair(ixLA,iyLA));
383 //_____________________________________________________________________________
385 AliMUONTriggerSegmentationV2::IGlo2ILoc(Int_t ixGlo, Int_t iyGlo,
386 Int_t& ixLA, Int_t& iyLA)
389 GetPadGlo2Loc(ixGlo,iyGlo,ixPC,iyPC);
390 PC2LA(ixPC,iyPC,ixLA,iyLA);
393 //_____________________________________________________________________________
395 AliMUONTriggerSegmentationV2::ILoc2IGlo(Int_t ixLA, Int_t iyLA,
396 Int_t& ixGlo, Int_t& iyGlo)
399 LA2PC(ixLA,iyLA,ixPC,iyPC);
400 GetPadLoc2Glo(ixPC,iyPC,ixGlo,iyGlo);
403 //_____________________________________________________________________________
405 AliMUONTriggerSegmentationV2::Init(int)
407 AliWarning("Not Implemented because not needed ;-)");
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)
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)
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");