]>
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$ | |
18 | */ | |
19 | ||
20 | /////////////////////////////////////////////////////////////////////////////// | |
21 | // // | |
22 | // // | |
23 | /////////////////////////////////////////////////////////////////////////////// | |
24 | ||
25 | #include "TSystem.h" | |
26 | #include "TFile.h" | |
27 | ||
28 | #include "AliRndm.h" | |
29 | #include "TRandom3.h" | |
30 | ||
31 | ClassImp(AliRndm) | |
32 | ||
33 | ||
34 | //_____________________________________________________________________________ | |
35 | void AliRndm::Rndm(Float_t* array, const Int_t size) const | |
36 | { | |
37 | // | |
38 | // Return an array of n random numbers uniformly distributed | |
39 | // between 0 and 1 not included | |
40 | // | |
41 | for(Int_t i=0; i<size; i++) | |
42 | #ifdef CKNONE | |
43 | array[i]=fRandom->Rndm(); | |
44 | #else | |
45 | do array[i]=fRandom->Rndm(); while(0>=array[i] || array[i]>=1); | |
46 | #endif | |
47 | } | |
48 | ||
49 | //_____________________________________________________________________________ | |
50 | void AliRndm::SetRandom(TRandom *ran) | |
51 | { | |
52 | if(ran) fRandom=ran; | |
53 | else fRandom=sRandom=gRandom; | |
54 | } | |
55 | ||
56 | //_____________________________________________________________________________ | |
57 | void AliRndm::ReadRandom(const char *filename) | |
58 | { | |
59 | char *fntmp = gSystem->ExpandPathName(filename); | |
60 | TFile *file = new TFile(fntmp,"r"); | |
61 | delete [] fntmp; | |
62 | if(!file) { | |
63 | printf("AliRndm:: Could not open file %s\n",filename); | |
64 | } else { | |
65 | if(!fRandom) fRandom = new TRandom(); | |
66 | fRandom->Read("Random"); | |
67 | file->Close(); | |
68 | delete file; | |
69 | } | |
70 | } | |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | void AliRndm::WriteRandom(const char *filename) const | |
74 | { | |
75 | char *fntmp = gSystem->ExpandPathName(filename); | |
76 | TFile *file = new TFile(fntmp,"new"); | |
77 | delete [] fntmp; | |
78 | if(!file) { | |
79 | printf("AliRndm:: Could not open file %s\n",filename); | |
80 | } else { | |
81 | fRandom->Write(); | |
82 | file->Close(); | |
83 | delete file; | |
84 | } | |
85 | } |