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