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 // -------------------------------------
19 // Class AliMUONSt345SlatSegmentation
20 // -------------------------------------
21 // Segmentation for MUON slat stations using
22 // the mapping package
25 #include "AliMUONSt345SlatSegmentationV2.h"
26 #include "AliMUONConstants.h"
28 #include "AliMpArea.h"
29 #include "AliMpSlat.h"
30 #include "AliMpSlatSegmentation.h"
32 // FIXME: we should not need access to PCB at this level
33 // if the Dpx, Dpy, Sector interface would not be used.
34 // Investigate instead to direct use of AliMpVSegmentation and AliMpPad
35 // from the clusterFinder ? // :aphecetc:20050722
36 // or, or ... have the AliMpSlat handles the notion of zone, finally
37 // (where "zone" in mapping is equivalent to "sector" here), and thus
38 // let AliMpSlat offer the interface to get information similar to what
39 // Dpx, Dpy, Sector offer now to the clustering. That indeed should be
40 // handled directly at the level of AliMpVSegmentation...
41 #include "AliMpVPadIterator.h"
45 #include "Riostream.h"
47 ClassImp(AliMUONSt345SlatSegmentationV2)
54 //_____________________________________________________________________________
55 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2()
56 : AliMUONVGeometryDESegmentation(),
58 fPlaneType(kBendingPlane),
67 AliDebug(1,Form("this=%p default (empty) ctor",this));
70 //_____________________________________________________________________________
71 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2(
72 AliMpVSegmentation* segmentation,
73 Int_t detElemId, AliMpPlaneType bendingOrNonBending)
74 : AliMUONVGeometryDESegmentation(),
75 fDetElemId(detElemId),
76 fPlaneType(bendingOrNonBending),
87 fSlatSegmentation = dynamic_cast<AliMpSlatSegmentation*>(segmentation);
88 if (fSlatSegmentation)
89 fSlat = fSlatSegmentation->Slat();
91 AliFatal("Wrong mapping segmentation type");
93 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
94 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
98 //______________________________________________________________________________
99 AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2(
100 const AliMUONSt345SlatSegmentationV2& right)
101 : AliMUONVGeometryDESegmentation(right)
103 /// Protected copy constructor (not implemented)
105 AliFatal("Copy constructor not provided.");
108 //_____________________________________________________________________________
109 AliMUONSt345SlatSegmentationV2::~AliMUONSt345SlatSegmentationV2()
113 AliDebug(1,Form("dtor this=%p",this));
117 //______________________________________________________________________________
118 AliMUONSt345SlatSegmentationV2&
119 AliMUONSt345SlatSegmentationV2::operator=(const AliMUONSt345SlatSegmentationV2& right)
121 /// Protected assignement operator (not implemented)
123 // check assignement to self
124 if (this == &right) return *this;
126 AliFatal("Assignement operator not provided.");
131 //_____________________________________________________________________________
133 AliMUONSt345SlatSegmentationV2::CorrFunc(Int_t /*isec*/) const
137 AliFatal("Not Implemented");
141 //_____________________________________________________________________________
143 AliMUONSt345SlatSegmentationV2::Distance2AndOffset(Int_t /*iX*/, Int_t /*iY*/,
144 Float_t /*x*/, Float_t /*y*/, Int_t* /*dummy*/){
147 AliFatal("Not Implemented");
151 //_____________________________________________________________________________
153 AliMUONSt345SlatSegmentationV2::Draw(Option_t* /*opt*/)
157 AliFatal("Not Implemented");
160 //_____________________________________________________________________________
162 AliMUONSt345SlatSegmentationV2::Dpx() const
166 AliFatal("Not Implemented");
170 //_____________________________________________________________________________
172 AliMUONSt345SlatSegmentationV2::Dpy() const
176 AliFatal("Not Implemented");
180 //_____________________________________________________________________________
182 AliMUONSt345SlatSegmentationV2::Dpx(int ipcb) const
186 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
189 AliFatal("pcb is null!");
191 return pcb->PadSizeX();
194 //_____________________________________________________________________________
196 AliMUONSt345SlatSegmentationV2::Dpy(int ipcb) const
200 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
203 AliFatal("pcb is null!");
205 return pcb->PadSizeY();
208 //_____________________________________________________________________________
210 AliMUONSt345SlatSegmentationV2::FirstPad(Float_t xhit, Float_t yhit,Float_t /*zhit*/,
211 Float_t dx, Float_t dy)
213 // OK. We will do it in 2 steps. First get the area over which to
214 // iterate, based on hit coordinates and (dx,dy). This first step
215 // has nothing to do with segmentation in the first place, but with
216 // how we simulate the fact that at some point the charge is shared
217 // amongst several pads.
218 // The second step is the actual pad iteration and is handled by
219 // a specific class (which has to do only with iteration...)
221 // FIXME: this method should not be here in the first place, IMHO.
224 // Find the wire position (center of charge distribution)
225 Float_t xwire = GetAnod(xhit);
229 Double_t x01 = xwire - dx;
230 Double_t x02 = xwire + dx;
231 Double_t y01 = yhit - dy;
232 Double_t y02 = yhit + dy;
234 Double_t xext = x02 - x01;
235 Double_t yext = y02 - y01;
237 // we do not check area here, as we assume the iterator
238 // will do it, and will possibly truncate it if needed.
239 // Note that we convert the area position to a reference frame
240 // located in the lower-left corner of the slat, instead of its
242 // AliMpArea area(TVector2((x01+x02)/2.0+fSlat->DX(),
243 // (y01+y02)/2.0+fSlat->DY()),
244 // TVector2(xext/2.0,yext/2.0));
245 AliMpArea area(TVector2((x01+x02)/2.0,(y01+y02)/2.0),
246 TVector2(xext/2.0,yext/2.0));
250 fPadIterator = fSlatSegmentation->CreateIterator(area);
252 fPadIterator->First();
254 fCurrentPad = fPadIterator->CurrentItem();
256 if ( !fCurrentPad.IsValid() )
258 AliError(Form("Cannot get a valid pad for (xhit,yhit,dx,dy)=(%e,%e,%e,%e)",xhit,yhit,dx,dy));
261 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d slat=%s",
263 fCurrentPad.GetIndices().GetFirst(),
264 fCurrentPad.GetIndices().GetSecond(),fSlat->GetID()));
267 //_____________________________________________________________________________
269 AliMUONSt345SlatSegmentationV2::GetAnod(Float_t xhit) const
271 // Gets the x-coordinate of the wire which is the closest to xhit.
273 Int_t n = Int_t(xhit/AliMUONConstants::Pitch());
274 Float_t wire = (xhit>0) ? n+0.5 : n-0.5;
275 return AliMUONConstants::Pitch()*wire;
278 //_____________________________________________________________________________
279 AliMUONGeometryDirection
280 AliMUONSt345SlatSegmentationV2::GetDirection()
284 //AliWarning("Not Implemented");
285 return kDirUndefined;
288 //______________________________________________________________________________
289 const AliMpVSegmentation*
290 AliMUONSt345SlatSegmentationV2::GetMpSegmentation() const
292 // Returns the mapping segmentation
293 // (provides access to electronics info)
295 return fSlatSegmentation;
299 //_____________________________________________________________________________
301 AliMUONSt345SlatSegmentationV2::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
302 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
306 AliFatal("Not Implemented");
309 //_____________________________________________________________________________
311 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
312 Float_t& x, Float_t& y, Float_t& z)
314 // Transform from pad to real coordinates
320 //_____________________________________________________________________________
322 AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
323 Float_t& x, Float_t& y)
325 // Transform from pad to real coordinates
328 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
329 x = pad.Position().X();
330 y = pad.Position().Y();
334 //_____________________________________________________________________________
336 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
337 Int_t& ix, Int_t& iy)
339 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
344 //_____________________________________________________________________________
346 AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y,
347 Int_t& ix, Int_t& iy)
349 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
351 AliMpPad pad = fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
353 if ( pad != AliMpPad::Invalid() )
355 ix = pad.GetIndices().GetFirst();
356 iy = pad.GetIndices().GetSecond();
364 //_____________________________________________________________________________
366 AliMUONSt345SlatSegmentationV2::GiveTestPoints(Int_t& /*n*/,
367 Float_t* /*x*/, Float_t* /*y*/) const
371 AliFatal("Not Implemented");
374 //_____________________________________________________________________________
376 AliMUONSt345SlatSegmentationV2::HasPad(Float_t x, Float_t y, Float_t z)
378 // Returns true if a pad exists in the given position
381 GetPadI(x,y,z,ix,iy);
382 return HasPad(ix,iy);
385 //_____________________________________________________________________________
387 AliMUONSt345SlatSegmentationV2::HasPad(Int_t ix, Int_t iy)
389 // Returns true if a pad with given indices exists
391 return fSlatSegmentation->HasPad(AliMpIntPair(ix,iy));
394 //_____________________________________________________________________________
396 AliMUONSt345SlatSegmentationV2::IntegrationLimits(Float_t& x1, Float_t& x2,
397 Float_t& y1, Float_t& y2)
400 // Returns integration limits for current pad
403 // x1 = fXhit - fX - Dpx(fSector)/2.;
404 // x2 = x1 + Dpx(fSector);
405 // y1 = fYhit - fY - Dpy(fSector)/2.;
406 // y2 = y1 + Dpy(fSector);
408 Float_t x = fCurrentPad.Position().X();
409 Float_t y = fCurrentPad.Position().Y();
411 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0;
412 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0;
414 x1 = fXhit - x - padsizex/2.0;
416 y1 = fYhit - y - padsizey/2.0;
419 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));
422 //_____________________________________________________________________________
424 AliMUONSt345SlatSegmentationV2::ISector()
426 // FIXME: remove the usage of ISector from all the code.
430 //_____________________________________________________________________________
432 AliMUONSt345SlatSegmentationV2::Ix()
434 // Current pad cursor during disintegration
439 return fPadIterator->CurrentItem().GetIndices().GetFirst();
447 //_____________________________________________________________________________
449 AliMUONSt345SlatSegmentationV2::Iy()
451 // Current pad cursor during disintegration
456 return fPadIterator->CurrentItem().GetIndices().GetSecond();
464 //_____________________________________________________________________________
466 AliMUONSt345SlatSegmentationV2::MorePads()
468 return (fPadIterator && !fPadIterator->IsDone());
471 //_____________________________________________________________________________
473 AliMUONSt345SlatSegmentationV2::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
474 Int_t Xlist[10], Int_t Ylist[10])
476 // Find pad at (ix,iy) for which we'll search neighbours.
478 fSlatSegmentation->PadByIndices(AliMpIntPair(iX,iY),kTRUE);
480 // Define the region to look into : a region slightly bigger
481 // than the pad itself (5% bigger), in order to catch first neighbours.
483 AliMpArea area(pad.Position(),pad.Dimensions()*1.05);
485 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
488 while ( !it->IsDone() && n < 10 )
490 AliMpPad p = it->CurrentItem();
491 if ( p != pad ) // skip self
493 Xlist[n] = p.GetIndices().GetFirst();
494 Ylist[n] = p.GetIndices().GetSecond();
503 //_____________________________________________________________________________
505 AliMUONSt345SlatSegmentationV2::NextPad()
507 // Iterate over pads - stepper
511 fPadIterator->Next();
512 fCurrentPad = fPadIterator->CurrentItem();
516 AliError("PadIterator not initialized. Please use First() first ;-)");
520 //_____________________________________________________________________________
522 AliMUONSt345SlatSegmentationV2::Npx() const
524 // Maximum number of Pads in x
526 return fSlatSegmentation->MaxPadIndexX()+1;
529 //_____________________________________________________________________________
531 AliMUONSt345SlatSegmentationV2::Npy() const
533 // Maximum number of Pads in y
535 return fSlatSegmentation->MaxPadIndexY()+1;
538 //_____________________________________________________________________________
540 AliMUONSt345SlatSegmentationV2::Print(Option_t* /*opt*/) const
544 cout << "DetElemId=" << fDetElemId << " PlaneType="
545 << fPlaneType << " Npx,Npy=" << Npx() << "," << Npy() << " fSlat=" << fSlat
546 << " fSlatSegmentation=" << fSlatSegmentation
547 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
550 //_____________________________________________________________________________
552 AliMUONSt345SlatSegmentationV2::Sector(Int_t ix, Int_t /*iy*/)
554 // Calculate sector from pad coordinates
556 return fSlat->FindPCBIndex(ix);
559 //_____________________________________________________________________________
561 AliMUONSt345SlatSegmentationV2::Sector(Float_t x, Float_t y)
563 // Calculate sector from pad coordinates
565 return fSlat->FindPCBIndex(x,y);
568 //_____________________________________________________________________________
570 AliMUONSt345SlatSegmentationV2::SetCorrFunc(Int_t /*isec*/,TF1* /*func*/)
574 AliFatal("Not Implemented");
577 //_____________________________________________________________________________
579 AliMUONSt345SlatSegmentationV2::SetDAnod(float /*d*/)
583 AliFatal("Not Implemented");
586 //_____________________________________________________________________________
588 AliMUONSt345SlatSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
591 // Sets virtual hit position, needed for evaluating pad response
592 // outside the tracking program
598 // insure we're within the slat limits. If not, issue a simple
599 // warning, as this might be correct (due to clustering/fitting algorithm
600 // that is allowed to go a little bit outside limits).
601 // That should only be considered an error in case the point is way
602 // outside (but by how much is the question you'll have to determine
605 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
606 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
608 Double_t dx = - fSlat->DX() + TMath::Abs(fXhit);
609 Double_t dy = - fSlat->DY() + TMath::Abs(fYhit);
610 dx = ( dx > 0 ? dx : 0);
611 dy = ( dy > 0 ? dy : 0);
612 AliWarning(Form("Hit outside slat %s limits (x,y)hit = (%e,%e). "
613 "Outside by (%e,%e) cm. Might be ok though.",
614 fSlat->GetID(),fXhit,fYhit,dx,dy));
618 //_____________________________________________________________________________
620 AliMUONSt345SlatSegmentationV2::SetPad(Int_t ix, Int_t iy)
623 // Sets virtual pad coordinates, needed for evaluating pad response
624 // outside the tracking program.
627 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
628 if ( !fCurrentPad.IsValid() )
630 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
634 //_____________________________________________________________________________
636 AliMUONSt345SlatSegmentationV2::SetPadSize(float /*p1*/,float /*p2*/)
640 AliFatal("Not Implemented");
643 //_____________________________________________________________________________
645 AliMUONSt345SlatSegmentationV2::SigGenCond(Float_t /*x*/, Float_t /*y*/, Float_t /*z*/)
649 AliFatal("Not Implemented");
653 //_____________________________________________________________________________
655 AliMUONSt345SlatSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
659 AliFatal("Not Implemented");