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