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(),
257 Double_t slatx = fSlat->DX();
258 Double_t slaty = fSlat->DY();
260 fSlatSegmentation->PadByPosition(TVector2(x+slatx,y+slaty), kTRUE);
262 if ( pad != AliMpPad::Invalid() )
264 Int_t ix = pad.GetIndices().GetFirst();
265 Int_t iy = pad.GetIndices().GetSecond();
266 ILoc2IGlo(ix,iy,ixGlo,iyGlo);
272 AliDebug(2,Form("ixGlo,iyGlo=%d,%d\n",ixGlo,iyGlo));
275 //_____________________________________________________________________________
277 AliMUONTriggerSegmentationV2::GetPadLoc2Glo(Int_t ix, Int_t iy,
278 Int_t& ixGlo, Int_t& iyGlo) const
281 // Converts from local (in PC convention) to (ix,iy) to global (ix,iy)
284 ixGlo=iyGlo=-1; // starts with invalid values
286 if ( fPlaneType == kBendingPlane )
288 ixGlo = 10*LineNumber() + ix;
289 iyGlo = iy - fgIntOffset;
291 else if ( fPlaneType == kNonBendingPlane )
293 Int_t i = fSlat->GetLayer(0)->FindPCBIndex(ix-fgIntOffset);
296 AliError(Form("Invalid local (ix=%d,iy=%d) ?",ix,iy));
299 AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ix-fgIntOffset);
300 iyGlo = ix - pcb->Ixmin() - fgIntOffset;
301 if ( LineNumber() == 5 ) ++i;
302 ixGlo = 10*LineNumber() + i + fgIntOffset;
306 //_____________________________________________________________________________
308 AliMUONTriggerSegmentationV2::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
309 Int_t& ix, Int_t& iy) const
312 // Converts from global (ix,iy) to local (ix,iy) (in PC convention)
315 ix=iy=-1; // starts with invalid values
317 if ( abs(ixGlo) == 51 ) return;
319 Int_t column = ModuleColNum(ixGlo);
321 if ( fPlaneType == kBendingPlane )
323 ix = column + fgIntOffset;
324 iy = iyGlo + fgIntOffset;
326 else if ( fPlaneType == kNonBendingPlane )
328 if ( LineNumber()==5 ) --column;
329 AliMpPCB* pcb = fSlat->GetLayer(0)->GetPCB(column);
332 AliError(Form("Invalid global (ix=%d,iy=%d)",ixGlo,iyGlo));
335 ix = pcb->Ixmin() + iyGlo + fgIntOffset;
340 //_____________________________________________________________________________
342 AliMUONTriggerSegmentationV2::GiveTestPoints(Int_t&,Float_t*,Float_t*) const
344 AliFatal("Not Implemented");
347 //_____________________________________________________________________________
349 AliMUONTriggerSegmentationV2::HasPad(Float_t x, Float_t y, Float_t)
352 // Well, 2 implementations are possible here
353 // Either reuse HasPad(int,int), or get it from scratch using
354 // underlying fSlatSegmentation.
355 // Took second option, but w/o checking whether this is the faster.
356 // The second option is commented out below, for the record.
359 // GetPadI(x,y,z,ix,iy);
361 // IGlo2ILoc(ix,iy,ixLA,iyLA);
363 // LA2PC(ixLA,iyLA,ixPC,iyPC);
364 // Bool_t ok1 = HasPad(ixPC,iyPC);
367 fSlatSegmentation->PadByPosition(TVector2(x+fSlat->DX(),y+fSlat->DY()),
369 return pad.IsValid();
372 //_____________________________________________________________________________
374 AliMUONTriggerSegmentationV2::HasPad(Int_t ixGlo, Int_t iyGlo)
377 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
378 return fSlatSegmentation->HasPad(AliMpIntPair(ixLA,iyLA));
381 //_____________________________________________________________________________
383 AliMUONTriggerSegmentationV2::IGlo2ILoc(Int_t ixGlo, Int_t iyGlo,
384 Int_t& ixLA, Int_t& iyLA)
387 GetPadGlo2Loc(ixGlo,iyGlo,ixPC,iyPC);
388 PC2LA(ixPC,iyPC,ixLA,iyLA);
391 //_____________________________________________________________________________
393 AliMUONTriggerSegmentationV2::ILoc2IGlo(Int_t ixLA, Int_t iyLA,
394 Int_t& ixGlo, Int_t& iyGlo)
397 LA2PC(ixLA,iyLA,ixPC,iyPC);
398 GetPadLoc2Glo(ixPC,iyPC,ixGlo,iyGlo);
401 //_____________________________________________________________________________
403 AliMUONTriggerSegmentationV2::Init(int)
405 AliWarning("Not Implemented because not needed ;-)");
408 //_____________________________________________________________________________
410 AliMUONTriggerSegmentationV2::ISector()
412 // FIXME: remove the usage of ISector from all the code.
416 //_____________________________________________________________________________
417 void AliMUONTriggerSegmentationV2::IntegrationLimits(Float_t& x1,
422 // x1 : hit x(y) position
423 // x2 : x(y) coordinate of the main strip
424 // x3 : current strip real x(y) coordinate
425 // x4 : dist. between x(y) hit pos. and the closest border of the current strip
427 // Note : need to return (only) x4.
429 AliFatal("Check me before usage. ResponseTrigger does not use me, while"
430 "ResponseTriggerV1 does ?");
433 fSlatSegmentation->PadByPosition(TVector2(fXhit,fYhit),kFALSE);
434 if ( !strip.IsValid() )
436 AliWarning(Form("%s got invalid fXhit,fYhit=%e,%e\n",
437 fSlatSegmentation->GetName(),fXhit,fYhit));
442 Double_t xstrip = strip.Position().X();
443 Double_t ystrip = strip.Position().Y();
444 AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
445 fXhit,fYhit,xstrip,ystrip));
446 x1 = (fPlaneType==kBendingPlane) ? fYhit : fXhit;
447 x2 = (fPlaneType==kBendingPlane) ? ystrip : xstrip;
448 x3 = (fPlaneType==kBendingPlane) ?
449 fCurrentPad.Position().Y() : fCurrentPad.Position().X();
452 if (fPlaneType==kBendingPlane)
454 xmin = x3 - fCurrentPad.Dimensions().X();
455 xmax = x3 + fCurrentPad.Dimensions().X();
459 xmin = x3 - fCurrentPad.Dimensions().Y();
460 xmax = x3 + fCurrentPad.Dimensions().Y();
462 // dist. between the hit and the closest border of the current strip
463 x4 = (TMath::Abs(xmax-x1) > TMath::Abs(xmin-x1)) ?
464 TMath::Abs(xmin-x1):TMath::Abs(xmax-x1);
466 AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
467 fPlaneType,x1,x2,x3,x4,xmin,xmax));
472 //_____________________________________________________________________________
474 AliMUONTriggerSegmentationV2::Ix()
476 if ( fCurrentPad.IsValid() )
479 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
480 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
486 //_____________________________________________________________________________
488 AliMUONTriggerSegmentationV2::Iy()
490 if ( fCurrentPad.IsValid() )
493 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
494 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
501 //_____________________________________________________________________________
503 AliMUONTriggerSegmentationV2::LA2PC(Int_t ixLA, Int_t iyLA,
504 Int_t& ixPC, Int_t& iyPC)
507 // From LA to PC conventions for integers indices.
511 if ( ixLA<0 || iyLA<0 ) return;
516 if ( fPlaneType == kBendingPlane )
518 if ( LineNumber()==5 )
522 if ( LineNumber()==4 && ixLA==0 )
528 AliDebug(3,Form("ix,iy LA (%d,%d) -> PC (%d,%d)",ixLA,iyLA,ixPC,iyPC));
532 //_____________________________________________________________________________
534 AliMUONTriggerSegmentationV2::LineNumber() const
536 return 10-fLineNumber;
539 //_____________________________________________________________________________
541 AliMUONTriggerSegmentationV2::ModuleColNum(Int_t ixGlo) const
543 // returns column number (from 0 to 6) in which the (global) module
544 // ix is sitting (could return 7 if ix=isec)
545 return TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10-1;
548 //_____________________________________________________________________________
550 AliMUONTriggerSegmentationV2::MorePads()
552 AliFatal("Not implemented");
556 //_____________________________________________________________________________
557 void AliMUONTriggerSegmentationV2::Neighbours(Int_t /*iX*/, Int_t /*iY*/,
562 //-----------------BENDING-----------------------------------------
563 // Returns list of 10 next neighbours for given X strip (ix, iy)
564 // neighbour number 4 in the list -
565 // neighbour number 3 in the list |
566 // neighbour number 2 in the list |_ Upper part
567 // neighbour number 1 in the list |
568 // neighbour number 0 in the list -
570 // neighbour number 5 in the list -
571 // neighbour number 6 in the list | _ Lower part
572 // neighbour number 7 in the list |
573 // neighbour number 8 in the list |
574 // neighbour number 9 in the list -
576 //-----------------NON-BENDING-------------------------------------
577 // Returns list of 10 next neighbours for given Y strip (ix, iy)
578 // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
579 // \_______/ \_______/
581 AliFatal("Please implement me");
584 //_____________________________________________________________________________
586 AliMUONTriggerSegmentationV2::NextPad()
588 AliFatal("Not implemented");
591 //_____________________________________________________________________________
593 AliMUONTriggerSegmentationV2::Npx() const
595 return 124;// FIXME: this should not have to be done, if only we'd stick
596 // to a local (ix,iy) convention !!!
597 // return fSlatSegmentation->MaxPadIndexX()+1;
600 //_____________________________________________________________________________
602 AliMUONTriggerSegmentationV2::Npy() const
605 // return fSlatSegmentation->MaxPadIndexY()+1;
608 //_____________________________________________________________________________
610 AliMUONTriggerSegmentationV2::PC2LA(Int_t ixPC, Int_t iyPC,
611 Int_t& ixLA, Int_t& iyLA)
614 // From PC to LA conventions for integers indices.
618 if ( ixPC<0 || iyPC<0 ) return;
623 if ( fPlaneType == kBendingPlane )
625 if ( LineNumber()==5 )
629 if ( LineNumber()==4 && ixLA==0 )
635 AliDebug(3,Form("ix,iy PC (%d,%d) -> LA (%d,%d)",ixPC,iyPC,ixLA,iyLA));
638 //_____________________________________________________________________________
640 AliMUONTriggerSegmentationV2::Print(Option_t* opt) const
644 cout << "DetElemId=" << fDetElemId << " PlaneType="
645 << fPlaneType << " Npx=" << Npx() << " Npy=" << Npy() << endl;
646 if ( ( sopt.Contains("SEG") || sopt.Contains("ALL") ) && fSlatSegmentation )
648 fSlatSegmentation->Print();
650 if ( sopt.Contains("ALL") && fSlat )
656 //_____________________________________________________________________________
658 AliMUONTriggerSegmentationV2::ReadMappingData()
660 fSlatSegmentation = dynamic_cast<AliMpTriggerSegmentation*>
661 (AliMUONSegmentationManager::Segmentation(fDetElemId,fPlaneType));
663 if (!fSlatSegmentation)
665 AliFatal("Wrong segmentation type encountered");
667 fSlat = fSlatSegmentation->Slat();
668 TString id(fSlat->GetID());
669 Ssiz_t pos = id.Last('L');
672 AliFatal(Form("Cannot infer line number for slat %s",id.Data()));
674 fLineNumber = TString(id(pos+1),1).Atoi();
677 //_____________________________________________________________________________
679 AliMUONTriggerSegmentationV2::Sector(Int_t ix, Int_t iy)
682 IGlo2ILoc(ix,iy,ixLA,iyLA);
683 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
684 if ( !pad.IsValid() ) return -1;
685 return Code(ixLA,iyLA);
687 // AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ixLA);
690 // AliError(Form("Could not find a pcb at (%d,%d) for slat %s",
691 // ix,iy,fSlat->GetName()));
694 // if ( pcb->PadSizeX()==-1.0 )
696 // // special case of column 7 non-bending.
697 // return SPECIAL_SECTOR;
699 // return fSlat->GetLayer(0)->FindPCBIndex(ixLA);
702 //_____________________________________________________________________________
704 AliMUONTriggerSegmentationV2::Sector(Float_t, Float_t)
706 AliFatal("Not implemented");
710 //_____________________________________________________________________________
712 AliMUONTriggerSegmentationV2::SetCorrFunc(Int_t,TF1*)
714 AliFatal("Not Implemented");
717 //_____________________________________________________________________________
719 AliMUONTriggerSegmentationV2::SetDAnod(float)
721 AliFatal("Not Implemented");
724 //_____________________________________________________________________________
726 AliMUONTriggerSegmentationV2::SetHit(Float_t x, Float_t y)
732 // insure we're within the slat limits. If not, issue an error and sets
733 // the current hit to slat center.
734 // FIXME: this should probably a) not happen at all b) be a fatal error
736 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
737 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
739 AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
740 " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
747 //_____________________________________________________________________________
749 AliMUONTriggerSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
754 //_____________________________________________________________________________
756 AliMUONTriggerSegmentationV2::SetPad(Int_t ix, Int_t iy)
759 IGlo2ILoc(ix,iy,ixLA,iyLA);
760 fCurrentPad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
761 if ( !fCurrentPad.IsValid() )
763 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
767 //_____________________________________________________________________________
769 AliMUONTriggerSegmentationV2::SetPadSize(float,float)
771 AliFatal("Not Implemented");
774 //_____________________________________________________________________________
776 AliMUONTriggerSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
778 AliFatal("Not Implemented");
782 //_____________________________________________________________________________
784 AliMUONTriggerSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
786 AliFatal("Not Implemented");
789 //_____________________________________________________________________________
791 AliMUONTriggerSegmentationV2::Streamer(TBuffer &R__b)
793 if (R__b.IsReading())
795 AliMUONTriggerSegmentationV2::Class()->ReadBuffer(R__b, this);
800 AliMUONTriggerSegmentationV2::Class()->WriteBuffer(R__b, this);