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