]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSt345SlatSegmentationV2.cxx
Comments for Doxygen
[u/mrichter/AliRoot.git] / MUON / AliMUONSt345SlatSegmentationV2.cxx
CommitLineData
90e8f97c 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15
16/* $Id$ */
17
18#include "AliMUONSt345SlatSegmentationV2.h"
8fbf5237 19#include "AliMUONConstants.h"
90e8f97c 20
90e8f97c 21#include "AliMpArea.h"
22#include "AliMpSlat.h"
23#include "AliMpSlatSegmentation.h"
24#include "AliMpPCB.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"
90e8f97c 35
8fbf5237 36#include "AliLog.h"
90e8f97c 37
8fbf5237 38#include "Riostream.h"
90e8f97c 39
5398f946 40/// \cond CLASSIMP
90e8f97c 41ClassImp(AliMUONSt345SlatSegmentationV2)
5398f946 42/// \endcond
90e8f97c 43
44namespace
45{
90e8f97c 46 Float_t FMAX(1E9);
47}
48
49//_____________________________________________________________________________
50AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2()
51: AliMUONVGeometryDESegmentation(),
52fDetElemId(-1),
53fPlaneType(kBendingPlane),
54fSlat(0),
55fSlatSegmentation(0),
56fPadIterator(0),
ccea41d4 57fCurrentPad(),
90e8f97c 58fXhit(FMAX),
59fYhit(FMAX)
60{
5398f946 61/// Default ctor
c895a991 62
90e8f97c 63 AliDebug(1,Form("this=%p default (empty) ctor",this));
64}
65
66//_____________________________________________________________________________
8fbf5237 67AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2(
68 AliMpVSegmentation* segmentation,
69 Int_t detElemId, AliMpPlaneType bendingOrNonBending)
90e8f97c 70: AliMUONVGeometryDESegmentation(),
71fDetElemId(detElemId),
72fPlaneType(bendingOrNonBending),
73fSlat(0),
74fSlatSegmentation(0),
75fPadIterator(0),
ccea41d4 76fCurrentPad(),
90e8f97c 77fXhit(FMAX),
78fYhit(FMAX)
79{
5398f946 80/// Normal ctor.
8fbf5237 81
82 fSlatSegmentation = dynamic_cast<AliMpSlatSegmentation*>(segmentation);
83 if (fSlatSegmentation)
84 fSlat = fSlatSegmentation->Slat();
85 else
86 AliFatal("Wrong mapping segmentation type");
90e8f97c 87
88 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
89 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
90 fSlatSegmentation));
91}
92
93//_____________________________________________________________________________
94AliMUONSt345SlatSegmentationV2::~AliMUONSt345SlatSegmentationV2()
95{
5398f946 96/// Destructor
c895a991 97
90e8f97c 98 AliDebug(1,Form("dtor this=%p",this));
99 delete fPadIterator;
100}
101
102//_____________________________________________________________________________
103TF1*
c895a991 104AliMUONSt345SlatSegmentationV2::CorrFunc(Int_t /*isec*/) const
90e8f97c 105{
5398f946 106/// Not implemented
c895a991 107
90e8f97c 108 AliFatal("Not Implemented");
109 return 0x0;
110}
111
112//_____________________________________________________________________________
113Float_t
c895a991 114AliMUONSt345SlatSegmentationV2::Distance2AndOffset(Int_t /*iX*/, Int_t /*iY*/,
115 Float_t /*x*/, Float_t /*y*/, Int_t* /*dummy*/){
5398f946 116/// Not implemented
c895a991 117
90e8f97c 118 AliFatal("Not Implemented");
119 return 0.0;
120}
121
122//_____________________________________________________________________________
123void
c895a991 124AliMUONSt345SlatSegmentationV2::Draw(Option_t* /*opt*/)
90e8f97c 125{
5398f946 126/// Not implemented
c895a991 127
90e8f97c 128 AliFatal("Not Implemented");
129}
130
131//_____________________________________________________________________________
132Float_t
133AliMUONSt345SlatSegmentationV2::Dpx() const
134{
5398f946 135/// Not implemented
c895a991 136
90e8f97c 137 AliFatal("Not Implemented");
138 return 0.0;
139}
140
141//_____________________________________________________________________________
142Float_t
143AliMUONSt345SlatSegmentationV2::Dpy() const
144{
5398f946 145/// Not implemented
c895a991 146
90e8f97c 147 AliFatal("Not Implemented");
148 return 0.0;
149}
150
151//_____________________________________________________________________________
152Float_t
153AliMUONSt345SlatSegmentationV2::Dpx(int ipcb) const
154{
5398f946 155/// Get pad size in x
c895a991 156
90e8f97c 157 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
df484e06 158 if (!pcb)
159 {
160 AliFatal("pcb is null!");
161 }
dfaf6b0d 162 return pcb->PadSizeX();
90e8f97c 163}
164
165//_____________________________________________________________________________
166Float_t
167AliMUONSt345SlatSegmentationV2::Dpy(int ipcb) const
168{
5398f946 169/// Get pad size in y
c895a991 170
90e8f97c 171 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
df484e06 172 if (!pcb)
173 {
174 AliFatal("pcb is null!");
175 }
dfaf6b0d 176 return pcb->PadSizeY();
90e8f97c 177}
178
179//_____________________________________________________________________________
180void
c895a991 181AliMUONSt345SlatSegmentationV2::FirstPad(Float_t xhit, Float_t yhit,Float_t /*zhit*/,
182 Float_t dx, Float_t dy)
90e8f97c 183{
5398f946 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...)
191///
192/// \todo FIXME: this method should not be here in the first place, IMHO.
90e8f97c 193
194 // Find the wire position (center of charge distribution)
195 Float_t xwire = GetAnod(xhit);
196 fXhit = xwire;
197 fYhit = yhit;
198
199 Double_t x01 = xwire - dx;
200 Double_t x02 = xwire + dx;
201 Double_t y01 = yhit - dy;
202 Double_t y02 = yhit + dy;
203
204 Double_t xext = x02 - x01;
205 Double_t yext = y02 - y01;
206
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
211 // center.
dfaf6b0d 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));
90e8f97c 217
218 delete fPadIterator;
219
220 fPadIterator = fSlatSegmentation->CreateIterator(area);
221
222 fPadIterator->First();
223
224 fCurrentPad = fPadIterator->CurrentItem();
225
226 if ( !fCurrentPad.IsValid() )
227 {
228 AliError(Form("Cannot get a valid pad for (xhit,yhit,dx,dy)=(%e,%e,%e,%e)",xhit,yhit,dx,dy));
229 }
230
231 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d slat=%s",
232 xhit,yhit,dx,dy,
2cc78641 233 fCurrentPad.GetIndices().GetFirst(),
234 fCurrentPad.GetIndices().GetSecond(),fSlat->GetID()));
90e8f97c 235}
236
237//_____________________________________________________________________________
238Float_t
239AliMUONSt345SlatSegmentationV2::GetAnod(Float_t xhit) const
240{
5398f946 241/// Gets the x-coordinate of the wire which is the closest to xhit.
90e8f97c 242
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;
246}
247
248//_____________________________________________________________________________
249AliMUONGeometryDirection
250AliMUONSt345SlatSegmentationV2::GetDirection()
251{
5398f946 252/// Not implemented
c895a991 253
5289cf2f 254 //AliWarning("Not Implemented");
90e8f97c 255 return kDirUndefined;
256}
257
b7ef3c96 258//______________________________________________________________________________
259const AliMpVSegmentation*
260AliMUONSt345SlatSegmentationV2::GetMpSegmentation() const
261{
5398f946 262/// Returns the mapping segmentation
263/// (provides access to electronics info)
b7ef3c96 264
265 return fSlatSegmentation;
266}
267
268
90e8f97c 269//_____________________________________________________________________________
270void
c895a991 271AliMUONSt345SlatSegmentationV2::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
272 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
90e8f97c 273{
5398f946 274/// Not implemented
c895a991 275
90e8f97c 276 AliFatal("Not Implemented");
277}
278
279//_____________________________________________________________________________
280void
281AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
c895a991 282 Float_t& x, Float_t& y, Float_t& z)
283{
5398f946 284/// Transform from pad to real coordinates
c895a991 285
90e8f97c 286 z = 0;
287 GetPadC(ix,iy,x,y);
288}
289
290//_____________________________________________________________________________
291void
292AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
c895a991 293 Float_t& x, Float_t& y)
90e8f97c 294{
5398f946 295/// Transform from pad to real coordinates
c895a991 296
df484e06 297 AliMpPad pad =
2cc78641 298 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
dfaf6b0d 299 x = pad.Position().X();
300 y = pad.Position().Y();
90e8f97c 301}
302
90e8f97c 303
304//_____________________________________________________________________________
305void
306AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
307Int_t& ix, Int_t& iy)
308{
5398f946 309/// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
c895a991 310
90e8f97c 311 GetPadI(x,y,ix,iy);
312}
313
314//_____________________________________________________________________________
315void
316AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y,
c895a991 317 Int_t& ix, Int_t& iy)
90e8f97c 318{
5398f946 319/// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
c895a991 320
2cc78641 321 AliMpPad pad = fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
90e8f97c 322
323 if ( pad != AliMpPad::Invalid() )
324 {
2cc78641 325 ix = pad.GetIndices().GetFirst();
326 iy = pad.GetIndices().GetSecond();
90e8f97c 327 }
328 else
329 {
330 ix = iy = -1;
331 }
332}
333
334//_____________________________________________________________________________
335void
c895a991 336AliMUONSt345SlatSegmentationV2::GiveTestPoints(Int_t& /*n*/,
337 Float_t* /*x*/, Float_t* /*y*/) const
90e8f97c 338{
5398f946 339/// Not implemented
c895a991 340
90e8f97c 341 AliFatal("Not Implemented");
342}
343
344//_____________________________________________________________________________
345Bool_t
346AliMUONSt345SlatSegmentationV2::HasPad(Float_t x, Float_t y, Float_t z)
347{
5398f946 348/// Returns true if a pad exists in the given position
c895a991 349
90e8f97c 350 Int_t ix, iy;
351 GetPadI(x,y,z,ix,iy);
352 return HasPad(ix,iy);
353}
354
355//_____________________________________________________________________________
356Bool_t
357AliMUONSt345SlatSegmentationV2::HasPad(Int_t ix, Int_t iy)
358{
5398f946 359/// Returns true if a pad with given indices exists
c895a991 360
2cc78641 361 return fSlatSegmentation->HasPad(AliMpIntPair(ix,iy));
90e8f97c 362}
363
364//_____________________________________________________________________________
365void
c895a991 366AliMUONSt345SlatSegmentationV2::IntegrationLimits(Float_t& x1, Float_t& x2,
367 Float_t& y1, Float_t& y2)
90e8f97c 368{
5398f946 369/// Returns integration limits for current pad
90e8f97c 370
371 // x1 = fXhit - fX - Dpx(fSector)/2.;
372 // x2 = x1 + Dpx(fSector);
373 // y1 = fYhit - fY - Dpy(fSector)/2.;
374 // y2 = y1 + Dpy(fSector);
375
dfaf6b0d 376 Float_t x = fCurrentPad.Position().X();
377 Float_t y = fCurrentPad.Position().Y();
90e8f97c 378
dfaf6b0d 379 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0;
380 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0;
90e8f97c 381
382 x1 = fXhit - x - padsizex/2.0;
383 x2 = x1 + padsizex;
384 y1 = fYhit - y - padsizey/2.0;
385 y2 = y1 + padsizey;
386
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));
388}
389
390//_____________________________________________________________________________
391Int_t
392AliMUONSt345SlatSegmentationV2::ISector()
393{
5398f946 394/// \todo FIXME: remove the usage of ISector from all the code.
395
90e8f97c 396 return -10;
397}
398
399//_____________________________________________________________________________
400Int_t
401AliMUONSt345SlatSegmentationV2::Ix()
402{
5398f946 403/// Current pad cursor during disintegration
404/// x, y-coordinate
c895a991 405
90e8f97c 406 if ( fPadIterator )
407 {
2cc78641 408 return fPadIterator->CurrentItem().GetIndices().GetFirst();
90e8f97c 409 }
410 else
411 {
412 return -1;
413 }
414}
415
416//_____________________________________________________________________________
417Int_t
418AliMUONSt345SlatSegmentationV2::Iy()
419{
5398f946 420/// Current pad cursor during disintegration
421/// x, y-coordinate
c895a991 422
90e8f97c 423 if ( fPadIterator )
424 {
2cc78641 425 return fPadIterator->CurrentItem().GetIndices().GetSecond();
90e8f97c 426 }
427 else
428 {
429 return -1;
430 }
431}
432
433//_____________________________________________________________________________
434Int_t
435AliMUONSt345SlatSegmentationV2::MorePads()
436{
5398f946 437/// Iterate over pads - condition
438
90e8f97c 439 return (fPadIterator && !fPadIterator->IsDone());
440}
441
442//_____________________________________________________________________________
443void
c895a991 444AliMUONSt345SlatSegmentationV2::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
445 Int_t Xlist[10], Int_t Ylist[10])
90e8f97c 446{
5398f946 447/// Find pad at (ix,iy) for which we'll search neighbours.
448
90e8f97c 449 AliMpPad pad =
2cc78641 450 fSlatSegmentation->PadByIndices(AliMpIntPair(iX,iY),kTRUE);
90e8f97c 451
452 // Define the region to look into : a region slightly bigger
e46a0808 453 // than the pad itself (5% bigger), in order to catch first neighbours.
454
455 AliMpArea area(pad.Position(),pad.Dimensions()*1.05);
90e8f97c 456
457 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
458 it->First();
459 Int_t n = 0;
460 while ( !it->IsDone() && n < 10 )
461 {
462 AliMpPad p = it->CurrentItem();
463 if ( p != pad ) // skip self
464 {
2cc78641 465 Xlist[n] = p.GetIndices().GetFirst();
466 Ylist[n] = p.GetIndices().GetSecond();
90e8f97c 467 ++n;
468 }
469 it->Next();
470 }
471 delete it;
472 *Nlist = n;
473}
474
475//_____________________________________________________________________________
476void
477AliMUONSt345SlatSegmentationV2::NextPad()
478{
5398f946 479/// Iterate over pads - stepper
c895a991 480
90e8f97c 481 if ( fPadIterator )
482 {
483 fPadIterator->Next();
484 fCurrentPad = fPadIterator->CurrentItem();
485 }
486 else
487 {
488 AliError("PadIterator not initialized. Please use First() first ;-)");
489 }
490}
491
492//_____________________________________________________________________________
493Int_t
494AliMUONSt345SlatSegmentationV2::Npx() const
495{
5398f946 496/// Maximum number of Pads in x
c895a991 497
90e8f97c 498 return fSlatSegmentation->MaxPadIndexX()+1;
499}
500
501//_____________________________________________________________________________
502Int_t
503AliMUONSt345SlatSegmentationV2::Npy() const
504{
5398f946 505/// Maximum number of Pads in y
c895a991 506
90e8f97c 507 return fSlatSegmentation->MaxPadIndexY()+1;
508}
509
510//_____________________________________________________________________________
511void
c895a991 512AliMUONSt345SlatSegmentationV2::Print(Option_t* /*opt*/) const
90e8f97c 513{
5398f946 514/// Printing
c895a991 515
90e8f97c 516 cout << "DetElemId=" << fDetElemId << " PlaneType="
df484e06 517 << fPlaneType << " Npx,Npy=" << Npx() << "," << Npy() << " fSlat=" << fSlat
90e8f97c 518 << " fSlatSegmentation=" << fSlatSegmentation
519 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
520}
521
90e8f97c 522//_____________________________________________________________________________
523Int_t
c895a991 524AliMUONSt345SlatSegmentationV2::Sector(Int_t ix, Int_t /*iy*/)
90e8f97c 525{
5398f946 526/// Calculate sector from pad coordinates
c895a991 527
2cc78641 528 return fSlat->FindPCBIndex(ix);
90e8f97c 529}
530
531//_____________________________________________________________________________
532Int_t
533AliMUONSt345SlatSegmentationV2::Sector(Float_t x, Float_t y)
534{
5398f946 535/// Calculate sector from pad coordinates
c895a991 536
90e8f97c 537 return fSlat->FindPCBIndex(x,y);
538}
539
540//_____________________________________________________________________________
541void
c895a991 542AliMUONSt345SlatSegmentationV2::SetCorrFunc(Int_t /*isec*/,TF1* /*func*/)
90e8f97c 543{
5398f946 544/// Not implemented
c895a991 545
90e8f97c 546 AliFatal("Not Implemented");
547}
548
549//_____________________________________________________________________________
550void
c895a991 551AliMUONSt345SlatSegmentationV2::SetDAnod(float /*d*/)
90e8f97c 552{
5398f946 553/// Not implemented
c895a991 554
90e8f97c 555 AliFatal("Not Implemented");
556}
557
558//_____________________________________________________________________________
559void
560AliMUONSt345SlatSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
561{
5398f946 562/// Set hit position
563/// Sets virtual hit position, needed for evaluating pad response
564/// outside the tracking program
c895a991 565
90e8f97c 566 fXhit = x;
567 fYhit = y;
568
569 //
2cc78641 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
575 // by yourself...)
90e8f97c 576 //
577 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
578 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
579 {
c895a991 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);
2cc78641 584 AliWarning(Form("Hit outside slat %s limits (x,y)hit = (%e,%e). "
585 "Outside by (%e,%e) cm. Might be ok though.",
c895a991 586 fSlat->GetID(),fXhit,fYhit,dx,dy));
2cc78641 587 }
90e8f97c 588}
589
590//_____________________________________________________________________________
591void
592AliMUONSt345SlatSegmentationV2::SetPad(Int_t ix, Int_t iy)
593{
5398f946 594/// Set pad position.
595/// Sets virtual pad coordinates, needed for evaluating pad response
596/// outside the tracking program.
c895a991 597
90e8f97c 598 fCurrentPad =
2cc78641 599 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
90e8f97c 600 if ( !fCurrentPad.IsValid() )
601 {
602 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
603 }
604}
605
606//_____________________________________________________________________________
607void
c895a991 608AliMUONSt345SlatSegmentationV2::SetPadSize(float /*p1*/,float /*p2*/)
90e8f97c 609{
5398f946 610/// Not implemented
c895a991 611
90e8f97c 612 AliFatal("Not Implemented");
613}
614
615//_____________________________________________________________________________
616Int_t
c895a991 617AliMUONSt345SlatSegmentationV2::SigGenCond(Float_t /*x*/, Float_t /*y*/, Float_t /*z*/)
90e8f97c 618{
5398f946 619/// Not implemented
c895a991 620
90e8f97c 621 AliFatal("Not Implemented");
622 return 0;
623}
624
625//_____________________________________________________________________________
626void
627AliMUONSt345SlatSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
628{
5398f946 629/// Not implemented
c895a991 630
90e8f97c 631 AliFatal("Not Implemented");
632}