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)
45 Int_t fgIntOffset = 1;
49 //_____________________________________________________________________________
50 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2()
51 : AliMUONVGeometryDESegmentation(),
53 fPlaneType(kBendingPlane),
60 AliDebug(1,Form("this=%p default (empty) ctor",this));
63 //_____________________________________________________________________________
64 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2(
65 AliMpVSegmentation* segmentation,
66 Int_t detElemId, AliMpPlaneType bendingOrNonBending)
67 : AliMUONVGeometryDESegmentation(),
68 fDetElemId(detElemId),
69 fPlaneType(bendingOrNonBending),
80 fSlatSegmentation = dynamic_cast<AliMpSlatSegmentation*>(segmentation);
81 if (fSlatSegmentation)
82 fSlat = fSlatSegmentation->Slat();
84 AliFatal("Wrong mapping segmentation type");
86 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
87 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
91 //_____________________________________________________________________________
92 AliMUONSt345SlatSegmentationV2::~AliMUONSt345SlatSegmentationV2()
94 AliDebug(1,Form("dtor this=%p",this));
98 //_____________________________________________________________________________
100 AliMUONSt345SlatSegmentationV2::CorrFunc(Int_t) const
102 AliFatal("Not Implemented");
106 //_____________________________________________________________________________
108 AliMUONSt345SlatSegmentationV2::Distance2AndOffset(Int_t,Int_t,
109 Float_t,Float_t,Int_t*)
111 AliFatal("Not Implemented");
115 //_____________________________________________________________________________
117 AliMUONSt345SlatSegmentationV2::Draw(Option_t*)
119 AliFatal("Not Implemented");
122 //_____________________________________________________________________________
124 AliMUONSt345SlatSegmentationV2::Dpx() const
126 AliFatal("Not Implemented");
130 //_____________________________________________________________________________
132 AliMUONSt345SlatSegmentationV2::Dpy() const
134 AliFatal("Not Implemented");
138 //_____________________________________________________________________________
140 AliMUONSt345SlatSegmentationV2::Dpx(int ipcb) const
142 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
145 AliFatal("pcb is null!");
147 return pcb->PadSizeX();
150 //_____________________________________________________________________________
152 AliMUONSt345SlatSegmentationV2::Dpy(int ipcb) const
154 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
157 AliFatal("pcb is null!");
159 return pcb->PadSizeY();
162 //_____________________________________________________________________________
164 AliMUONSt345SlatSegmentationV2::FirstPad(Float_t xhit, Float_t yhit,
166 Float_t dx, Float_t dy)
168 // OK. We will do it in 2 steps. First get the area over which to
169 // iterate, based on hit coordinates and (dx,dy). This first step
170 // has nothing to do with segmentation in the first place, but with
171 // how we simulate the fact that at some point the charge is shared
172 // amongst several pads.
173 // The second step is the actual pad iteration and is handled by
174 // a specific class (which has to do only with iteration...)
176 // FIXME: this method should not be here in the first place, IMHO.
179 // Find the wire position (center of charge distribution)
180 Float_t xwire = GetAnod(xhit);
184 Double_t x01 = xwire - dx;
185 Double_t x02 = xwire + dx;
186 Double_t y01 = yhit - dy;
187 Double_t y02 = yhit + dy;
189 Double_t xext = x02 - x01;
190 Double_t yext = y02 - y01;
192 // we do not check area here, as we assume the iterator
193 // will do it, and will possibly truncate it if needed.
194 // Note that we convert the area position to a reference frame
195 // located in the lower-left corner of the slat, instead of its
197 // AliMpArea area(TVector2((x01+x02)/2.0+fSlat->DX(),
198 // (y01+y02)/2.0+fSlat->DY()),
199 // TVector2(xext/2.0,yext/2.0));
200 AliMpArea area(TVector2((x01+x02)/2.0,(y01+y02)/2.0),
201 TVector2(xext/2.0,yext/2.0));
205 fPadIterator = fSlatSegmentation->CreateIterator(area);
207 fPadIterator->First();
209 fCurrentPad = fPadIterator->CurrentItem();
211 if ( !fCurrentPad.IsValid() )
213 AliError(Form("Cannot get a valid pad for (xhit,yhit,dx,dy)=(%e,%e,%e,%e)",xhit,yhit,dx,dy));
216 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d slat=%s",
218 fCurrentPad.GetIndices().GetFirst()+1,
219 fCurrentPad.GetIndices().GetSecond()+1,fSlat->GetID()));
222 //_____________________________________________________________________________
224 AliMUONSt345SlatSegmentationV2::GetAnod(Float_t xhit) const
226 // Gets the x-coordinate of the wire which is the closest to xhit.
228 Int_t n = Int_t(xhit/AliMUONConstants::Pitch());
229 Float_t wire = (xhit>0) ? n+0.5 : n-0.5;
230 return AliMUONConstants::Pitch()*wire;
233 //_____________________________________________________________________________
234 AliMUONGeometryDirection
235 AliMUONSt345SlatSegmentationV2::GetDirection()
237 //AliWarning("Not Implemented");
238 return kDirUndefined;
241 //______________________________________________________________________________
242 const AliMpVSegmentation*
243 AliMUONSt345SlatSegmentationV2::GetMpSegmentation() const
245 // Returns the mapping segmentation
246 // (provides access to electronics info)
248 return fSlatSegmentation;
252 //_____________________________________________________________________________
254 AliMUONSt345SlatSegmentationV2::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
256 AliFatal("Not Implemented");
259 //_____________________________________________________________________________
261 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
262 Float_t& x, Float_t& y, Float_t& z)
268 //_____________________________________________________________________________
270 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
271 Float_t& x, Float_t& y)
274 fSlatSegmentation->PadByIndices(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset),
276 x = pad.Position().X();
277 y = pad.Position().Y();
281 //_____________________________________________________________________________
283 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
284 Int_t& ix, Int_t& iy)
289 //_____________________________________________________________________________
291 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y,
292 Int_t& ix, Int_t& iy)
294 // Double_t slatx = fSlat->DX();
295 // Double_t slaty = fSlat->DY();
297 fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
298 // fSlatSegmentation->PadByPosition(TVector2(x+slatx,y+slaty), kTRUE);
300 if ( pad != AliMpPad::Invalid() )
302 ix = pad.GetIndices().GetFirst() + fgIntOffset;
303 iy = pad.GetIndices().GetSecond() + fgIntOffset;
311 //_____________________________________________________________________________
313 AliMUONSt345SlatSegmentationV2::GiveTestPoints(Int_t&,Float_t*,Float_t*) const
315 AliFatal("Not Implemented");
318 //_____________________________________________________________________________
320 AliMUONSt345SlatSegmentationV2::HasPad(Float_t x, Float_t y, Float_t z)
323 GetPadI(x,y,z,ix,iy);
324 return HasPad(ix,iy);
327 //_____________________________________________________________________________
329 AliMUONSt345SlatSegmentationV2::HasPad(Int_t ix, Int_t iy)
331 return fSlatSegmentation->HasPad(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset));
334 //_____________________________________________________________________________
336 AliMUONSt345SlatSegmentationV2::Init(int)
338 AliWarning("Not Implemented because not needed ;-)");
341 //_____________________________________________________________________________
343 AliMUONSt345SlatSegmentationV2::IntegrationLimits(Float_t& x1, Float_t& x2,
344 Float_t& y1, Float_t& y2)
347 // Returns integration limits for current pad
350 // x1 = fXhit - fX - Dpx(fSector)/2.;
351 // x2 = x1 + Dpx(fSector);
352 // y1 = fYhit - fY - Dpy(fSector)/2.;
353 // y2 = y1 + Dpy(fSector);
355 Float_t x = fCurrentPad.Position().X();
356 Float_t y = fCurrentPad.Position().Y();
358 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0;
359 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0;
361 x1 = fXhit - x - padsizex/2.0;
363 y1 = fYhit - y - padsizey/2.0;
366 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));
369 //_____________________________________________________________________________
371 AliMUONSt345SlatSegmentationV2::ISector()
373 // FIXME: remove the usage of ISector from all the code.
377 //_____________________________________________________________________________
379 AliMUONSt345SlatSegmentationV2::Ix()
383 return fPadIterator->CurrentItem().GetIndices().GetFirst() + fgIntOffset;
391 //_____________________________________________________________________________
393 AliMUONSt345SlatSegmentationV2::Iy()
397 return fPadIterator->CurrentItem().GetIndices().GetSecond() + fgIntOffset;
405 //_____________________________________________________________________________
407 AliMUONSt345SlatSegmentationV2::MorePads()
409 return (fPadIterator && !fPadIterator->IsDone());
412 //_____________________________________________________________________________
414 AliMUONSt345SlatSegmentationV2::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
415 Int_t Xlist[10], Int_t Ylist[10])
417 // Find pad at (ix,iy) for which we'll search neighbours.
419 fSlatSegmentation->PadByIndices(AliMpIntPair(iX-fgIntOffset,iY-fgIntOffset),kTRUE);
421 // Define the region to look into : a region slightly bigger
422 // than the pad itself (10% bigger), in order to catch first neighbours.
423 // AliMpArea area(pad.Position()+fSlat->Dimensions(),pad.Dimensions()*2.1);
424 AliMpArea area(pad.Position(),pad.Dimensions()*2.1);
426 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
429 while ( !it->IsDone() && n < 10 )
431 AliMpPad p = it->CurrentItem();
432 if ( p != pad ) // skip self
434 Xlist[n] = p.GetIndices().GetFirst() + fgIntOffset;
435 Ylist[n] = p.GetIndices().GetSecond() + fgIntOffset;
444 //_____________________________________________________________________________
446 AliMUONSt345SlatSegmentationV2::NextPad()
450 fPadIterator->Next();
451 fCurrentPad = fPadIterator->CurrentItem();
455 AliError("PadIterator not initialized. Please use First() first ;-)");
459 //_____________________________________________________________________________
461 AliMUONSt345SlatSegmentationV2::Npx() const
463 return fSlatSegmentation->MaxPadIndexX()+1;
466 //_____________________________________________________________________________
468 AliMUONSt345SlatSegmentationV2::Npy() const
470 return fSlatSegmentation->MaxPadIndexY()+1;
473 //_____________________________________________________________________________
475 AliMUONSt345SlatSegmentationV2::Print(Option_t*) const
477 cout << "DetElemId=" << fDetElemId << " PlaneType="
478 << fPlaneType << " Npx,Npy=" << Npx() << "," << Npy() << " fSlat=" << fSlat
479 << " fSlatSegmentation=" << fSlatSegmentation
480 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
483 //_____________________________________________________________________________
485 AliMUONSt345SlatSegmentationV2::Sector(Int_t ix, Int_t)
487 return fSlat->FindPCBIndex(ix - fgIntOffset);
490 //_____________________________________________________________________________
492 AliMUONSt345SlatSegmentationV2::Sector(Float_t x, Float_t y)
494 return fSlat->FindPCBIndex(x,y);
497 //_____________________________________________________________________________
499 AliMUONSt345SlatSegmentationV2::SetCorrFunc(Int_t,TF1*)
501 AliFatal("Not Implemented");
504 //_____________________________________________________________________________
506 AliMUONSt345SlatSegmentationV2::SetDAnod(float)
508 AliFatal("Not Implemented");
511 //_____________________________________________________________________________
513 AliMUONSt345SlatSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
519 // insure we're within the slat limits. If not, issue an error and sets
520 // the current hit to slat center.
521 // FIXME: this should probably a) not happen at all b) be a fatal error
523 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
524 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
526 AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
527 " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
534 //_____________________________________________________________________________
536 AliMUONSt345SlatSegmentationV2::SetPad(Int_t ix, Int_t iy)
539 fSlatSegmentation->PadByIndices(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset),kTRUE);
540 if ( !fCurrentPad.IsValid() )
542 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
546 //_____________________________________________________________________________
548 AliMUONSt345SlatSegmentationV2::SetPadSize(float,float)
550 AliFatal("Not Implemented");
553 //_____________________________________________________________________________
555 AliMUONSt345SlatSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
557 AliFatal("Not Implemented");
561 //_____________________________________________________________________________
563 AliMUONSt345SlatSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
565 AliFatal("Not Implemented");