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 Int_t fgIntOffset = 1;
50 //_____________________________________________________________________________
51 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2()
52 : AliMUONVGeometryDESegmentation(),
54 fPlaneType(kBendingPlane),
61 AliDebug(1,Form("this=%p default (empty) ctor",this));
64 //_____________________________________________________________________________
65 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2(Int_t detElemId, AliMpPlaneType bendingOrNonBending)
66 : AliMUONVGeometryDESegmentation(),
67 fDetElemId(detElemId),
68 fPlaneType(bendingOrNonBending),
81 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
82 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
86 //_____________________________________________________________________________
87 AliMUONSt345SlatSegmentationV2::~AliMUONSt345SlatSegmentationV2()
89 AliDebug(1,Form("dtor this=%p",this));
93 //_____________________________________________________________________________
95 AliMUONSt345SlatSegmentationV2::CorrFunc(Int_t) const
97 AliFatal("Not Implemented");
101 //_____________________________________________________________________________
103 AliMUONSt345SlatSegmentationV2::Distance2AndOffset(Int_t,Int_t,
104 Float_t,Float_t,Int_t*)
106 AliFatal("Not Implemented");
110 //_____________________________________________________________________________
112 AliMUONSt345SlatSegmentationV2::Draw(Option_t*)
114 AliFatal("Not Implemented");
117 //_____________________________________________________________________________
119 AliMUONSt345SlatSegmentationV2::Dpx() const
121 AliFatal("Not Implemented");
125 //_____________________________________________________________________________
127 AliMUONSt345SlatSegmentationV2::Dpy() const
129 AliFatal("Not Implemented");
133 //_____________________________________________________________________________
135 AliMUONSt345SlatSegmentationV2::Dpx(int ipcb) const
137 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
140 AliFatal("pcb is null!");
142 return pcb->PadSizeX();
145 //_____________________________________________________________________________
147 AliMUONSt345SlatSegmentationV2::Dpy(int ipcb) const
149 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
152 AliFatal("pcb is null!");
154 return pcb->PadSizeY();
157 //_____________________________________________________________________________
159 AliMUONSt345SlatSegmentationV2::FirstPad(Float_t xhit, Float_t yhit,
161 Float_t dx, Float_t dy)
163 // OK. We will do it in 2 steps. First get the area over which to
164 // iterate, based on hit coordinates and (dx,dy). This first step
165 // has nothing to do with segmentation in the first place, but with
166 // how we simulate the fact that at some point the charge is shared
167 // amongst several pads.
168 // The second step is the actual pad iteration and is handled by
169 // a specific class (which has to do only with iteration...)
171 // FIXME: this method should not be here in the first place, IMHO.
174 // Find the wire position (center of charge distribution)
175 Float_t xwire = GetAnod(xhit);
179 Double_t x01 = xwire - dx;
180 Double_t x02 = xwire + dx;
181 Double_t y01 = yhit - dy;
182 Double_t y02 = yhit + dy;
184 Double_t xext = x02 - x01;
185 Double_t yext = y02 - y01;
187 // we do not check area here, as we assume the iterator
188 // will do it, and will possibly truncate it if needed.
189 // Note that we convert the area position to a reference frame
190 // located in the lower-left corner of the slat, instead of its
192 // AliMpArea area(TVector2((x01+x02)/2.0+fSlat->DX(),
193 // (y01+y02)/2.0+fSlat->DY()),
194 // TVector2(xext/2.0,yext/2.0));
195 AliMpArea area(TVector2((x01+x02)/2.0,(y01+y02)/2.0),
196 TVector2(xext/2.0,yext/2.0));
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 //______________________________________________________________________________
237 const AliMpVSegmentation*
238 AliMUONSt345SlatSegmentationV2::GetMpSegmentation() const
240 // Returns the mapping segmentation
241 // (provides access to electronics info)
243 return fSlatSegmentation;
247 //_____________________________________________________________________________
249 AliMUONSt345SlatSegmentationV2::GetNParallelAndOffset(Int_t,Int_t,Int_t*,Int_t*)
251 AliFatal("Not Implemented");
254 //_____________________________________________________________________________
256 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
257 Float_t& x, Float_t& y, Float_t& z)
263 //_____________________________________________________________________________
265 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
266 Float_t& x, Float_t& y)
269 fSlatSegmentation->PadByIndices(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset),
271 x = pad.Position().X();
272 y = pad.Position().Y();
276 //_____________________________________________________________________________
278 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
279 Int_t& ix, Int_t& iy)
284 //_____________________________________________________________________________
286 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y,
287 Int_t& ix, Int_t& iy)
289 // Double_t slatx = fSlat->DX();
290 // Double_t slaty = fSlat->DY();
292 fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
293 // fSlatSegmentation->PadByPosition(TVector2(x+slatx,y+slaty), kTRUE);
295 if ( pad != AliMpPad::Invalid() )
297 ix = pad.GetIndices().GetFirst() + fgIntOffset;
298 iy = pad.GetIndices().GetSecond() + fgIntOffset;
306 //_____________________________________________________________________________
308 AliMUONSt345SlatSegmentationV2::GiveTestPoints(Int_t&,Float_t*,Float_t*) const
310 AliFatal("Not Implemented");
313 //_____________________________________________________________________________
315 AliMUONSt345SlatSegmentationV2::HasPad(Float_t x, Float_t y, Float_t z)
318 GetPadI(x,y,z,ix,iy);
319 return HasPad(ix,iy);
322 //_____________________________________________________________________________
324 AliMUONSt345SlatSegmentationV2::HasPad(Int_t ix, Int_t iy)
326 return fSlatSegmentation->HasPad(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset));
329 //_____________________________________________________________________________
331 AliMUONSt345SlatSegmentationV2::Init(int)
333 AliWarning("Not Implemented because not needed ;-)");
336 //_____________________________________________________________________________
338 AliMUONSt345SlatSegmentationV2::IntegrationLimits(Float_t& x1, Float_t& x2,
339 Float_t& y1, Float_t& y2)
342 // Returns integration limits for current pad
345 // x1 = fXhit - fX - Dpx(fSector)/2.;
346 // x2 = x1 + Dpx(fSector);
347 // y1 = fYhit - fY - Dpy(fSector)/2.;
348 // y2 = y1 + Dpy(fSector);
350 Float_t x = fCurrentPad.Position().X();
351 Float_t y = fCurrentPad.Position().Y();
353 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0;
354 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0;
356 x1 = fXhit - x - padsizex/2.0;
358 y1 = fYhit - y - padsizey/2.0;
361 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));
364 //_____________________________________________________________________________
366 AliMUONSt345SlatSegmentationV2::ISector()
368 // FIXME: remove the usage of ISector from all the code.
372 //_____________________________________________________________________________
374 AliMUONSt345SlatSegmentationV2::Ix()
378 return fPadIterator->CurrentItem().GetIndices().GetFirst() + fgIntOffset;
386 //_____________________________________________________________________________
388 AliMUONSt345SlatSegmentationV2::Iy()
392 return fPadIterator->CurrentItem().GetIndices().GetSecond() + fgIntOffset;
400 //_____________________________________________________________________________
402 AliMUONSt345SlatSegmentationV2::MorePads()
404 return (fPadIterator && !fPadIterator->IsDone());
407 //_____________________________________________________________________________
409 AliMUONSt345SlatSegmentationV2::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
410 Int_t Xlist[10], Int_t Ylist[10])
412 // Find pad at (ix,iy) for which we'll search neighbours.
414 fSlatSegmentation->PadByIndices(AliMpIntPair(iX-fgIntOffset,iY-fgIntOffset),kTRUE);
416 // Define the region to look into : a region slightly bigger
417 // than the pad itself (10% bigger), in order to catch first neighbours.
418 // AliMpArea area(pad.Position()+fSlat->Dimensions(),pad.Dimensions()*2.1);
419 AliMpArea area(pad.Position(),pad.Dimensions()*2.1);
421 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
424 while ( !it->IsDone() && n < 10 )
426 AliMpPad p = it->CurrentItem();
427 if ( p != pad ) // skip self
429 Xlist[n] = p.GetIndices().GetFirst() + fgIntOffset;
430 Ylist[n] = p.GetIndices().GetSecond() + fgIntOffset;
439 //_____________________________________________________________________________
441 AliMUONSt345SlatSegmentationV2::NextPad()
445 fPadIterator->Next();
446 fCurrentPad = fPadIterator->CurrentItem();
450 AliError("PadIterator not initialized. Please use First() first ;-)");
454 //_____________________________________________________________________________
456 AliMUONSt345SlatSegmentationV2::Npx() const
458 return fSlatSegmentation->MaxPadIndexX()+1;
461 //_____________________________________________________________________________
463 AliMUONSt345SlatSegmentationV2::Npy() const
465 return fSlatSegmentation->MaxPadIndexY()+1;
468 //_____________________________________________________________________________
470 AliMUONSt345SlatSegmentationV2::Print(Option_t*) const
472 cout << "DetElemId=" << fDetElemId << " PlaneType="
473 << fPlaneType << " Npx,Npy=" << Npx() << "," << Npy() << " fSlat=" << fSlat
474 << " fSlatSegmentation=" << fSlatSegmentation
475 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
478 //_____________________________________________________________________________
480 AliMUONSt345SlatSegmentationV2::ReadMappingData()
482 fSlatSegmentation = dynamic_cast<AliMpSlatSegmentation*>
483 (AliMUONSegmentationManager::Segmentation(fDetElemId,fPlaneType));
485 if (!fSlatSegmentation)
487 AliFatal("Wrong segmentation type encountered");
489 fSlat = fSlatSegmentation->Slat();
492 //_____________________________________________________________________________
494 AliMUONSt345SlatSegmentationV2::Sector(Int_t ix, Int_t)
496 return fSlat->FindPCBIndex(ix - fgIntOffset);
499 //_____________________________________________________________________________
501 AliMUONSt345SlatSegmentationV2::Sector(Float_t x, Float_t y)
503 return fSlat->FindPCBIndex(x,y);
506 //_____________________________________________________________________________
508 AliMUONSt345SlatSegmentationV2::SetCorrFunc(Int_t,TF1*)
510 AliFatal("Not Implemented");
513 //_____________________________________________________________________________
515 AliMUONSt345SlatSegmentationV2::SetDAnod(float)
517 AliFatal("Not Implemented");
520 //_____________________________________________________________________________
522 AliMUONSt345SlatSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
528 // insure we're within the slat limits. If not, issue an error and sets
529 // the current hit to slat center.
530 // FIXME: this should probably a) not happen at all b) be a fatal error
532 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
533 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
535 AliError(Form("Hit outside slat %s limits (x,y)hit = (%e,%e)."
536 " Forcing to (0,0)",fSlat->GetID(),fXhit,fYhit));
543 //_____________________________________________________________________________
545 AliMUONSt345SlatSegmentationV2::SetPad(Int_t ix, Int_t iy)
548 fSlatSegmentation->PadByIndices(AliMpIntPair(ix-fgIntOffset,iy-fgIntOffset),kTRUE);
549 if ( !fCurrentPad.IsValid() )
551 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
555 //_____________________________________________________________________________
557 AliMUONSt345SlatSegmentationV2::SetPadSize(float,float)
559 AliFatal("Not Implemented");
562 //_____________________________________________________________________________
564 AliMUONSt345SlatSegmentationV2::SigGenCond(Float_t,Float_t,Float_t)
566 AliFatal("Not Implemented");
570 //_____________________________________________________________________________
572 AliMUONSt345SlatSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
574 AliFatal("Not Implemented");
577 //_____________________________________________________________________________
579 AliMUONSt345SlatSegmentationV2::Streamer(TBuffer &R__b)
581 if (R__b.IsReading())
583 AliMUONSt345SlatSegmentationV2::Class()->ReadBuffer(R__b, this);
588 AliMUONSt345SlatSegmentationV2::Class()->WriteBuffer(R__b, this);