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),
77 // slatType is the description of the PCBs of that slat,
78 // e.g. 122200N, 112200SR2, 112233NR3, etc...
79 // The actual filename used is dealt with by the AliMpSt345Reader class.
80 // Same thing for the path if that file, by the way.
84 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
85 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
89 //_____________________________________________________________________________
90 AliMUONSt345SlatSegmentationV2::~AliMUONSt345SlatSegmentationV2()
92 AliDebug(1,Form("dtor this=%p",this));
96 //_____________________________________________________________________________
98 AliMUONSt345SlatSegmentationV2::CorrFunc(Int_t) const
100 AliFatal("Not Implemented");
104 //_____________________________________________________________________________
106 AliMUONSt345SlatSegmentationV2::Distance2AndOffset(Int_t,Int_t,
107 Float_t,Float_t,Int_t*)
109 AliFatal("Not Implemented");
113 //_____________________________________________________________________________
115 AliMUONSt345SlatSegmentationV2::Draw(Option_t*)
117 AliFatal("Not Implemented");
120 //_____________________________________________________________________________
122 AliMUONSt345SlatSegmentationV2::Dpx() const
124 AliFatal("Not Implemented");
128 //_____________________________________________________________________________
130 AliMUONSt345SlatSegmentationV2::Dpy() const
132 AliFatal("Not Implemented");
136 //_____________________________________________________________________________
138 AliMUONSt345SlatSegmentationV2::Dpx(int ipcb) const
140 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
141 if (!pcb) AliFatal("pcb is null!");
142 return pcb->PadSizeX();
145 //_____________________________________________________________________________
147 AliMUONSt345SlatSegmentationV2::Dpy(int ipcb) const
149 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
150 if (!pcb) AliFatal("pcb is null!");
151 return pcb->PadSizeY();
154 //_____________________________________________________________________________
156 AliMUONSt345SlatSegmentationV2::FirstPad(Float_t xhit, Float_t yhit,
158 Float_t dx, Float_t dy)
160 // OK. We will do it in 2 steps. First get the area over which to
161 // iterate, based on hit coordinates and (dx,dy). This first step
162 // has nothing to do with segmentation in the first place, but with
163 // how we simulate the fact that at some point the charge is shared
164 // amongst several pads.
165 // The second step is the actual pad iteration and is handled by
166 // a specific class (which has to do only with iteration...)
168 // FIXME: this method should not be here in the first place, IMHO.
171 // Find the wire position (center of charge distribution)
172 Float_t xwire = GetAnod(xhit);
176 Double_t x01 = xwire - dx;
177 Double_t x02 = xwire + dx;
178 Double_t y01 = yhit - dy;
179 Double_t y02 = yhit + dy;
181 Double_t xext = x02 - x01;
182 Double_t yext = y02 - y01;
184 // we do not check area here, as we assume the iterator
185 // will do it, and will possibly truncate it if needed.
186 // Note that we convert the area position to a reference frame
187 // located in the lower-left corner of the slat, instead of its
189 AliMpArea area(TVector2((x01+x02)/2.0/fgkLengthUnit+fSlat->DX(),
190 (y01+y02)/2.0/fgkLengthUnit+fSlat->DY()),
191 TVector2(xext/2.0/fgkLengthUnit,yext/2.0/fgkLengthUnit));
195 fPadIterator = fSlatSegmentation->CreateIterator(area);
197 fPadIterator->First();
199 fCurrentPad = fPadIterator->CurrentItem();
201 if ( !fCurrentPad.IsValid() )
203 AliError(Form("Cannot get a valid pad for (xhit,yhit,dx,dy)=(%e,%e,%e,%e)",xhit,yhit,dx,dy));
206 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d slat=%s",
208 fCurrentPad.GetIndices().GetFirst()+1,
209 fCurrentPad.GetIndices().GetSecond()+1,fSlat->GetID()));
212 //_____________________________________________________________________________
214 AliMUONSt345SlatSegmentationV2::GetAnod(Float_t xhit) const
216 // Gets the x-coordinate of the wire which is the closest to xhit.
218 Int_t n = Int_t(xhit/AliMUONConstants::Pitch());
219 Float_t wire = (xhit>0) ? n+0.5 : n-0.5;
220 return AliMUONConstants::Pitch()*wire;
223 //_____________________________________________________________________________
224 AliMUONGeometryDirection
225 AliMUONSt345SlatSegmentationV2::GetDirection()
227 AliFatal("Not Implemented");
228 return kDirUndefined;
231 //_____________________________________________________________________________
233 AliMUONSt345SlatSegmentationV2::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
235 AliFatal("Not Implemented");
238 //_____________________________________________________________________________
240 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
241 Float_t& x, Float_t& y, Float_t& z)
247 //_____________________________________________________________________________
249 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
250 Float_t& x, Float_t& y)
252 AliMpPad pad = fSlatSegmentation->PadByIndices(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset),true);
253 x = pad.Position().X() * fgkLengthUnit;
254 y = pad.Position().Y() * fgkLengthUnit;
258 //_____________________________________________________________________________
260 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
261 Int_t& ix, Int_t& iy)
266 //_____________________________________________________________________________
268 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y,
269 Int_t& ix, Int_t& iy)
271 Double_t slatx = fSlat->DX();
272 Double_t slaty = fSlat->DY();
274 fSlatSegmentation->PadByPosition(TVector2(x/fgkLengthUnit+slatx,
275 y/fgkLengthUnit+slaty), true);
277 if ( pad != AliMpPad::Invalid() )
279 ix = pad.GetIndices().GetFirst() + fgIntOffset;
280 iy = pad.GetIndices().GetSecond() + fgIntOffset;
288 //_____________________________________________________________________________
290 AliMUONSt345SlatSegmentationV2::GiveTestPoints(Int_t&,Float_t*,Float_t*) const
292 AliFatal("Not Implemented");
295 //_____________________________________________________________________________
297 AliMUONSt345SlatSegmentationV2::HasPad(Float_t x, Float_t y, Float_t z)
300 GetPadI(x,y,z,ix,iy);
301 return HasPad(ix,iy);
304 //_____________________________________________________________________________
306 AliMUONSt345SlatSegmentationV2::HasPad(Int_t ix, Int_t iy)
308 return fSlatSegmentation->HasPad(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset));
311 //_____________________________________________________________________________
313 AliMUONSt345SlatSegmentationV2::Init(int)
315 AliWarning("Not Implemented because not needed ;-)");
318 //_____________________________________________________________________________
320 AliMUONSt345SlatSegmentationV2::IntegrationLimits(Float_t& x1, Float_t& x2,
321 Float_t& y1, Float_t& y2)
324 // Returns integration limits for current pad
327 // x1 = fXhit - fX - Dpx(fSector)/2.;
328 // x2 = x1 + Dpx(fSector);
329 // y1 = fYhit - fY - Dpy(fSector)/2.;
330 // y2 = y1 + Dpy(fSector);
332 Float_t x = fCurrentPad.Position().X() * fgkLengthUnit;
333 Float_t y = fCurrentPad.Position().Y() * fgkLengthUnit;
335 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0 * fgkLengthUnit;
336 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0 * fgkLengthUnit;
338 x1 = fXhit - x - padsizex/2.0;
340 y1 = fYhit - y - padsizey/2.0;
343 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));
346 //_____________________________________________________________________________
348 AliMUONSt345SlatSegmentationV2::ISector()
350 // FIXME: remove the usage of ISector from all the code.
354 //_____________________________________________________________________________
356 AliMUONSt345SlatSegmentationV2::Ix()
360 return fPadIterator->CurrentItem().GetIndices().GetFirst() + fgIntOffset;
368 //_____________________________________________________________________________
370 AliMUONSt345SlatSegmentationV2::Iy()
374 return fPadIterator->CurrentItem().GetIndices().GetSecond() + fgIntOffset;
382 //_____________________________________________________________________________
384 AliMUONSt345SlatSegmentationV2::MorePads()
386 return (fPadIterator && !fPadIterator->IsDone());
389 //_____________________________________________________________________________
391 AliMUONSt345SlatSegmentationV2::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
392 Int_t Xlist[10], Int_t Ylist[10])
394 // Find pad at (ix,iy) for which we'll search neighbours.
396 fSlatSegmentation->PadByIndices(AliMpIntPair(iX-fgIntOffset,iY-fgIntOffset),kTRUE);
398 // Define the region to look into : a region slightly bigger
399 // than the pad itself (10% bigger), in order to catch first neighbours.
400 AliMpArea area(pad.Position()+fSlat->Dimensions(),pad.Dimensions()*2.1);
402 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
405 while ( !it->IsDone() && n < 10 )
407 AliMpPad p = it->CurrentItem();
408 if ( p != pad ) // skip self
410 Xlist[n] = p.GetIndices().GetFirst() + fgIntOffset;
411 Ylist[n] = p.GetIndices().GetSecond() + fgIntOffset;
420 //_____________________________________________________________________________
422 AliMUONSt345SlatSegmentationV2::NextPad()
426 fPadIterator->Next();
427 fCurrentPad = fPadIterator->CurrentItem();
431 AliError("PadIterator not initialized. Please use First() first ;-)");
435 //_____________________________________________________________________________
437 AliMUONSt345SlatSegmentationV2::Npx() const
439 return fSlatSegmentation->MaxPadIndexX()+1;
442 //_____________________________________________________________________________
444 AliMUONSt345SlatSegmentationV2::Npy() const
446 return fSlatSegmentation->MaxPadIndexY()+1;
449 //_____________________________________________________________________________
451 AliMUONSt345SlatSegmentationV2::Print(Option_t*) const
453 cout << "DetElemId=" << fDetElemId << " PlaneType="
454 << fPlaneType << " fSlat=" << fSlat
455 << " fSlatSegmentation=" << fSlatSegmentation
456 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
459 //_____________________________________________________________________________
461 AliMUONSt345SlatSegmentationV2::ReadMappingData()
463 fSlatSegmentation = dynamic_cast<AliMpSlatSegmentation*>(AliMUONSegmentationManager::Segmentation(fDetElemId,fPlaneType));
464 if (!fSlatSegmentation)
466 AliFatal("Wrong segmentation type encountered");
468 fSlat = fSlatSegmentation->Slat();
471 //_____________________________________________________________________________
473 AliMUONSt345SlatSegmentationV2::Sector(Int_t ix, Int_t iy)
475 return fSlat->FindPCBIndex(ix,iy);
478 //_____________________________________________________________________________
480 AliMUONSt345SlatSegmentationV2::Sector(Float_t x, Float_t y)
482 return fSlat->FindPCBIndex(x,y);
485 //_____________________________________________________________________________
487 AliMUONSt345SlatSegmentationV2::SetCorrFunc(Int_t,TF1*)
489 AliFatal("Not Implemented");
492 //_____________________________________________________________________________
494 AliMUONSt345SlatSegmentationV2::SetDAnod(float)
496 AliFatal("Not Implemented");
499 //_____________________________________________________________________________
501 AliMUONSt345SlatSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
507 // insure we're within the slat limits. If not, issue an error and sets
508 // the current hit to slat center.
509 // FIXME: this should probably a) not happen at all b) be a fatal error
511 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
512 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
514 AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
515 " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
522 //_____________________________________________________________________________
524 AliMUONSt345SlatSegmentationV2::SetPad(Int_t ix, Int_t iy)
527 fSlatSegmentation->PadByIndices(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset),kTRUE);
528 if ( !fCurrentPad.IsValid() )
530 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
534 //_____________________________________________________________________________
536 AliMUONSt345SlatSegmentationV2::SetPadSize(float,float)
538 AliFatal("Not Implemented");
541 //_____________________________________________________________________________
543 AliMUONSt345SlatSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
545 AliFatal("Not Implemented");
549 //_____________________________________________________________________________
551 AliMUONSt345SlatSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
553 AliFatal("Not Implemented");
556 //_____________________________________________________________________________
558 AliMUONSt345SlatSegmentationV2::Streamer(TBuffer &R__b)
560 if (R__b.IsReading())
562 AliMUONSt345SlatSegmentationV2::Class()->ReadBuffer(R__b, this);
567 AliMUONSt345SlatSegmentationV2::Class()->WriteBuffer(R__b, this);