]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSt12QuadrantSegmentation.cxx
Renamed vector and methods by removing Geant3 from the names
[u/mrichter/AliRoot.git] / MUON / AliMUONSt12QuadrantSegmentation.cxx
CommitLineData
e118b27e 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
f7006443 18// -------------------------------------
e118b27e 19// Class AliMUONSt12QuadrantSegmentation
20// -------------------------------------
21// Segmentation for MUON quadrants of stations 1 and 2 using
22// the mapping package
e118b27e 23// Author: Ivana Hrivnacova, IPN Orsay
9afdc733 24
e118b27e 25#include <TError.h>
26#include <TF1.h>
27#include <TObjArray.h>
28#include <TVector2.h>
b7ef3c96 29#include <TSystem.h>
30
31#include "AliLog.h"
e118b27e 32
33#include "AliMpPad.h"
34#include "AliMpArea.h"
ab126d0a 35#include "AliMpSectorReader.h"
e118b27e 36#include "AliMpSector.h"
37#include "AliMpVPadIterator.h"
38#include "AliMpSectorSegmentation.h"
a713db22 39#include "AliMpFiles.h"
ddde88da 40#include "AliMpNeighboursPadIterator.h"
b7ef3c96 41
42#include "AliMUONSt12QuadrantSegmentation.h"
43#include "AliMUONConstants.h"
e118b27e 44
5398f946 45/// \cond CLASSIMP
e118b27e 46ClassImp(AliMUONSt12QuadrantSegmentation)
5398f946 47/// \endcond
e118b27e 48
e118b27e 49//______________________________________________________________________________
50AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
8fbf5237 51 AliMpVSegmentation* segmentation,
e118b27e 52 AliMpStationType stationType,
53 AliMpPlaneType planeType)
e0a49962 54: AliMUONVGeometryDESegmentation(),
59090931 55 fStationType(stationType),
56 fPlaneType(planeType),
e118b27e 57 fSector(0),
58 fSectorSegmentation(0),
59 fSectorIterator(0),
8fed3fe9 60 fWireD(0),
e118b27e 61 fChamber(0),
62 fId(0),
63 fRmin(0.),
64 fRmax(0.),
65 fZ(0.),
66 fIx(0),
67 fIy(0),
68 fX(0.),
69 fY(0.),
70 fZone(0),
71 fXhit(0.),
72 fYhit(0.),
73 fIxt(0),
74 fIyt(0),
75 fIwt(0),
76 fXt(0.),
77 fYt(0.),
78 fCorrA(0)
79{
5398f946 80/// Standard constructor
a713db22 81
8fbf5237 82 fSectorSegmentation = dynamic_cast<AliMpSectorSegmentation*>(segmentation);
83 if (fSectorSegmentation)
84 fSector = fSectorSegmentation->GetSector();
85 else
86 AliFatal("Wrong mapping segmentation type");
8fed3fe9 87
88 // Anod pitch
89 if ( stationType == kStation1 )
90 fWireD = AliMUONConstants::PitchSt1();
91 else if ( stationType == kStation2 )
92 fWireD = AliMUONConstants::Pitch();
93 else
94 AliFatal("Wrong station type");
e118b27e 95
96 fCorrA = new TObjArray(3);
97 fCorrA->AddAt(0,0);
98 fCorrA->AddAt(0,1);
99 fCorrA->AddAt(0,2);
b7ef3c96 100
101 AliDebug(1, Form("ctor this = %p", this) );
e118b27e 102}
103
104//______________________________________________________________________________
105AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation()
e0a49962 106: AliMUONVGeometryDESegmentation(),
59090931 107 fStationType(kStation1),
108 fPlaneType(kBendingPlane),
e118b27e 109 fSector(0),
110 fSectorSegmentation(0),
111 fSectorIterator(0),
8fed3fe9 112 fWireD(0),
e118b27e 113 fChamber(0),
114 fId(0),
115 fRmin(0.),
116 fRmax(0.),
117 fZ(0.),
118 fIx(0),
119 fIy(0),
120 fX(0.),
121 fY(0.),
122 fZone(0),
123 fXhit(0.),
124 fYhit(0.),
125 fIxt(0),
126 fIyt(0),
127 fIwt(0),
128 fXt(0.),
129 fYt(0.),
5398f946 130 fCorrA(0)
131{
132/// Default Constructor
b7ef3c96 133
134 AliDebug(1, Form("default (empty) ctor this = %p", this));
e118b27e 135}
136
137//______________________________________________________________________________
5398f946 138AliMUONSt12QuadrantSegmentation::~AliMUONSt12QuadrantSegmentation()
e118b27e 139{
5398f946 140/// Destructor
e118b27e 141
b7ef3c96 142 AliDebug(1, Form("dtor this = %p", this));
143
e118b27e 144 delete fSectorIterator;
145}
146
e118b27e 147//
148// private methods
149//
150
151//______________________________________________________________________________
152void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad)
153{
5398f946 154/// Updates current pad values.
e118b27e 155
156 fIx = pad.GetIndices().GetFirst();
157 fIy = pad.GetIndices().GetSecond();
dfaf6b0d 158 fX = pad.Position().X();
159 fY = pad.Position().Y();
e118b27e 160 fZone = fSectorSegmentation->Zone(pad);
161}
162
59090931 163
e118b27e 164//
165// public methods
166//
167
168//______________________________________________________________________________
169void AliMUONSt12QuadrantSegmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
170{
5398f946 171/// Set pad size Dx*Dy
e118b27e 172
173 AliFatal("Not uniform pad size.");
174}
175
176//______________________________________________________________________________
177void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
178{
5398f946 179/// Set anod pitch
e118b27e 180
181 fWireD = d;
182}
183
59090931 184#include "AliMpMotifMap.h"
e0a49962 185//______________________________________________________________________________
186Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
187{
5398f946 188/// Returns true if a pad exists in the given position
e0a49962 189
59090931 190 // fSector->GetMotifMap()->Print();
191
e0a49962 192 AliMpPad pad = fSectorSegmentation
dfaf6b0d 193 ->PadByPosition(TVector2(x,y), false);
e0a49962 194
195 return pad.IsValid();
196}
197
198
199//______________________________________________________________________________
200Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Int_t ix, Int_t iy)
201{
5398f946 202/// Returns true if a pad with given indices exists
e0a49962 203
204 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), false);
205
206 return pad.IsValid();
207}
208
209
6b1e4b22 210//______________________________________________________________________________
211AliMUONGeometryDirection AliMUONSt12QuadrantSegmentation::GetDirection()
212{
5398f946 213/// Returns the direction with a constant pad size
214/// (Direction or coordinate where the resolution is the best)
6b1e4b22 215
216 switch ( fSector->GetDirection() ) {
217 case kX: return kDirX;
218 case kY: return kDirY;
219 default: return kDirUndefined;
220 }
221}
222
f5ed7890 223//______________________________________________________________________________
b7ef3c96 224const AliMpVSegmentation*
f5ed7890 225AliMUONSt12QuadrantSegmentation::GetMpSegmentation() const
226{
5398f946 227/// Returns the mapping segmentation
228/// (provides access to electronics info)
f5ed7890 229
230 return fSectorSegmentation;
231}
232
e118b27e 233//______________________________________________________________________________
234Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
235{
5398f946 236/// Anod wire coordinate closest to xhit
237/// Returns for a hit position xhit the position of the nearest anode wire
238/// From AliMUONSegmentationV01.
e118b27e 239
240 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
241 : Int_t(xhit/fWireD) - 0.5;
242 return fWireD*wire;
243
244}
245
246//______________________________________________________________________________
247void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
248 Int_t& ix, Int_t& iy)
249{
5398f946 250/// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
e118b27e 251
252 GetPadI(x, y, ix, iy);
253}
254
255//______________________________________________________________________________
256void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
257 Int_t& ix, Int_t& iy)
258{
5398f946 259/// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
260/// If there is no pad, ix = 0, iy = 0 are returned.
e118b27e 261
dfaf6b0d 262 AliMpPad pad = fSectorSegmentation->PadByPosition(TVector2(x,y), true);
e118b27e 263
264 ix = pad.GetIndices().GetFirst();
265 iy = pad.GetIndices().GetSecond();
266}
267
268//______________________________________________________________________________
269void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
270 Float_t& x, Float_t& y, Float_t& z)
271{
5398f946 272/// Transform from pad to real coordinates
e118b27e 273
274 z = fZ;
275 GetPadC(ix, iy, x , y);
276}
277
278//______________________________________________________________________________
279void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
280 Float_t& x, Float_t& y)
281{
5398f946 282/// Transform from pad to real coordinates
283/// If there is no pad, x = 0., y = 0. are returned.
e118b27e 284
e0a49962 285 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
e118b27e 286
dfaf6b0d 287 x = pad.Position().X();
288 y = pad.Position().Y();
e118b27e 289}
290
291
292//______________________________________________________________________________
293void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
294{
5398f946 295/// Initialize segmentation
e118b27e 296
59090931 297 // find Npx, Npy and save this info
e118b27e 298
299 // reference to chamber
b7ef3c96 300 fRmin=AliMUONConstants::Rmin(0);
301 fRmax=AliMUONConstants::Rmax(0);
e118b27e 302 fZ = 0;
303 fId=chamber;
304}
305
306//______________________________________________________________________________
307Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
308{
5398f946 309/// Get pad size in x
e118b27e 310
311 AliFatal( "Not uniform pad size.");
312 return 0.;
313}
314
315//______________________________________________________________________________
316Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
317{
5398f946 318/// Get pad size in y
e118b27e 319
320 AliFatal("Not uniform pad size.");
321 return 0.;
322}
323
324//______________________________________________________________________________
325Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
326{
5398f946 327/// Pad size in x by sector
e118b27e 328
dfaf6b0d 329 return fSectorSegmentation->PadDimensions(isector).X()*2.0;
e118b27e 330}
331
332//______________________________________________________________________________
333Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
334{
5398f946 335/// Pad size in x, y by Sector
e118b27e 336
dfaf6b0d 337 return fSectorSegmentation->PadDimensions(isector).Y()*2.0;
e118b27e 338}
339
340//______________________________________________________________________________
341Int_t AliMUONSt12QuadrantSegmentation::Npx() const
342{
5398f946 343/// Maximum number of Pads in x
344/// hard coded for the time being
e118b27e 345
580c28fd 346 return fSectorSegmentation->MaxPadIndexX();
e118b27e 347}
348
349//______________________________________________________________________________
350Int_t AliMUONSt12QuadrantSegmentation::Npy() const
351{
5398f946 352/// Maximum number of Pads in y
353/// hard coded for the time being
e118b27e 354
580c28fd 355 return fSectorSegmentation->MaxPadIndexY();
e118b27e 356}
357
358//______________________________________________________________________________
359void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
360{
5398f946 361/// Set pad position.
362/// Sets virtual pad coordinates, needed for evaluating pad response
363/// outside the tracking program.
364/// From AliMUONSegmentationV01.
e118b27e 365
366 GetPadC(ix, iy, fX, fY);
367 fZone = Sector(ix, iy);
368}
369
370//______________________________________________________________________________
371void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
372{
5398f946 373/// Set hit position
374/// Sets virtual hit position, needed for evaluating pad response
375/// outside the tracking program
376/// From AliMUONSegmentationV01.
e118b27e 377
378 fXhit = xhit;
379 fYhit = yhit;
380}
381
382//______________________________________________________________________________
383void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
384 Float_t dx, Float_t dy)
385{
5398f946 386/// Iterate over pads - initialiser
e118b27e 387
388 // Sets the current pad to that located in the hit position
389
390 SetHit(GetAnod(xhit), yhit, 0.);
391
392 // Enable iterating in one dimension
393 if (dx == 0.) dx = 0.01;
394 if (dy == 0.) dy = 0.01;
395
9eeaee6f 396 // Delete previous iterator
397 delete fSectorIterator;
398
e118b27e 399 fSectorIterator
400 = fSectorSegmentation
dfaf6b0d 401 ->CreateIterator(AliMpArea(TVector2(fXhit,fYhit),TVector2(dx,dy)));
e118b27e 402
dfaf6b0d 403 AliDebug(1,Form("CreateIterator area=%e,%e +- %e,%e %s",
8fbf5237 404 fXhit,fYhit,dx,dy,PlaneTypeName(fPlaneType).Data()));
dfaf6b0d 405
e118b27e 406 fSectorIterator->First();
407
408 if (! fSectorIterator->IsDone())
409 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
410}
411
412//______________________________________________________________________________
413void AliMUONSt12QuadrantSegmentation::NextPad()
414{
5398f946 415/// Iterate over pads - stepper
e118b27e 416
417 fSectorIterator->Next();
418
419 if (! fSectorIterator->IsDone())
420 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
421}
422
423//______________________________________________________________________________
424Int_t AliMUONSt12QuadrantSegmentation::MorePads()
425{
5398f946 426/// Iterate over pads - condition
e118b27e 427
428 if (fSectorIterator->IsDone())
429 return 0;
430 else
431 return 1;
432}
433
434//______________________________________________________________________________
435Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
436 Float_t x, Float_t y, Int_t* /*dummy*/)
437{
5398f946 438/// Returns the square of the distance between 1 pad
439/// labelled by its channel numbers and a coordinate
e118b27e 440
441 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
442
443 if (!pad.IsValid())
444 AliFatal("Cannot locate pad.");
445
dfaf6b0d 446 return (pad.Position() - TVector2(x, y)).Mod2();
e118b27e 447}
448
449//______________________________________________________________________________
450void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
451 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
452{
5398f946 453/// Number of pads read in parallel and offset to add to x
454/// (specific to LYON, but mandatory for display)
e118b27e 455
456 AliFatal( "Not yet implemented.");
457}
458
459
460//______________________________________________________________________________
461void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
462 Int_t* Nlist,
463 Int_t Xlist[10], Int_t Ylist[10])
464{
5398f946 465/// Get next neighbours
e118b27e 466
467 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
468 Int_t &i = *Nlist;
469 i=0;
f167062f 470 AliMpNeighboursPadIterator iter(fSectorSegmentation, pad, kFALSE);
e118b27e 471
ddde88da 472 for( iter.First(); !iter.IsDone() && i<10; iter.Next()) {
473 Xlist[i] = iter.CurrentItem().GetIndices().GetFirst();
474 Ylist[i] = iter.CurrentItem().GetIndices().GetSecond();
e118b27e 475 i++;
476 }
e118b27e 477}
ddde88da 478
e118b27e 479//______________________________________________________________________________
480Int_t AliMUONSt12QuadrantSegmentation::Ix()
481{
5398f946 482/// Current pad cursor during disintegration
483/// x, y-coordinate
e118b27e 484
485 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
486}
487
488//______________________________________________________________________________
489Int_t AliMUONSt12QuadrantSegmentation::Iy()
490{
5398f946 491/// Current pad cursor during disintegration
492/// x, y-coordinate
e118b27e 493
494 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
495}
496
497//______________________________________________________________________________
498Int_t AliMUONSt12QuadrantSegmentation::ISector()
499{
5398f946 500/// Current sector
e118b27e 501
502 return fZone;
503}
504
505//______________________________________________________________________________
506Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
507{
5398f946 508/// Calculate sector from pad coordinates
e118b27e 509
510 return fSectorSegmentation
511 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
512}
513
514//______________________________________________________________________________
515Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
516{
5398f946 517/// Calculate sector from pad coordinates
e118b27e 518
519 return fSectorSegmentation
520 ->Zone(fSectorSegmentation
dfaf6b0d 521 ->PadByPosition(TVector2(x,y)));
e118b27e 522}
523
524//______________________________________________________________________________
525void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
526 Float_t& y1, Float_t& y2)
527{
5398f946 528/// Current integration limits
e118b27e 529
530 x1 = fXhit - fX - Dpx(fZone)/2.;
531 x2 = x1 + Dpx(fZone);
532
533 y1 = fYhit - fY - Dpy(fZone)/2.;
534 y2 = y1 + Dpy(fZone);
535}
536
537//______________________________________________________________________________
538Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
539{
5398f946 540/// Signal Generation Condition during Stepping
541/// - 0: don't generate signal
542/// - 1: generate signal
543///
544/// Comments: \n
545///
546/// Crossing of pad boundary and mid plane between neighbouring wires is checked.
547/// To correctly simulate the dependence of the spatial resolution on the angle
548/// of incidence signal must be generated for constant steps on
549/// the projection of the trajectory along the anode wire.
550///
551/// Signal will be generated if particle crosses pad boundary or
552/// boundary between two wires.
553///
554/// From AliMUONSegmentationV01
e118b27e 555
556 Int_t ixt, iyt;
557 GetPadI(x, y, ixt, iyt);
558 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
559
560 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
561 return 1;
562 }
563 else {
564 return 0;
565 }
566}
567
e118b27e 568//______________________________________________________________________________
569void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
570{
5398f946 571/// Initialise signal generation at coord (x,y,z)
572/// Initialises pad and wire position during stepping.
573/// From AliMUONSegmentationV01
e118b27e 574
575 fXt = x;
576 fYt = y;
577 GetPadI(x, y, fIxt, fIyt);
578 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
579}
580
581//______________________________________________________________________________
582void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
583{
5398f946 584/// Test points for auto calibration
585/// Returns test point on the pad plane.
586/// Used during determination of the segmoid correction of the COG-method
587/// From AliMUONSegmentationV01
e118b27e 588
589 n=1;
590 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
591 y[0] = x[0];
592}
593
594//______________________________________________________________________________
595void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
596{
5398f946 597/// Draw the segmentation zones.
598/// (Called from AliMUON::BuildGeometry)
e118b27e 599
600 AliWarning("Not yet implemented.");
601}
602
603//______________________________________________________________________________
604void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
605{
5398f946 606/// Set the correction function.
607/// From AliMUONSegmentationV01
e118b27e 608
609 fCorrA->AddAt(func, isec);
610}
611
612//______________________________________________________________________________
613TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
614{
5398f946 615/// Get the correction Function.
616/// From AliMUONSegmentationV01
e118b27e 617
618 return (TF1*) fCorrA->At(isec);
619}