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"
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"
35 #include "AliMUONSegmentationManager.h"
36 #include "AliMUONConstants.h"
38 #include "Riostream.h"
42 ClassImp(AliMUONSt345SlatSegmentationV2)
46 Double_t fgkLengthUnit = 0.1; // This class expects centimeters, while
47 // AliMpSlat works with milimeters.
48 Int_t fgIntOffset = 1;
52 //_____________________________________________________________________________
53 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2()
54 : AliMUONVGeometryDESegmentation(),
56 fPlaneType(kBendingPlane),
63 AliDebug(1,Form("this=%p default (empty) ctor",this));
66 //_____________________________________________________________________________
67 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2(Int_t detElemId, AliMpPlaneType bendingOrNonBending)
68 : AliMUONVGeometryDESegmentation(),
69 fDetElemId(detElemId),
70 fPlaneType(bendingOrNonBending),
83 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
84 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
88 //_____________________________________________________________________________
89 AliMUONSt345SlatSegmentationV2::~AliMUONSt345SlatSegmentationV2()
91 AliDebug(1,Form("dtor this=%p",this));
95 //_____________________________________________________________________________
97 AliMUONSt345SlatSegmentationV2::CorrFunc(Int_t) const
99 AliFatal("Not Implemented");
103 //_____________________________________________________________________________
105 AliMUONSt345SlatSegmentationV2::Distance2AndOffset(Int_t,Int_t,
106 Float_t,Float_t,Int_t*)
108 AliFatal("Not Implemented");
112 //_____________________________________________________________________________
114 AliMUONSt345SlatSegmentationV2::Draw(Option_t*)
116 AliFatal("Not Implemented");
119 //_____________________________________________________________________________
121 AliMUONSt345SlatSegmentationV2::Dpx() const
123 AliFatal("Not Implemented");
127 //_____________________________________________________________________________
129 AliMUONSt345SlatSegmentationV2::Dpy() const
131 AliFatal("Not Implemented");
135 //_____________________________________________________________________________
137 AliMUONSt345SlatSegmentationV2::Dpx(int ipcb) const
139 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
142 AliFatal("pcb is null!");
144 return pcb->PadSizeX() * fgkLengthUnit;
147 //_____________________________________________________________________________
149 AliMUONSt345SlatSegmentationV2::Dpy(int ipcb) const
151 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
154 AliFatal("pcb is null!");
156 return pcb->PadSizeY() * fgkLengthUnit;
159 //_____________________________________________________________________________
161 AliMUONSt345SlatSegmentationV2::FirstPad(Float_t xhit, Float_t yhit,
163 Float_t dx, Float_t dy)
165 // OK. We will do it in 2 steps. First get the area over which to
166 // iterate, based on hit coordinates and (dx,dy). This first step
167 // has nothing to do with segmentation in the first place, but with
168 // how we simulate the fact that at some point the charge is shared
169 // amongst several pads.
170 // The second step is the actual pad iteration and is handled by
171 // a specific class (which has to do only with iteration...)
173 // FIXME: this method should not be here in the first place, IMHO.
176 // Find the wire position (center of charge distribution)
177 Float_t xwire = GetAnod(xhit);
181 Double_t x01 = xwire - dx;
182 Double_t x02 = xwire + dx;
183 Double_t y01 = yhit - dy;
184 Double_t y02 = yhit + dy;
186 Double_t xext = x02 - x01;
187 Double_t yext = y02 - y01;
189 // we do not check area here, as we assume the iterator
190 // will do it, and will possibly truncate it if needed.
191 // Note that we convert the area position to a reference frame
192 // located in the lower-left corner of the slat, instead of its
194 AliMpArea area(TVector2((x01+x02)/2.0/fgkLengthUnit+fSlat->DX(),
195 (y01+y02)/2.0/fgkLengthUnit+fSlat->DY()),
196 TVector2(xext/2.0/fgkLengthUnit,yext/2.0/fgkLengthUnit));
200 fPadIterator = fSlatSegmentation->CreateIterator(area);
202 fPadIterator->First();
204 fCurrentPad = fPadIterator->CurrentItem();
206 if ( !fCurrentPad.IsValid() )
208 AliError(Form("Cannot get a valid pad for (xhit,yhit,dx,dy)=(%e,%e,%e,%e)",xhit,yhit,dx,dy));
211 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d slat=%s",
213 fCurrentPad.GetIndices().GetFirst()+1,
214 fCurrentPad.GetIndices().GetSecond()+1,fSlat->GetID()));
217 //_____________________________________________________________________________
219 AliMUONSt345SlatSegmentationV2::GetAnod(Float_t xhit) const
221 // Gets the x-coordinate of the wire which is the closest to xhit.
223 Int_t n = Int_t(xhit/AliMUONConstants::Pitch());
224 Float_t wire = (xhit>0) ? n+0.5 : n-0.5;
225 return AliMUONConstants::Pitch()*wire;
228 //_____________________________________________________________________________
229 AliMUONGeometryDirection
230 AliMUONSt345SlatSegmentationV2::GetDirection()
232 //AliWarning("Not Implemented");
233 return kDirUndefined;
236 //_____________________________________________________________________________
238 AliMUONSt345SlatSegmentationV2::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
240 AliFatal("Not Implemented");
243 //_____________________________________________________________________________
245 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
246 Float_t& x, Float_t& y, Float_t& z)
252 //_____________________________________________________________________________
254 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
255 Float_t& x, Float_t& y)
258 fSlatSegmentation->PadByIndices(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset),
260 x = pad.Position().X() * fgkLengthUnit;
261 y = pad.Position().Y() * fgkLengthUnit;
265 //_____________________________________________________________________________
267 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
268 Int_t& ix, Int_t& iy)
273 //_____________________________________________________________________________
275 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y,
276 Int_t& ix, Int_t& iy)
278 Double_t slatx = fSlat->DX();
279 Double_t slaty = fSlat->DY();
281 fSlatSegmentation->PadByPosition(TVector2(x/fgkLengthUnit+slatx,
282 y/fgkLengthUnit+slaty), kTRUE);
284 if ( pad != AliMpPad::Invalid() )
286 ix = pad.GetIndices().GetFirst() + fgIntOffset;
287 iy = pad.GetIndices().GetSecond() + fgIntOffset;
295 //_____________________________________________________________________________
297 AliMUONSt345SlatSegmentationV2::GiveTestPoints(Int_t&,Float_t*,Float_t*) const
299 AliFatal("Not Implemented");
302 //_____________________________________________________________________________
304 AliMUONSt345SlatSegmentationV2::HasPad(Float_t x, Float_t y, Float_t z)
307 GetPadI(x,y,z,ix,iy);
308 return HasPad(ix,iy);
311 //_____________________________________________________________________________
313 AliMUONSt345SlatSegmentationV2::HasPad(Int_t ix, Int_t iy)
315 return fSlatSegmentation->HasPad(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset));
318 //_____________________________________________________________________________
320 AliMUONSt345SlatSegmentationV2::Init(int)
322 AliWarning("Not Implemented because not needed ;-)");
325 //_____________________________________________________________________________
327 AliMUONSt345SlatSegmentationV2::IntegrationLimits(Float_t& x1, Float_t& x2,
328 Float_t& y1, Float_t& y2)
331 // Returns integration limits for current pad
334 // x1 = fXhit - fX - Dpx(fSector)/2.;
335 // x2 = x1 + Dpx(fSector);
336 // y1 = fYhit - fY - Dpy(fSector)/2.;
337 // y2 = y1 + Dpy(fSector);
339 Float_t x = fCurrentPad.Position().X() * fgkLengthUnit;
340 Float_t y = fCurrentPad.Position().Y() * fgkLengthUnit;
342 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0 * fgkLengthUnit;
343 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0 * fgkLengthUnit;
345 x1 = fXhit - x - padsizex/2.0;
347 y1 = fYhit - y - padsizey/2.0;
350 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));
353 //_____________________________________________________________________________
355 AliMUONSt345SlatSegmentationV2::ISector()
357 // FIXME: remove the usage of ISector from all the code.
361 //_____________________________________________________________________________
363 AliMUONSt345SlatSegmentationV2::Ix()
367 return fPadIterator->CurrentItem().GetIndices().GetFirst() + fgIntOffset;
375 //_____________________________________________________________________________
377 AliMUONSt345SlatSegmentationV2::Iy()
381 return fPadIterator->CurrentItem().GetIndices().GetSecond() + fgIntOffset;
389 //_____________________________________________________________________________
391 AliMUONSt345SlatSegmentationV2::MorePads()
393 return (fPadIterator && !fPadIterator->IsDone());
396 //_____________________________________________________________________________
398 AliMUONSt345SlatSegmentationV2::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
399 Int_t Xlist[10], Int_t Ylist[10])
401 // Find pad at (ix,iy) for which we'll search neighbours.
403 fSlatSegmentation->PadByIndices(AliMpIntPair(iX-fgIntOffset,iY-fgIntOffset),kTRUE);
405 // Define the region to look into : a region slightly bigger
406 // than the pad itself (10% bigger), in order to catch first neighbours.
407 AliMpArea area(pad.Position()+fSlat->Dimensions(),pad.Dimensions()*2.1);
409 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
412 while ( !it->IsDone() && n < 10 )
414 AliMpPad p = it->CurrentItem();
415 if ( p != pad ) // skip self
417 Xlist[n] = p.GetIndices().GetFirst() + fgIntOffset;
418 Ylist[n] = p.GetIndices().GetSecond() + fgIntOffset;
427 //_____________________________________________________________________________
429 AliMUONSt345SlatSegmentationV2::NextPad()
433 fPadIterator->Next();
434 fCurrentPad = fPadIterator->CurrentItem();
438 AliError("PadIterator not initialized. Please use First() first ;-)");
442 //_____________________________________________________________________________
444 AliMUONSt345SlatSegmentationV2::Npx() const
446 return fSlatSegmentation->MaxPadIndexX()+1;
449 //_____________________________________________________________________________
451 AliMUONSt345SlatSegmentationV2::Npy() const
453 return fSlatSegmentation->MaxPadIndexY()+1;
456 //_____________________________________________________________________________
458 AliMUONSt345SlatSegmentationV2::Print(Option_t*) const
460 cout << "DetElemId=" << fDetElemId << " PlaneType="
461 << fPlaneType << " Npx,Npy=" << Npx() << "," << Npy() << " fSlat=" << fSlat
462 << " fSlatSegmentation=" << fSlatSegmentation
463 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
466 //_____________________________________________________________________________
468 AliMUONSt345SlatSegmentationV2::ReadMappingData()
470 fSlatSegmentation = dynamic_cast<AliMpSlatSegmentation*>
471 (AliMUONSegmentationManager::Segmentation(fDetElemId,fPlaneType));
473 if (!fSlatSegmentation)
475 AliFatal("Wrong segmentation type encountered");
477 fSlat = fSlatSegmentation->Slat();
480 //_____________________________________________________________________________
482 AliMUONSt345SlatSegmentationV2::Sector(Int_t ix, Int_t)
484 return fSlat->FindPCBIndex(ix - fgIntOffset);
487 //_____________________________________________________________________________
489 AliMUONSt345SlatSegmentationV2::Sector(Float_t x, Float_t y)
491 return fSlat->FindPCBIndex(x,y);
494 //_____________________________________________________________________________
496 AliMUONSt345SlatSegmentationV2::SetCorrFunc(Int_t,TF1*)
498 AliFatal("Not Implemented");
501 //_____________________________________________________________________________
503 AliMUONSt345SlatSegmentationV2::SetDAnod(float)
505 AliFatal("Not Implemented");
508 //_____________________________________________________________________________
510 AliMUONSt345SlatSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
516 // insure we're within the slat limits. If not, issue an error and sets
517 // the current hit to slat center.
518 // FIXME: this should probably a) not happen at all b) be a fatal error
520 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
521 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
523 AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
524 " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
531 //_____________________________________________________________________________
533 AliMUONSt345SlatSegmentationV2::SetPad(Int_t ix, Int_t iy)
536 fSlatSegmentation->PadByIndices(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset),kTRUE);
537 if ( !fCurrentPad.IsValid() )
539 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
543 //_____________________________________________________________________________
545 AliMUONSt345SlatSegmentationV2::SetPadSize(float,float)
547 AliFatal("Not Implemented");
550 //_____________________________________________________________________________
552 AliMUONSt345SlatSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
554 AliFatal("Not Implemented");
558 //_____________________________________________________________________________
560 AliMUONSt345SlatSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
562 AliFatal("Not Implemented");
565 //_____________________________________________________________________________
567 AliMUONSt345SlatSegmentationV2::Streamer(TBuffer &R__b)
569 if (R__b.IsReading())
571 AliMUONSt345SlatSegmentationV2::Class()->ReadBuffer(R__b, this);
576 AliMUONSt345SlatSegmentationV2::Class()->WriteBuffer(R__b, this);