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 "AliMUONSt345SlatSegmentationV2.h"
19 #include "AliMUONConstants.h"
21 #include "AliMpArea.h"
22 #include "AliMpSlat.h"
23 #include "AliMpSlatSegmentation.h"
25 // FIXME: we should not need access to PCB at this level
26 // if the Dpx, Dpy, Sector interface would not be used.
27 // Investigate instead to direct use of AliMpVSegmentation and AliMpPad
28 // from the clusterFinder ? // :aphecetc:20050722
29 // or, or ... have the AliMpSlat handles the notion of zone, finally
30 // (where "zone" in mapping is equivalent to "sector" here), and thus
31 // let AliMpSlat offer the interface to get information similar to what
32 // Dpx, Dpy, Sector offer now to the clustering. That indeed should be
33 // handled directly at the level of AliMpVSegmentation...
34 #include "AliMpVPadIterator.h"
38 #include "Riostream.h"
41 ClassImp(AliMUONSt345SlatSegmentationV2)
48 //_____________________________________________________________________________
49 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2()
50 : AliMUONVGeometryDESegmentation(),
52 fPlaneType(kBendingPlane),
59 AliDebug(1,Form("this=%p default (empty) ctor",this));
62 //_____________________________________________________________________________
63 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2(
64 AliMpVSegmentation* segmentation,
65 Int_t detElemId, AliMpPlaneType bendingOrNonBending)
66 : AliMUONVGeometryDESegmentation(),
67 fDetElemId(detElemId),
68 fPlaneType(bendingOrNonBending),
79 fSlatSegmentation = dynamic_cast<AliMpSlatSegmentation*>(segmentation);
80 if (fSlatSegmentation)
81 fSlat = fSlatSegmentation->Slat();
83 AliFatal("Wrong mapping segmentation type");
85 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
86 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
90 //_____________________________________________________________________________
91 AliMUONSt345SlatSegmentationV2::~AliMUONSt345SlatSegmentationV2()
93 AliDebug(1,Form("dtor this=%p",this));
97 //_____________________________________________________________________________
99 AliMUONSt345SlatSegmentationV2::CorrFunc(Int_t) const
101 AliFatal("Not Implemented");
105 //_____________________________________________________________________________
107 AliMUONSt345SlatSegmentationV2::Distance2AndOffset(Int_t,Int_t,
108 Float_t,Float_t,Int_t*)
110 AliFatal("Not Implemented");
114 //_____________________________________________________________________________
116 AliMUONSt345SlatSegmentationV2::Draw(Option_t*)
118 AliFatal("Not Implemented");
121 //_____________________________________________________________________________
123 AliMUONSt345SlatSegmentationV2::Dpx() const
125 AliFatal("Not Implemented");
129 //_____________________________________________________________________________
131 AliMUONSt345SlatSegmentationV2::Dpy() const
133 AliFatal("Not Implemented");
137 //_____________________________________________________________________________
139 AliMUONSt345SlatSegmentationV2::Dpx(int ipcb) const
141 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
144 AliFatal("pcb is null!");
146 return pcb->PadSizeX();
149 //_____________________________________________________________________________
151 AliMUONSt345SlatSegmentationV2::Dpy(int ipcb) const
153 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
156 AliFatal("pcb is null!");
158 return pcb->PadSizeY();
161 //_____________________________________________________________________________
163 AliMUONSt345SlatSegmentationV2::FirstPad(Float_t xhit, Float_t yhit,
165 Float_t dx, Float_t dy)
167 // OK. We will do it in 2 steps. First get the area over which to
168 // iterate, based on hit coordinates and (dx,dy). This first step
169 // has nothing to do with segmentation in the first place, but with
170 // how we simulate the fact that at some point the charge is shared
171 // amongst several pads.
172 // The second step is the actual pad iteration and is handled by
173 // a specific class (which has to do only with iteration...)
175 // FIXME: this method should not be here in the first place, IMHO.
178 // Find the wire position (center of charge distribution)
179 Float_t xwire = GetAnod(xhit);
183 Double_t x01 = xwire - dx;
184 Double_t x02 = xwire + dx;
185 Double_t y01 = yhit - dy;
186 Double_t y02 = yhit + dy;
188 Double_t xext = x02 - x01;
189 Double_t yext = y02 - y01;
191 // we do not check area here, as we assume the iterator
192 // will do it, and will possibly truncate it if needed.
193 // Note that we convert the area position to a reference frame
194 // located in the lower-left corner of the slat, instead of its
196 // AliMpArea area(TVector2((x01+x02)/2.0+fSlat->DX(),
197 // (y01+y02)/2.0+fSlat->DY()),
198 // TVector2(xext/2.0,yext/2.0));
199 AliMpArea area(TVector2((x01+x02)/2.0,(y01+y02)/2.0),
200 TVector2(xext/2.0,yext/2.0));
204 fPadIterator = fSlatSegmentation->CreateIterator(area);
206 fPadIterator->First();
208 fCurrentPad = fPadIterator->CurrentItem();
210 if ( !fCurrentPad.IsValid() )
212 AliError(Form("Cannot get a valid pad for (xhit,yhit,dx,dy)=(%e,%e,%e,%e)",xhit,yhit,dx,dy));
215 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d slat=%s",
217 fCurrentPad.GetIndices().GetFirst(),
218 fCurrentPad.GetIndices().GetSecond(),fSlat->GetID()));
221 //_____________________________________________________________________________
223 AliMUONSt345SlatSegmentationV2::GetAnod(Float_t xhit) const
225 // Gets the x-coordinate of the wire which is the closest to xhit.
227 Int_t n = Int_t(xhit/AliMUONConstants::Pitch());
228 Float_t wire = (xhit>0) ? n+0.5 : n-0.5;
229 return AliMUONConstants::Pitch()*wire;
232 //_____________________________________________________________________________
233 AliMUONGeometryDirection
234 AliMUONSt345SlatSegmentationV2::GetDirection()
236 //AliWarning("Not Implemented");
237 return kDirUndefined;
240 //______________________________________________________________________________
241 const AliMpVSegmentation*
242 AliMUONSt345SlatSegmentationV2::GetMpSegmentation() const
244 // Returns the mapping segmentation
245 // (provides access to electronics info)
247 return fSlatSegmentation;
251 //_____________________________________________________________________________
253 AliMUONSt345SlatSegmentationV2::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
255 AliFatal("Not Implemented");
258 //_____________________________________________________________________________
260 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
261 Float_t& x, Float_t& y, Float_t& z)
267 //_____________________________________________________________________________
269 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
270 Float_t& x, Float_t& y)
273 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
274 x = pad.Position().X();
275 y = pad.Position().Y();
279 //_____________________________________________________________________________
281 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
282 Int_t& ix, Int_t& iy)
287 //_____________________________________________________________________________
289 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y,
290 Int_t& ix, Int_t& iy)
292 AliMpPad pad = fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
294 if ( pad != AliMpPad::Invalid() )
296 ix = pad.GetIndices().GetFirst();
297 iy = pad.GetIndices().GetSecond();
305 //_____________________________________________________________________________
307 AliMUONSt345SlatSegmentationV2::GiveTestPoints(Int_t&,Float_t*,Float_t*) const
309 AliFatal("Not Implemented");
312 //_____________________________________________________________________________
314 AliMUONSt345SlatSegmentationV2::HasPad(Float_t x, Float_t y, Float_t z)
317 GetPadI(x,y,z,ix,iy);
318 return HasPad(ix,iy);
321 //_____________________________________________________________________________
323 AliMUONSt345SlatSegmentationV2::HasPad(Int_t ix, Int_t iy)
325 return fSlatSegmentation->HasPad(AliMpIntPair(ix,iy));
328 //_____________________________________________________________________________
330 AliMUONSt345SlatSegmentationV2::IntegrationLimits(Float_t& x1, Float_t& x2,
331 Float_t& y1, Float_t& y2)
334 // Returns integration limits for current pad
337 // x1 = fXhit - fX - Dpx(fSector)/2.;
338 // x2 = x1 + Dpx(fSector);
339 // y1 = fYhit - fY - Dpy(fSector)/2.;
340 // y2 = y1 + Dpy(fSector);
342 Float_t x = fCurrentPad.Position().X();
343 Float_t y = fCurrentPad.Position().Y();
345 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0;
346 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0;
348 x1 = fXhit - x - padsizex/2.0;
350 y1 = fYhit - y - padsizey/2.0;
353 AliDebug(4,Form("xhit,yhit=%e,%e x,y=%e,%e, x1,x2,y1,y2=%e,%e,%e,%e",fXhit,fYhit,x,y,x1,x2,y1,y2));
356 //_____________________________________________________________________________
358 AliMUONSt345SlatSegmentationV2::ISector()
360 // FIXME: remove the usage of ISector from all the code.
364 //_____________________________________________________________________________
366 AliMUONSt345SlatSegmentationV2::Ix()
370 return fPadIterator->CurrentItem().GetIndices().GetFirst();
378 //_____________________________________________________________________________
380 AliMUONSt345SlatSegmentationV2::Iy()
384 return fPadIterator->CurrentItem().GetIndices().GetSecond();
392 //_____________________________________________________________________________
394 AliMUONSt345SlatSegmentationV2::MorePads()
396 return (fPadIterator && !fPadIterator->IsDone());
399 //_____________________________________________________________________________
401 AliMUONSt345SlatSegmentationV2::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
402 Int_t Xlist[10], Int_t Ylist[10])
404 // Find pad at (ix,iy) for which we'll search neighbours.
406 fSlatSegmentation->PadByIndices(AliMpIntPair(iX,iY),kTRUE);
408 // Define the region to look into : a region slightly bigger
409 // than the pad itself (5% bigger), in order to catch first neighbours.
411 AliMpArea area(pad.Position(),pad.Dimensions()*1.05);
413 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
416 while ( !it->IsDone() && n < 10 )
418 AliMpPad p = it->CurrentItem();
419 if ( p != pad ) // skip self
421 Xlist[n] = p.GetIndices().GetFirst();
422 Ylist[n] = p.GetIndices().GetSecond();
431 //_____________________________________________________________________________
433 AliMUONSt345SlatSegmentationV2::NextPad()
437 fPadIterator->Next();
438 fCurrentPad = fPadIterator->CurrentItem();
442 AliError("PadIterator not initialized. Please use First() first ;-)");
446 //_____________________________________________________________________________
448 AliMUONSt345SlatSegmentationV2::Npx() const
450 return fSlatSegmentation->MaxPadIndexX()+1;
453 //_____________________________________________________________________________
455 AliMUONSt345SlatSegmentationV2::Npy() const
457 return fSlatSegmentation->MaxPadIndexY()+1;
460 //_____________________________________________________________________________
462 AliMUONSt345SlatSegmentationV2::Print(Option_t*) const
464 cout << "DetElemId=" << fDetElemId << " PlaneType="
465 << fPlaneType << " Npx,Npy=" << Npx() << "," << Npy() << " fSlat=" << fSlat
466 << " fSlatSegmentation=" << fSlatSegmentation
467 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
470 //_____________________________________________________________________________
472 AliMUONSt345SlatSegmentationV2::Sector(Int_t ix, Int_t)
474 return fSlat->FindPCBIndex(ix);
477 //_____________________________________________________________________________
479 AliMUONSt345SlatSegmentationV2::Sector(Float_t x, Float_t y)
481 return fSlat->FindPCBIndex(x,y);
484 //_____________________________________________________________________________
486 AliMUONSt345SlatSegmentationV2::SetCorrFunc(Int_t,TF1*)
488 AliFatal("Not Implemented");
491 //_____________________________________________________________________________
493 AliMUONSt345SlatSegmentationV2::SetDAnod(float)
495 AliFatal("Not Implemented");
498 //_____________________________________________________________________________
500 AliMUONSt345SlatSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
506 // insure we're within the slat limits. If not, issue a simple
507 // warning, as this might be correct (due to clustering/fitting algorithm
508 // that is allowed to go a little bit outside limits).
509 // That should only be considered an error in case the point is way
510 // outside (but by how much is the question you'll have to determine
513 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
514 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
516 Double_t DX = - fSlat->DX() + TMath::Abs(fXhit);
517 Double_t DY = - fSlat->DY() + TMath::Abs(fYhit);
518 DX = ( DX > 0 ? DX : 0);
519 DY = ( DY > 0 ? DY : 0);
520 AliWarning(Form("Hit outside slat %s limits (x,y)hit = (%e,%e). "
521 "Outside by (%e,%e) cm. Might be ok though.",
522 fSlat->GetID(),fXhit,fYhit,DX,DY));
526 //_____________________________________________________________________________
528 AliMUONSt345SlatSegmentationV2::SetPad(Int_t ix, Int_t iy)
531 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
532 if ( !fCurrentPad.IsValid() )
534 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
538 //_____________________________________________________________________________
540 AliMUONSt345SlatSegmentationV2::SetPadSize(float,float)
542 AliFatal("Not Implemented");
545 //_____________________________________________________________________________
547 AliMUONSt345SlatSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
549 AliFatal("Not Implemented");
553 //_____________________________________________________________________________
555 AliMUONSt345SlatSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
557 AliFatal("Not Implemented");