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