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