]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSt1Segmentation.cxx
Compiler warning removed
[u/mrichter/AliRoot.git] / MUON / AliMUONSt1Segmentation.cxx
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
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
25 #include <TError.h>
26 #include <TObjArray.h>
27 #include <TVector2.h>
28 #include <TF1.h>
29
30 #include "AliMpPlane.h"
31 #include "AliMpPlaneSegmentation.h"
32 #include "AliMpPlaneAreaPadIterator.h"
33 #include "AliMpPad.h"
34
35 #include "AliMUONSt1Segmentation.h"
36 #include "AliRun.h"
37 #include "AliMUON.h"
38 #include "AliMUONChamber.h"
39
40 ClassImp(AliMUONSt1Segmentation)
41
42 const Float_t  AliMUONSt1Segmentation::fgkWireD = 0.20; 
43 const Float_t  AliMUONSt1Segmentation::fgkLengthUnit = 0.1; 
44
45 //______________________________________________________________________________
46 AliMUONSt1Segmentation::AliMUONSt1Segmentation(const AliMpPlaneType planeType) 
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
72   fPlane = AliMpPlane::Create(kStation1, planeType);
73   fPlaneSegmentation = new AliMpPlaneSegmentation(fPlane);
74
75   fCorrA = new TObjArray(3);
76   fCorrA->AddAt(0,0);
77   fCorrA->AddAt(0,1);
78   fCorrA->AddAt(0,2);
79 }
80
81 //______________________________________________________________________________
82 AliMUONSt1Segmentation::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 //______________________________________________________________________________
110 AliMUONSt1Segmentation::AliMUONSt1Segmentation(const AliMUONSt1Segmentation& rhs) :AliSegmentation(rhs)
111 {
112 // Copy constructor
113   Fatal("Copy constructor", 
114         "Copy constructor is not implemented.");
115 }
116
117 //______________________________________________________________________________
118 AliMUONSt1Segmentation::~AliMUONSt1Segmentation() {
119 // Destructor
120
121   delete fPlane;
122   delete fPlaneSegmentation;  
123   delete fPlaneIterator;  
124
125
126 //
127 // operators
128 //
129
130 //______________________________________________________________________________
131 AliMUONSt1Segmentation& 
132 AliMUONSt1Segmentation::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 //______________________________________________________________________________
150 void AliMUONSt1Segmentation::UpdateCurrentPadValues(const AliMpPad& pad)
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 //______________________________________________________________________________
167 void AliMUONSt1Segmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
168 {
169 // Set pad size Dx*Dy 
170 // ---
171
172   Fatal("SetPadSize", "Not uniform pad size.");
173 }
174
175 //______________________________________________________________________________
176 void AliMUONSt1Segmentation::SetDAnod(Float_t d)
177 {
178 // Set anod pitch
179 // ---
180
181   fWireD = d;
182 }
183
184 //______________________________________________________________________________
185 Float_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 //______________________________________________________________________________
199 void  AliMUONSt1Segmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/, 
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 //______________________________________________________________________________
209 void  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
216   AliMpPad pad = fPlaneSegmentation
217                ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), false);
218
219   ix = pad.GetIndices().GetFirst();
220   iy = pad.GetIndices().GetSecond();
221 }
222                        
223 //______________________________________________________________________________
224 void  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 //______________________________________________________________________________
235 void  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
242   AliMpPad pad = fPlaneSegmentation->PadByIndices(AliMpIntPair(ix,iy));
243
244   x = pad.Position().X() * fgkLengthUnit;
245   y = pad.Position().Y() * fgkLengthUnit;
246 }
247
248
249 //______________________________________________________________________________
250 void 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 //______________________________________________________________________________
267 Float_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 //______________________________________________________________________________
277 Float_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 //______________________________________________________________________________
287 Float_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 //______________________________________________________________________________
296 Float_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 //______________________________________________________________________________
305 Int_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 //______________________________________________________________________________
315 Int_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 //______________________________________________________________________________
325 void  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 //______________________________________________________________________________
338 void  AliMUONSt1Segmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
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 //______________________________________________________________________________
350 void  AliMUONSt1Segmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, 
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
366         ->CreateIterator(AliMpArea(TVector2(fXhit/fgkLengthUnit, fYhit/fgkLengthUnit), 
367                                    TVector2(dx/fgkLengthUnit, dy/fgkLengthUnit)));
368
369   fPlaneIterator->First();              
370
371   if (! fPlaneIterator->IsDone())
372     UpdateCurrentPadValues(fPlaneIterator->CurrentItem());
373 }
374  
375 //______________________________________________________________________________
376 void  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 //______________________________________________________________________________
388 Int_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 //______________________________________________________________________________
400 Float_t AliMUONSt1Segmentation::Distance2AndOffset(Int_t iX, Int_t iY, 
401                                                    Float_t x, Float_t y, Int_t* /*dummy*/)
402 {                                          
403 // Returns the square of the distance between 1 pad
404 // labelled by its channel numbers and a coordinate
405 // ---
406
407   AliMpPad pad = fPlaneSegmentation->PadByIndices(AliMpIntPair(iX, iY));
408   
409   if (!pad.IsValid())
410     Fatal("Distance2AndOffset", "Cannot locate pad.");
411
412   return (pad.Position()*fgkLengthUnit - TVector2(x, y)).Mod2();
413 }
414
415 //______________________________________________________________________________
416 void AliMUONSt1Segmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
417                                                    Int_t* /*Nparallel*/, Int_t* /*Offset*/)
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 //______________________________________________________________________________
428 void 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
435   AliMpPad pad = fPlaneSegmentation->PadByIndices(AliMpIntPair(iX,iY));
436   Int_t &i = *Nlist;
437   i=0;
438   AliMpVPadIterator* iter
439     = fPlaneSegmentation
440       ->CreateIterator(AliMpArea(pad.Position(),2.*pad.Dimensions()*1.1));
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 //______________________________________________________________________________
452 Int_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 //______________________________________________________________________________
462 Int_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 //______________________________________________________________________________
472 Int_t  AliMUONSt1Segmentation::ISector()
473 {
474 // Current sector
475 // ---
476
477   return fSector;
478 }
479
480 //______________________________________________________________________________
481 Int_t AliMUONSt1Segmentation::Sector(Int_t ix, Int_t iy)
482 {
483 // Calculate sector from pad coordinates
484 // ---
485
486   return fPlaneSegmentation
487            ->Zone(fPlaneSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
488 }
489
490 //______________________________________________________________________________
491 Int_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 //______________________________________________________________________________
502 void  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 //______________________________________________________________________________
516 Int_t AliMUONSt1Segmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
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 //______________________________________________________________________________
548 void  AliMUONSt1Segmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
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 //______________________________________________________________________________
562 void 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 //______________________________________________________________________________
576 void AliMUONSt1Segmentation::Draw(const char * /*opt*/) const
577 {
578 // Draw the segmentation zones.
579 // (Called from AliMUON::BuildGeometry)
580 // ---
581
582   Warning("Draw", "Not yet implemented.");
583 }
584
585 //______________________________________________________________________________
586 void 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 //______________________________________________________________________________
596 TF1* 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