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 // -------------------------------------
19 // Class AliMUONTriggerSegmentation
20 // -------------------------------------
21 // Segmentation for MUON trigger stations using
22 // the mapping package
24 #include "AliMUONTriggerSegmentation.h"
27 #include "AliMpTrigger.h"
28 #include "AliMpTriggerSegmentation.h"
29 #include "AliMpSlat.h"
33 #include "Riostream.h"
38 ClassImp(AliMUONTriggerSegmentation)
43 // Int_t SPECIAL_SECTOR = 8;
46 Int_t CODEMAKER(1000);
48 Int_t Code(Int_t ixLA, Int_t iyLA)
50 return iyLA*CODEMAKER + ixLA;
53 void Decode(Int_t code, Int_t& ixLA, Int_t& iyLA)
55 iyLA = code/CODEMAKER;
56 ixLA = code - iyLA*CODEMAKER;
60 //_____________________________________________________________________________
61 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation()
62 : AliMUONVGeometryDESegmentation(),
64 fPlaneType(AliMp::kBendingPlane),
72 /// Default ctor (empty).
74 AliDebug(1,Form("this=%p default (empty) ctor",this));
77 //_____________________________________________________________________________
78 AliMUONTriggerSegmentation::AliMUONTriggerSegmentation(
79 AliMpVSegmentation* segmentation,
80 Int_t detElemId, AliMp::PlaneType bendingOrNonBending)
81 : AliMUONVGeometryDESegmentation(),
82 fDetElemId(detElemId),
83 fPlaneType(bendingOrNonBending),
93 fSlatSegmentation = dynamic_cast<AliMpTriggerSegmentation*>(segmentation);
94 if (fSlatSegmentation)
95 fSlat = fSlatSegmentation->Slat();
97 AliFatal("Wrong mapping segmentation type");
99 TString id(fSlat->GetID());
100 Ssiz_t pos = id.Last('L');
103 AliFatal(Form("Cannot infer line number for slat %s",id.Data()));
105 fLineNumber = TString(id(pos+1),1).Atoi();
107 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
108 ( (bendingOrNonBending==AliMp::kBendingPlane)?"Bending":"NonBending" ),
112 //_____________________________________________________________________________
113 AliMUONTriggerSegmentation::~AliMUONTriggerSegmentation()
117 AliDebug(1,Form("this=%p",this));
120 //_____________________________________________________________________________
122 AliMUONTriggerSegmentation::CorrFunc(Int_t) const
126 AliFatal("Not implemented");
130 //_____________________________________________________________________________
132 AliMUONTriggerSegmentation::Distance2AndOffset(Int_t, Int_t,
133 Float_t, Float_t, Int_t*)
137 AliFatal("Not implemented");
141 //_____________________________________________________________________________
143 AliMUONTriggerSegmentation::Draw(Option_t*)
147 AliFatal("Not Implemented");
150 //_____________________________________________________________________________
152 AliMUONTriggerSegmentation::Dpx() const
156 AliFatal("Not Implemented");
160 //_____________________________________________________________________________
162 AliMUONTriggerSegmentation::Dpy() const
166 AliFatal("Not Implemented");
170 //_____________________________________________________________________________
172 AliMUONTriggerSegmentation::Dpx(Int_t sectorCode) const
174 /// Get pad size in x
177 Decode(sectorCode,ixLA,iyLA);
178 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
179 if ( !pad.IsValid() ) return 0.0;
180 return pad.Dimensions().X()*2.0;
183 //_____________________________________________________________________________
185 AliMUONTriggerSegmentation::Dpy(Int_t sectorCode) const
187 /// Get pad size in y
190 Decode(sectorCode,ixLA,iyLA);
191 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
192 if ( !pad.IsValid() ) return 0.0;
193 return pad.Dimensions().Y()*2.0;
196 //_____________________________________________________________________________
198 AliMUONTriggerSegmentation::FirstPad(Float_t /*xhit*/, Float_t /*yhit*/, Float_t /*zhit*/,
199 Float_t /*dx*/, Float_t /*dy*/)
203 AliFatal("Not implemented");
206 //_____________________________________________________________________________
208 AliMUONTriggerSegmentation::GetAnod(Float_t) const
212 AliFatal("Not implemented");
216 //_____________________________________________________________________________
217 AliMUONGeometryDirection
218 AliMUONTriggerSegmentation::GetDirection()
222 //AliWarning("Not Implemented");
223 return kDirUndefined;
226 //______________________________________________________________________________
227 const AliMpVSegmentation*
228 AliMUONTriggerSegmentation::GetMpSegmentation() const
230 /// Returns the mapping segmentation
231 /// (provides access to electronics info)
233 return fSlatSegmentation;
236 //_____________________________________________________________________________
238 AliMUONTriggerSegmentation::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
242 AliFatal("Not Implemented");
245 //_____________________________________________________________________________
247 AliMUONTriggerSegmentation::GetPadC(Int_t ix, Int_t iy,
248 Float_t& x, Float_t& y, Float_t& z)
250 /// Transform from pad to real coordinates
256 //_____________________________________________________________________________
258 AliMUONTriggerSegmentation::GetPadC(Int_t ixGlo, Int_t iyGlo,
259 Float_t& x, Float_t& y)
261 /// Transform from pad to real coordinates
264 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
265 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
266 x = pad.Position().X();
267 y = pad.Position().Y();
270 //_____________________________________________________________________________
272 AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y, Float_t,
273 Int_t& ix, Int_t& iy)
275 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
280 //_____________________________________________________________________________
282 AliMUONTriggerSegmentation::GetPadI(Float_t x, Float_t y,
283 Int_t& ixGlo, Int_t& iyGlo)
285 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
287 AliDebug(2,Form("%s x=%e y=%e ixGlo,iyGlo=%d,%d\n",
288 fSlatSegmentation->GetName(),
292 fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
294 if ( pad != AliMpPad::Invalid() )
296 Int_t ix = pad.GetIndices().GetFirst();
297 Int_t iy = pad.GetIndices().GetSecond();
298 ILoc2IGlo(ix,iy,ixGlo,iyGlo);
304 AliDebug(2,Form("ixGlo,iyGlo=%d,%d\n",ixGlo,iyGlo));
307 //_____________________________________________________________________________
309 AliMUONTriggerSegmentation::GetPadLoc2Glo(Int_t ix, Int_t iy,
310 Int_t& ixGlo, Int_t& iyGlo) const
312 /// Converts from local (in PC convention) to (ix,iy) to global (ix,iy)
314 ixGlo=iyGlo=-1; // starts with invalid values
316 if ( fPlaneType == AliMp::kBendingPlane )
318 ixGlo = 10*LineNumber() + ix;
319 iyGlo = iy - fgIntOffset;
321 else if ( fPlaneType == AliMp::kNonBendingPlane )
323 Int_t i = fSlat->GetLayer(0)->FindPCBIndex(ix-fgIntOffset);
326 AliError(Form("Invalid local (ix=%d,iy=%d) ?",ix,iy));
329 AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ix-fgIntOffset);
330 iyGlo = ix - pcb->Ixmin() - fgIntOffset;
331 if ( LineNumber() == 5 ) ++i;
332 ixGlo = 10*LineNumber() + i + fgIntOffset;
336 //_____________________________________________________________________________
338 AliMUONTriggerSegmentation::GetPadGlo2Loc(Int_t ixGlo, Int_t iyGlo,
339 Int_t& ix, Int_t& iy) const
341 /// Converts from global (ix,iy) to local (ix,iy) (in PC convention)
343 ix=iy=-1; // starts with invalid values
345 if ( abs(ixGlo) == 51 ) return;
347 Int_t column = ModuleColNum(ixGlo);
349 if ( fPlaneType == AliMp::kBendingPlane )
351 ix = column + fgIntOffset;
352 iy = iyGlo + fgIntOffset;
354 else if ( fPlaneType == AliMp::kNonBendingPlane )
356 if ( LineNumber()==5 ) --column;
357 AliMpPCB* pcb = fSlat->GetLayer(0)->GetPCB(column);
360 AliError(Form("Invalid global (ix=%d,iy=%d)",ixGlo,iyGlo));
363 ix = pcb->Ixmin() + iyGlo + fgIntOffset;
368 //_____________________________________________________________________________
370 AliMUONTriggerSegmentation::GiveTestPoints(Int_t& /*n*/,
371 Float_t* /*x*/, Float_t*/*y*/) const
375 AliFatal("Not Implemented");
378 //_____________________________________________________________________________
380 AliMUONTriggerSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
382 /// Returns true if a pad exists in the given position
384 /// Well, 2 implementations are possible here
385 /// Either reuse HasPad(int,int), or get it from scratch using
386 /// underlying fSlatSegmentation.
387 /// Took second option, but w/o checking whether this is the faster.
388 /// The second option is commented out below, for the record.
391 // GetPadI(x,y,z,ix,iy);
393 // IGlo2ILoc(ix,iy,ixLA,iyLA);
395 // LA2PC(ixLA,iyLA,ixPC,iyPC);
396 // Bool_t ok1 = HasPad(ixPC,iyPC);
399 fSlatSegmentation->PadByPosition(TVector2(x,y),kFALSE);
400 return pad.IsValid();
403 //_____________________________________________________________________________
405 AliMUONTriggerSegmentation::HasPad(Int_t ixGlo, Int_t iyGlo)
407 /// Returns true if a pad with given indices exists
410 IGlo2ILoc(ixGlo,iyGlo,ixLA,iyLA);
411 return fSlatSegmentation->HasPad(AliMpIntPair(ixLA,iyLA));
414 //_____________________________________________________________________________
416 AliMUONTriggerSegmentation::IGlo2ILoc(Int_t ixGlo, Int_t iyGlo,
417 Int_t& ixLA, Int_t& iyLA) const
419 /// \todo FIXME: add comment
422 GetPadGlo2Loc(ixGlo,iyGlo,ixPC,iyPC);
423 PC2LA(ixPC,iyPC,ixLA,iyLA);
426 //_____________________________________________________________________________
428 AliMUONTriggerSegmentation::ILoc2IGlo(Int_t ixLA, Int_t iyLA,
429 Int_t& ixGlo, Int_t& iyGlo) const
431 /// \todo FIXME: add comment
434 LA2PC(ixLA,iyLA,ixPC,iyPC);
435 GetPadLoc2Glo(ixPC,iyPC,ixGlo,iyGlo);
438 //_____________________________________________________________________________
440 AliMUONTriggerSegmentation::ISector()
442 /// \todo FIXME: remove the usage of ISector from all the code.
447 //_____________________________________________________________________________
448 void AliMUONTriggerSegmentation::IntegrationLimits(Float_t& x1,
453 /// \param x1 : hit x(y) position
454 /// \param x2 : x(y) coordinate of the main strip
455 /// \param x3 : current strip real x(y) coordinate
456 /// \param x4 : dist. between x(y) hit pos. and the closest border of the current strip
458 /// Note : need to return (only) x4.
460 AliFatal("Check me before usage. ResponseTrigger does not use me, while"
461 "ResponseTriggerV1 does ?");
464 fSlatSegmentation->PadByPosition(TVector2(fXhit,fYhit),kFALSE);
465 if ( !strip.IsValid() )
467 AliWarning(Form("%s got invalid fXhit,fYhit=%e,%e\n",
468 fSlatSegmentation->GetName(),fXhit,fYhit));
473 Double_t xstrip = strip.Position().X();
474 Double_t ystrip = strip.Position().Y();
475 AliDebug(1,Form("fXhit,Yhit=%e,%e xstrip,ystrip=%e,%e\n",
476 fXhit,fYhit,xstrip,ystrip));
477 x1 = (fPlaneType==AliMp::kBendingPlane) ? fYhit : fXhit;
478 x2 = (fPlaneType==AliMp::kBendingPlane) ? ystrip : xstrip;
479 x3 = (fPlaneType==AliMp::kBendingPlane) ?
480 fCurrentPad.Position().Y() : fCurrentPad.Position().X();
483 if (fPlaneType==AliMp::kBendingPlane)
485 xmin = x3 - fCurrentPad.Dimensions().X();
486 xmax = x3 + fCurrentPad.Dimensions().X();
490 xmin = x3 - fCurrentPad.Dimensions().Y();
491 xmax = x3 + fCurrentPad.Dimensions().Y();
493 // dist. between the hit and the closest border of the current strip
494 x4 = (TMath::Abs(xmax-x1) > TMath::Abs(xmin-x1)) ?
495 TMath::Abs(xmin-x1):TMath::Abs(xmax-x1);
497 AliDebug(1,Form("Bending %d x1=%e x2=%e x3=%e x4=%e xmin,max=%e,%e\n",
498 fPlaneType,x1,x2,x3,x4,xmin,xmax));
503 //_____________________________________________________________________________
505 AliMUONTriggerSegmentation::Ix()
507 /// Current pad cursor during disintegration
510 if ( fCurrentPad.IsValid() )
513 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
514 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
520 //_____________________________________________________________________________
522 AliMUONTriggerSegmentation::Iy()
524 /// Current pad cursor during disintegration
527 if ( fCurrentPad.IsValid() )
530 ILoc2IGlo(fCurrentPad.GetIndices().GetFirst(),
531 fCurrentPad.GetIndices().GetSecond(),ixGlo,iyGlo);
538 //_____________________________________________________________________________
540 AliMUONTriggerSegmentation::LA2PC(Int_t ixLA, Int_t iyLA,
541 Int_t& ixPC, Int_t& iyPC) const
543 /// From LA to PC conventions for integers indices.
547 if ( ixLA<0 || iyLA<0 ) return;
552 if ( fPlaneType == AliMp::kBendingPlane )
554 if ( LineNumber()==5 )
558 if ( LineNumber()==4 && ixLA==0 )
564 AliDebug(3,Form("ix,iy LA (%d,%d) -> PC (%d,%d)",ixLA,iyLA,ixPC,iyPC));
568 //_____________________________________________________________________________
570 AliMUONTriggerSegmentation::LineNumber() const
572 /// \todo FIXME: add comment
574 return 10-fLineNumber;
577 //_____________________________________________________________________________
579 AliMUONTriggerSegmentation::ModuleColNum(Int_t ixGlo) const
581 /// returns column number (from 0 to 6) in which the (global) module
582 /// ix is sitting (could return 7 if ix=isec)
584 return TMath::Abs(ixGlo)-Int_t(TMath::Abs(ixGlo)/10)*10-1;
587 //_____________________________________________________________________________
589 AliMUONTriggerSegmentation::MorePads()
593 AliFatal("Not implemented");
597 //_____________________________________________________________________________
598 void AliMUONTriggerSegmentation::Neighbours(Int_t /*iX*/, Int_t /*iY*/,
605 //-----------------BENDING-----------------------------------------
606 // Returns list of 10 next neighbours for given X strip (ix, iy)
607 // neighbour number 4 in the list -
608 // neighbour number 3 in the list |
609 // neighbour number 2 in the list |_ Upper part
610 // neighbour number 1 in the list |
611 // neighbour number 0 in the list -
613 // neighbour number 5 in the list -
614 // neighbour number 6 in the list | _ Lower part
615 // neighbour number 7 in the list |
616 // neighbour number 8 in the list |
617 // neighbour number 9 in the list -
619 //-----------------NON-BENDING-------------------------------------
620 // Returns list of 10 next neighbours for given Y strip (ix, iy)
621 // neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list
622 // \_______/ \_______/
624 AliFatal("Please implement me");
627 //_____________________________________________________________________________
629 AliMUONTriggerSegmentation::NextPad()
633 AliFatal("Not implemented");
636 //_____________________________________________________________________________
638 AliMUONTriggerSegmentation::Npx() const
640 /// Maximum number of Pads in x
641 /// hard coded for the time being
643 return 124;// FIXME: this should not have to be done, if only we'd stick
644 // to a local (ix,iy) convention !!!
645 // return fSlatSegmentation->MaxPadIndexX()+1;
648 //_____________________________________________________________________________
650 AliMUONTriggerSegmentation::Npy() const
652 /// Maximum number of Pads in y
653 /// hard coded for the time being
656 // return fSlatSegmentation->MaxPadIndexY()+1;
659 //_____________________________________________________________________________
661 AliMUONTriggerSegmentation::PC2LA(Int_t ixPC, Int_t iyPC,
662 Int_t& ixLA, Int_t& iyLA) const
664 /// From PC to LA conventions for integers indices.
668 if ( ixPC<0 || iyPC<0 ) return;
673 if ( fPlaneType == AliMp::kBendingPlane )
675 if ( LineNumber()==5 )
679 if ( LineNumber()==4 && ixLA==0 )
685 AliDebug(3,Form("ix,iy PC (%d,%d) -> LA (%d,%d)",ixPC,iyPC,ixLA,iyLA));
688 //_____________________________________________________________________________
690 AliMUONTriggerSegmentation::Print(Option_t* opt) const
696 cout << "DetElemId=" << fDetElemId << " PlaneType="
697 << fPlaneType << " Npx=" << Npx() << " Npy=" << Npy() << endl;
698 if ( ( sopt.Contains("SEG") || sopt.Contains("ALL") ) && fSlatSegmentation )
700 fSlatSegmentation->Print();
702 if ( sopt.Contains("ALL") && fSlat )
708 //_____________________________________________________________________________
710 AliMUONTriggerSegmentation::Sector(Int_t ix, Int_t iy)
712 /// Calculate sector from pad coordinates
715 IGlo2ILoc(ix,iy,ixLA,iyLA);
716 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kFALSE);
717 if ( !pad.IsValid() ) return -1;
718 return Code(ixLA,iyLA);
720 // AliMpPCB* pcb = fSlat->GetLayer(0)->FindPCB(ixLA);
723 // AliError(Form("Could not find a pcb at (%d,%d) for slat %s",
724 // ix,iy,fSlat->GetName()));
727 // if ( pcb->PadSizeX()==-1.0 )
729 // // special case of column 7 non-bending.
730 // return SPECIAL_SECTOR;
732 // return fSlat->GetLayer(0)->FindPCBIndex(ixLA);
735 //_____________________________________________________________________________
737 AliMUONTriggerSegmentation::Sector(Float_t, Float_t)
741 AliFatal("Not implemented");
745 //_____________________________________________________________________________
747 AliMUONTriggerSegmentation::SetCorrFunc(Int_t,TF1*)
751 AliFatal("Not Implemented");
754 //_____________________________________________________________________________
756 AliMUONTriggerSegmentation::SetDAnod(Float_t)
760 AliFatal("Not Implemented");
763 //_____________________________________________________________________________
765 AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y)
768 /// Sets virtual hit position, needed for evaluating pad response
769 /// outside the tracking program
775 // insure we're within the slat limits. If not, issue an error and sets
776 // the current hit to slat center.
777 // FIXME: this should probably a) not happen at all b) be a fatal error
779 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
780 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
782 AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
783 " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
790 //_____________________________________________________________________________
792 AliMUONTriggerSegmentation::SetHit(Float_t x, Float_t y, Float_t)
795 /// Sets virtual hit position, needed for evaluating pad response
796 /// outside the tracking program
801 //_____________________________________________________________________________
803 AliMUONTriggerSegmentation::SetPad(Int_t ix, Int_t iy)
805 /// Set pad position.
806 /// Sets virtual pad coordinates, needed for evaluating pad response
807 /// outside the tracking program.
810 IGlo2ILoc(ix,iy,ixLA,iyLA);
811 fCurrentPad = fSlatSegmentation->PadByIndices(AliMpIntPair(ixLA,iyLA),kTRUE);
812 if ( !fCurrentPad.IsValid() )
814 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
818 //_____________________________________________________________________________
820 AliMUONTriggerSegmentation::SetPadSize(Float_t,Float_t)
824 AliFatal("Not Implemented");
827 //_____________________________________________________________________________
829 AliMUONTriggerSegmentation::SigGenCond(Float_t,Float_t,Float_t)
833 AliFatal("Not Implemented");
837 //_____________________________________________________________________________
839 AliMUONTriggerSegmentation::SigGenInit(Float_t,Float_t,Float_t)
843 AliFatal("Not Implemented");