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

/* $Id$ */

/// \ingroup rec
/// \class AliMUONClusterFinderPeakCOG
/// \brief Cluster finder in MUON arm of ALICE
///
//  Author Alexander Zinchenko, JINR Dubna; Laurent Aphecetche, SUBATECH
//

#include "AliMUONVClusterFinder.h"

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

class AliMUONPad;

class TH2D;

class AliMUONClusterFinderPeakCOG : public AliMUONVClusterFinder
{
public:
  AliMUONClusterFinderPeakCOG(Bool_t plot, AliMUONVClusterFinder* clusterFinder); // Constructor
  virtual ~AliMUONClusterFinderPeakCOG(); // Destructor

  /// It needs segmentation
  virtual Bool_t NeedSegmentation() const { return kTRUE; }

  using AliMUONVClusterFinder::Prepare;

  virtual Bool_t Prepare(Int_t detElemId, TObjArray* pads[2],
                         const AliMpArea& area, const AliMpVSegmentation* seg[2]);
  
  virtual AliMUONCluster* NextCluster();
  
  virtual void Print(Option_t* opt="") const;

private:
  /// Not implemented
  AliMUONClusterFinderPeakCOG(const AliMUONClusterFinderPeakCOG& rhs);
  /// Not implemented
  AliMUONClusterFinderPeakCOG& operator=(const AliMUONClusterFinderPeakCOG& rhs);

  Bool_t WorkOnPreCluster();

  /// Check precluster to simplify it (if possible), and return the simplified cluster
  AliMUONCluster* CheckPrecluster(const AliMUONCluster& cluster); 
  AliMUONCluster* CheckPreclusterTwoCathodes(AliMUONCluster* cluster); 
  
  /// Checks whether a pad and a pixel have an overlapping area.
  Bool_t Overlap(const AliMUONPad& pad, const AliMUONPad& pixel); 
  
  /// build array of pixels
  void BuildPixArray(AliMUONCluster& cluster); 
  void BuildPixArrayOneCathode(AliMUONCluster& cluster); 
  void PadOverHist(Int_t idir, Int_t ix0, Int_t iy0, AliMUONPad *pad, TH2D *h1, TH2D *h2);

  void RemovePixel(Int_t i);
  
  AliMUONPad* Pixel(Int_t i) const;
  
  Int_t FindLocalMaxima(TObjArray *pixArray, Int_t *localMax, Double_t *maxVal); // find local maxima 
  void  FlagLocalMax(TH2D *hist, Int_t i, Int_t j, Int_t *isLocalMax); // flag local max
  void  FindCluster(AliMUONCluster& cluster, const Int_t *localMax, Int_t iMax); // find cluster around local max
  void  PadsInXandY(AliMUONCluster& cluster, Int_t &nInX, Int_t &nInY) const; // get number of pads in X and Y

  void CheckOverlaps();

private:
  // Status flags for pads
  static const Int_t fgkZero; ///< pad "basic" state
  static const Int_t fgkMustKeep; ///< do not kill (for pixels)
  static const Int_t fgkUseForFit; ///< should be used for fit
  static const Int_t fgkOver; ///< processing is over
  static const Int_t fgkModified; ///< modified pad charge 
  static const Int_t fgkCoupled; ///< coupled pad  
  
    
  // Some constants
  static const Double_t fgkZeroSuppression; ///< average zero suppression value
  static const Double_t fgkDistancePrecision; ///< used to check overlaps and so on
  static const TVector2 fgkIncreaseSize; ///< idem
  static const TVector2 fgkDecreaseSize; ///< idem
  
  AliMUONVClusterFinder* fPreClusterFinder; //!< the pre-clustering worker
  AliMUONCluster* fPreCluster; //!< current pre-cluster
  TObjArray fClusterList; //!< clusters corresponding to the current pre-cluster
  
  Int_t fEventNumber; //!< current event being processed
  Int_t fDetElemId; //!< current DE being processed
  Int_t fClusterNumber; //!< current cluster number
  
  const AliMpVSegmentation *fkSegmentation[2]; //!< new segmentation
  
  TH2D *fHistAnode; //!< histo for peak search
  TObjArray* fPixArray; //!< collection of pixels
  Int_t fDebug; //!< debug level
  Bool_t fPlot; //!< whether we should plot thing (for debug only, quite slow!)
  
  Int_t fNClusters; //!< total number of clusters
  Int_t fNAddVirtualPads; //!< number of clusters for which we added virtual pads
  
  ClassDef(AliMUONClusterFinderPeakCOG,0) // cluster finder in MUON arm of ALICE
};

