ROOT logo
#ifndef ALIMUONPAD_H
#define ALIMUONPAD_H

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

// $Id$

/// \ingroup rec
/// \class AliMUONPad
/// \brief Combination of digit and mppad informations.
/// 
//  Author Laurent Aphecetche

#ifndef ROOT_TObject
#  include "TObject.h"
#endif
#ifndef ROOT_TVector2
#  include "TVector2.h"
#endif
#ifndef ALI_MP_AREA_H
#  include "AliMpArea.h"
#endif

class AliMUONPad : public TObject
{
public:
  AliMUONPad();
  AliMUONPad(Double_t x, Double_t y,
             Double_t dx, Double_t dy, Double_t charge);
  AliMUONPad(const TVector2& position, const TVector2& dimensions,
             Double_t charge);
  AliMUONPad(Int_t detElemId, Int_t cathode,
             Int_t ix, Int_t iy, Double_t x, Double_t y,
             Double_t dx, Double_t dy, Double_t charge);
  virtual ~AliMUONPad();

  /// \brief Backup charge 
  /// Usefull if clustering somehow plays with the charge, this one is the "original" one
  void BackupCharge() { fChargeBackup = fCharge; }
  
  /// Return cathode number
  Int_t Cathode() const { return fCathode; }

  Double_t Coord(Int_t ixy) const;
  
  /// Return pad charge
  Double_t Charge() const { return fCharge; }
  /// Return backup charge
  Double_t ChargeBackup() const { return fChargeBackup; }

  /// Return detection element id
  Int_t DetElemId() const { return fDetElemId; }
  
  /// Return half dimensions in x and y (cm)
  TVector2 Dimensions() const { return fDimensions; }
  
  /// Return half dimensions in x (cm)
  Double_t DX() const { return fDimensions.X(); }
  /// Return  half dimensions in y (cm)
  Double_t DY() const { return fDimensions.Y(); }

  /// Return info whether this is a real pad or a virtual one
  Bool_t IsReal() const { return fIsReal; }

  /// Return info whether this pad is saturated or not
  Bool_t IsSaturated() const { return fIsSaturated; }
  
  /// Return true as the function Compare is implemented
  Bool_t IsSortable() const { return kTRUE; }
  
  virtual Int_t Compare(const TObject* obj) const;

  /// Return true if is used
  Bool_t IsUsed() const { return fClusterId >= 0; }

  /// Return x-index
  Int_t Ix() const { return fIx; }
  /// Return y-index
  Int_t Iy() const { return fIy; }

  virtual void Paint(Option_t* opt="");

  /// Return positions in x and y (cm)
  TVector2 Position() const { return fPosition; }

  void Print(Option_t* opt = "") const;

  /// Detach this pad from a cluster
  void Release() { fClusterId = -1; }
  
  /// Set charge to value in backup charge
  void RevertCharge() { fCharge = fChargeBackup; }

  /// Set charge
  void SetCharge(Double_t charge) { fCharge = charge; }
  
  /// Set charge backup
  void SetChargeBackup(Double_t charge) { fChargeBackup = charge; }

  void SetCoord(Int_t ixy, Double_t Coord);

  /// Set status word
  void SetStatus(Int_t status) { fStatus = status; }
    
  /// \brief Set cluster id this pad belongs to
  /// -1 if not attached to a cluster
  void SetClusterId(Int_t id) { fClusterId = id; }  
  
  /// Set info whether this pad is saturated or not
  void SetSaturated(Bool_t val) { fIsSaturated = val; }
  
  void SetSize(Int_t ixy, Double_t Size);
  
  /// Set info whether this is a real pad or a virtual one
  void SetReal(Bool_t val) { fIsReal = val; }

  void Shift(Int_t ixy, Double_t shift);
  
  Double_t Size(Int_t ixy) const;

  /// Return status word
  Int_t Status() const { return fStatus; }
  
  /// Return position in x (cm)
  Double_t X() const { return fPosition.X(); }
  /// Return position in y (cm)
  Double_t Y() const { return fPosition.Y(); }
  
  static AliMpArea Overlap(const AliMUONPad& d1, const AliMUONPad& d2);
  
  static Bool_t AreOverlapping(const AliMUONPad& d1, const AliMUONPad& d2,
                               const TVector2& precision,
                               AliMpArea& overlapArea);

  static Bool_t AreOverlapping(const AliMUONPad& d1, const AliMUONPad& d2,
                               const TVector2& precision);
  
  static Bool_t AreNeighbours(const AliMUONPad& d1, const AliMUONPad& d2);

  
private:
    void Init(Int_t detElemId, Int_t cathode,
              Int_t ix, Int_t iy,
              const TVector2& position,
              const TVector2& dimensions,
              Double_t charge);
  
private:
  Bool_t fIsSaturated; ///< whether this pad is saturated or not
  Bool_t fIsReal; ///< whether this is a real pad or a virtual one
  Int_t fClusterId; ///< cluster id this pad belongs to (-1 if not attached to a cluster)
  Int_t fCathode; ///< cathode number
  Int_t fDetElemId; ///< detection element id
  Int_t fIx; ///< x-index
  Int_t fIy; ///< y-index
  Int_t fStatus; ///< status word
  TVector2 fDimensions; ///< half dimensions in x and y (cm)
  TVector2 fPosition; ///< positions in x and y (cm)
  Double_t fCharge; ///< pad charge
  Double_t fChargeBackup; ///< backup charge (usefull if clustering somehow plays with the charge, this one is the "original" one)
  
  ClassDef(AliMUONPad,2) // A full grown pad 
};

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