ROOT logo
#ifndef ALIMUONCLUSTER_H
#define ALIMUONCLUSTER_H

/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice                               */

// $Id$

/// \ingroup rec
/// \class AliMUONCluster
/// \brief A group of adjacent pads
/// 
// Author Laurent Aphecetche

#ifndef ROOT_TObject
#  include "TObject.h"
#endif
#ifndef ROOT_TVector2
#  include "TVector2.h"
#endif
#ifndef ROOT_TString
#  include "TString.h"
#endif
#ifndef ALI_MP_AREA_H
#  include "AliMpArea.h"
#endif
#ifndef ALI_MP_DIRECTION_H
#  include "AliMpDirection.h"
#endif
#ifndef ALI_MP_ENCODE_PAIR_H
#  include "AliMpEncodePair.h"
#endif

#ifndef ROOT_TObjArray
#  include "TObjArray.h"
#endif

class AliMUONPad;

class AliMUONCluster : public TObject
{
public:
  AliMUONCluster();
  AliMUONCluster(const AliMUONCluster& rhs);
  AliMUONCluster& operator=(const AliMUONCluster& rhs);
  
  virtual ~AliMUONCluster();
  
  Bool_t Contains(const AliMUONPad& pad) const;
  
  TString AsString() const;
  
  static Bool_t AreOverlapping(const AliMUONCluster& c1, const AliMUONCluster& c2);
  
  AliMUONPad* AddPad(const AliMUONPad& pad);

  /// Area that contains all the pads (whatever the cathode)
  AliMpArea Area() const;

  /// Area that contains all the pads of a given cathode
  AliMpArea Area(Int_t cathode) const;

  Float_t Charge() const;
  Float_t Charge(Int_t cathode) const;

  /// Return the cathode's charges asymmetry
  Float_t ChargeAsymmetry() const;

  /// Return chi2 of the RawCharge fit (if any)
  Float_t Chi2() const { return fChi2; }

  virtual void Copy(TObject& obj) const;

  /// Return false for pre-cluster
  Bool_t HasPosition() const { return fHasPosition; }

  /// Whether we have at least one saturated pad in a given cathode 
  Bool_t IsSaturated(Int_t cathode) const { return fIsSaturated[cathode]; }
  
  /// Whether we have one saturated pad on *each* cathode
  Bool_t IsSaturated() const { return IsSaturated(0) && IsSaturated(1); }
  
  /// Return the max charge on the chathod
  Int_t MaxChargeCathode() const { return Charge(0) > Charge(1) ? 0:1; }

  /// Return the max raw charge on the chathod
  Int_t MaxRawChargeCathode() const { return RawCharge(0) > RawCharge(1) ? 0:1; }

  /// Return the biggest pad dimensions for a given cathode
  TVector2 MaxPadDimensions(Int_t cathode, Int_t statusMask, Bool_t matchMask) const;
  
  /// Return the biggest pad dimensions
  TVector2 MaxPadDimensions(Int_t statusMask, Bool_t matchMask) const;
  
  /// Return the smallest pad dimensions for a given cathode
  TVector2 MinPadDimensions(Int_t cathode, Int_t statusMask, Bool_t matchMask) const;
  
  /// Return the smallest pad dimensions
  TVector2 MinPadDimensions(Int_t statusMask, Bool_t matchMask) const;
  
  Int_t Multiplicity() const;
  Int_t Multiplicity(Int_t cathode) const;

  /// Compute number of pads in X and Y direction for a given cathode.  
  Long_t NofPads(Int_t cathode, Int_t statusMask, Bool_t matchMask) const;
  
  /// Number of pads in (X,Y) direction, whatever the cathode.
  Long_t NofPads(Int_t statusMask, Bool_t matchMask=kTRUE) const;
  
  /// Return true as the function Compare is implemented
  Bool_t IsSortable() const { return kTRUE; }
  
//  Bool_t IsEqual(const TObject* obj) const;
  
  virtual Int_t Compare(const TObject* obj) const;
  
  AliMUONPad* Pad(Int_t index) const;
  
  virtual void Paint(Option_t* opt="");
  
  /// Return (x,y) of that cluster
  TVector2 Position() const { return fPosition; }
  /// Return errors on (x,y)
  TVector2 PositionError() const { return fPositionError; }

