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[ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/clhep/src/StaticRandomStates.cc (Version 11.3.0) and /externals/clhep/src/StaticRandomStates.cc (Version 10.6.p2)


  1 // -*- C++ -*-                                      1 // -*- C++ -*-
  2 //                                                  2 //
  3 // -------------------------------------------      3 // -----------------------------------------------------------------------
  4 //                             HEP Random           4 //                             HEP Random
  5 //                      --- StaticRandomStates      5 //                      --- StaticRandomStates ---
  6 //                      class implementation f      6 //                      class implementation file
  7 // -------------------------------------------      7 // -----------------------------------------------------------------------
  8 //                                                  8 //
  9 // ===========================================      9 // =======================================================================
 10 // Mark Fischler  - Created: Dec. 21, 2004         10 // Mark Fischler  - Created: Dec. 21, 2004
 11 // Mark Fischler  - Modified restore() to util     11 // Mark Fischler  - Modified restore() to utilize anonymous engine input
 12 //                  to create anonymous restor     12 //                  to create anonymous restore of the static distributions
 13 //                                                 13 //
 14 // ===========================================     14 // =======================================================================
 15                                                    15 
 16 #include "CLHEP/Random/StaticRandomStates.h"       16 #include "CLHEP/Random/StaticRandomStates.h"
 17 #include "CLHEP/Random/RandGauss.h"                17 #include "CLHEP/Random/RandGauss.h"
 18 #include "CLHEP/Random/RandFlat.h"                 18 #include "CLHEP/Random/RandFlat.h"
 19 #include <iostream>                            << 
 20 #include <string>                                  19 #include <string>
 21 #include <sstream>                                 20 #include <sstream>
 22                                                    21 
 23 //======================//                         22 //======================//
 24 //                      //                         23 //                      //
 25 // Maintenance warning: //                         24 // Maintenance warning: //
 26 //      //                                         25 //      //
 27 //======================//                         26 //======================//
 28 //                                                 27 //
 29 // Currently, only two distributions (RandFlat     28 // Currently, only two distributions (RandFlat and RandGauss) have cached
 30 // distribution state.  All such distributions     29 // distribution state.  All such distributions must be saved below, so if
 31 // another such distribution is added, this im     30 // another such distribution is added, this implementation file must be 
 32 // modified to reflect that.                       31 // modified to reflect that.
 33                                                    32 
 34 namespace CLHEP {                                  33 namespace CLHEP {
 35                                                    34 
 36                                                    35 
 37 std::ostream & StaticRandomStates::save(std::o     36 std::ostream & StaticRandomStates::save(std::ostream & os){
 38   RandGauss::saveFullState(os);                    37   RandGauss::saveFullState(os);
 39   RandFlat::saveDistState(os);                     38   RandFlat::saveDistState(os);
 40   return os;                                       39   return os;
 41 }                                                  40 }
 42                                                    41 
 43 #ifdef NOTYET                                      42 #ifdef NOTYET
 44 std::istream & StaticRandomStates::restore(std     43 std::istream & StaticRandomStates::restore(std::istream & is) {
 45   RandGauss::restoreFullState(is);                 44   RandGauss::restoreFullState(is);
 46   RandFlat::restoreDistState(is);                  45   RandFlat::restoreDistState(is);
 47   return is;                                       46   return is;
 48 }                                                  47 }
 49 #endif                                             48 #endif
 50                                                    49 
 51 std::istream & StaticRandomStates::restore(std     50 std::istream & StaticRandomStates::restore(std::istream & is) {
 52   HepRandomEngine * e = HepRandom::getTheEngin     51   HepRandomEngine * e = HepRandom::getTheEngine();
 53   HepRandomEngine *ne = HepRandomEngine::newEn     52   HepRandomEngine *ne = HepRandomEngine::newEngine(is);
 54   if ( !is ) return is;                            53   if ( !is ) return is;
 55   if ( !ne ) return is;                            54   if ( !ne ) return is;
 56   if (ne->name() == e->name()) {                   55   if (ne->name() == e->name()) {
 57     // Because e has const data members, canno     56     // Because e has const data members, cannot simply do *e = *ne
 58     std::ostringstream os;                         57     std::ostringstream os;
 59     os << *ne;                                     58     os << *ne;
 60     std::istringstream istst(os.str());            59     std::istringstream istst(os.str());
 61     istst >> *e;                                   60     istst >> *e;
 62     if (!istst) {                                  61     if (!istst) {
 63       std::cerr << "???? Unexpected behavior i     62       std::cerr << "???? Unexpected behavior in StaticRandomStates::restore:\n"
 64         << "The new engine, which had been inp     63         << "The new engine, which had been input successfully from istream\n"
 65   << "has encountered a problem when used to s     64   << "has encountered a problem when used to set state of theEngine\n";
 66       is.clear(std::ios::badbit | is.rdstate()     65       is.clear(std::ios::badbit | is.rdstate());
 67       return is;                                   66       return is;
 68     }                                              67     }
 69   } else {                                         68   } else {
 70     HepRandom::setTheEngine(ne);                   69     HepRandom::setTheEngine(ne);
 71   }                                                70   }
 72   RandGauss::restoreDistState(is);                 71   RandGauss::restoreDistState(is);
 73   RandFlat::restoreDistState(is);                  72   RandFlat::restoreDistState(is);
 74   return is;                                       73   return is;
 75 }                                                  74 }
 76                                                    75 
 77 }  // namespace CLHEP                              76 }  // namespace CLHEP
 78                                                    77