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(
92 const AliMUONSt345SlatSegmentationV2& right)
93 : AliMUONVGeometryDESegmentation(right)
95 /// Protected copy constructor (not implemented)
97 AliFatal("Copy constructor not provided.");
100 //_____________________________________________________________________________
101 AliMUONSt345SlatSegmentationV2::~AliMUONSt345SlatSegmentationV2()
103 AliDebug(1,Form("dtor this=%p",this));
107 //______________________________________________________________________________
108 AliMUONSt345SlatSegmentationV2&
109 AliMUONSt345SlatSegmentationV2::operator=(const AliMUONSt345SlatSegmentationV2& right)
111 /// Protected assignement operator (not implemented)
113 // check assignement to self
114 if (this == &right) return *this;
116 AliFatal("Assignement operator not provided.");
121 //_____________________________________________________________________________
123 AliMUONSt345SlatSegmentationV2::CorrFunc(Int_t) const
125 AliFatal("Not Implemented");
129 //_____________________________________________________________________________
131 AliMUONSt345SlatSegmentationV2::Distance2AndOffset(Int_t,Int_t,
132 Float_t,Float_t,Int_t*)
134 AliFatal("Not Implemented");
138 //_____________________________________________________________________________
140 AliMUONSt345SlatSegmentationV2::Draw(Option_t*)
142 AliFatal("Not Implemented");
145 //_____________________________________________________________________________
147 AliMUONSt345SlatSegmentationV2::Dpx() const
149 AliFatal("Not Implemented");
153 //_____________________________________________________________________________
155 AliMUONSt345SlatSegmentationV2::Dpy() const
157 AliFatal("Not Implemented");
161 //_____________________________________________________________________________
163 AliMUONSt345SlatSegmentationV2::Dpx(int ipcb) const
165 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
168 AliFatal("pcb is null!");
170 return pcb->PadSizeX();
173 //_____________________________________________________________________________
175 AliMUONSt345SlatSegmentationV2::Dpy(int ipcb) const
177 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
180 AliFatal("pcb is null!");
182 return pcb->PadSizeY();
185 //_____________________________________________________________________________
187 AliMUONSt345SlatSegmentationV2::FirstPad(Float_t xhit, Float_t yhit,
189 Float_t dx, Float_t dy)
191 // OK. We will do it in 2 steps. First get the area over which to
192 // iterate, based on hit coordinates and (dx,dy). This first step
193 // has nothing to do with segmentation in the first place, but with
194 // how we simulate the fact that at some point the charge is shared
195 // amongst several pads.
196 // The second step is the actual pad iteration and is handled by
197 // a specific class (which has to do only with iteration...)
199 // FIXME: this method should not be here in the first place, IMHO.
202 // Find the wire position (center of charge distribution)
203 Float_t xwire = GetAnod(xhit);
207 Double_t x01 = xwire - dx;
208 Double_t x02 = xwire + dx;
209 Double_t y01 = yhit - dy;
210 Double_t y02 = yhit + dy;
212 Double_t xext = x02 - x01;
213 Double_t yext = y02 - y01;
215 // we do not check area here, as we assume the iterator
216 // will do it, and will possibly truncate it if needed.
217 // Note that we convert the area position to a reference frame
218 // located in the lower-left corner of the slat, instead of its
220 // AliMpArea area(TVector2((x01+x02)/2.0+fSlat->DX(),
221 // (y01+y02)/2.0+fSlat->DY()),
222 // TVector2(xext/2.0,yext/2.0));
223 AliMpArea area(TVector2((x01+x02)/2.0,(y01+y02)/2.0),
224 TVector2(xext/2.0,yext/2.0));
228 fPadIterator = fSlatSegmentation->CreateIterator(area);
230 fPadIterator->First();
232 fCurrentPad = fPadIterator->CurrentItem();
234 if ( !fCurrentPad.IsValid() )
236 AliError(Form("Cannot get a valid pad for (xhit,yhit,dx,dy)=(%e,%e,%e,%e)",xhit,yhit,dx,dy));
239 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d slat=%s",
241 fCurrentPad.GetIndices().GetFirst(),
242 fCurrentPad.GetIndices().GetSecond(),fSlat->GetID()));
245 //_____________________________________________________________________________
247 AliMUONSt345SlatSegmentationV2::GetAnod(Float_t xhit) const
249 // Gets the x-coordinate of the wire which is the closest to xhit.
251 Int_t n = Int_t(xhit/AliMUONConstants::Pitch());
252 Float_t wire = (xhit>0) ? n+0.5 : n-0.5;
253 return AliMUONConstants::Pitch()*wire;
256 //_____________________________________________________________________________
257 AliMUONGeometryDirection
258 AliMUONSt345SlatSegmentationV2::GetDirection()
260 //AliWarning("Not Implemented");
261 return kDirUndefined;
264 //______________________________________________________________________________
265 const AliMpVSegmentation*
266 AliMUONSt345SlatSegmentationV2::GetMpSegmentation() const
268 // Returns the mapping segmentation
269 // (provides access to electronics info)
271 return fSlatSegmentation;
275 //_____________________________________________________________________________
277 AliMUONSt345SlatSegmentationV2::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
279 AliFatal("Not Implemented");
282 //_____________________________________________________________________________
284 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
285 Float_t& x, Float_t& y, Float_t& z)
291 //_____________________________________________________________________________
293 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
294 Float_t& x, Float_t& y)
297 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
298 x = pad.Position().X();
299 y = pad.Position().Y();
303 //_____________________________________________________________________________
305 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
306 Int_t& ix, Int_t& iy)
311 //_____________________________________________________________________________
313 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y,
314 Int_t& ix, Int_t& iy)
316 AliMpPad pad = fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
318 if ( pad != AliMpPad::Invalid() )
320 ix = pad.GetIndices().GetFirst();
321 iy = pad.GetIndices().GetSecond();
329 //_____________________________________________________________________________
331 AliMUONSt345SlatSegmentationV2::GiveTestPoints(Int_t&,Float_t*,Float_t*) const
333 AliFatal("Not Implemented");
336 //_____________________________________________________________________________
338 AliMUONSt345SlatSegmentationV2::HasPad(Float_t x, Float_t y, Float_t z)
341 GetPadI(x,y,z,ix,iy);
342 return HasPad(ix,iy);
345 //_____________________________________________________________________________
347 AliMUONSt345SlatSegmentationV2::HasPad(Int_t ix, Int_t iy)
349 return fSlatSegmentation->HasPad(AliMpIntPair(ix,iy));
352 //_____________________________________________________________________________
354 AliMUONSt345SlatSegmentationV2::IntegrationLimits(Float_t& x1, Float_t& x2,
355 Float_t& y1, Float_t& y2)
358 // Returns integration limits for current pad
361 // x1 = fXhit - fX - Dpx(fSector)/2.;
362 // x2 = x1 + Dpx(fSector);
363 // y1 = fYhit - fY - Dpy(fSector)/2.;
364 // y2 = y1 + Dpy(fSector);
366 Float_t x = fCurrentPad.Position().X();
367 Float_t y = fCurrentPad.Position().Y();
369 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0;
370 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0;
372 x1 = fXhit - x - padsizex/2.0;
374 y1 = fYhit - y - padsizey/2.0;
377 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));
380 //_____________________________________________________________________________
382 AliMUONSt345SlatSegmentationV2::ISector()
384 // FIXME: remove the usage of ISector from all the code.
388 //_____________________________________________________________________________
390 AliMUONSt345SlatSegmentationV2::Ix()
394 return fPadIterator->CurrentItem().GetIndices().GetFirst();
402 //_____________________________________________________________________________
404 AliMUONSt345SlatSegmentationV2::Iy()
408 return fPadIterator->CurrentItem().GetIndices().GetSecond();
416 //_____________________________________________________________________________
418 AliMUONSt345SlatSegmentationV2::MorePads()
420 return (fPadIterator && !fPadIterator->IsDone());
423 //_____________________________________________________________________________
425 AliMUONSt345SlatSegmentationV2::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
426 Int_t Xlist[10], Int_t Ylist[10])
428 // Find pad at (ix,iy) for which we'll search neighbours.
430 fSlatSegmentation->PadByIndices(AliMpIntPair(iX,iY),kTRUE);
432 // Define the region to look into : a region slightly bigger
433 // than the pad itself (5% bigger), in order to catch first neighbours.
435 AliMpArea area(pad.Position(),pad.Dimensions()*1.05);
437 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
440 while ( !it->IsDone() && n < 10 )
442 AliMpPad p = it->CurrentItem();
443 if ( p != pad ) // skip self
445 Xlist[n] = p.GetIndices().GetFirst();
446 Ylist[n] = p.GetIndices().GetSecond();
455 //_____________________________________________________________________________
457 AliMUONSt345SlatSegmentationV2::NextPad()
461 fPadIterator->Next();
462 fCurrentPad = fPadIterator->CurrentItem();
466 AliError("PadIterator not initialized. Please use First() first ;-)");
470 //_____________________________________________________________________________
472 AliMUONSt345SlatSegmentationV2::Npx() const
474 return fSlatSegmentation->MaxPadIndexX()+1;
477 //_____________________________________________________________________________
479 AliMUONSt345SlatSegmentationV2::Npy() const
481 return fSlatSegmentation->MaxPadIndexY()+1;
484 //_____________________________________________________________________________
486 AliMUONSt345SlatSegmentationV2::Print(Option_t*) const
488 cout << "DetElemId=" << fDetElemId << " PlaneType="
489 << fPlaneType << " Npx,Npy=" << Npx() << "," << Npy() << " fSlat=" << fSlat
490 << " fSlatSegmentation=" << fSlatSegmentation
491 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
494 //_____________________________________________________________________________
496 AliMUONSt345SlatSegmentationV2::Sector(Int_t ix, Int_t)
498 return fSlat->FindPCBIndex(ix);
501 //_____________________________________________________________________________
503 AliMUONSt345SlatSegmentationV2::Sector(Float_t x, Float_t y)
505 return fSlat->FindPCBIndex(x,y);
508 //_____________________________________________________________________________
510 AliMUONSt345SlatSegmentationV2::SetCorrFunc(Int_t,TF1*)
512 AliFatal("Not Implemented");
515 //_____________________________________________________________________________
517 AliMUONSt345SlatSegmentationV2::SetDAnod(float)
519 AliFatal("Not Implemented");
522 //_____________________________________________________________________________
524 AliMUONSt345SlatSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
530 // insure we're within the slat limits. If not, issue a simple
531 // warning, as this might be correct (due to clustering/fitting algorithm
532 // that is allowed to go a little bit outside limits).
533 // That should only be considered an error in case the point is way
534 // outside (but by how much is the question you'll have to determine
537 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
538 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
540 Double_t DX = - fSlat->DX() + TMath::Abs(fXhit);
541 Double_t DY = - fSlat->DY() + TMath::Abs(fYhit);
542 DX = ( DX > 0 ? DX : 0);
543 DY = ( DY > 0 ? DY : 0);
544 AliWarning(Form("Hit outside slat %s limits (x,y)hit = (%e,%e). "
545 "Outside by (%e,%e) cm. Might be ok though.",
546 fSlat->GetID(),fXhit,fYhit,DX,DY));
550 //_____________________________________________________________________________
552 AliMUONSt345SlatSegmentationV2::SetPad(Int_t ix, Int_t iy)
555 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
556 if ( !fCurrentPad.IsValid() )
558 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
562 //_____________________________________________________________________________
564 AliMUONSt345SlatSegmentationV2::SetPadSize(float,float)
566 AliFatal("Not Implemented");
569 //_____________________________________________________________________________
571 AliMUONSt345SlatSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
573 AliFatal("Not Implemented");
577 //_____________________________________________________________________________
579 AliMUONSt345SlatSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
581 AliFatal("Not Implemented");