]>
Commit | Line | Data |
---|---|---|
65fb704d | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | /* | |
17 | $Log$ | |
b23a502f | 18 | Revision 1.2 2000/12/01 08:40:48 alibrary |
19 | Correction of a small bug - sRandom can be used now | |
20 | ||
3e54283a | 21 | Revision 1.1 2000/11/30 07:12:48 alibrary |
22 | Introducing new Rndm and QA classes | |
23 | ||
65fb704d | 24 | */ |
25 | ||
26 | /////////////////////////////////////////////////////////////////////////////// | |
27 | // // | |
28 | // // | |
29 | /////////////////////////////////////////////////////////////////////////////// | |
30 | ||
31 | #include "TSystem.h" | |
32 | #include "TFile.h" | |
33 | ||
34 | #include "AliRndm.h" | |
35 | #include "TRandom3.h" | |
36 | ||
37 | ClassImp(AliRndm) | |
38 | ||
39 | ||
40 | //_____________________________________________________________________________ | |
41 | void AliRndm::Rndm(Float_t* array, const Int_t size) const | |
42 | { | |
43 | // | |
44 | // Return an array of n random numbers uniformly distributed | |
45 | // between 0 and 1 not included | |
46 | // | |
47 | for(Int_t i=0; i<size; i++) | |
48 | #ifdef CKNONE | |
49 | array[i]=fRandom->Rndm(); | |
50 | #else | |
51 | do array[i]=fRandom->Rndm(); while(0>=array[i] || array[i]>=1); | |
52 | #endif | |
53 | } | |
54 | ||
65fb704d | 55 | //_____________________________________________________________________________ |
56 | void AliRndm::ReadRandom(const char *filename) | |
57 | { | |
b23a502f | 58 | // |
59 | // Reads saved random generator status from filename | |
60 | // | |
65fb704d | 61 | char *fntmp = gSystem->ExpandPathName(filename); |
62 | TFile *file = new TFile(fntmp,"r"); | |
63 | delete [] fntmp; | |
64 | if(!file) { | |
65 | printf("AliRndm:: Could not open file %s\n",filename); | |
66 | } else { | |
67 | if(!fRandom) fRandom = new TRandom(); | |
68 | fRandom->Read("Random"); | |
69 | file->Close(); | |
70 | delete file; | |
71 | } | |
72 | } | |
73 | ||
74 | //_____________________________________________________________________________ | |
75 | void AliRndm::WriteRandom(const char *filename) const | |
76 | { | |
b23a502f | 77 | // |
78 | // Writes random generator status to filename | |
79 | // | |
65fb704d | 80 | char *fntmp = gSystem->ExpandPathName(filename); |
81 | TFile *file = new TFile(fntmp,"new"); | |
82 | delete [] fntmp; | |
83 | if(!file) { | |
84 | printf("AliRndm:: Could not open file %s\n",filename); | |
85 | } else { | |
86 | fRandom->Write(); | |
87 | file->Close(); | |
88 | delete file; | |
89 | } | |
90 | } |