]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliRndm.cxx
Change fgkRpadW to 1.0 cm for new pad plane
[u/mrichter/AliRoot.git] / STEER / AliRndm.cxx
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 Revision 1.3  2000/12/21 15:30:18  fca
19 Correcting coding convention violations
20
21 Revision 1.2  2000/12/01 08:40:48  alibrary
22 Correction of a small bug - sRandom can be used now
23
24 Revision 1.1  2000/11/30 07:12:48  alibrary
25 Introducing new Rndm and QA classes
26
27 */
28
29 ///////////////////////////////////////////////////////////////////////////////
30 //                                                                           //
31 //                                                                           //
32 ///////////////////////////////////////////////////////////////////////////////
33
34 #include "TFile.h"
35 #include "TError.h"
36 #include "TRandom3.h"
37 #include "TSystem.h"
38
39 #include "AliRndm.h"
40
41 ClassImp(AliRndm)
42
43 //_______________________________________________________________________
44 AliRndm::AliRndm():
45   fRandom(0)
46 {
47   // 
48   // Default ctor
49   //
50   SetRandom();
51 }
52
53 //_______________________________________________________________________
54 AliRndm::AliRndm(const AliRndm& rn):
55   fRandom(0)
56 {
57   //
58   // Copy constructor
59   //
60   rn.Copy(*this);
61 }
62
63 //_______________________________________________________________________
64 void AliRndm::Copy(AliRndm&) const
65 {
66   ::Fatal("Copy","Not implemented\n");
67 }
68
69
70 //_____________________________________________________________________________
71 void AliRndm::Rndm(Float_t* array, const Int_t size) const
72 {
73   //
74   // Return an array of n random numbers uniformly distributed 
75   // between 0 and 1 not included
76   //
77   for(Int_t i=0; i<size; i++) 
78 #ifdef CKNONE
79     array[i]=fRandom->Rndm();
80 #else
81     do array[i]=fRandom->Rndm(); while(0>=array[i] || array[i]>=1);
82 #endif
83 }
84
85 //_____________________________________________________________________________
86 void AliRndm::ReadRandom(const char *filename)
87 {
88   //
89   // Reads saved random generator status from filename
90   //
91   char *fntmp = gSystem->ExpandPathName(filename);
92   TFile *file = new TFile(fntmp,"r");
93   delete [] fntmp;
94   if(!file) {
95     printf("AliRndm:: Could not open file %s\n",filename);
96   } else {
97     if(!fRandom) fRandom = new TRandom();
98     fRandom->Read("Random");
99     file->Close();
100     delete file;
101   }
102 }
103
104 //_____________________________________________________________________________
105 void AliRndm::WriteRandom(const char *filename) const
106 {
107   //
108   // Writes random generator status to filename
109   //
110   char *fntmp = gSystem->ExpandPathName(filename);
111   TFile *file = new TFile(fntmp,"new");
112   delete [] fntmp;
113   if(!file) {
114     printf("AliRndm:: Could not open file %s\n",filename);
115   } else {
116     fRandom->Write();
117     file->Close();
118     delete file;
119   }
120 }