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