# How to continue sequence of randoms in TRandom3 generator?

**URL:** <https://root-forum.cern.ch/t/how-to-continue-sequence-of-randoms-in-trandom3-generator/43820>\
**Category:** Newbie\
**Created:** [March 4, 2021, 1:19pm UTC](https://root-forum.cern.ch/t/how-to-continue-sequence-of-randoms-in-trandom3-generator/43820 "2021-03-04T13:19:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kurbatov](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/ee7513/32.png) [@kurbatov](https://root-forum.cern.ch/u/kurbatov)\
**Post date:** [March 4, 2021, 1:19pm UTC](https://root-forum.cern.ch/t/how-to-continue-sequence-of-randoms-in-trandom3-generator/43820/1 "2021-03-04T13:19:36Z")

</div>

I have :

_ROOT Version:_ 6.22/01  
_Platform:_ 18.04.1-Ubuntu  
_Compiler:_ g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

Problem : I am planning long simulation by geant4, using TRandom3 generator in  
a form of series of files and each file should be generated on independent  
randoms.I want In one run before close of output file to remember  
status of generator,wirte it out( either seed number or …?) and in the following  
run to continue since what I had in the end of previous one.

Thanks

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [March 4, 2021, 1:35pm UTC](https://root-forum.cern.ch/t/how-to-continue-sequence-of-randoms-in-trandom3-generator/43820/2 "2021-03-04T13:35:32Z")

</div>

Try to `gRandom->Write("MyRandom");` to a ROOT file (you can then retrieve it using a standard “Get” / “GetObject” statement).

Actually, there exist [TRandom::WriteRandom](https://root.cern/doc/master/classTRandom.html#a36d598919fcdeb65b6c73e1c4ecb76ff) and [TRandom::ReadRandom](https://root.cern/doc/master/classTRandom.html#a738f7f45e21750ef8b966fe6390cccb1) which you could try to use.

---

<div class="post-metadata">

**Author:** ![kurbatov](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/ee7513/32.png) [@kurbatov](https://root-forum.cern.ch/u/kurbatov)\
**Post date:** [March 5, 2021, 7:34am UTC](https://root-forum.cern.ch/t/how-to-continue-sequence-of-randoms-in-trandom3-generator/43820/3 "2021-03-05T07:34:04Z")

</div>

Dear Mr. Wile E. Coyote!  
Thanks one more for the respond!  
May be you know answer to the next couple of questions:

1.In ROOT documentaion( page 42,ROOTUsersGuideA4.pdf) there is  
a phrase “…Setting the seed to 0 implies that the seed will be  
uniquely generated using  
the TUUID. Any other value will be used as a constant…”. What is the  
difference  
between these two cases?

1. According to ROOT documentation, TRandom3 does not have good  
statistical  
characteristics. When I worked on FORTRAN I used to work with  
TRandomRanluxpp  
generator. While using it in root, may I organize the prolongation of  
random  
numbers as you recommended in a prvious e-mail? - In this case I  
should do resetting like this:

root[] delete gRandom;  
root[] gRandom = new TRandomRanluxpp(0); //seed=0

Am I right?

V.Kurbatov

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [March 5, 2021, 9:27am UTC](https://root-forum.cern.ch/t/how-to-continue-sequence-of-randoms-in-trandom3-generator/43820/4 "2021-03-05T09:27:46Z")

</div>

```cpp
{
  // delete gRandom; gRandom = new TRandomRanluxpp();
  gRandom->Print();
  std::cout << "Observe!" << std::endl;
  gRandom->SetSeed(1234); std::cout << gRandom->Rndm() << std::endl;
  gRandom->SetSeed(1234); std::cout << gRandom->Rndm() << std::endl;
  gRandom->SetSeed(0); std::cout << gRandom->Rndm() << std::endl;
  gRandom->SetSeed(0); std::cout << gRandom->Rndm() << std::endl;
  gRandom->SetSeed(1234); std::cout << gRandom->Rndm() << std::endl;
  gRandom->SetSeed(1234); std::cout << gRandom->Rndm() << std::endl;
  gRandom->SetSeed(0); std::cout << gRandom->Rndm() << std::endl;
  gRandom->SetSeed(0); std::cout << gRandom->Rndm() << std::endl;
  std::cout << "Dashing, no?" << std::endl;
}

```

---

<div class="post-metadata">

**Author:** ![kurbatov](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/ee7513/32.png) [@kurbatov](https://root-forum.cern.ch/u/kurbatov)\
**Post date:** [March 5, 2021, 9:51am UTC](https://root-forum.cern.ch/t/how-to-continue-sequence-of-randoms-in-trandom3-generator/43820/5 "2021-03-05T09:51:36Z")

</div>

Trying :

delete gRandom;  
gRandom = new TRandomRanluxpp(0);

root gives :

ROOT\_prompt\_1:1:15: error: unknown type name ‘TRandomRanluxpp’

Why?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [March 5, 2021, 9:59am UTC](https://root-forum.cern.ch/t/how-to-continue-sequence-of-randoms-in-trandom3-generator/43820/6 "2021-03-05T09:59:45Z")

</div>

Your ROOT version does not have it (as of today, you need the git “master”).