#endif
 AliMUONClusterFinderPeakCOG.h:1
 AliMUONClusterFinderPeakCOG.h:2
 AliMUONClusterFinderPeakCOG.h:3
 AliMUONClusterFinderPeakCOG.h:4
 AliMUONClusterFinderPeakCOG.h:5
 AliMUONClusterFinderPeakCOG.h:6
 AliMUONClusterFinderPeakCOG.h:7
 AliMUONClusterFinderPeakCOG.h:8
 AliMUONClusterFinderPeakCOG.h:9
 AliMUONClusterFinderPeakCOG.h:10
 AliMUONClusterFinderPeakCOG.h:11
 AliMUONClusterFinderPeakCOG.h:12
 AliMUONClusterFinderPeakCOG.h:13
 AliMUONClusterFinderPeakCOG.h:14
 AliMUONClusterFinderPeakCOG.h:15
 AliMUONClusterFinderPeakCOG.h:16
 AliMUONClusterFinderPeakCOG.h:17
 AliMUONClusterFinderPeakCOG.h:18
 AliMUONClusterFinderPeakCOG.h:19
 AliMUONClusterFinderPeakCOG.h:20
 AliMUONClusterFinderPeakCOG.h:21
 AliMUONClusterFinderPeakCOG.h:22
 AliMUONClusterFinderPeakCOG.h:23
 AliMUONClusterFinderPeakCOG.h:24
 AliMUONClusterFinderPeakCOG.h:25
 AliMUONClusterFinderPeakCOG.h:26
 AliMUONClusterFinderPeakCOG.h:27
 AliMUONClusterFinderPeakCOG.h:28
 AliMUONClusterFinderPeakCOG.h:29
 AliMUONClusterFinderPeakCOG.h:30
 AliMUONClusterFinderPeakCOG.h:31
 AliMUONClusterFinderPeakCOG.h:32
 AliMUONClusterFinderPeakCOG.h:33
 AliMUONClusterFinderPeakCOG.h:34
 AliMUONClusterFinderPeakCOG.h:35
 AliMUONClusterFinderPeakCOG.h:36
 AliMUONClusterFinderPeakCOG.h:37
 AliMUONClusterFinderPeakCOG.h:38
 AliMUONClusterFinderPeakCOG.h:39
 AliMUONClusterFinderPeakCOG.h:40
 AliMUONClusterFinderPeakCOG.h:41
 AliMUONClusterFinderPeakCOG.h:42
 AliMUONClusterFinderPeakCOG.h:43
 AliMUONClusterFinderPeakCOG.h:44
 AliMUONClusterFinderPeakCOG.h:45
 AliMUONClusterFinderPeakCOG.h:46
 AliMUONClusterFinderPeakCOG.h:47
 AliMUONClusterFinderPeakCOG.h:48
 AliMUONClusterFinderPeakCOG.h:49
 AliMUONClusterFinderPeakCOG.h:50
 AliMUONClusterFinderPeakCOG.h:51
 AliMUONClusterFinderPeakCOG.h:52
 AliMUONClusterFinderPeakCOG.h:53
 AliMUONClusterFinderPeakCOG.h:54
 AliMUONClusterFinderPeakCOG.h:55
 AliMUONClusterFinderPeakCOG.h:56
 AliMUONClusterFinderPeakCOG.h:57
 AliMUONClusterFinderPeakCOG.h:58
 AliMUONClusterFinderPeakCOG.h:59
 AliMUONClusterFinderPeakCOG.h:60
 AliMUONClusterFinderPeakCOG.h:61
 AliMUONClusterFinderPeakCOG.h:62
 AliMUONClusterFinderPeakCOG.h:63
 AliMUONClusterFinderPeakCOG.h:64
 AliMUONClusterFinderPeakCOG.h:65
 AliMUONClusterFinderPeakCOG.h:66
 AliMUONClusterFinderPeakCOG.h:67
 AliMUONClusterFinderPeakCOG.h:68
 AliMUONClusterFinderPeakCOG.h:69
 AliMUONClusterFinderPeakCOG.h:70
 AliMUONClusterFinderPeakCOG.h:71
 AliMUONClusterFinderPeakCOG.h:72
 AliMUONClusterFinderPeakCOG.h:73
 AliMUONClusterFinderPeakCOG.h:74
 AliMUONClusterFinderPeakCOG.h:75
 AliMUONClusterFinderPeakCOG.h:76
 AliMUONClusterFinderPeakCOG.h:77
 AliMUONClusterFinderPeakCOG.h:78
 AliMUONClusterFinderPeakCOG.h:79
 AliMUONClusterFinderPeakCOG.h:80
 AliMUONClusterFinderPeakCOG.h:81
 AliMUONClusterFinderPeakCOG.h:82
 AliMUONClusterFinderPeakCOG.h:83
 AliMUONClusterFinderPeakCOG.h:84
 AliMUONClusterFinderPeakCOG.h:85
 AliMUONClusterFinderPeakCOG.h:86
 AliMUONClusterFinderPeakCOG.h:87
 AliMUONClusterFinderPeakCOG.h:88
 AliMUONClusterFinderPeakCOG.h:89
 AliMUONClusterFinderPeakCOG.h:90
 AliMUONClusterFinderPeakCOG.h:91
 AliMUONClusterFinderPeakCOG.h:92
 AliMUONClusterFinderPeakCOG.h:93
 AliMUONClusterFinderPeakCOG.h:94
 AliMUONClusterFinderPeakCOG.h:95
 AliMUONClusterFinderPeakCOG.h:96
 AliMUONClusterFinderPeakCOG.h:97
 AliMUONClusterFinderPeakCOG.h:98
 AliMUONClusterFinderPeakCOG.h:99
 AliMUONClusterFinderPeakCOG.h:100
 AliMUONClusterFinderPeakCOG.h:101
 AliMUONClusterFinderPeakCOG.h:102
 AliMUONClusterFinderPeakCOG.h:103
 AliMUONClusterFinderPeakCOG.h:104
 AliMUONClusterFinderPeakCOG.h:105
 AliMUONClusterFinderPeakCOG.h:106
 AliMUONClusterFinderPeakCOG.h:107
 AliMUONClusterFinderPeakCOG.h:108
 AliMUONClusterFinderPeakCOG.h:109
 AliMUONClusterFinderPeakCOG.h:110
 AliMUONClusterFinderPeakCOG.h:111
 AliMUONClusterFinderPeakCOG.h:112
 AliMUONClusterFinderPeakCOG.h:113
 AliMUONClusterFinderPeakCOG.h:114