From 740ebff31b6584a78bc7e49341261dc254ba3e71 Mon Sep 17 00:00:00 2001 From: hristov Date: Thu, 7 Mar 2002 08:39:51 +0000 Subject: [PATCH] Generation of N gaussian numbers through a known covariance matrix. It probably will be moved to Root later. (M.Masera) --- STEER/AliGausCorr.cxx | 144 ++++++++++++++++++++++++++++++++++++++++++ STEER/AliGausCorr.h | 41 ++++++++++++ STEER/Makefile | 3 +- STEER/STEERLinkDef.h | 1 + STEER/libSTEER.pkg | 3 +- 5 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 STEER/AliGausCorr.cxx create mode 100644 STEER/AliGausCorr.h diff --git a/STEER/AliGausCorr.cxx b/STEER/AliGausCorr.cxx new file mode 100644 index 00000000000..15f8f2663e7 --- /dev/null +++ b/STEER/AliGausCorr.cxx @@ -0,0 +1,144 @@ +/************************************************************************** + * Copyright(c) 2001-2002, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +//////////////////////////////////////////////////////////////////////// +// Class used to generate correlated gaussian numbers with mean +// zero and known covariance matrix. +// Adapted from the Fortran code in Cernlib V122 (corset, corgen) +// F. James, Monte Carlo theory and practice, +// Rep. Prog. Phys. 43 (1980) 1145-1189. +// M.Masera 15.03.2001 9:30 - modified on 26.02.2002 17:40 +//////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include "AliGausCorr.h" + +ClassImp(AliGausCorr) + +//________________________________________________________ +AliGausCorr::AliGausCorr() +{ + // Default constructor + fSize = 0; + fCv = 0; +} + +//________________________________________________________ +AliGausCorr::AliGausCorr(const TMatrixD & vec, Int_t size) +{ + // Standard constructor + fSize = size; + fCv = new TMatrixD(fSize,fSize); + for(Int_t j=0;jRndm(); + } while (!y); + z = gRandom->Rndm(); + x = z * 6.283185; + tmpv[i] = TMath::Sin(x)*TMath::Sqrt(-2*TMath::Log(y)); + } + + for(Int_t i=0;i +class TArrayD; + + +class AliGausCorr : public TObject { +//////////////////////////////////////////////////////////////////////// +// Class used to generate correlated gaussian numbers with mean +// zero and known covariance matrix. +// Adapted from the Fortran code in Cernlib V122 (corset, corgen) +// F. James, Monte Carlo theory and practice, +// Rep. Prog. Phys. 43 (1980) 1145-1189. +// M.Masera 14.03.2001 19:30 - last mod. 26.02.2002 17:45 +//////////////////////////////////////////////////////////////////////// + public: + // + AliGausCorr(); + AliGausCorr(const TMatrixD & cov, Int_t size); + AliGausCorr(const AliGausCorr & tgcorr); + virtual ~AliGausCorr(); + void GetGaussN(TArrayD &vec) const; + TMatrixD GetSqrtMatrix() const { return *fCv;} + void PrintCv() const; + AliGausCorr & operator=(const AliGausCorr & tgcorr); + // + private: + // + Int_t fSize; // number of correlated gaussian random numbers + TMatrixD *fCv; // 'square root' of the covariance matrix + + ClassDef(AliGausCorr,1) +}; + + +#endif + + + diff --git a/STEER/Makefile b/STEER/Makefile index b5f9a99a3d8..17992157175 100644 --- a/STEER/Makefile +++ b/STEER/Makefile @@ -23,7 +23,8 @@ SRCS = AliDetector.cxx AliHeader.cxx AliMagF.cxx \ AliGenEventHeader.cxx AliStack.cxx AliConfig.cxx \ AliRunDigitizer.cxx AliDigitizer.cxx\ AliStream.cxx AliMergeCombi.cxx \ - AliMagFMaps.cxx AliFieldMap.cxx + AliMagFMaps.cxx AliFieldMap.cxx \ + AliGausCorr.cxx # C++ Headers diff --git a/STEER/STEERLinkDef.h b/STEER/STEERLinkDef.h index 969c4089aaf..016e86a32a6 100644 --- a/STEER/STEERLinkDef.h +++ b/STEER/STEERLinkDef.h @@ -55,6 +55,7 @@ #pragma link C++ class AliStream+; #pragma link C++ class AliMergeCombi+; #pragma link C++ class AliFieldMap-; +#pragma link C++ class AliGaussCorr+; #endif diff --git a/STEER/libSTEER.pkg b/STEER/libSTEER.pkg index f6444efaf08..b74335174ae 100644 --- a/STEER/libSTEER.pkg +++ b/STEER/libSTEER.pkg @@ -12,7 +12,8 @@ AliKalmanTrack.cxx AliCluster.cxx AliTracker.cxx\ AliMCQA.cxx AliPDG.cxx AliDebugVolume.cxx \ AliGenEventHeader.cxx AliStack.cxx AliConfig.cxx \ AliRunDigitizer.cxx AliDigitizer.cxx AliStream.cxx \ -AliMergeCombi.cxx AliMagFMaps.cxx AliFieldMap.cxx +AliMergeCombi.cxx AliMagFMaps.cxx AliFieldMap.cxx \ +AliGausCorr.cxx HDRS:= $(SRCS:.cxx=.h) -- 2.43.0