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