]>
Commit | Line | Data |
---|---|---|
df9db588 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | #include <TMath.h> | |
19 | ||
20 | #include "AliRedCov.h" | |
21 | ||
22 | templateClassImp(AliRedCov) | |
23 | ||
24 | //______________________________________________________________________________ | |
25 | template <Int_t N> template <class T> void AliRedCov<N>::GetCovMatrix(T *cmat) const | |
26 | { | |
27 | // | |
28 | // Returns the external cov matrix | |
29 | // | |
30 | ||
31 | for(Int_t i=0; i<N; ++i) { | |
32 | // Off diagonal elements | |
33 | for(Int_t j=0; j<i; ++j) { | |
34 | printf("cmat[%2d] = fODia[%2d]*fDiag[%2d]*fDiag[%2d];\n", | |
35 | i*(i+1)/2+j,(i-1)*i/2+j,j,i); | |
36 | cmat[i*(i+1)/2+j] = fODia[(i-1)*i/2+j]*fDiag[j]*fDiag[i];} | |
37 | ||
38 | // Diagonal elements | |
39 | printf("cmat[%2d] = fDiag[%2d]*fDiag[%2d];\n", | |
40 | i*(i+1)/2+i,i,i); | |
41 | cmat[i*(i+1)/2+i] = fDiag[i]*fDiag[i]; | |
42 | } | |
43 | } | |
44 | ||
45 | ||
46 | //______________________________________________________________________________ | |
47 | template <Int_t N> template <class T> void AliRedCov<N>::SetCovMatrix(T *cmat) | |
48 | { | |
49 | // | |
50 | // Sets the external cov matrix | |
51 | // | |
52 | ||
53 | if(cmat) { | |
54 | // Diagonal elements first | |
55 | for(Int_t i=0; i<N; ++i) { | |
56 | printf("fDiag[%2d] = TMath::Sqrt(cmat[%2d]);\n", | |
57 | i,i*(i+1)/2+i); | |
58 | fDiag[i] = TMath::Sqrt(cmat[i*(i+1)/2+i]);} | |
59 | ||
60 | // ... then the ones off diagonal | |
61 | for(Int_t i=0; i<N; ++i) | |
62 | // Off diagonal elements | |
63 | for(Int_t j=0; j<i; ++j) { | |
64 | printf("fODia[%2d] = cmat[%2d]/(fDiag[%2d]*fDiag[%2d]);\n", | |
65 | (i-1)*i/2+j,i*(i+1)/2+j,j,i); | |
66 | fODia[(i-1)*i/2+j] = cmat[i*(i+1)/2+j]/(fDiag[j]*fDiag[i]); | |
67 | } | |
68 | } else { | |
69 | for(Int_t i=0; i< N; ++i) fDiag[i]=-999.; | |
70 | for(Int_t i=0; i< N*(N-1)/2; ++i) fODia[i]=0.; | |
71 | } | |
72 | } |