  virtual void Print(Option_t* opt="") const;
      
  /// By default, return the average of both cathode RawCharges.
  Float_t RawCharge() const;
  
  /// Returns the RawCharge on the given cathode.
  Float_t RawCharge(Int_t cathode) const;
    
  /// Return the cathode's raw charges asymmetry
  Float_t RawChargeAsymmetry() const;
  
  void RemovePad(AliMUONPad* pad);

  /// Set cathode (re)computed charges  
  void SetCharge(Float_t chargeCath0, Float_t chargeCath1)
  { fHasCharge = kTRUE; fCharge[0]=chargeCath0; fCharge[1]=chargeCath1; }

  /// Set chi2 of the RawCharge fit   
  void SetChi2(Float_t chi2) { fChi2 = chi2; }

  /// Set (x,y) of that cluster and errors   
  void SetPosition(const TVector2& pos, const TVector2& errorOnPos) 
  { fHasPosition = kTRUE; fPosition = pos; fPositionError = errorOnPos; }
  
  Int_t Cathode() const;
  
  void AddCluster(const AliMUONCluster& cluster);

  void Clear(Option_t* opt="");
  
  Bool_t IsMonoCathode() const;

//private:
    void DumpMe() const;
  
private:
  TObjArray fPads; ///< AliMUONPad(s) composing this cluster
  Bool_t fHasPosition; ///< false for pre-cluster (i.e. not yet computed)
  TVector2 fPosition; ///< (x,y) of that cluster (only valid if fHasPosition is kTRUE)
  TVector2 fPositionError; ///< errors on (x,y)
  Int_t fMultiplicity[2]; ///< number of pads in each cathode
  Float_t fRawCharge[2]; ///< cathode RawCharges
  Bool_t fHasCharge; ///< false if SetCharge has not been called
  Float_t fCharge[2]; ///< cathode (re)computed charges
  Float_t fChi2; ///< chi2 of the RawCharge fit (if any)
  Bool_t fIsSaturated[2]; ///< saturation status of cathodes
  
  ClassDef(AliMUONCluster,3) // A cluster of AliMUONPad
};

