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"
23 #include "AliMpTrigger.h"
24 #include "AliMpTriggerSegmentation.h"
25 #include "AliMpSlat.h"
27 #include "AliMUONSegmentationManager.h"
29 #include "Riostream.h"
33 ClassImp(AliMUONTriggerSegmentationV2)
37 // Int_t SPECIAL_SECTOR = 8;
40 Int_t CODEMAKER(1000);
42 Int_t Code(Int_t ixLA, Int_t iyLA)
44 return iyLA*CODEMAKER + ixLA;
47 void Decode(Int_t code, Int_t& ixLA, Int_t& iyLA)
49 iyLA = code/CODEMAKER;
50 ixLA = code - iyLA*CODEMAKER;
54 //_____________________________________________________________________________
55 AliMUONTriggerSegmentationV2::AliMUONTriggerSegmentationV2()
56 : AliMUONVGeometryDESegmentation(),
58 fPlaneType(kNonBendingPlane),
66 // Default ctor (empty).
68 AliDebug(1,Form("this=%p default (empty) ctor",this));
71 //_____________________________________________________________________________
72 AliMUONTriggerSegmentationV2::AliMUONTriggerSegmentationV2(Int_t detElemId,
73 AliMpPlaneType bendingOrNonBending)
74 : AliMUONVGeometryDESegmentation(),
75 fDetElemId(detElemId),
76 fPlaneType(bendingOrNonBending),
88 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
89 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
93 //_____________________________________________________________________________
94 AliMUONTriggerSegmentationV2::AliMUONTriggerSegmentationV2(const AliMUONTriggerSegmentationV2& rhs) : AliMUONVGeometryDESegmentation(rhs)
96 AliFatal("Not implemented.");
99 //_____________________________________________________________________________
100 AliMUONTriggerSegmentationV2::~AliMUONTriggerSegmentationV2()
102 AliDebug(1,Form("this=%p",this));
106 //_____________________________________________________________________________
107 AliMUONTriggerSegmentationV2& AliMUONTriggerSegmentationV2::operator=(const AliMUONTriggerSegmentationV2& rhs)
109 // Protected assignement operator
110 if (this == &rhs) return *this;
111 AliFatal("Not implemented.");
115 //_____________________________________________________________________________
117 AliMUONTriggerSegmentationV2::CorrFunc(Int_t) const
119 AliFatal("Not implemented");
123 //_____________________________________________________________________________
125 AliMUONTriggerSegmentationV2::Distance2AndOffset(Int_t, Int_t,
126 Float_t, Float_t, Int_t*)
128 AliFatal("Not implemented");
132 //_____________________________________________________________________________
134 AliMUONTriggerSegmentationV2::Draw(Option_t*)
136 AliFatal("Not Implemented");
139 //_____________________________________________________________________________
141 AliMUONTriggerSegmentationV2::Dpx() const
143 AliFatal("Not Implemented");
147 //_____________________________________________________________________________
149 AliMUONTriggerSegmentationV2::Dpy() const
151 AliFatal("Not Implemented");
155 //_____________________________________________________________________________
157 AliMUONTriggerSegmentationV2::Dpx(int sectorCode) const
160 Decode(sectorCode,ixLA,iyLA);
161 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
162 if ( !pad.IsValid() ) return 0.0;
163 return pad.Dimensions().X()*2.0;
166 //_____________________________________________________________________________
168 AliMUONTriggerSegmentationV2::Dpy(int sectorCode) const
171 Decode(sectorCode,ixLA,iyLA);
172 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
173 if ( !pad.IsValid() ) return 0.0;
174 return pad.Dimensions().Y()*2.0;
177 //_____________________________________________________________________________
179 AliMUONTriggerSegmentationV2::FirstPad(Float_t /*xhit*/, Float_t /*yhit*/,
181 Float_t /*dx*/, Float_t /*dy*/)
183 AliFatal("Not implemented");
186 //_____________________________________________________________________________
188 AliMUONTriggerSegmentationV2::GetAnod(Float_t) const
190 AliFatal("Not implemented");
194 //_____________________________________________________________________________
195 AliMUONGeometryDirection
196 AliMUONTriggerSegmentationV2::GetDirection()
198 //AliWarning("Not Implemented");
199 return kDirUndefined;
202 //______________________________________________________________________________
203 const AliMpVSegmentation*
204 AliMUONTriggerSegmentationV2::GetMpSegmentation() const
206 // Returns the mapping segmentation
207 // (provides access to electronics info)
209 return fSlatSegmentation;
212 //_____________________________________________________________________________
214 AliMUONTriggerSegmentationV2::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
216 AliFatal("Not Implemented");
219 //_____________________________________________________________________________
221 AliMUONTriggerSegmentationV2::GetPadC(Int_t ix, Int_t iy,
222 Float_t& x, Float_t& y, Float_t& z)
228 //_____________________________________________________________________________
230 AliMUONTriggerSegmentationV2::GetPadC(Int_t ixGlo, Int_t iyGlo,
231 Float_t& x, Float_t& y)
234 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
235 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
236 x = pad.Position().X();
237 y = pad.Position().Y();
240 //_____________________________________________________________________________
242 AliMUONTriggerSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t,
243 Int_t& ix, Int_t& iy)
248 //_____________________________________________________________________________
250 AliMUONTriggerSegmentationV2::GetPadI(Float_t x, Float_t y,
251 Int_t& ixGlo, Int_t& iyGlo)
253 AliDebug(2,Form("%s x=%e y=%e ixGlo,iyGlo=%d,%d\n",
254 fSlatSegmentation->GetName(),
258 fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
260 if ( pad != AliMpPad::Invalid() )
262 Int_t ix = pad.GetIndices().GetFirst();
263 Int_t iy = pad.GetIndices().GetSecond();
264 ILoc2IGlo(ix,iy,ixGlo,iyGlo);
270 AliDebug(2,Form("ixGlo,iyGlo=%d,%d\n",ixGlo,iyGlo));
273 //_____________________________________________________________________________
275 AliMUONTriggerSegmentationV2::GetPadLoc2Glo(Int_t ix, Int_t iy,
276 Int_t& ixGlo, Int_t& iyGlo) const
279 // Converts from local (in PC convention) to (ix,iy) to global (ix,iy)
282 ixGlo=iyGlo=-1; // starts with invalid values
284 if ( fPlaneType == kBendingPlane )
286 ixGlo = 10*LineNumber() + ix;
287 iyGlo = iy - fgIntOffset;
289 else if ( fPlaneType == kNonBendingPlane )
291 Int_t i = fSlat->GetLayer(0)->FindPCBIndex(ix-fgIntOffset);
294 AliError(Form("Invalid local (ix=%d,iy=%d) ?",ix,iy));
297 AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ix-fgIntOffset);
298 iyGlo = ix - pcb->Ixmin() - fgIntOffset;
299 if ( LineNumber() == 5 ) ++i;
300 ixGlo = 10*LineNumber() + i + fgIntOffset;
304 //_____________________________________________________________________________
306 AliMUONTriggerSegmentationV2::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
307 Int_t& ix, Int_t& iy) const
310 // Converts from global (ix,iy) to local (ix,iy) (in PC convention)
313 ix=iy=-1; // starts with invalid values
315 if ( abs(ixGlo) == 51 ) return;
317 Int_t column = ModuleColNum(ixGlo);
319 if ( fPlaneType == kBendingPlane )
321 ix = column + fgIntOffset;
322 iy = iyGlo + fgIntOffset;
324 else if ( fPlaneType == kNonBendingPlane )
326 if ( LineNumber()==5 ) --column;
327 AliMpPCB* pcb = fSlat->GetLayer(0)->GetPCB(column);
330 AliError(Form("Invalid global (ix=%d,iy=%d)",ixGlo,iyGlo));
333 ix = pcb->Ixmin() + iyGlo + fgIntOffset;
338 //_____________________________________________________________________________
340 AliMUONTriggerSegmentationV2::GiveTestPoints(Int_t&,Float_t*,Float_t*) const
342 AliFatal("Not Implemented");
345 //_____________________________________________________________________________
347 AliMUONTriggerSegmentationV2::HasPad(Float_t x, Float_t y, Float_t)
350 // Well, 2 implementations are possible here
351 // Either reuse HasPad(int,int), or get it from scratch using
352 // underlying fSlatSegmentation.
353 // Took second option, but w/o checking whether this is the faster.
354 // The second option is commented out below, for the record.
357 // GetPadI(x,y,z,ix,iy);
359 // IGlo2ILoc(ix,iy,ixLA,iyLA);
361 // LA2PC(ixLA,iyLA,ixPC,iyPC);
362 // Bool_t ok1 = HasPad(ixPC,iyPC);
365 fSlatSegmentation->PadByPosition(TVector2(x,y),kFALSE);
366 return pad.IsValid();
369 //_____________________________________________________________________________
371 AliMUONTriggerSegmentationV2::HasPad(Int_t ixGlo, Int_t iyGlo)
374 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
375 return fSlatSegmentation->HasPad(AliMpIntPair(ixLA,iyLA));
378 //_____________________________________________________________________________
380 AliMUONTriggerSegmentationV2::IGlo2ILoc(Int_t ixGlo, Int_t iyGlo,
381 Int_t& ixLA, Int_t& iyLA)
384 GetPadGlo2Loc(ixGlo,iyGlo,ixPC,iyPC);
385 PC2LA(ixPC,iyPC,ixLA,iyLA);
388 //_____________________________________________________________________________
390 AliMUONTriggerSegmentationV2::ILoc2IGlo(Int_t ixLA, Int_t iyLA,
391 Int_t& ixGlo, Int_t& iyGlo)
394 LA2PC(ixLA,iyLA,ixPC,iyPC);
395 GetPadLoc2Glo(ixPC,iyPC,ixGlo,iyGlo);
398 //_____________________________________________________________________________
400 AliMUONTriggerSegmentationV2::Init(int)
402 AliWarning("Not Implemented because not needed ;-)");
405 //_____________________________________________________________________________
407 AliMUONTriggerSegmentationV2::ISector()
409 // FIXME: remove the usage of ISector from all the code.
413 //_____________________________________________________________________________
414 void AliMUONTriggerSegmentationV2::IntegrationLimits(Float_t& x1,
419 // x1 : hit x(y) position
420 // x2 : x(y) coordinate of the main strip
421 // x3 : current strip real x(y) coordinate
422 // x4 : dist. between x(y) hit pos. and the closest border of the current strip
424 // Note : need to return (only) x4.
426 AliFatal("Check me before usage. ResponseTrigger does not use me, while"
427 "ResponseTriggerV1 does ?");
430 fSlatSegmentation->PadByPosition(TVector2(fXhit,fYhit),kFALSE);
431 if ( !strip.IsValid() )
433 AliWarning(Form("%s got invalid fXhit,fYhit=%e,%e\n",
434 fSlatSegmentation->GetName(),fXhit,fYhit));
439 Double_t xstrip = strip.Position().X();
440 Double_t ystrip = strip.Position().Y();
441 AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
442 fXhit,fYhit,xstrip,ystrip));
443 x1 = (fPlaneType==kBendingPlane) ? fYhit : fXhit;
444 x2 = (fPlaneType==kBendingPlane) ? ystrip : xstrip;
445 x3 = (fPlaneType==kBendingPlane) ?
446 fCurrentPad.Position().Y() : fCurrentPad.Position().X();
449 if (fPlaneType==kBendingPlane)
451 xmin = x3 - fCurrentPad.Dimensions().X();
452 xmax = x3 + fCurrentPad.Dimensions().X();
456 xmin = x3 - fCurrentPad.Dimensions().Y();
457 xmax = x3 + fCurrentPad.Dimensions().Y();
459 // dist. between the hit and the closest border of the current strip
460 x4 = (TMath::Abs(xmax-x1) > TMath::Abs(xmin-x1)) ?
461 TMath::Abs(xmin-x1):TMath::Abs(xmax-x1);
463 AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
464 fPlaneType,x1,x2,x3,x4,xmin,xmax));
469 //_____________________________________________________________________________
471 AliMUONTriggerSegmentationV2::Ix()
473 if ( fCurrentPad.IsValid() )
476 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
477 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
483 //_____________________________________________________________________________
485 AliMUONTriggerSegmentationV2::Iy()
487 if ( fCurrentPad.IsValid() )
490 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
491 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
498 //_____________________________________________________________________________
500 AliMUONTriggerSegmentationV2::LA2PC(Int_t ixLA, Int_t iyLA,
501 Int_t& ixPC, Int_t& iyPC)
504 // From LA to PC conventions for integers indices.
508 if ( ixLA<0 || iyLA<0 ) return;
513 if ( fPlaneType == kBendingPlane )
515 if ( LineNumber()==5 )
519 if ( LineNumber()==4 && ixLA==0 )
525 AliDebug(3,Form("ix,iy LA (%d,%d) -> PC (%d,%d)",ixLA,iyLA,ixPC,iyPC));
529 //_____________________________________________________________________________
531 AliMUONTriggerSegmentationV2::LineNumber() const
533 return 10-fLineNumber;
536 //_____________________________________________________________________________
538 AliMUONTriggerSegmentationV2::ModuleColNum(Int_t ixGlo) const
540 // returns column number (from 0 to 6) in which the (global) module
541 // ix is sitting (could return 7 if ix=isec)
542 return TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10-1;
545 //_____________________________________________________________________________
547 AliMUONTriggerSegmentationV2::MorePads()
549 AliFatal("Not implemented");
553 //_____________________________________________________________________________
554 void AliMUONTriggerSegmentationV2::Neighbours(Int_t /*iX*/, Int_t /*iY*/,
559 //-----------------BENDING-----------------------------------------
560 // Returns list of 10 next neighbours for given X strip (ix, iy)
561 // neighbour number 4 in the list -
562 // neighbour number 3 in the list |
563 // neighbour number 2 in the list |_ Upper part
564 // neighbour number 1 in the list |
565 // neighbour number 0 in the list -
567 // neighbour number 5 in the list -
568 // neighbour number 6 in the list | _ Lower part
569 // neighbour number 7 in the list |
570 // neighbour number 8 in the list |
571 // neighbour number 9 in the list -
573 //-----------------NON-BENDING-------------------------------------
574 // Returns list of 10 next neighbours for given Y strip (ix, iy)
575 // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
576 // \_______/ \_______/
578 AliFatal("Please implement me");
581 //_____________________________________________________________________________
583 AliMUONTriggerSegmentationV2::NextPad()
585 AliFatal("Not implemented");
588 //_____________________________________________________________________________
590 AliMUONTriggerSegmentationV2::Npx() const
592 return 124;// FIXME: this should not have to be done, if only we'd stick
593 // to a local (ix,iy) convention !!!
594 // return fSlatSegmentation->MaxPadIndexX()+1;
597 //_____________________________________________________________________________
599 AliMUONTriggerSegmentationV2::Npy() const
602 // return fSlatSegmentation->MaxPadIndexY()+1;
605 //_____________________________________________________________________________
607 AliMUONTriggerSegmentationV2::PC2LA(Int_t ixPC, Int_t iyPC,
608 Int_t& ixLA, Int_t& iyLA)
611 // From PC to LA conventions for integers indices.
615 if ( ixPC<0 || iyPC<0 ) return;
620 if ( fPlaneType == kBendingPlane )
622 if ( LineNumber()==5 )
626 if ( LineNumber()==4 && ixLA==0 )
632 AliDebug(3,Form("ix,iy PC (%d,%d) -> LA (%d,%d)",ixPC,iyPC,ixLA,iyLA));
635 //_____________________________________________________________________________
637 AliMUONTriggerSegmentationV2::Print(Option_t* opt) const
641 cout << "DetElemId=" << fDetElemId << " PlaneType="
642 << fPlaneType << " Npx=" << Npx() << " Npy=" << Npy() << endl;
643 if ( ( sopt.Contains("SEG") || sopt.Contains("ALL") ) && fSlatSegmentation )
645 fSlatSegmentation->Print();
647 if ( sopt.Contains("ALL") && fSlat )
653 //_____________________________________________________________________________
655 AliMUONTriggerSegmentationV2::ReadMappingData()
657 fSlatSegmentation = dynamic_cast<AliMpTriggerSegmentation*>
658 (AliMUONSegmentationManager::Segmentation(fDetElemId,fPlaneType));
660 if (!fSlatSegmentation)
662 AliFatal("Wrong segmentation type encountered");
664 fSlat = fSlatSegmentation->Slat();
665 TString id(fSlat->GetID());
666 Ssiz_t pos = id.Last('L');
669 AliFatal(Form("Cannot infer line number for slat %s",id.Data()));
671 fLineNumber = TString(id(pos+1),1).Atoi();
674 //_____________________________________________________________________________
676 AliMUONTriggerSegmentationV2::Sector(Int_t ix, Int_t iy)
679 IGlo2ILoc(ix,iy,ixLA,iyLA);
680 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
681 if ( !pad.IsValid() ) return -1;
682 return Code(ixLA,iyLA);
684 // AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ixLA);
687 // AliError(Form("Could not find a pcb at (%d,%d) for slat %s",
688 // ix,iy,fSlat->GetName()));
691 // if ( pcb->PadSizeX()==-1.0 )
693 // // special case of column 7 non-bending.
694 // return SPECIAL_SECTOR;
696 // return fSlat->GetLayer(0)->FindPCBIndex(ixLA);
699 //_____________________________________________________________________________
701 AliMUONTriggerSegmentationV2::Sector(Float_t, Float_t)
703 AliFatal("Not implemented");
707 //_____________________________________________________________________________
709 AliMUONTriggerSegmentationV2::SetCorrFunc(Int_t,TF1*)
711 AliFatal("Not Implemented");
714 //_____________________________________________________________________________
716 AliMUONTriggerSegmentationV2::SetDAnod(float)
718 AliFatal("Not Implemented");
721 //_____________________________________________________________________________
723 AliMUONTriggerSegmentationV2::SetHit(Float_t x, Float_t y)
729 // insure we're within the slat limits. If not, issue an error and sets
730 // the current hit to slat center.
731 // FIXME: this should probably a) not happen at all b) be a fatal error
733 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
734 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
736 AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
737 " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
744 //_____________________________________________________________________________
746 AliMUONTriggerSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
751 //_____________________________________________________________________________
753 AliMUONTriggerSegmentationV2::SetPad(Int_t ix, Int_t iy)
756 IGlo2ILoc(ix,iy,ixLA,iyLA);
757 fCurrentPad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
758 if ( !fCurrentPad.IsValid() )
760 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
764 //_____________________________________________________________________________
766 AliMUONTriggerSegmentationV2::SetPadSize(float,float)
768 AliFatal("Not Implemented");
771 //_____________________________________________________________________________
773 AliMUONTriggerSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
775 AliFatal("Not Implemented");
779 //_____________________________________________________________________________
781 AliMUONTriggerSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
783 AliFatal("Not Implemented");
786 //_____________________________________________________________________________
788 AliMUONTriggerSegmentationV2::Streamer(TBuffer &R__b)
790 if (R__b.IsReading())
792 AliMUONTriggerSegmentationV2::Class()->ReadBuffer(R__b, this);
797 AliMUONTriggerSegmentationV2::Class()->WriteBuffer(R__b, this);