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