EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RandomNumbers.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RandomNumbers.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 //
10 // RandomNumbers.cpp
11 // ActsExamples
12 //
13 // Created by Andreas Salzburger on 17/05/16.
14 //
15 //
16 
18 
20 
22  const AlgorithmContext& context) const {
23  return RandomEngine(generateSeed(context));
24 }
25 
27  const AlgorithmContext& context) const {
28  // use Cantor pairing function to generate a unique generator id from
29  // algorithm and event number to get a consistent seed
30  // see https://en.wikipedia.org/wiki/Pairing_function#Cantor_pairing_function
31  const uint64_t k1 = context.algorithmNumber;
32  const uint64_t k2 = context.eventNumber;
33  const uint64_t id = (k1 + k2) * (k1 + k2 + 1) / 2 + k2;
34  return m_cfg.seed + id;
35 }