StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
randomTest3.cc
1 /***************************************************************************
2  *
3  * $Id: randomTest3.cc,v 1.2 2003/09/02 17:59:38 perev Exp $
4  *
5  * Author: Brian Lasiuk, July 1998
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: randomTest3.cc,v $
13  * Revision 1.2 2003/09/02 17:59:38 perev
14  * gcc 3.2 updates + WarnOff
15  *
16  * Revision 1.1 1999/02/17 12:44:02 ullrich
17  * New Revision
18  *
19  * Revision 1.1 1999/01/23 00:26:52 ullrich
20  * Initial Revision
21  *
22  **************************************************************************/
23 #include <Stiostream.h>
24 #include <vector>
25 
26 #include "StGlobals.hh"
27 #include "Random.h"
28 
29 // the random engines
30 #include "JamesRandom.h"
31 #include "RanluxEngine.h"
32 
33 // the different distributions
34 #include "RandFlat.h"
35 #include "RandPoisson.h"
36 #include "RandExponential.h"
37 #include "RandGauss.h"
38 #include "RandBreitWigner.h"
39 
40 #ifndef ST_NO_TEMPLATE_DEF_ARGS
41 void printArray(vector<double>& vec)
42 #else
43 void printArray(vector<double, allocator<double> >& vec)
44 #endif
45 {
46  for(int ii=0; ii<vec.size(); ii++)
47  cout << "(" << ii << ") " << vec[ii] << endl;
48  cout << endl;
49 }
50 // --------------------- MAIN -------------------------- //
51 int main()
52 {
53  const int size = 5;
54 
55  // Generator must be given an engine:
56  // - HepJamesRandom used by default
57  HepJamesRandom engine1;
58  RanluxEngine engine2;
59 
60 #ifndef ST_NO_TEMPLATE_DEF_ARGS
61  vector<double> listOfRandoms(size);
62 #else
63  vector<double, allocator<double> > listOfRandoms(size);
64 #endif
65  RandFlat flatDistribution(engine1);
66  RandGauss gaussDistribution(engine2);
67  RandExponential exponentialDistribution(engine1);
68  RandPoisson poissonDistribution(engine2);
69  RandBreitWigner breitWignerDistribution(engine2);
70 
71 
72  cout << "\nAn Array of Numbers from a Flat Distribution:" << endl;
73  flatDistribution.shootArray(listOfRandoms);
74  printArray(listOfRandoms);
75 
76  cout << "\nAn Array of Numbers from a Gauss Distribution:" << endl;
77  gaussDistribution.fireArray(listOfRandoms);
78  printArray(listOfRandoms);
79 
80  cout << "\nAn Array of Numbers from an Exponential Distribution:" << endl;
81  exponentialDistribution.fireArray(listOfRandoms);
82  printArray(listOfRandoms);
83 
84  cout << "\nAn Array of Numbers from an BW Distribution:" << endl;
85  breitWignerDistribution.shootArray(listOfRandoms);
86  printArray(listOfRandoms);
87 
88  return 0;
89 }