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"
40 ClassImp(AliMUONSt345SlatSegmentationV2)
47 //_____________________________________________________________________________
48 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2()
49 : AliMUONVGeometryDESegmentation(),
51 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(
93 const AliMUONSt345SlatSegmentationV2& right)
94 : AliMUONVGeometryDESegmentation(right)
96 /// Protected copy constructor (not implemented)
98 AliFatal("Copy constructor not provided.");
101 //_____________________________________________________________________________
102 AliMUONSt345SlatSegmentationV2::~AliMUONSt345SlatSegmentationV2()
106 AliDebug(1,Form("dtor this=%p",this));
110 //______________________________________________________________________________
111 AliMUONSt345SlatSegmentationV2&
112 AliMUONSt345SlatSegmentationV2::operator=(const AliMUONSt345SlatSegmentationV2& right)
114 /// Protected assignement operator (not implemented)
116 // check assignement to self
117 if (this == &right) return *this;
119 AliFatal("Assignement operator not provided.");
124 //_____________________________________________________________________________
126 AliMUONSt345SlatSegmentationV2::CorrFunc(Int_t /*isec*/) const
130 AliFatal("Not Implemented");
134 //_____________________________________________________________________________
136 AliMUONSt345SlatSegmentationV2::Distance2AndOffset(Int_t /*iX*/, Int_t /*iY*/,
137 Float_t /*x*/, Float_t /*y*/, Int_t* /*dummy*/){
140 AliFatal("Not Implemented");
144 //_____________________________________________________________________________
146 AliMUONSt345SlatSegmentationV2::Draw(Option_t* /*opt*/)
150 AliFatal("Not Implemented");
153 //_____________________________________________________________________________
155 AliMUONSt345SlatSegmentationV2::Dpx() const
159 AliFatal("Not Implemented");
163 //_____________________________________________________________________________
165 AliMUONSt345SlatSegmentationV2::Dpy() const
169 AliFatal("Not Implemented");
173 //_____________________________________________________________________________
175 AliMUONSt345SlatSegmentationV2::Dpx(int ipcb) const
179 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
182 AliFatal("pcb is null!");
184 return pcb->PadSizeX();
187 //_____________________________________________________________________________
189 AliMUONSt345SlatSegmentationV2::Dpy(int ipcb) const
193 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
196 AliFatal("pcb is null!");
198 return pcb->PadSizeY();
201 //_____________________________________________________________________________
203 AliMUONSt345SlatSegmentationV2::FirstPad(Float_t xhit, Float_t yhit,Float_t /*zhit*/,
204 Float_t dx, Float_t dy)
206 // OK. We will do it in 2 steps. First get the area over which to
207 // iterate, based on hit coordinates and (dx,dy). This first step
208 // has nothing to do with segmentation in the first place, but with
209 // how we simulate the fact that at some point the charge is shared
210 // amongst several pads.
211 // The second step is the actual pad iteration and is handled by
212 // a specific class (which has to do only with iteration...)
214 // FIXME: this method should not be here in the first place, IMHO.
217 // Find the wire position (center of charge distribution)
218 Float_t xwire = GetAnod(xhit);
222 Double_t x01 = xwire - dx;
223 Double_t x02 = xwire + dx;
224 Double_t y01 = yhit - dy;
225 Double_t y02 = yhit + dy;
227 Double_t xext = x02 - x01;
228 Double_t yext = y02 - y01;
230 // we do not check area here, as we assume the iterator
231 // will do it, and will possibly truncate it if needed.
232 // Note that we convert the area position to a reference frame
233 // located in the lower-left corner of the slat, instead of its
235 // AliMpArea area(TVector2((x01+x02)/2.0+fSlat->DX(),
236 // (y01+y02)/2.0+fSlat->DY()),
237 // TVector2(xext/2.0,yext/2.0));
238 AliMpArea area(TVector2((x01+x02)/2.0,(y01+y02)/2.0),
239 TVector2(xext/2.0,yext/2.0));
243 fPadIterator = fSlatSegmentation->CreateIterator(area);
245 fPadIterator->First();
247 fCurrentPad = fPadIterator->CurrentItem();
249 if ( !fCurrentPad.IsValid() )
251 AliError(Form("Cannot get a valid pad for (xhit,yhit,dx,dy)=(%e,%e,%e,%e)",xhit,yhit,dx,dy));
254 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d slat=%s",
256 fCurrentPad.GetIndices().GetFirst(),
257 fCurrentPad.GetIndices().GetSecond(),fSlat->GetID()));
260 //_____________________________________________________________________________
262 AliMUONSt345SlatSegmentationV2::GetAnod(Float_t xhit) const
264 // Gets the x-coordinate of the wire which is the closest to xhit.
266 Int_t n = Int_t(xhit/AliMUONConstants::Pitch());
267 Float_t wire = (xhit>0) ? n+0.5 : n-0.5;
268 return AliMUONConstants::Pitch()*wire;
271 //_____________________________________________________________________________
272 AliMUONGeometryDirection
273 AliMUONSt345SlatSegmentationV2::GetDirection()
277 //AliWarning("Not Implemented");
278 return kDirUndefined;
281 //______________________________________________________________________________
282 const AliMpVSegmentation*
283 AliMUONSt345SlatSegmentationV2::GetMpSegmentation() const
285 // Returns the mapping segmentation
286 // (provides access to electronics info)
288 return fSlatSegmentation;
292 //_____________________________________________________________________________
294 AliMUONSt345SlatSegmentationV2::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
295 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
299 AliFatal("Not Implemented");
302 //_____________________________________________________________________________
304 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
305 Float_t& x, Float_t& y, Float_t& z)
307 // Transform from pad to real coordinates
313 //_____________________________________________________________________________
315 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
316 Float_t& x, Float_t& y)
318 // Transform from pad to real coordinates
321 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
322 x = pad.Position().X();
323 y = pad.Position().Y();
327 //_____________________________________________________________________________
329 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
330 Int_t& ix, Int_t& iy)
332 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
337 //_____________________________________________________________________________
339 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y,
340 Int_t& ix, Int_t& iy)
342 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
344 AliMpPad pad = fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
346 if ( pad != AliMpPad::Invalid() )
348 ix = pad.GetIndices().GetFirst();
349 iy = pad.GetIndices().GetSecond();
357 //_____________________________________________________________________________
359 AliMUONSt345SlatSegmentationV2::GiveTestPoints(Int_t& /*n*/,
360 Float_t* /*x*/, Float_t* /*y*/) const
364 AliFatal("Not Implemented");
367 //_____________________________________________________________________________
369 AliMUONSt345SlatSegmentationV2::HasPad(Float_t x, Float_t y, Float_t z)
371 // Returns true if a pad exists in the given position
374 GetPadI(x,y,z,ix,iy);
375 return HasPad(ix,iy);
378 //_____________________________________________________________________________
380 AliMUONSt345SlatSegmentationV2::HasPad(Int_t ix, Int_t iy)
382 // Returns true if a pad with given indices exists
384 return fSlatSegmentation->HasPad(AliMpIntPair(ix,iy));
387 //_____________________________________________________________________________
389 AliMUONSt345SlatSegmentationV2::IntegrationLimits(Float_t& x1, Float_t& x2,
390 Float_t& y1, Float_t& y2)
393 // Returns integration limits for current pad
396 // x1 = fXhit - fX - Dpx(fSector)/2.;
397 // x2 = x1 + Dpx(fSector);
398 // y1 = fYhit - fY - Dpy(fSector)/2.;
399 // y2 = y1 + Dpy(fSector);
401 Float_t x = fCurrentPad.Position().X();
402 Float_t y = fCurrentPad.Position().Y();
404 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0;
405 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0;
407 x1 = fXhit - x - padsizex/2.0;
409 y1 = fYhit - y - padsizey/2.0;
412 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));
415 //_____________________________________________________________________________
417 AliMUONSt345SlatSegmentationV2::ISector()
419 // FIXME: remove the usage of ISector from all the code.
423 //_____________________________________________________________________________
425 AliMUONSt345SlatSegmentationV2::Ix()
427 // Current pad cursor during disintegration
432 return fPadIterator->CurrentItem().GetIndices().GetFirst();
440 //_____________________________________________________________________________
442 AliMUONSt345SlatSegmentationV2::Iy()
444 // Current pad cursor during disintegration
449 return fPadIterator->CurrentItem().GetIndices().GetSecond();
457 //_____________________________________________________________________________
459 AliMUONSt345SlatSegmentationV2::MorePads()
461 return (fPadIterator && !fPadIterator->IsDone());
464 //_____________________________________________________________________________
466 AliMUONSt345SlatSegmentationV2::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
467 Int_t Xlist[10], Int_t Ylist[10])
469 // Find pad at (ix,iy) for which we'll search neighbours.
471 fSlatSegmentation->PadByIndices(AliMpIntPair(iX,iY),kTRUE);
473 // Define the region to look into : a region slightly bigger
474 // than the pad itself (5% bigger), in order to catch first neighbours.
476 AliMpArea area(pad.Position(),pad.Dimensions()*1.05);
478 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
481 while ( !it->IsDone() && n < 10 )
483 AliMpPad p = it->CurrentItem();
484 if ( p != pad ) // skip self
486 Xlist[n] = p.GetIndices().GetFirst();
487 Ylist[n] = p.GetIndices().GetSecond();
496 //_____________________________________________________________________________
498 AliMUONSt345SlatSegmentationV2::NextPad()
500 // Iterate over pads - stepper
504 fPadIterator->Next();
505 fCurrentPad = fPadIterator->CurrentItem();
509 AliError("PadIterator not initialized. Please use First() first ;-)");
513 //_____________________________________________________________________________
515 AliMUONSt345SlatSegmentationV2::Npx() const
517 // Maximum number of Pads in x
519 return fSlatSegmentation->MaxPadIndexX()+1;
522 //_____________________________________________________________________________
524 AliMUONSt345SlatSegmentationV2::Npy() const
526 // Maximum number of Pads in y
528 return fSlatSegmentation->MaxPadIndexY()+1;
531 //_____________________________________________________________________________
533 AliMUONSt345SlatSegmentationV2::Print(Option_t* /*opt*/) const
537 cout << "DetElemId=" << fDetElemId << " PlaneType="
538 << fPlaneType << " Npx,Npy=" << Npx() << "," << Npy() << " fSlat=" << fSlat
539 << " fSlatSegmentation=" << fSlatSegmentation
540 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
543 //_____________________________________________________________________________
545 AliMUONSt345SlatSegmentationV2::Sector(Int_t ix, Int_t /*iy*/)
547 // Calculate sector from pad coordinates
549 return fSlat->FindPCBIndex(ix);
552 //_____________________________________________________________________________
554 AliMUONSt345SlatSegmentationV2::Sector(Float_t x, Float_t y)
556 // Calculate sector from pad coordinates
558 return fSlat->FindPCBIndex(x,y);
561 //_____________________________________________________________________________
563 AliMUONSt345SlatSegmentationV2::SetCorrFunc(Int_t /*isec*/,TF1* /*func*/)
567 AliFatal("Not Implemented");
570 //_____________________________________________________________________________
572 AliMUONSt345SlatSegmentationV2::SetDAnod(float /*d*/)
576 AliFatal("Not Implemented");
579 //_____________________________________________________________________________
581 AliMUONSt345SlatSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
584 // Sets virtual hit position, needed for evaluating pad response
585 // outside the tracking program
591 // insure we're within the slat limits. If not, issue a simple
592 // warning, as this might be correct (due to clustering/fitting algorithm
593 // that is allowed to go a little bit outside limits).
594 // That should only be considered an error in case the point is way
595 // outside (but by how much is the question you'll have to determine
598 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
599 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
601 Double_t dx = - fSlat->DX() + TMath::Abs(fXhit);
602 Double_t dy = - fSlat->DY() + TMath::Abs(fYhit);
603 dx = ( dx > 0 ? dx : 0);
604 dy = ( dy > 0 ? dy : 0);
605 AliWarning(Form("Hit outside slat %s limits (x,y)hit = (%e,%e). "
606 "Outside by (%e,%e) cm. Might be ok though.",
607 fSlat->GetID(),fXhit,fYhit,dx,dy));
611 //_____________________________________________________________________________
613 AliMUONSt345SlatSegmentationV2::SetPad(Int_t ix, Int_t iy)
616 // Sets virtual pad coordinates, needed for evaluating pad response
617 // outside the tracking program.
620 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
621 if ( !fCurrentPad.IsValid() )
623 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
627 //_____________________________________________________________________________
629 AliMUONSt345SlatSegmentationV2::SetPadSize(float /*p1*/,float /*p2*/)
633 AliFatal("Not Implemented");
636 //_____________________________________________________________________________
638 AliMUONSt345SlatSegmentationV2::SigGenCond(Float_t /*x*/, Float_t /*y*/, Float_t /*z*/)
642 AliFatal("Not Implemented");
646 //_____________________________________________________________________________
648 AliMUONSt345SlatSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
652 AliFatal("Not Implemented");