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)
49 //_____________________________________________________________________________
50 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2()
51 : AliMUONVGeometryDESegmentation(),
53 fPlaneType(kBendingPlane),
62 AliDebug(1,Form("this=%p default (empty) ctor",this));
65 //_____________________________________________________________________________
66 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2(
67 AliMpVSegmentation* segmentation,
68 Int_t detElemId, AliMpPlaneType bendingOrNonBending)
69 : AliMUONVGeometryDESegmentation(),
70 fDetElemId(detElemId),
71 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()
96 AliDebug(1,Form("dtor this=%p",this));
100 //_____________________________________________________________________________
102 AliMUONSt345SlatSegmentationV2::CorrFunc(Int_t /*isec*/) const
106 AliFatal("Not Implemented");
110 //_____________________________________________________________________________
112 AliMUONSt345SlatSegmentationV2::Distance2AndOffset(Int_t /*iX*/, Int_t /*iY*/,
113 Float_t /*x*/, Float_t /*y*/, Int_t* /*dummy*/){
116 AliFatal("Not Implemented");
120 //_____________________________________________________________________________
122 AliMUONSt345SlatSegmentationV2::Draw(Option_t* /*opt*/)
126 AliFatal("Not Implemented");
129 //_____________________________________________________________________________
131 AliMUONSt345SlatSegmentationV2::Dpx() const
135 AliFatal("Not Implemented");
139 //_____________________________________________________________________________
141 AliMUONSt345SlatSegmentationV2::Dpy() const
145 AliFatal("Not Implemented");
149 //_____________________________________________________________________________
151 AliMUONSt345SlatSegmentationV2::Dpx(int ipcb) const
153 /// Get pad size in x
155 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
158 AliFatal("pcb is null!");
160 return pcb->PadSizeX();
163 //_____________________________________________________________________________
165 AliMUONSt345SlatSegmentationV2::Dpy(int ipcb) const
167 /// Get pad size in y
169 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
172 AliFatal("pcb is null!");
174 return pcb->PadSizeY();
177 //_____________________________________________________________________________
179 AliMUONSt345SlatSegmentationV2::FirstPad(Float_t xhit, Float_t yhit,Float_t /*zhit*/,
180 Float_t dx, Float_t dy)
182 /// OK. We will do it in 2 steps. First get the area over which to
183 /// iterate, based on hit coordinates and (dx,dy). This first step
184 /// has nothing to do with segmentation in the first place, but with
185 /// how we simulate the fact that at some point the charge is shared
186 /// amongst several pads.
187 /// The second step is the actual pad iteration and is handled by
188 /// a specific class (which has to do only with iteration...)
190 /// \todo FIXME: this method should not be here in the first place, IMHO.
192 // Find the wire position (center of charge distribution)
193 Float_t xwire = GetAnod(xhit);
197 Double_t x01 = xwire - dx;
198 Double_t x02 = xwire + dx;
199 Double_t y01 = yhit - dy;
200 Double_t y02 = yhit + dy;
202 Double_t xext = x02 - x01;
203 Double_t yext = y02 - y01;
205 // we do not check area here, as we assume the iterator
206 // will do it, and will possibly truncate it if needed.
207 // Note that we convert the area position to a reference frame
208 // located in the lower-left corner of the slat, instead of its
210 // AliMpArea area(TVector2((x01+x02)/2.0+fSlat->DX(),
211 // (y01+y02)/2.0+fSlat->DY()),
212 // TVector2(xext/2.0,yext/2.0));
213 AliMpArea area(TVector2((x01+x02)/2.0,(y01+y02)/2.0),
214 TVector2(xext/2.0,yext/2.0));
218 fPadIterator = fSlatSegmentation->CreateIterator(area);
220 fPadIterator->First();
222 fCurrentPad = fPadIterator->CurrentItem();
224 if ( !fCurrentPad.IsValid() )
226 AliError(Form("Cannot get a valid pad for (xhit,yhit,dx,dy)=(%e,%e,%e,%e)",xhit,yhit,dx,dy));
229 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d slat=%s",
231 fCurrentPad.GetIndices().GetFirst(),
232 fCurrentPad.GetIndices().GetSecond(),fSlat->GetID()));
235 //_____________________________________________________________________________
237 AliMUONSt345SlatSegmentationV2::GetAnod(Float_t xhit) const
239 /// Gets the x-coordinate of the wire which is the closest to xhit.
241 Int_t n = Int_t(xhit/AliMUONConstants::Pitch());
242 Float_t wire = (xhit>0) ? n+0.5 : n-0.5;
243 return AliMUONConstants::Pitch()*wire;
246 //_____________________________________________________________________________
247 AliMUONGeometryDirection
248 AliMUONSt345SlatSegmentationV2::GetDirection()
252 //AliWarning("Not Implemented");
253 return kDirUndefined;
256 //______________________________________________________________________________
257 const AliMpVSegmentation*
258 AliMUONSt345SlatSegmentationV2::GetMpSegmentation() const
260 /// Returns the mapping segmentation
261 /// (provides access to electronics info)
263 return fSlatSegmentation;
267 //_____________________________________________________________________________
269 AliMUONSt345SlatSegmentationV2::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
270 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
274 AliFatal("Not Implemented");
277 //_____________________________________________________________________________
279 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
280 Float_t& x, Float_t& y, Float_t& z)
282 /// Transform from pad to real coordinates
288 //_____________________________________________________________________________
290 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
291 Float_t& x, Float_t& y)
293 /// Transform from pad to real coordinates
296 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
297 x = pad.Position().X();
298 y = pad.Position().Y();
302 //_____________________________________________________________________________
304 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
305 Int_t& ix, Int_t& iy)
307 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
312 //_____________________________________________________________________________
314 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y,
315 Int_t& ix, Int_t& iy)
317 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
319 AliMpPad pad = fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
321 if ( pad != AliMpPad::Invalid() )
323 ix = pad.GetIndices().GetFirst();
324 iy = pad.GetIndices().GetSecond();
332 //_____________________________________________________________________________
334 AliMUONSt345SlatSegmentationV2::GiveTestPoints(Int_t& /*n*/,
335 Float_t* /*x*/, Float_t* /*y*/) const
339 AliFatal("Not Implemented");
342 //_____________________________________________________________________________
344 AliMUONSt345SlatSegmentationV2::HasPad(Float_t x, Float_t y, Float_t z)
346 /// Returns true if a pad exists in the given position
349 GetPadI(x,y,z,ix,iy);
350 return HasPad(ix,iy);
353 //_____________________________________________________________________________
355 AliMUONSt345SlatSegmentationV2::HasPad(Int_t ix, Int_t iy)
357 /// Returns true if a pad with given indices exists
359 return fSlatSegmentation->HasPad(AliMpIntPair(ix,iy));
362 //_____________________________________________________________________________
364 AliMUONSt345SlatSegmentationV2::IntegrationLimits(Float_t& x1, Float_t& x2,
365 Float_t& y1, Float_t& y2)
367 /// Returns integration limits for current pad
369 // x1 = fXhit - fX - Dpx(fSector)/2.;
370 // x2 = x1 + Dpx(fSector);
371 // y1 = fYhit - fY - Dpy(fSector)/2.;
372 // y2 = y1 + Dpy(fSector);
374 Float_t x = fCurrentPad.Position().X();
375 Float_t y = fCurrentPad.Position().Y();
377 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0;
378 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0;
380 x1 = fXhit - x - padsizex/2.0;
382 y1 = fYhit - y - padsizey/2.0;
385 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));
388 //_____________________________________________________________________________
390 AliMUONSt345SlatSegmentationV2::ISector()
392 /// \todo FIXME: remove the usage of ISector from all the code.
397 //_____________________________________________________________________________
399 AliMUONSt345SlatSegmentationV2::Ix()
401 /// Current pad cursor during disintegration
406 return fPadIterator->CurrentItem().GetIndices().GetFirst();
414 //_____________________________________________________________________________
416 AliMUONSt345SlatSegmentationV2::Iy()
418 /// Current pad cursor during disintegration
423 return fPadIterator->CurrentItem().GetIndices().GetSecond();
431 //_____________________________________________________________________________
433 AliMUONSt345SlatSegmentationV2::MorePads()
435 /// Iterate over pads - condition
437 return (fPadIterator && !fPadIterator->IsDone());
440 //_____________________________________________________________________________
442 AliMUONSt345SlatSegmentationV2::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
443 Int_t Xlist[10], Int_t Ylist[10])
445 /// Find pad at (ix,iy) for which we'll search neighbours.
448 fSlatSegmentation->PadByIndices(AliMpIntPair(iX,iY),kTRUE);
450 // Define the region to look into : a region slightly bigger
451 // than the pad itself (5% bigger), in order to catch first neighbours.
453 AliMpArea area(pad.Position(),pad.Dimensions()*1.05);
455 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
458 while ( !it->IsDone() && n < 10 )
460 AliMpPad p = it->CurrentItem();
461 if ( p != pad ) // skip self
463 Xlist[n] = p.GetIndices().GetFirst();
464 Ylist[n] = p.GetIndices().GetSecond();
473 //_____________________________________________________________________________
475 AliMUONSt345SlatSegmentationV2::NextPad()
477 /// Iterate over pads - stepper
481 fPadIterator->Next();
482 fCurrentPad = fPadIterator->CurrentItem();
486 AliError("PadIterator not initialized. Please use First() first ;-)");
490 //_____________________________________________________________________________
492 AliMUONSt345SlatSegmentationV2::Npx() const
494 /// Maximum number of Pads in x
496 return fSlatSegmentation->MaxPadIndexX()+1;
499 //_____________________________________________________________________________
501 AliMUONSt345SlatSegmentationV2::Npy() const
503 /// Maximum number of Pads in y
505 return fSlatSegmentation->MaxPadIndexY()+1;
508 //_____________________________________________________________________________
510 AliMUONSt345SlatSegmentationV2::Print(Option_t* /*opt*/) const
514 cout << "DetElemId=" << fDetElemId << " PlaneType="
515 << fPlaneType << " Npx,Npy=" << Npx() << "," << Npy() << " fSlat=" << fSlat
516 << " fSlatSegmentation=" << fSlatSegmentation
517 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
520 //_____________________________________________________________________________
522 AliMUONSt345SlatSegmentationV2::Sector(Int_t ix, Int_t /*iy*/)
524 /// Calculate sector from pad coordinates
526 return fSlat->FindPCBIndex(ix);
529 //_____________________________________________________________________________
531 AliMUONSt345SlatSegmentationV2::Sector(Float_t x, Float_t y)
533 /// Calculate sector from pad coordinates
535 return fSlat->FindPCBIndex(x,y);
538 //_____________________________________________________________________________
540 AliMUONSt345SlatSegmentationV2::SetCorrFunc(Int_t /*isec*/,TF1* /*func*/)
544 AliFatal("Not Implemented");
547 //_____________________________________________________________________________
549 AliMUONSt345SlatSegmentationV2::SetDAnod(float /*d*/)
553 AliFatal("Not Implemented");
556 //_____________________________________________________________________________
558 AliMUONSt345SlatSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
561 /// Sets virtual hit position, needed for evaluating pad response
562 /// outside the tracking program
568 // insure we're within the slat limits. If not, issue a simple
569 // warning, as this might be correct (due to clustering/fitting algorithm
570 // that is allowed to go a little bit outside limits).
571 // That should only be considered an error in case the point is way
572 // outside (but by how much is the question you'll have to determine
575 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
576 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
578 Double_t dx = - fSlat->DX() + TMath::Abs(fXhit);
579 Double_t dy = - fSlat->DY() + TMath::Abs(fYhit);
580 dx = ( dx > 0 ? dx : 0);
581 dy = ( dy > 0 ? dy : 0);
582 AliWarning(Form("Hit outside slat %s limits (x,y)hit = (%e,%e). "
583 "Outside by (%e,%e) cm. Might be ok though.",
584 fSlat->GetID(),fXhit,fYhit,dx,dy));
588 //_____________________________________________________________________________
590 AliMUONSt345SlatSegmentationV2::SetPad(Int_t ix, Int_t iy)
592 /// Set pad position.
593 /// Sets virtual pad coordinates, needed for evaluating pad response
594 /// outside the tracking program.
597 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
598 if ( !fCurrentPad.IsValid() )
600 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
604 //_____________________________________________________________________________
606 AliMUONSt345SlatSegmentationV2::SetPadSize(float /*p1*/,float /*p2*/)
610 AliFatal("Not Implemented");
613 //_____________________________________________________________________________
615 AliMUONSt345SlatSegmentationV2::SigGenCond(Float_t /*x*/, Float_t /*y*/, Float_t /*z*/)
619 AliFatal("Not Implemented");
623 //_____________________________________________________________________________
625 AliMUONSt345SlatSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
629 AliFatal("Not Implemented");