#endif
 AliMUONCluster.h:1
 AliMUONCluster.h:2
 AliMUONCluster.h:3
 AliMUONCluster.h:4
 AliMUONCluster.h:5
 AliMUONCluster.h:6
 AliMUONCluster.h:7
 AliMUONCluster.h:8
 AliMUONCluster.h:9
 AliMUONCluster.h:10
 AliMUONCluster.h:11
 AliMUONCluster.h:12
 AliMUONCluster.h:13
 AliMUONCluster.h:14
 AliMUONCluster.h:15
 AliMUONCluster.h:16
 AliMUONCluster.h:17
 AliMUONCluster.h:18
 AliMUONCluster.h:19
 AliMUONCluster.h:20
 AliMUONCluster.h:21
 AliMUONCluster.h:22
 AliMUONCluster.h:23
 AliMUONCluster.h:24
 AliMUONCluster.h:25
 AliMUONCluster.h:26
 AliMUONCluster.h:27
 AliMUONCluster.h:28
 AliMUONCluster.h:29
 AliMUONCluster.h:30
 AliMUONCluster.h:31
 AliMUONCluster.h:32
 AliMUONCluster.h:33
 AliMUONCluster.h:34
 AliMUONCluster.h:35
 AliMUONCluster.h:36
 AliMUONCluster.h:37
 AliMUONCluster.h:38
 AliMUONCluster.h:39
 AliMUONCluster.h:40
 AliMUONCluster.h:41
 AliMUONCluster.h:42
 AliMUONCluster.h:43
 AliMUONCluster.h:44
 AliMUONCluster.h:45
 AliMUONCluster.h:46
 AliMUONCluster.h:47
 AliMUONCluster.h:48
 AliMUONCluster.h:49
 AliMUONCluster.h:50
 AliMUONCluster.h:51
 AliMUONCluster.h:52
 AliMUONCluster.h:53
 AliMUONCluster.h:54
 AliMUONCluster.h:55
 AliMUONCluster.h:56
 AliMUONCluster.h:57
 AliMUONCluster.h:58
 AliMUONCluster.h:59
 AliMUONCluster.h:60
 AliMUONCluster.h:61
 AliMUONCluster.h:62
 AliMUONCluster.h:63
 AliMUONCluster.h:64
 AliMUONCluster.h:65
 AliMUONCluster.h:66
 AliMUONCluster.h:67
 AliMUONCluster.h:68
 AliMUONCluster.h:69
 AliMUONCluster.h:70
 AliMUONCluster.h:71
 AliMUONCluster.h:72
 AliMUONCluster.h:73
 AliMUONCluster.h:74
 AliMUONCluster.h:75
 AliMUONCluster.h:76
 AliMUONCluster.h:77
 AliMUONCluster.h:78
 AliMUONCluster.h:79
 AliMUONCluster.h:80
 AliMUONCluster.h:81
 AliMUONCluster.h:82
 AliMUONCluster.h:83
 AliMUONCluster.h:84
 AliMUONCluster.h:85
 AliMUONCluster.h:86
 AliMUONCluster.h:87
 AliMUONCluster.h:88
 AliMUONCluster.h:89
 AliMUONCluster.h:90
 AliMUONCluster.h:91
 AliMUONCluster.h:92
 AliMUONCluster.h:93
 AliMUONCluster.h:94
 AliMUONCluster.h:95
 AliMUONCluster.h:96
 AliMUONCluster.h:97
 AliMUONCluster.h:98
 AliMUONCluster.h:99
 AliMUONCluster.h:100
 AliMUONCluster.h:101
 AliMUONCluster.h:102
 AliMUONCluster.h:103
 AliMUONCluster.h:104
 AliMUONCluster.h:105
 AliMUONCluster.h:106
 AliMUONCluster.h:107
 AliMUONCluster.h:108
 AliMUONCluster.h:109
 AliMUONCluster.h:110
 AliMUONCluster.h:111
 AliMUONCluster.h:112
 AliMUONCluster.h:113
 AliMUONCluster.h:114
 AliMUONCluster.h:115
 AliMUONCluster.h:116
 AliMUONCluster.h:117
 AliMUONCluster.h:118
 AliMUONCluster.h:119
 AliMUONCluster.h:120
 AliMUONCluster.h:121
 AliMUONCluster.h:122
 AliMUONCluster.h:123
 AliMUONCluster.h:124
 AliMUONCluster.h:125
 AliMUONCluster.h:126
 AliMUONCluster.h:127
 AliMUONCluster.h:128
 AliMUONCluster.h:129
 AliMUONCluster.h:130
 AliMUONCluster.h:131
 AliMUONCluster.h:132
 AliMUONCluster.h:133
 AliMUONCluster.h:134
 AliMUONCluster.h:135
 AliMUONCluster.h:136
 AliMUONCluster.h:137
 AliMUONCluster.h:138
 AliMUONCluster.h:139
 AliMUONCluster.h:140
 AliMUONCluster.h:141
 AliMUONCluster.h:142
 AliMUONCluster.h:143
 AliMUONCluster.h:144
 AliMUONCluster.h:145
 AliMUONCluster.h:146
 AliMUONCluster.h:147
 AliMUONCluster.h:148
 AliMUONCluster.h:149
 AliMUONCluster.h:150
 AliMUONCluster.h:151
 AliMUONCluster.h:152
 AliMUONCluster.h:153
 AliMUONCluster.h:154
 AliMUONCluster.h:155
 AliMUONCluster.h:156
 AliMUONCluster.h:157
 AliMUONCluster.h:158
 AliMUONCluster.h:159
 AliMUONCluster.h:160
 AliMUONCluster.h:161
 AliMUONCluster.h:162
 AliMUONCluster.h:163
 AliMUONCluster.h:164
 AliMUONCluster.h:165
 AliMUONCluster.h:166
 AliMUONCluster.h:167
 AliMUONCluster.h:168
 AliMUONCluster.h:169
 AliMUONCluster.h:170
 AliMUONCluster.h:171
 AliMUONCluster.h:172
 AliMUONCluster.h:173
 AliMUONCluster.h:174
 AliMUONCluster.h:175
 AliMUONCluster.h:176