Belle II Software  release-06-02-00
PhotosDebugRandom.cc
1 #include <iostream>
2 #include "PhotosDebugRandom.h"
3 #include "Log.h"
4 using std::ios_base;
5 
6 namespace Photospp {
7 
8  int PhotosDebugRandom::i97_saved = 0;
9  int PhotosDebugRandom::j97_saved = 0;
10  double PhotosDebugRandom::uran_saved[97] = { 0 };
11  double PhotosDebugRandom::cran_saved = 0;
12 
13  void PhotosDebugRandom::saveState()
14  {
15  i97_saved = i97;
16  j97_saved = j97;
17  cran_saved = cran;
18 
19  for (int i = 0; i < 97; i++) uran_saved[i] = uran[i];
20  }
21 
22  void PhotosDebugRandom::restoreState()
23  {
24  i97 = i97_saved;
25  j97 = j97_saved;
26  cran = cran_saved;
27 
28  for (int i = 0; i < 97; i++) uran[i] = uran_saved[i];
29  }
30 
31  void PhotosDebugRandom::setState(int i, int j, double c, double list[97])
32  {
33  i97 = i;
34  j97 = j;
35  cran = c;
36  for (int ii = 0; ii < 97; ii++) uran[ii] = list[ii];
37  }
38 
39  void PhotosDebugRandom::setSaveState(int i, int j, double c, double list[97])
40  {
41  i97_saved = i;
42  j97_saved = j;
43  cran_saved = c;
44  for (int ii = 0; ii < 97; ii++) uran_saved[ii] = list[ii];
45  }
46 
47  void PhotosDebugRandom::print()
48  {
49  int coutPrec = cout.precision(18);
50  ios_base::fmtflags flags = cout.setf(ios_base::scientific, ios_base::floatfield);
51 
52  Log::RedirectOutput(Log::Info());
53 
54  cout << "double uran_state[97] = { ";
55  for (int i = 0; i < 96; i++) cout << uran[i] << ", ";
56  cout << uran[96] << " };" << endl << endl;
57  cout << "PhotosDebugRandom::setState( " << i97 << ", " << j97 << ", " << cran << ", uran_state );" << endl;
58 
60 
61  // Revert output stream flags and precision
62  cout.precision(coutPrec);
63  cout.flags(flags);
64  }
65 
66 } // namespace Photospp
static void RedirectOutput(void(*func)(), ostream &where= *out)
Redirects output to log.
Definition: Log.cc:90
static void RevertOutput()
WARNING! If You're redirecting more than one function, do not forget to use RevertOutput() afterwards...
Definition: Log.h:89