]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONCluster.cxx
Removing an AliInfo
[u/mrichter/AliRoot.git] / MUON / AliMUONCluster.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 #include <Riostream.h>
19 #include <TMath.h>
20 #include <TObjArray.h>
21 #include <TVirtualPad.h>
22 #include <TVirtualX.h>
23
24 #include "AliMUONCluster.h"
25
26 #include "AliLog.h"
27 #include "AliMUONPad.h"
28
29 //-----------------------------------------------------------------------------
30 /// \class AliMUONCluster
31 ///
32 /// A group of adjacent pads
33 ///
34 /// Besides holding an internal array of AliMUONPads, this object
35 /// also computes some global characteristics for that pad sets.
36 ///
37 /// \author Laurent Aphecetche
38 ///
39 //-----------------------------------------------------------------------------
40
41 /// \cond CLASSIMP
42 ClassImp(AliMUONCluster)
43 /// \endcond
44
45 namespace
46 {
47   //___________________________________________________________________________
48   Bool_t
49   ShouldUsePad(const AliMUONPad& pad, 
50                Int_t cathode, Int_t statusMask, Bool_t matchMask)
51   {
52
53       // FIXME : we should only use >=0 status, so we can fully
54       // use masking possibility ?
55     if ( pad.Status() < 0 ) return kFALSE;
56     
57     if ( pad.Cathode() == cathode && pad.IsReal() && !pad.IsSaturated() )
58     {
59       Bool_t test = ( ( pad.Status() & statusMask ) != 0 );
60       if ( !statusMask ) 
61       {
62         test = ( pad.Status() == 0 );
63       }
64       if ( ( test && matchMask ) || ( !test && !matchMask ) )
65       {
66         return kTRUE;
67       }
68     }
69     return kFALSE;
70   }
71
72   //___________________________________________________________________________
73   Int_t Unique(Int_t n, Double_t* array, Double_t precision)
74   {
75     /// Return the number of *different* elements in array 
76     /// where different is up to precision
77     /// Note that we assume that n is >= 1
78     
79     Int_t count(1);
80     
81     Int_t* index = new Int_t[n];
82     
83     TMath::Sort(n,array,index);
84         
85     for ( Int_t i = 1; i < n; ++i )
86     {
87       if ( array[index[i]] - array[index[i-1]] < -precision ) ++count;
88     }
89     
90     delete[] index;
91         
92     return count;
93   }
94 }
95
96 //_____________________________________________________________________________
97 AliMUONCluster::AliMUONCluster() 
98 : TObject(), 
99 fPads(0x0),
100 fHasPosition(kFALSE),
101 fPosition(1E9,1E9),
102 fPositionError(1E9,1E9),
103 fHasCharge(kFALSE),
104 fChi2(0)
105 {
106   /// ctor
107   fMultiplicity[0]=fMultiplicity[1]=0;
108   fRawCharge[0]=fRawCharge[1]=0;
109   fCharge[0]=fCharge[1]=0;
110   fIsSaturated[0]=fIsSaturated[1]=kFALSE;
111 }
112
113 //_____________________________________________________________________________
114 AliMUONCluster::AliMUONCluster(const AliMUONCluster& src)
115 : TObject(src),
116 fPads(0x0),
117 fHasPosition(kFALSE),
118 fPosition(1E9,1E9),
119 fPositionError(1E9,1E9),
120 fHasCharge(kFALSE),
121 fChi2(0)
122 {
123   /// copy ctor
124   src.Copy(*this);
125 }
126
127 //_____________________________________________________________________________
128 AliMUONCluster&
129 AliMUONCluster::operator=(const AliMUONCluster& src)
130 {
131   /// assignement operator
132   if ( this != &src ) 
133   {
134     src.Copy(*this);
135   }
136   return *this;
137 }
138
139 //_____________________________________________________________________________
140 AliMUONCluster::~AliMUONCluster()
141 {
142   /// dtor : note that we're owner of our pads
143   delete fPads;
144 }
145
146 //_____________________________________________________________________________
147 void
148 AliMUONCluster::Clear(Option_t*)
149 {
150   /// Clear our pad array
151   if (fPads) fPads->Clear("C");
152 }
153
154 //_____________________________________________________________________________
155 Bool_t
156 AliMUONCluster::Contains(const AliMUONPad& pad) const
157 {
158   /// Whether this cluster contains the pad
159   if (!fPads) return kFALSE;
160   for ( Int_t i = 0; i < Multiplicity(); ++i ) 
161   {
162     AliMUONPad* p = Pad(i);
163     if ( pad.Compare(p) == 0 ) return kTRUE;
164   }
165   return kFALSE;
166 }
167
168 //_____________________________________________________________________________
169 void
170 AliMUONCluster::AddCluster(const AliMUONCluster& cluster)
171 {
172   /// Add all the pads for cluster to this one
173   for ( Int_t i = 0; i < cluster.Multiplicity(); ++i )
174   {
175     AliMUONPad* p = cluster.Pad(i);
176     if ( Contains(*p) ) 
177     {
178       AliError("I already got this pad : ");
179       StdoutToAliError(p->Print(););
180       AliFatal("");
181     }
182     AddPad(*p);
183   }
184   
185 }
186
187 //_____________________________________________________________________________
188 AliMUONPad*
189 AliMUONCluster::AddPad(const AliMUONPad& pad)
190 {
191   /// Add a pad to our pad array, and update some internal information
192   /// accordingly.
193   
194   if (!fPads) 
195   {
196     fPads = new TObjArray(10);
197     fPads->SetOwner(kTRUE);
198   }
199   AliMUONPad* p = new AliMUONPad(pad);
200   fPads->AddLast(p);
201   p->SetClusterId(GetUniqueID());
202   Int_t cathode = p->Cathode();
203   ++(fMultiplicity[cathode]);
204   fRawCharge[cathode] += p->Charge();
205   if ( p->IsSaturated() )
206   {
207     fIsSaturated[p->Cathode()]=kTRUE;
208   }
209   return p;
210 }
211
212 //___________________________________________________________________________
213 TString
214 AliMUONCluster::AsString() const
215 {
216   /// Return a string containing a compact form of the pad list
217   TString s(Form("NPADS(%d,%d)",Multiplicity(0),Multiplicity(1)));
218   
219   for (Int_t i = 0; i < Multiplicity(); ++i ) 
220   {
221     AliMUONPad* p = Pad(i);
222     s += Form(" (%d,%d,%d) ",p->Cathode(),p->Ix(),p->Iy());
223   }
224   return s;
225 }
226
227
228 //___________________________________________________________________________
229 Bool_t
230 AliMUONCluster::AreOverlapping(const AliMUONCluster& c1, const AliMUONCluster& c2)
231 {
232   /// Whether the two clusters overlap
233   
234   static Double_t precision = 1E-4; // cm
235   static TVector2 precisionAdjustment(precision,precision);
236     
237   for ( Int_t i1 = 0; i1 < c1.Multiplicity(); ++i1 )
238   {
239     AliMUONPad* p1 = c1.Pad(i1);
240     
241     for ( Int_t i2 = 0; i2 < c2.Multiplicity(); ++i2 )
242     {
243       AliMUONPad* p2 = c2.Pad(i2);
244       // Note: we use negative precision numbers, meaning
245       // the area of the pads will be *increased* by these small numbers
246       // prior to check the overlap by the AreOverlapping method,
247       // so pads touching only by the corners will be considered as
248       // overlapping.    
249       if ( AliMUONPad::AreOverlapping(*p1,*p2,precisionAdjustment) )
250       {
251         return kTRUE;
252       }
253     }
254   }
255   return kFALSE;
256 }
257
258 //_____________________________________________________________________________
259 AliMpArea
260 AliMUONCluster::Area() const
261 {
262   /// Return the geometrical area covered by this cluster
263   
264   // Start by finding the (x,y) limits of this cluster
265   TVector2 lowerLeft(1E9,1E9);
266   TVector2 upperRight(-1E9,-1E9);
267   
268   for ( Int_t i = 0; i < Multiplicity(); ++i )
269   {
270     AliMUONPad* pad = Pad(i);
271     TVector2 ll = pad->Position() - pad->Dimensions();
272     TVector2 ur = pad->Position() + pad->Dimensions();
273     lowerLeft.Set( TMath::Min(ll.X(),lowerLeft.X()),
274                    TMath::Min(ll.Y(),lowerLeft.Y()) );
275     upperRight.Set( TMath::Max(ur.X(),upperRight.X()),
276                     TMath::Max(ur.Y(),upperRight.Y()) );
277   }
278
279   // then construct the area from those limits
280   return AliMpArea((lowerLeft+upperRight)/2,
281                    (upperRight-lowerLeft)/2);
282 }
283
284 //_____________________________________________________________________________
285 AliMpArea
286 AliMUONCluster::Area(Int_t cathode) const
287 {
288   /// Return the geometrical area covered by this cluster's pads on 
289   /// a given cathode
290   
291   // Start by finding the (x,y) limits of this cluster
292   TVector2 lowerLeft(1E9,1E9);
293   TVector2 upperRight(-1E9,-1E9);
294   
295   for ( Int_t i = 0; i < Multiplicity(); ++i )
296   {
297     AliMUONPad* pad = Pad(i);
298     if ( pad->Cathode() == cathode ) 
299     {
300       TVector2 ll = pad->Position() - pad->Dimensions();
301       TVector2 ur = pad->Position() + pad->Dimensions();
302       lowerLeft.Set( TMath::Min(ll.X(),lowerLeft.X()),
303                      TMath::Min(ll.Y(),lowerLeft.Y()) );
304       upperRight.Set( TMath::Max(ur.X(),upperRight.X()),
305                       TMath::Max(ur.Y(),upperRight.Y()) );
306     }
307   }
308   
309   // then construct the area from those limits
310   return AliMpArea((lowerLeft+upperRight)/2,
311                    (upperRight-lowerLeft)/2);
312 }
313
314 //_____________________________________________________________________________
315 Int_t
316 AliMUONCluster::Cathode() const
317 {
318   /// Return the cathode "number" of this cluster : 
319   /// 0 if all its pads are on cathode 0
320   /// 1 if all its pads are on cathode 1
321   /// 2 if some pads on cath 0 and some on cath 1
322   
323   Int_t cathode(-1);
324   if (Multiplicity(0)>0 && Multiplicity(1)>0) 
325   {
326     cathode=2;
327   }
328   else if (Multiplicity(0)>0) 
329   {
330     cathode=0;
331   }
332   else if (Multiplicity(1)>0) 
333   {
334     cathode=1;
335   }
336   
337   return cathode;
338 }
339
340 //_____________________________________________________________________________
341 void
342 AliMUONCluster::Copy(TObject& obj) const
343 {
344   ///
345   /// Copy this cluster to (cluster&)obj
346   ///
347   TObject::Copy(obj);
348   AliMUONCluster& dest = static_cast<AliMUONCluster&>(obj);
349   delete dest.fPads;
350   dest.fPads = 0x0;
351   if ( fPads )
352   {
353     dest.fPads = static_cast<TObjArray*>(fPads->Clone());
354   }
355   dest.fHasPosition = fHasPosition;
356   dest.fPosition = fPosition;
357   dest.fPositionError = fPositionError;
358   dest.fHasCharge = fHasCharge;
359   dest.fChi2 = fChi2;
360   for ( Int_t i = 0; i < 2; ++i )
361   {
362     dest.fRawCharge[i] = fRawCharge[i];
363     dest.fCharge[i] = fCharge[i];
364     dest.fMultiplicity[i] = fMultiplicity[i];
365     dest.fIsSaturated[i] = fIsSaturated[i];
366   }
367 }
368
369 //_____________________________________________________________________________
370 Float_t 
371 AliMUONCluster::Charge() const
372 {
373   /// Return the average charge over both cathodes
374   
375   if ( Multiplicity(0) && Multiplicity(1) )
376   {
377     return (Charge(0)+Charge(1))/2.0;
378   }
379   else if ( Multiplicity(0) ) 
380   {
381     return Charge(0);
382   }
383   else if ( Multiplicity(1) ) 
384   {
385     return Charge(1);
386   }
387   AliError("Should not be here ?!");
388   return -1.0;
389 }
390
391 //_____________________________________________________________________________
392 Float_t
393 AliMUONCluster::Charge(Int_t cathode) const
394 {
395   /// Returns the charge of a given cathode
396   if ( !fHasCharge ) return RawCharge(cathode);
397   
398   if ( cathode == 0 || cathode == 1 )
399   {
400     return fCharge[cathode];
401   }
402   return 0;
403 }
404
405 //_____________________________________________________________________________
406 Float_t
407 AliMUONCluster::ChargeAsymmetry() const
408 {
409   /// Returns the charge asymmetry
410   if ( Charge() > 0 )
411   {
412     return TMath::Abs(Charge(0)-Charge(1))/Charge();
413   }
414   return 0;
415 }
416
417 //_____________________________________________________________________________
418 TVector2
419 AliMUONCluster::MaxPadDimensions(Int_t statusMask, Bool_t matchMask) const
420 {
421   /// Returns the maximum pad dimensions (half sizes), only considering
422   /// pads matching (or not, depending matchMask) a given mask
423   
424   TVector2 cath0(MaxPadDimensions(0,statusMask,matchMask)); 
425   TVector2 cath1(MaxPadDimensions(1,statusMask,matchMask)); 
426   
427   return TVector2( TMath::Max(cath0.X(),cath1.X()),
428                    TMath::Max(cath0.Y(),cath1.Y()) );
429 }
430
431 //_____________________________________________________________________________
432 TVector2
433 AliMUONCluster::MaxPadDimensions(Int_t cathode, 
434                                  Int_t statusMask, Bool_t matchMask) const
435 {
436   /// Returns the maximum pad dimensions (half sizes), only considering
437   /// pads matching (or not, depending matchMask) a given mask, within a
438   /// given cathode
439   
440   Double_t xmax(0);
441   Double_t ymax(0);
442   
443   for ( Int_t i = 0; i < Multiplicity(); ++i )
444   {
445     AliMUONPad* pad = Pad(i);
446     if ( ShouldUsePad(*pad,cathode,statusMask,matchMask) )
447     {
448       xmax = TMath::Max(xmax,pad->DX());
449       ymax = TMath::Max(ymax,pad->DY());
450     }
451   }
452   return TVector2(xmax,ymax);
453 }
454
455 //_____________________________________________________________________________
456 TVector2
457 AliMUONCluster::MinPadDimensions(Int_t statusMask, Bool_t matchMask) const
458 {
459   /// Returns the minimum pad dimensions (half sizes), only considering
460   /// pads matching (or not, depending matchMask) a given mask
461   
462   TVector2 cath0(MinPadDimensions(0,statusMask,matchMask)); 
463   TVector2 cath1(MinPadDimensions(1,statusMask,matchMask)); 
464   
465   return TVector2( TMath::Min(cath0.X(),cath1.X()),
466                    TMath::Min(cath0.Y(),cath1.Y()) );
467 }
468
469 //_____________________________________________________________________________
470 TVector2
471 AliMUONCluster::MinPadDimensions(Int_t cathode, 
472                                  Int_t statusMask, Bool_t matchMask) const
473 {
474   /// Returns the minimum pad dimensions (half sizes), only considering
475   /// pads matching (or not, depending matchMask) a given mask, within a
476   /// given cathode
477   
478   Double_t xmin(1E9);
479   Double_t ymin(1E9);
480     
481   for ( Int_t i = 0; i < Multiplicity(); ++i )
482   {
483     AliMUONPad* pad = Pad(i);
484     if ( ShouldUsePad(*pad,cathode,statusMask,matchMask) )
485     {
486       xmin = TMath::Min(xmin,pad->DX());
487       ymin = TMath::Min(ymin,pad->DY());
488     }
489   }
490   return TVector2(xmin,ymin);
491 }
492
493 //_____________________________________________________________________________
494 Int_t 
495 AliMUONCluster::Multiplicity() const
496 {
497   /// Returns the total number of pads in this cluster
498   return Multiplicity(0)+Multiplicity(1);
499 }
500
501 //_____________________________________________________________________________
502 Int_t
503 AliMUONCluster::Multiplicity(Int_t cathode) const
504 {
505   /// Returns the number of pads in this cluster, in the given cathode
506   if ( cathode == 0 || cathode == 1 )
507   {
508     return fMultiplicity[cathode];
509   }
510   return 0;
511 }
512
513 //_____________________________________________________________________________
514 AliMpIntPair
515 AliMUONCluster::NofPads(Int_t statusMask, Bool_t matchMask) const
516 {
517   /// Number of pads satisfying (or not, depending matchMask) a
518   /// given mask
519   
520   Int_t nx, ny;
521   
522   TVector2 dim0(MinPadDimensions(0,statusMask,matchMask));
523   TVector2 dim1(MinPadDimensions(1,statusMask,matchMask));
524   
525   AliMpIntPair npad0(NofPads(0,statusMask,matchMask));
526   AliMpIntPair npad1(NofPads(1,statusMask,matchMask));
527   
528   if ( TMath::Abs( (dim0-dim1).X() ) < 1E-3 )
529   {
530     nx = TMath::Max( npad0.GetFirst(), npad1.GetFirst() );
531   }
532   else
533   {
534     nx = dim0.X() < dim1.X() ? npad0.GetFirst() : npad1.GetFirst();
535   }
536   
537   if ( TMath::Abs( (dim0-dim1).Y() ) < 1E-3 )
538   {
539     ny = TMath::Max( npad0.GetSecond(), npad1.GetSecond() );
540   }
541   else
542   {
543     ny = dim0.Y() < dim1.Y() ? npad0.GetSecond() : npad1.GetSecond();
544   }
545   
546   return AliMpIntPair(nx,ny);
547 }
548
549 //_____________________________________________________________________________
550 AliMpIntPair
551 AliMUONCluster::NofPads(Int_t cathode,
552                         Int_t statusMask, Bool_t matchMask) const
553 {
554   /// Number of pads of a given cathode, satisfying (or not, 
555   /// depending matchMask) a given mask
556
557   Int_t n = Multiplicity(cathode);
558   if (!n) 
559   {
560     return AliMpIntPair(0,0);
561   }
562   Double_t* x = new Double_t[n];
563   Double_t* y = new Double_t[n];
564   Int_t np(0);
565   
566   for ( Int_t i = 0; i < Multiplicity(); ++i )
567   {
568     AliMUONPad* pad = Pad(i);
569     if ( ShouldUsePad(*pad,cathode,statusMask,matchMask) )
570     {
571       x[np] = pad->X();
572       y[np] = pad->Y();
573       ++np;
574     }
575   }
576   
577   Int_t cx = Unique(np,x,0.01);
578   Int_t cy = Unique(np,y,0.01);
579   
580   delete[] x;
581   delete[] y;
582   
583   return AliMpIntPair(cx,cy);
584 }
585
586 //_____________________________________________________________________________
587 AliMUONPad*
588 AliMUONCluster::Pad(Int_t index) const
589 {
590   /// Returns the index-th pad
591   
592   if (!fPads) return 0x0;
593   if ( index < fPads->GetLast()+1 )
594   {
595     return static_cast<AliMUONPad*>(fPads->At(index));
596   }
597   else
598   {
599     AliError(Form("Requested index %d out of bounds (%d) Mult is %d",index,
600                   fPads->GetLast(),Multiplicity()));
601     DumpMe();
602   }
603   return 0x0;
604 }
605
606
607 //_____________________________________________________________________________
608 void
609 AliMUONCluster::Paint(Option_t*)
610 {
611   /// Paint this cluster   
612   if (!Multiplicity()) return;
613   
614   AliMpArea area(Area());
615   
616   gPad->Range(area.LeftBorder(),area.DownBorder(),area.RightBorder(),area.UpBorder());
617       
618   gVirtualX->SetFillStyle(0);
619   
620   gVirtualX->SetLineColor(2);
621   gVirtualX->SetLineWidth(4);  
622   for ( Int_t i = 0; i < Multiplicity(); ++i)
623   {
624     AliMUONPad* pad = Pad(i);
625     if ( pad->Cathode() == 0 ) pad->Paint();
626   }
627
628   gVirtualX->SetLineColor(4);
629   gVirtualX->SetLineWidth(2);  
630   for ( Int_t i = 0; i < Multiplicity(); ++i)
631   {
632     AliMUONPad* pad = Pad(i);
633     if ( pad->Cathode() == 1 ) pad->Paint();
634   }
635   
636 }
637
638 //_____________________________________________________________________________
639 void
640 AliMUONCluster::DumpMe() const
641 {
642   /// printout
643   cout << "Cluster Id " << GetUniqueID() << " npads=" << Multiplicity() 
644   << "(" << Multiplicity(0) << "," << Multiplicity(1) << ") RawCharge=" 
645   << RawCharge() << " (" << RawCharge(0) << "," << RawCharge(1)
646   << ") Charge=(" << Charge(0) << "," << Charge(1) <<")";
647   if ( HasPosition() )
648   {
649     cout << " (x,y)=(" << Position().X() << "," << Position().Y() << ")";
650     cout << " (errX,errY)=(" << PositionError().X() << "," << PositionError().Y() << ")";
651   }
652   cout << endl;
653 //  cout << " " << Area() << endl;
654   if (fPads) 
655   {
656     for (Int_t i = 0; i < fPads->GetSize(); ++i) 
657     {
658       cout << Form("fPads[%d]=%x",i,fPads->At(i)) << endl;
659       if ( fPads->At(i) ) fPads->At(i)->Print();
660     }
661   }  
662 }
663
664
665 //_____________________________________________________________________________
666 void
667 AliMUONCluster::Print(Option_t* opt) const
668 {
669   /// printout
670   cout << "Cluster Id " << GetUniqueID() << " npads=" << Multiplicity() 
671   << "(" << Multiplicity(0) << "," << Multiplicity(1) << ") RawCharge=" 
672   << RawCharge() << " (" << RawCharge(0) << "," << RawCharge(1)
673   << ") Charge=(" << Charge(0) << "," << Charge(1) <<")";
674   if ( HasPosition() )
675   {
676     cout << " (x,y)=(" << Position().X() << "," << Position().Y() << ")";
677     cout << " (errX,errY)=(" << PositionError().X() << "," << PositionError().Y() << ")";
678   }
679   cout << " " << Area();
680   if (fPads) 
681   {
682     TObjArray* a = static_cast<TObjArray*>(fPads->Clone());
683     a->Sort();
684     a->Print("",opt);
685     delete a;
686   }
687 }
688
689 //_____________________________________________________________________________
690 //Bool_t
691 //AliMUONCluster::IsEqual(const TObject* obj) const
692 //{
693 //  const AliMUONCluster* c = static_cast<const AliMUONCluster*>(obj);
694 //  if ( c->Multiplicity() != Multiplicity() ) return kFALSE;
695 //  
696 //  for ( Int_t i = 0; i < c->Multiplicity(); ++i ) 
697 //  {
698 //    AliMUONPad* p = c->Pad(i);
699 //    if ( p->Compare(Pad(i)) ) return kFALSE;
700 //  }
701 //  return kTRUE;
702 //}
703
704 //_____________________________________________________________________________
705 Int_t 
706 AliMUONCluster::Compare(const TObject* obj) const
707 {
708   /// Compare two clusters. Comparison is made on position and rawcharge only.
709   
710   const AliMUONCluster* cluster = static_cast<const AliMUONCluster*>(obj);
711   
712   AliMpArea carea(cluster->Area());
713   AliMpArea area(Area());
714
715   if ( carea.Position().X() > area.Position().X() ) 
716   {
717     return 1;
718   }
719   else if ( carea.Position().X() < area.Position().X() ) 
720   {
721     return -1;
722   }
723   else 
724   {
725     if ( carea.Position().Y() > area.Position().Y() ) 
726     {
727       return 1;
728     }
729     else if ( carea.Position().Y() < area.Position().Y() ) 
730     {
731       return -1;
732     }
733     else
734     {
735       if ( cluster->RawCharge() > RawCharge() ) 
736       {
737         return 1;
738       }
739       else if ( cluster->RawCharge() < RawCharge() )
740       {
741         return -1;
742       }
743     }
744   }
745   return 0;
746 }
747
748 //_____________________________________________________________________________
749 void
750 AliMUONCluster::RemovePad(AliMUONPad* pad)
751 {
752   /// Remove a pad. 
753   /// As a consequence, some internal information must be updated
754   
755   fPads->Remove(pad);
756   fPads->Compress();
757   // update cluster's data
758   fIsSaturated[0]=fIsSaturated[1]=kFALSE;
759   fMultiplicity[0]=fMultiplicity[1]=0;
760   fRawCharge[0]=fRawCharge[1]=0;
761   for ( Int_t i = 0; i <= fPads->GetLast(); ++i )
762   {
763     AliMUONPad* p = Pad(i);
764     if ( p->IsSaturated() ) 
765     {
766       fIsSaturated[p->Cathode()] = kTRUE;
767     }
768     ++fMultiplicity[p->Cathode()];
769     fRawCharge[p->Cathode()] += p->Charge();
770   }
771 }
772
773 //_____________________________________________________________________________
774 Float_t 
775 AliMUONCluster::RawCharge() const
776 {
777   /// Returns the raw average charge
778   return (RawCharge(0)+RawCharge(1))/2.0;
779 }
780
781 //_____________________________________________________________________________
782 Float_t
783 AliMUONCluster::RawCharge(Int_t cathode) const
784 {
785   /// Returns the average charge of a given cathode
786   if ( cathode == 0 || cathode == 1 )
787   {
788     return fRawCharge[cathode];
789   }
790   return 0;
791 }
792
793 //_____________________________________________________________________________
794 Float_t
795 AliMUONCluster::RawChargeAsymmetry() const
796 {
797   /// Returns the raw charge asymmetry
798    if ( RawCharge() > 0 )
799    {
800      return TMath::Abs(RawCharge(0)-RawCharge(1))/RawCharge();
801    }
802   return 0;
803 }