]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterFinderMLEM.h
Removing compiler warnings from AliMUONGain, AliMUONPedestal.
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterFinderMLEM.h
1 #ifndef ALIMUONCLUSTERFINDERMLEM_H
2 #define ALIMUONCLUSTERFINDERMLEM_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 /// \ingroup rec
9 /// \class AliMUONClusterFinderMLEM
10 /// \brief Cluster finder in MUON arm of ALICE
11 ///
12 //  Author Alexander Zinchenko, JINR Dubna; Laurent Aphecetche, SUBATECH
13 //
14
15 class TH2D;
16 class TClonesArray;
17 class TMinuit;
18
19 #ifndef ROOT_TObjArray
20 #  include "TObjArray.h"
21 #endif
22 #ifndef ROOT_TVector2
23 #  include "TVector2.h"
24 #endif
25
26 class AliMUONPad;
27
28 #include "AliMUONVClusterFinder.h"
29
30 class AliMUONClusterSplitterMLEM;
31
32 class AliMUONClusterFinderMLEM : public AliMUONVClusterFinder
33 {
34 public:
35   AliMUONClusterFinderMLEM(Bool_t plot, AliMUONVClusterFinder* clusterFinder); // Constructor
36   virtual ~AliMUONClusterFinderMLEM(); // Destructor
37
38   virtual Bool_t NeedSegmentation() const { return kTRUE; }
39   
40   using AliMUONVClusterFinder::Prepare;
41
42   virtual Bool_t Prepare(Int_t detElemId,
43                          TClonesArray* pads[2],
44                          const AliMpArea& area,
45                          const AliMpVSegmentation* segmentations[2]);
46   
47   virtual AliMUONCluster* NextCluster();
48   
49   virtual void Print(Option_t* opt="") const;
50
51   virtual void Paint(Option_t* opt="");
52
53   // Status flags for pads
54
55                /// Return pad "basic" state flag
56   static Int_t GetZeroFlag()       { return fgkZero; }
57                /// Return do not kill flag
58   static Int_t GetMustKeepFlag()   { return fgkMustKeep; }
59                /// Return should be used for fit flag
60   static Int_t GetUseForFitFlag()  { return fgkUseForFit; }
61                /// Return processing is over flag
62   static Int_t GetOverFlag()       { return fgkOver; }
63                /// Return modified pad charge flag
64   static Int_t GetModifiedFlag()   { return fgkModified; }
65                /// Return coupled pad flag
66   static Int_t GetCoupledFlag()    { return fgkCoupled; }
67   
68 private:
69   /// Not implemented
70   AliMUONClusterFinderMLEM(const AliMUONClusterFinderMLEM& rhs);
71   /// Not implemented
72   AliMUONClusterFinderMLEM& operator=(const AliMUONClusterFinderMLEM& rhs);
73
74   Bool_t WorkOnPreCluster();
75
76   /// Check precluster to simplify it (if possible), and return the simplified cluster
77   AliMUONCluster* CheckPrecluster(const AliMUONCluster& cluster); 
78   AliMUONCluster* CheckPreclusterTwoCathodes(AliMUONCluster* cluster); 
79   
80   /// Checks whether a pad and a pixel have an overlapping area.
81   Bool_t Overlap(const AliMUONPad& pad, const AliMUONPad& pixel); 
82   
83   /// build array of pixels
84   void BuildPixArray(AliMUONCluster& cluster); 
85   void BuildPixArrayOneCathode(AliMUONCluster& cluster); 
86   void PadOverHist(Int_t idir, Int_t ix0, Int_t iy0, AliMUONPad *pad,
87                    TH2D *hist1, TH2D *hist2);
88
89   void RemovePixel(Int_t i);
90   
91   AliMUONPad* Pixel(Int_t i) const;
92   
93   Bool_t MainLoop(AliMUONCluster& cluster, Int_t iSimple); // repeat MLEM algorithm until pixels become sufficiently small
94   
95   void   Mlem(AliMUONCluster& cluster, const Double_t *coef, Double_t *probi, Int_t nIter); // use MLEM for cluster finding
96   
97   void   FindCOG(Double_t *xyc); // find COG position around maximum bin
98   Int_t  FindNearest(const AliMUONPad *pixPtr0); // find nearest neighbouring pixel to the given one
99
100   Int_t FindLocalMaxima(TObjArray *pixArray, Int_t *localMax, Double_t *maxVal); // find local maxima 
101   void  FlagLocalMax(TH2D *hist, Int_t i, Int_t j, Int_t *isLocalMax); // flag local max
102   void  FindCluster(AliMUONCluster& cluster, const Int_t *localMax, Int_t iMax); // find cluster around local max
103   void  AddVirtualPad(AliMUONCluster& cluster); // add virtual pads for some clusters (if necessary)
104   
105   void  PadsInXandY(AliMUONCluster& cluster, Int_t &nInX, Int_t &nInY) const; // get number of pads in X and Y
106
107   /// Process simple cluster
108   void Simple(AliMUONCluster& cluster); 
109   
110   void Plot(const char* outputfile);
111     
112   void ComputeCoefficients(AliMUONCluster& cluster, 
113                            Double_t* coef, Double_t* probi);
114   
115   void CheckOverlaps();
116   void AddBinSimple(TH2D *mlem, Int_t ic, Int_t jc);
117   void MaskPeaks(Int_t mask);
118
119 private:
120   // Status flags for pads
121   static const Int_t fgkZero; ///< pad "basic" state
122   static const Int_t fgkMustKeep; ///< do not kill (for pixels)
123   static const Int_t fgkUseForFit; ///< should be used for fit
124   static const Int_t fgkOver; ///< processing is over
125   static const Int_t fgkModified; ///< modified pad charge 
126   static const Int_t fgkCoupled; ///< coupled pad  
127       
128   // Some constants
129   static const Double_t fgkZeroSuppression; ///< average zero suppression value
130   static const Double_t fgkDistancePrecision; ///< used to check overlaps and so on
131   static const TVector2 fgkIncreaseSize; ///< idem
132   static const TVector2 fgkDecreaseSize; ///< idem
133   
134   AliMUONVClusterFinder* fPreClusterFinder; //!< the pre-clustering worker
135   AliMUONCluster* fPreCluster; //!< current pre-cluster
136   TObjArray fClusterList; //!< clusters corresponding to the current pre-cluster
137   
138   Int_t fEventNumber; //!< current event being processed
139   Int_t fDetElemId; //!< current DE being processed
140   Int_t fClusterNumber; //!< current cluster number
141   
142   const AliMpVSegmentation *fkSegmentation[2]; //!< new segmentation
143   
144   //Int_t fCathBeg;               //!< starting cathode (for combined cluster / track reco)
145   //Int_t fPadBeg[2];             //!< starting pads (for combined cluster / track reco)
146   
147   //static     TMinuit* fgMinuit; //!< Fitter
148   TH2D *fHistMlem; //!< histogram for MLEM procedure
149   TH2D *fHistAnode; //!< histogram for local maxima search
150   
151   TObjArray* fPixArray; //!< collection of pixels
152   Int_t fDebug; //!< debug level
153   Bool_t fPlot; //!< whether we should plot thing (for debug only, quite slow!)
154   
155   AliMUONClusterSplitterMLEM* fSplitter; //!< helper class to go from pixel arrays to clusters
156   Int_t fNClusters; //!< total number of clusters
157   Int_t fNAddVirtualPads; //!< number of clusters for which we added virtual pads
158   
159   ClassDef(AliMUONClusterFinderMLEM,0) // cluster finder in MUON arm of ALICE
160 };
161
162 #endif