]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSt345SlatSegmentationV2.cxx
Coding conventions (Ivana)
[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
c895a991 18// -------------------------------------
19// Class AliMUONSt345SlatSegmentation
20// -------------------------------------
21// Segmentation for MUON slat stations using
22// the mapping package
23
24
84aac932 25// -------------------------------------
26// Class AliMUONSt345SlatSegmentation
27// -------------------------------------
28// Segmentation for MUON slat stations using
29// the mapping package
30
31
90e8f97c 32#include "AliMUONSt345SlatSegmentationV2.h"
8fbf5237 33#include "AliMUONConstants.h"
90e8f97c 34
90e8f97c 35#include "AliMpArea.h"
36#include "AliMpSlat.h"
37#include "AliMpSlatSegmentation.h"
38#include "AliMpPCB.h"
39// FIXME: we should not need access to PCB at this level
40// if the Dpx, Dpy, Sector interface would not be used.
41// Investigate instead to direct use of AliMpVSegmentation and AliMpPad
42// from the clusterFinder ? // :aphecetc:20050722
43// or, or ... have the AliMpSlat handles the notion of zone, finally
44// (where "zone" in mapping is equivalent to "sector" here), and thus
45// let AliMpSlat offer the interface to get information similar to what
46// Dpx, Dpy, Sector offer now to the clustering. That indeed should be
47// handled directly at the level of AliMpVSegmentation...
48#include "AliMpVPadIterator.h"
90e8f97c 49
8fbf5237 50#include "AliLog.h"
90e8f97c 51
8fbf5237 52#include "Riostream.h"
90e8f97c 53
54ClassImp(AliMUONSt345SlatSegmentationV2)
55
56namespace
57{
90e8f97c 58 Float_t FMAX(1E9);
59}
60
61//_____________________________________________________________________________
62AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2()
63: AliMUONVGeometryDESegmentation(),
64fDetElemId(-1),
65fPlaneType(kBendingPlane),
66fSlat(0),
67fSlatSegmentation(0),
68fPadIterator(0),
69fXhit(FMAX),
70fYhit(FMAX)
71{
c895a991 72// Default ctor
73
90e8f97c 74 AliDebug(1,Form("this=%p default (empty) ctor",this));
75}
76
77//_____________________________________________________________________________
8fbf5237 78AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2(
79 AliMpVSegmentation* segmentation,
80 Int_t detElemId, AliMpPlaneType bendingOrNonBending)
90e8f97c 81: AliMUONVGeometryDESegmentation(),
82fDetElemId(detElemId),
83fPlaneType(bendingOrNonBending),
84fSlat(0),
85fSlatSegmentation(0),
86fPadIterator(0),
87fXhit(FMAX),
88fYhit(FMAX)
89{
df484e06 90 //
91 // Normal ctor.
92 //
8fbf5237 93
94 fSlatSegmentation = dynamic_cast<AliMpSlatSegmentation*>(segmentation);
95 if (fSlatSegmentation)
96 fSlat = fSlatSegmentation->Slat();
97 else
98 AliFatal("Wrong mapping segmentation type");
90e8f97c 99
100 AliDebug(1,Form("this=%p detElemId=%3d %s fSlatSegmentation=%p",this,detElemId,
101 ( (bendingOrNonBending==kBendingPlane)?"Bending":"NonBending" ),
102 fSlatSegmentation));
103}
104
884a73f1 105//______________________________________________________________________________
106AliMUONSt345SlatSegmentationV2::AliMUONSt345SlatSegmentationV2(
107 const AliMUONSt345SlatSegmentationV2& right)
108 : AliMUONVGeometryDESegmentation(right)
109{
110/// Protected copy constructor (not implemented)
111
112 AliFatal("Copy constructor not provided.");
113}
114
90e8f97c 115//_____________________________________________________________________________
116AliMUONSt345SlatSegmentationV2::~AliMUONSt345SlatSegmentationV2()
117{
c895a991 118// Destructor
119
90e8f97c 120 AliDebug(1,Form("dtor this=%p",this));
121 delete fPadIterator;
122}
123
884a73f1 124//______________________________________________________________________________
125AliMUONSt345SlatSegmentationV2&
126AliMUONSt345SlatSegmentationV2::operator=(const AliMUONSt345SlatSegmentationV2& right)
127{
128/// Protected assignement operator (not implemented)
129
130 // check assignement to self
131 if (this == &right) return *this;
132
133 AliFatal("Assignement operator not provided.");
134
135 return *this;
136}
137
90e8f97c 138//_____________________________________________________________________________
139TF1*
c895a991 140AliMUONSt345SlatSegmentationV2::CorrFunc(Int_t /*isec*/) const
90e8f97c 141{
c895a991 142// Not implemented
143
90e8f97c 144 AliFatal("Not Implemented");
145 return 0x0;
146}
147
148//_____________________________________________________________________________
149Float_t
c895a991 150AliMUONSt345SlatSegmentationV2::Distance2AndOffset(Int_t /*iX*/, Int_t /*iY*/,
151 Float_t /*x*/, Float_t /*y*/, Int_t* /*dummy*/){
152// Not implemented
153
90e8f97c 154 AliFatal("Not Implemented");
155 return 0.0;
156}
157
158//_____________________________________________________________________________
159void
c895a991 160AliMUONSt345SlatSegmentationV2::Draw(Option_t* /*opt*/)
90e8f97c 161{
c895a991 162// Not implemented
163
90e8f97c 164 AliFatal("Not Implemented");
165}
166
167//_____________________________________________________________________________
168Float_t
169AliMUONSt345SlatSegmentationV2::Dpx() const
170{
c895a991 171// Not implemented
172
90e8f97c 173 AliFatal("Not Implemented");
174 return 0.0;
175}
176
177//_____________________________________________________________________________
178Float_t
179AliMUONSt345SlatSegmentationV2::Dpy() const
180{
c895a991 181// Not implemented
182
90e8f97c 183 AliFatal("Not Implemented");
184 return 0.0;
185}
186
187//_____________________________________________________________________________
188Float_t
189AliMUONSt345SlatSegmentationV2::Dpx(int ipcb) const
190{
c895a991 191// Get pad size in x
192
90e8f97c 193 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
df484e06 194 if (!pcb)
195 {
196 AliFatal("pcb is null!");
197 }
dfaf6b0d 198 return pcb->PadSizeX();
90e8f97c 199}
200
201//_____________________________________________________________________________
202Float_t
203AliMUONSt345SlatSegmentationV2::Dpy(int ipcb) const
204{
c895a991 205// Get pad size in y
206
90e8f97c 207 AliMpPCB* pcb = fSlat->GetPCB(ipcb);
df484e06 208 if (!pcb)
209 {
210 AliFatal("pcb is null!");
211 }
dfaf6b0d 212 return pcb->PadSizeY();
90e8f97c 213}
214
215//_____________________________________________________________________________
216void
c895a991 217AliMUONSt345SlatSegmentationV2::FirstPad(Float_t xhit, Float_t yhit,Float_t /*zhit*/,
218 Float_t dx, Float_t dy)
90e8f97c 219{
220 // OK. We will do it in 2 steps. First get the area over which to
221 // iterate, based on hit coordinates and (dx,dy). This first step
222 // has nothing to do with segmentation in the first place, but with
223 // how we simulate the fact that at some point the charge is shared
224 // amongst several pads.
225 // The second step is the actual pad iteration and is handled by
226 // a specific class (which has to do only with iteration...)
227 //
228 // FIXME: this method should not be here in the first place, IMHO.
229 //
230
231 // Find the wire position (center of charge distribution)
232 Float_t xwire = GetAnod(xhit);
233 fXhit = xwire;
234 fYhit = yhit;
235
236 Double_t x01 = xwire - dx;
237 Double_t x02 = xwire + dx;
238 Double_t y01 = yhit - dy;
239 Double_t y02 = yhit + dy;
240
241 Double_t xext = x02 - x01;
242 Double_t yext = y02 - y01;
243
244 // we do not check area here, as we assume the iterator
245 // will do it, and will possibly truncate it if needed.
246 // Note that we convert the area position to a reference frame
247 // located in the lower-left corner of the slat, instead of its
248 // center.
dfaf6b0d 249// AliMpArea area(TVector2((x01+x02)/2.0+fSlat->DX(),
250// (y01+y02)/2.0+fSlat->DY()),
251// TVector2(xext/2.0,yext/2.0));
252 AliMpArea area(TVector2((x01+x02)/2.0,(y01+y02)/2.0),
253 TVector2(xext/2.0,yext/2.0));
90e8f97c 254
255 delete fPadIterator;
256
257 fPadIterator = fSlatSegmentation->CreateIterator(area);
258
259 fPadIterator->First();
260
261 fCurrentPad = fPadIterator->CurrentItem();
262
263 if ( !fCurrentPad.IsValid() )
264 {
265 AliError(Form("Cannot get a valid pad for (xhit,yhit,dx,dy)=(%e,%e,%e,%e)",xhit,yhit,dx,dy));
266 }
267
268 AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d slat=%s",
269 xhit,yhit,dx,dy,
2cc78641 270 fCurrentPad.GetIndices().GetFirst(),
271 fCurrentPad.GetIndices().GetSecond(),fSlat->GetID()));
90e8f97c 272}
273
274//_____________________________________________________________________________
275Float_t
276AliMUONSt345SlatSegmentationV2::GetAnod(Float_t xhit) const
277{
278 // Gets the x-coordinate of the wire which is the closest to xhit.
279
280 Int_t n = Int_t(xhit/AliMUONConstants::Pitch());
281 Float_t wire = (xhit>0) ? n+0.5 : n-0.5;
282 return AliMUONConstants::Pitch()*wire;
283}
284
285//_____________________________________________________________________________
286AliMUONGeometryDirection
287AliMUONSt345SlatSegmentationV2::GetDirection()
288{
c895a991 289// Not implemented
290
5289cf2f 291 //AliWarning("Not Implemented");
90e8f97c 292 return kDirUndefined;
293}
294
b7ef3c96 295//______________________________________________________________________________
296const AliMpVSegmentation*
297AliMUONSt345SlatSegmentationV2::GetMpSegmentation() const
298{
299// Returns the mapping segmentation
300// (provides access to electronics info)
301
302 return fSlatSegmentation;
303}
304
305
90e8f97c 306//_____________________________________________________________________________
307void
c895a991 308AliMUONSt345SlatSegmentationV2::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
309 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
90e8f97c 310{
c895a991 311// Not implemented
312
90e8f97c 313 AliFatal("Not Implemented");
314}
315
316//_____________________________________________________________________________
317void
318AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
c895a991 319 Float_t& x, Float_t& y, Float_t& z)
320{
321// Transform from pad to real coordinates
322
90e8f97c 323 z = 0;
324 GetPadC(ix,iy,x,y);
325}
326
327//_____________________________________________________________________________
328void
329AliMUONSt345SlatSegmentationV2::GetPadC(Int_t ix, Int_t iy,
c895a991 330 Float_t& x, Float_t& y)
90e8f97c 331{
c895a991 332// Transform from pad to real coordinates
333
df484e06 334 AliMpPad pad =
2cc78641 335 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
dfaf6b0d 336 x = pad.Position().X();
337 y = pad.Position().Y();
90e8f97c 338}
339
90e8f97c 340
341//_____________________________________________________________________________
342void
343AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
344Int_t& ix, Int_t& iy)
345{
c895a991 346// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
347
90e8f97c 348 GetPadI(x,y,ix,iy);
349}
350
351//_____________________________________________________________________________
352void
353AliMUONSt345SlatSegmentationV2::GetPadI(Float_t x, Float_t y,
c895a991 354 Int_t& ix, Int_t& iy)
90e8f97c 355{
c895a991 356// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
357
2cc78641 358 AliMpPad pad = fSlatSegmentation->PadByPosition(TVector2(x,y), kTRUE);
90e8f97c 359
360 if ( pad != AliMpPad::Invalid() )
361 {
2cc78641 362 ix = pad.GetIndices().GetFirst();
363 iy = pad.GetIndices().GetSecond();
90e8f97c 364 }
365 else
366 {
367 ix = iy = -1;
368 }
369}
370
371//_____________________________________________________________________________
372void
c895a991 373AliMUONSt345SlatSegmentationV2::GiveTestPoints(Int_t& /*n*/,
374 Float_t* /*x*/, Float_t* /*y*/) const
90e8f97c 375{
c895a991 376// Not implemented
377
90e8f97c 378 AliFatal("Not Implemented");
379}
380
381//_____________________________________________________________________________
382Bool_t
383AliMUONSt345SlatSegmentationV2::HasPad(Float_t x, Float_t y, Float_t z)
384{
c895a991 385// Returns true if a pad exists in the given position
386
90e8f97c 387 Int_t ix, iy;
388 GetPadI(x,y,z,ix,iy);
389 return HasPad(ix,iy);
390}
391
392//_____________________________________________________________________________
393Bool_t
394AliMUONSt345SlatSegmentationV2::HasPad(Int_t ix, Int_t iy)
395{
c895a991 396// Returns true if a pad with given indices exists
397
2cc78641 398 return fSlatSegmentation->HasPad(AliMpIntPair(ix,iy));
90e8f97c 399}
400
401//_____________________________________________________________________________
402void
c895a991 403AliMUONSt345SlatSegmentationV2::IntegrationLimits(Float_t& x1, Float_t& x2,
404 Float_t& y1, Float_t& y2)
90e8f97c 405{
406 //
407 // Returns integration limits for current pad
408 //
409
410 // x1 = fXhit - fX - Dpx(fSector)/2.;
411 // x2 = x1 + Dpx(fSector);
412 // y1 = fYhit - fY - Dpy(fSector)/2.;
413 // y2 = y1 + Dpy(fSector);
414
dfaf6b0d 415 Float_t x = fCurrentPad.Position().X();
416 Float_t y = fCurrentPad.Position().Y();
90e8f97c 417
dfaf6b0d 418 Float_t padsizex = fCurrentPad.Dimensions().X() * 2.0;
419 Float_t padsizey = fCurrentPad.Dimensions().Y() * 2.0;
90e8f97c 420
421 x1 = fXhit - x - padsizex/2.0;
422 x2 = x1 + padsizex;
423 y1 = fYhit - y - padsizey/2.0;
424 y2 = y1 + padsizey;
425
426 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));
427}
428
429//_____________________________________________________________________________
430Int_t
431AliMUONSt345SlatSegmentationV2::ISector()
432{
433 // FIXME: remove the usage of ISector from all the code.
434 return -10;
435}
436
437//_____________________________________________________________________________
438Int_t
439AliMUONSt345SlatSegmentationV2::Ix()
440{
c895a991 441// Current pad cursor during disintegration
442// x, y-coordinate
443
90e8f97c 444 if ( fPadIterator )
445 {
2cc78641 446 return fPadIterator->CurrentItem().GetIndices().GetFirst();
90e8f97c 447 }
448 else
449 {
450 return -1;
451 }
452}
453
454//_____________________________________________________________________________
455Int_t
456AliMUONSt345SlatSegmentationV2::Iy()
457{
c895a991 458// Current pad cursor during disintegration
459// x, y-coordinate
460
90e8f97c 461 if ( fPadIterator )
462 {
2cc78641 463 return fPadIterator->CurrentItem().GetIndices().GetSecond();
90e8f97c 464 }
465 else
466 {
467 return -1;
468 }
469}
470
471//_____________________________________________________________________________
472Int_t
473AliMUONSt345SlatSegmentationV2::MorePads()
474{
475 return (fPadIterator && !fPadIterator->IsDone());
476}
477
478//_____________________________________________________________________________
479void
c895a991 480AliMUONSt345SlatSegmentationV2::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist,
481 Int_t Xlist[10], Int_t Ylist[10])
90e8f97c 482{
483 // Find pad at (ix,iy) for which we'll search neighbours.
484 AliMpPad pad =
2cc78641 485 fSlatSegmentation->PadByIndices(AliMpIntPair(iX,iY),kTRUE);
90e8f97c 486
487 // Define the region to look into : a region slightly bigger
e46a0808 488 // than the pad itself (5% bigger), in order to catch first neighbours.
489
490 AliMpArea area(pad.Position(),pad.Dimensions()*1.05);
90e8f97c 491
492 AliMpVPadIterator* it = fSlatSegmentation->CreateIterator(area);
493 it->First();
494 Int_t n = 0;
495 while ( !it->IsDone() && n < 10 )
496 {
497 AliMpPad p = it->CurrentItem();
498 if ( p != pad ) // skip self
499 {
2cc78641 500 Xlist[n] = p.GetIndices().GetFirst();
501 Ylist[n] = p.GetIndices().GetSecond();
90e8f97c 502 ++n;
503 }
504 it->Next();
505 }
506 delete it;
507 *Nlist = n;
508}
509
510//_____________________________________________________________________________
511void
512AliMUONSt345SlatSegmentationV2::NextPad()
513{
c895a991 514// Iterate over pads - stepper
515
90e8f97c 516 if ( fPadIterator )
517 {
518 fPadIterator->Next();
519 fCurrentPad = fPadIterator->CurrentItem();
520 }
521 else
522 {
523 AliError("PadIterator not initialized. Please use First() first ;-)");
524 }
525}
526
527//_____________________________________________________________________________
528Int_t
529AliMUONSt345SlatSegmentationV2::Npx() const
530{
c895a991 531// Maximum number of Pads in x
532
90e8f97c 533 return fSlatSegmentation->MaxPadIndexX()+1;
534}
535
536//_____________________________________________________________________________
537Int_t
538AliMUONSt345SlatSegmentationV2::Npy() const
539{
c895a991 540// Maximum number of Pads in y
541
90e8f97c 542 return fSlatSegmentation->MaxPadIndexY()+1;
543}
544
545//_____________________________________________________________________________
546void
c895a991 547AliMUONSt345SlatSegmentationV2::Print(Option_t* /*opt*/) const
90e8f97c 548{
c895a991 549// Printing
550
90e8f97c 551 cout << "DetElemId=" << fDetElemId << " PlaneType="
df484e06 552 << fPlaneType << " Npx,Npy=" << Npx() << "," << Npy() << " fSlat=" << fSlat
90e8f97c 553 << " fSlatSegmentation=" << fSlatSegmentation
554 << " fSlatSegmentation->Slat()=" << fSlatSegmentation->Slat() << endl;
555}
556
90e8f97c 557//_____________________________________________________________________________
558Int_t
c895a991 559AliMUONSt345SlatSegmentationV2::Sector(Int_t ix, Int_t /*iy*/)
90e8f97c 560{
c895a991 561// Calculate sector from pad coordinates
562
2cc78641 563 return fSlat->FindPCBIndex(ix);
90e8f97c 564}
565
566//_____________________________________________________________________________
567Int_t
568AliMUONSt345SlatSegmentationV2::Sector(Float_t x, Float_t y)
569{
c895a991 570// Calculate sector from pad coordinates
571
90e8f97c 572 return fSlat->FindPCBIndex(x,y);
573}
574
575//_____________________________________________________________________________
576void
c895a991 577AliMUONSt345SlatSegmentationV2::SetCorrFunc(Int_t /*isec*/,TF1* /*func*/)
90e8f97c 578{
c895a991 579// Not implemented
580
90e8f97c 581 AliFatal("Not Implemented");
582}
583
584//_____________________________________________________________________________
585void
c895a991 586AliMUONSt345SlatSegmentationV2::SetDAnod(float /*d*/)
90e8f97c 587{
c895a991 588// Not implemented
589
90e8f97c 590 AliFatal("Not Implemented");
591}
592
593//_____________________________________________________________________________
594void
595AliMUONSt345SlatSegmentationV2::SetHit(Float_t x, Float_t y, Float_t)
596{
c895a991 597// Set hit position
598// Sets virtual hit position, needed for evaluating pad response
599// outside the tracking program
600
90e8f97c 601 fXhit = x;
602 fYhit = y;
603
604 //
2cc78641 605 // insure we're within the slat limits. If not, issue a simple
606 // warning, as this might be correct (due to clustering/fitting algorithm
607 // that is allowed to go a little bit outside limits).
608 // That should only be considered an error in case the point is way
609 // outside (but by how much is the question you'll have to determine
610 // by yourself...)
90e8f97c 611 //
612 if ( fXhit < -fSlat->DX() || fXhit > fSlat->DX() ||
613 fYhit < -fSlat->DY() || fYhit > fSlat->DY() )
614 {
c895a991 615 Double_t dx = - fSlat->DX() + TMath::Abs(fXhit);
616 Double_t dy = - fSlat->DY() + TMath::Abs(fYhit);
617 dx = ( dx > 0 ? dx : 0);
618 dy = ( dy > 0 ? dy : 0);
2cc78641 619 AliWarning(Form("Hit outside slat %s limits (x,y)hit = (%e,%e). "
620 "Outside by (%e,%e) cm. Might be ok though.",
c895a991 621 fSlat->GetID(),fXhit,fYhit,dx,dy));
2cc78641 622 }
90e8f97c 623}
624
625//_____________________________________________________________________________
626void
627AliMUONSt345SlatSegmentationV2::SetPad(Int_t ix, Int_t iy)
628{
c895a991 629// Set pad position.
630// Sets virtual pad coordinates, needed for evaluating pad response
631// outside the tracking program.
632
90e8f97c 633 fCurrentPad =
2cc78641 634 fSlatSegmentation->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
90e8f97c 635 if ( !fCurrentPad.IsValid() )
636 {
637 AliError(Form("Setting current pad to invalid ! (ix,iy)=(%4d,%4d)",ix,iy));
638 }
639}
640
641//_____________________________________________________________________________
642void
c895a991 643AliMUONSt345SlatSegmentationV2::SetPadSize(float /*p1*/,float /*p2*/)
90e8f97c 644{
c895a991 645// Not implemented
646
90e8f97c 647 AliFatal("Not Implemented");
648}
649
650//_____________________________________________________________________________
651Int_t
c895a991 652AliMUONSt345SlatSegmentationV2::SigGenCond(Float_t /*x*/, Float_t /*y*/, Float_t /*z*/)
90e8f97c 653{
c895a991 654// Not implemented
655
90e8f97c 656 AliFatal("Not Implemented");
657 return 0;
658}
659
660//_____________________________________________________________________________
661void
662AliMUONSt345SlatSegmentationV2::SigGenInit(Float_t,Float_t,Float_t)
663{
c895a991 664// Not implemented
665
90e8f97c 666 AliFatal("Not Implemented");
667}