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