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 "AliMUONSt345SlatSegmentation.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(AliMUONSt345SlatSegmentation)
49 //_____________________________________________________________________________
50 AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation()
51 : AliMUONVGeometryDESegmentation(),
53 fPlaneType(AliMp::kBendingPlane),
63 AliDebug(1,Form("this=%p default (empty) ctor",this));
66 //_____________________________________________________________________________
67 AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation(
68 AliMpVSegmentation* segmentation,
69 Int_t detElemId, AliMp::PlaneType bendingOrNonBending)
70 : AliMUONVGeometryDESegmentation(),
71 fDetElemId(detElemId),
72 fPlaneType(bendingOrNonBending),
82 fSlatSegmentation = dynamic_cast<AliMpSlatSegmentation*>(segmentation);
83 if (fSlatSegmentation)
84 fSlat = fSlatSegmentation->Slat();
86 AliFatal("Wrong mapping segmentation type");
88 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
89 ( (bendingOrNonBending==AliMp::kBendingPlane)?"Bending":"NonBending" ),
93 //_____________________________________________________________________________
94 AliMUONSt345SlatSegmentation::~AliMUONSt345SlatSegmentation()
98 AliDebug(1,Form("dtor this=%p",this));
102 //_____________________________________________________________________________
104 AliMUONSt345SlatSegmentation::CorrFunc(Int_t /*isec*/) const
108 AliFatal("Not Implemented");
112 //_____________________________________________________________________________
114 AliMUONSt345SlatSegmentation::Distance2AndOffset(Int_t /*iX*/, Int_t /*iY*/,
115 Float_t /*x*/, Float_t /*y*/, Int_t* /*dummy*/){
118 AliFatal("Not Implemented");
122 //_____________________________________________________________________________
124 AliMUONSt345SlatSegmentation::Draw(Option_t* /*opt*/)
128 AliFatal("Not Implemented");
131 //_____________________________________________________________________________
133 AliMUONSt345SlatSegmentation::Dpx() const
137 AliFatal("Not Implemented");
141 //_____________________________________________________________________________
143 AliMUONSt345SlatSegmentation::Dpy() const
147 AliFatal("Not Implemented");
151 //_____________________________________________________________________________
153 AliMUONSt345SlatSegmentation::Dpx(int ipcb) const
155 /// Get pad size in x
157 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
160 AliFatal("pcb is null!");
162 return pcb->PadSizeX();
165 //_____________________________________________________________________________
167 AliMUONSt345SlatSegmentation::Dpy(int ipcb) const
169 /// Get pad size in y
171 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
174 AliFatal("pcb is null!");
176 return pcb->PadSizeY();
179 //_____________________________________________________________________________
181 AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit,Float_t /*zhit*/,
182 Float_t dx, Float_t dy)
184 /// OK. We will do it in 2 steps. First get the area over which to
185 /// iterate, based on hit coordinates and (dx,dy). This first step
186 /// has nothing to do with segmentation in the first place, but with
187 /// how we simulate the fact that at some point the charge is shared
188 /// amongst several pads.
189 /// The second step is the actual pad iteration and is handled by
190 /// a specific class (which has to do only with iteration...)
192 /// \todo FIXME: this method should not be here in the first place, IMHO.
194 // Find the wire position (center of charge distribution)
195 Float_t xwire = GetAnod(xhit);
199 Double_t x01 = xwire - dx;
200 Double_t x02 = xwire + dx;
201 Double_t y01 = yhit - dy;
202 Double_t y02 = yhit + dy;
204 Double_t xext = x02 - x01;
205 Double_t yext = y02 - y01;
207 // we do not check area here, as we assume the iterator
208 // will do it, and will possibly truncate it if needed.
209 // Note that we convert the area position to a reference frame
210 // located in the lower-left corner of the slat, instead of its
212 // AliMpArea area(TVector2((x01+x02)/2.0+fSlat->DX(),
213 // (y01+y02)/2.0+fSlat->DY()),
214 // TVector2(xext/2.0,yext/2.0));
215 AliMpArea area(TVector2((x01+x02)/2.0,(y01+y02)/2.0),
216 TVector2(xext/2.0,yext/2.0));
220 fPadIterator = fSlatSegmentation->CreateIterator(area);
222 fPadIterator->First();
224 fCurrentPad = fPadIterator->CurrentItem();
226 if ( !fCurrentPad.IsValid() )
228 AliError(Form("Cannot get a valid pad for (xhit,yhit,dx,dy)=(%e,%e,%e,%e)",xhit,yhit,dx,dy));
231 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d slat=%s",
233 fCurrentPad.GetIndices().GetFirst(),
234 fCurrentPad.GetIndices().GetSecond(),fSlat->GetID()));
237 //_____________________________________________________________________________
239 AliMUONSt345SlatSegmentation::GetAnod(Float_t xhit) const
241 /// Gets the x-coordinate of the wire which is the closest to xhit.
243 Int_t n = Int_t(xhit/AliMUONConstants::Pitch());
244 Float_t wire = (xhit>0) ? n+0.5 : n-0.5;
245 return AliMUONConstants::Pitch()*wire;
248 //_____________________________________________________________________________
249 AliMUONGeometryDirection
250 AliMUONSt345SlatSegmentation::GetDirection()
254 //AliWarning("Not Implemented");
255 return kDirUndefined;
258 //______________________________________________________________________________
259 const AliMpVSegmentation*
260 AliMUONSt345SlatSegmentation::GetMpSegmentation() const
262 /// Returns the mapping segmentation
263 /// (provides access to electronics info)
265 return fSlatSegmentation;
269 //_____________________________________________________________________________
271 AliMUONSt345SlatSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
272 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
276 AliFatal("Not Implemented");
279 //_____________________________________________________________________________
281 AliMUONSt345SlatSegmentation::GetPadC(Int_t ix, Int_t iy,
282 Float_t& x, Float_t& y, Float_t& z)
284 /// Transform from pad to real coordinates
290 //_____________________________________________________________________________
292 AliMUONSt345SlatSegmentation::GetPadC(Int_t ix, Int_t iy,
293 Float_t& x, Float_t& y)
295 /// Transform from pad to real coordinates
298 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
299 x = pad.Position().X();
300 y = pad.Position().Y();
304 //_____________________________________________________________________________
306 AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
307 Int_t& ix, Int_t& iy)
309 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
314 //_____________________________________________________________________________
316 AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y,
317 Int_t& ix, Int_t& iy)
319 /// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
321 AliMpPad pad = fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
323 if ( pad != AliMpPad::Invalid() )
325 ix = pad.GetIndices().GetFirst();
326 iy = pad.GetIndices().GetSecond();
334 //_____________________________________________________________________________
336 AliMUONSt345SlatSegmentation::GiveTestPoints(Int_t& /*n*/,
337 Float_t* /*x*/, Float_t* /*y*/) const
341 AliFatal("Not Implemented");
344 //_____________________________________________________________________________
346 AliMUONSt345SlatSegmentation::HasPad(Float_t x, Float_t y, Float_t z)
348 /// Returns true if a pad exists in the given position
351 GetPadI(x,y,z,ix,iy);
352 return HasPad(ix,iy);
355 //_____________________________________________________________________________
357 AliMUONSt345SlatSegmentation::HasPad(Int_t ix, Int_t iy)
359 /// Returns true if a pad with given indices exists
361 return fSlatSegmentation->HasPad(AliMpIntPair(ix,iy));
364 //_____________________________________________________________________________
366 AliMUONSt345SlatSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
367 Float_t& y1, Float_t& y2)
369 /// Returns integration limits for current pad
371 // x1 = fXhit - fX - Dpx(fSector)/2.;
372 // x2 = x1 + Dpx(fSector);
373 // y1 = fYhit - fY - Dpy(fSector)/2.;
374 // y2 = y1 + Dpy(fSector);
376 Float_t x = fCurrentPad.Position().X();
377 Float_t y = fCurrentPad.Position().Y();
379 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0;
380 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0;
382 x1 = fXhit - x - padsizex/2.0;
384 y1 = fYhit - y - padsizey/2.0;
387 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));
390 //_____________________________________________________________________________
392 AliMUONSt345SlatSegmentation::ISector()
394 /// \todo FIXME: remove the usage of ISector from all the code.
399 //_____________________________________________________________________________
401 AliMUONSt345SlatSegmentation::Ix()
403 /// Current pad cursor during disintegration
408 return fPadIterator->CurrentItem().GetIndices().GetFirst();
416 //_____________________________________________________________________________
418 AliMUONSt345SlatSegmentation::Iy()
420 /// Current pad cursor during disintegration
425 return fPadIterator->CurrentItem().GetIndices().GetSecond();
433 //_____________________________________________________________________________
435 AliMUONSt345SlatSegmentation::MorePads()
437 /// Iterate over pads - condition
439 return (fPadIterator && !fPadIterator->IsDone());
442 //_____________________________________________________________________________
444 AliMUONSt345SlatSegmentation::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
445 Int_t Xlist[10], Int_t Ylist[10])
447 /// Find pad at (ix,iy) for which we'll search neighbours.
450 fSlatSegmentation->PadByIndices(AliMpIntPair(iX,iY),kTRUE);
452 // Define the region to look into : a region slightly bigger
453 // than the pad itself (5% bigger), in order to catch first neighbours.
455 AliMpArea area(pad.Position(),pad.Dimensions()*1.05);
457 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
460 while ( !it->IsDone() && n < 10 )
462 AliMpPad p = it->CurrentItem();
463 if ( p != pad ) // skip self
465 Xlist[n] = p.GetIndices().GetFirst();
466 Ylist[n] = p.GetIndices().GetSecond();
475 //_____________________________________________________________________________
477 AliMUONSt345SlatSegmentation::NextPad()
479 /// Iterate over pads - stepper
483 fPadIterator->Next();
484 fCurrentPad = fPadIterator->CurrentItem();
488 AliError("PadIterator not initialized. Please use First() first ;-)");
492 //_____________________________________________________________________________
494 AliMUONSt345SlatSegmentation::Npx() const
496 /// Maximum number of Pads in x
498 return fSlatSegmentation->MaxPadIndexX()+1;
501 //_____________________________________________________________________________
503 AliMUONSt345SlatSegmentation::Npy() const
505 /// Maximum number of Pads in y
507 return fSlatSegmentation->MaxPadIndexY()+1;
510 //_____________________________________________________________________________
512 AliMUONSt345SlatSegmentation::Print(Option_t* /*opt*/) const
516 cout << "DetElemId=" << fDetElemId << " PlaneType="
517 << fPlaneType << " Npx,Npy=" << Npx() << "," << Npy() << " fSlat=" << fSlat
518 << " fSlatSegmentation=" << fSlatSegmentation
519 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
522 //_____________________________________________________________________________
524 AliMUONSt345SlatSegmentation::Sector(Int_t ix, Int_t /*iy*/)
526 /// Calculate sector from pad coordinates
528 return fSlat->FindPCBIndex(ix);
531 //_____________________________________________________________________________
533 AliMUONSt345SlatSegmentation::Sector(Float_t x, Float_t y)
535 /// Calculate sector from pad coordinates
537 return fSlat->FindPCBIndex(x,y);
540 //_____________________________________________________________________________
542 AliMUONSt345SlatSegmentation::SetCorrFunc(Int_t /*isec*/,TF1* /*func*/)
546 AliFatal("Not Implemented");
549 //_____________________________________________________________________________
551 AliMUONSt345SlatSegmentation::SetDAnod(float /*d*/)
555 AliFatal("Not Implemented");
558 //_____________________________________________________________________________
560 AliMUONSt345SlatSegmentation::SetHit(Float_t x, Float_t y, Float_t)
563 /// Sets virtual hit position, needed for evaluating pad response
564 /// outside the tracking program
570 // insure we're within the slat limits. If not, issue a simple
571 // warning, as this might be correct (due to clustering/fitting algorithm
572 // that is allowed to go a little bit outside limits).
573 // That should only be considered an error in case the point is way
574 // outside (but by how much is the question you'll have to determine
577 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
578 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
580 Double_t dx = - fSlat->DX() + TMath::Abs(fXhit);
581 Double_t dy = - fSlat->DY() + TMath::Abs(fYhit);
582 dx = ( dx > 0 ? dx : 0);
583 dy = ( dy > 0 ? dy : 0);
584 AliWarning(Form("Hit outside slat %s limits (x,y)hit = (%e,%e). "
585 "Outside by (%e,%e) cm. Might be ok though.",
586 fSlat->GetID(),fXhit,fYhit,dx,dy));
590 //_____________________________________________________________________________
592 AliMUONSt345SlatSegmentation::SetPad(Int_t ix, Int_t iy)
594 /// Set pad position.
595 /// Sets virtual pad coordinates, needed for evaluating pad response
596 /// outside the tracking program.
599 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
600 if ( !fCurrentPad.IsValid() )
602 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
606 //_____________________________________________________________________________
608 AliMUONSt345SlatSegmentation::SetPadSize(float /*p1*/,float /*p2*/)
612 AliFatal("Not Implemented");
615 //_____________________________________________________________________________
617 AliMUONSt345SlatSegmentation::SigGenCond(Float_t /*x*/, Float_t /*y*/, Float_t /*z*/)
621 AliFatal("Not Implemented");
625 //_____________________________________________________________________________
627 AliMUONSt345SlatSegmentation::SigGenInit(Float_t,Float_t,Float_t)
631 AliFatal("Not Implemented");