]>
Commit | Line | Data |
---|---|---|
70f2ce9d | 1 | #ifndef ALIKMEANSCLUSTERING_H |
2 | #define ALIKMEANSCLUSTERING_H | |
3 | ||
4 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
5 | * See cxx source for full Copyright notice */ | |
6 | ||
7 | // Implemenatation of the K-Means Clustering Algorithm | |
8 | // http://en.wikipedia.org/wiki/K-means_clustering | |
9 | // This particular implementation is the so called Soft K-means algorithm. | |
10 | // It has been modified to work on the cylindrical topology in eta-phi space. | |
11 | // | |
12 | // Author: Andreas Morsch (CERN) | |
13 | // andreas.morsch@cern.ch | |
14 | ||
15 | #include <TObject.h> | |
16 | ||
17 | class AliKMeansClustering : public TObject | |
18 | { | |
19 | public: | |
20 | AliKMeansClustering() {} | |
21 | virtual ~AliKMeansClustering() {} | |
22 | ||
b7aa0494 | 23 | static Int_t SoftKMeans (Int_t k, Int_t n, Double_t* x, Double_t* y, Double_t* mx, Double_t* my , Double_t* rk ); |
24 | static Int_t SoftKMeans2(Int_t k, Int_t n, Double_t* x, Double_t* y, Double_t* mx, Double_t* my , Double_t* sigma2, | |
77f42a25 | 25 | Double_t* rk ); |
d31bcb3b | 26 | static Int_t SoftKMeans3(Int_t k, Int_t n, Double_t* x, Double_t* y, Double_t* mx, Double_t* my , |
27 | Double_t* sigmax2, Double_t* sigmay2, Double_t* rk ); | |
5145d1b5 | 28 | static void OptimalInit(Int_t k, Int_t n, Double_t* x, Double_t* y, Double_t* mx, Double_t* my); |
29 | static void SetBeta(Double_t beta) {fBeta = beta;} | |
70f2ce9d | 30 | static Double_t d(Double_t mx, Double_t my, Double_t x, Double_t y); |
31 | protected: | |
32 | static Double_t fBeta; | |
33 | ||
34 | ClassDef(AliKMeansClustering, 1) | |
35 | }; | |
19c5a36a | 36 | |
37 | class AliKMeansResult : public TObject | |
38 | { | |
39 | public: | |
40 | AliKMeansResult(Int_t k); | |
62c971ea | 41 | AliKMeansResult(const AliKMeansResult &res); |
42 | AliKMeansResult& operator=(const AliKMeansResult& trclass); | |
43 | ||
19c5a36a | 44 | virtual ~AliKMeansResult(); |
45 | Int_t GetK() const {return fK;} | |
46 | Double_t* GetMx() const {return fMx;} | |
47 | Double_t* GetMy() const {return fMy;} | |
48 | Double_t* GetSigma2() const {return fSigma2;} | |
49 | Double_t* GetRk() const {return fRk;} | |
50 | Int_t* GetInd() const {return fInd;} | |
51 | Double_t* GetTarget() const {return fTarget;} | |
62c971ea | 52 | void CopyResults(AliKMeansResult* res); |
19c5a36a | 53 | void Sort(); |
19c5a36a | 54 | void Sort(Int_t n, Double_t* x, Double_t* y); |
55 | protected: | |
56 | Int_t fK; //! Number of clusters | |
57 | Double_t* fMx; //! Position x | |
58 | Double_t* fMy; //! Position y | |
59 | Double_t* fSigma2; //! Sigma2 | |
60 | Double_t* fRk; //! Responsibility | |
61 | Double_t* fTarget; //! Target for sorting | |
62 | Int_t* fInd; //! Index for sorting | |
70f2ce9d | 63 | |
19c5a36a | 64 | ClassDef(AliKMeansResult, 1) |
65 | }; | |
66 | ||
70f2ce9d | 67 | #endif |