SQLamarr
The stand-alone ultra-fast simulation option for the LHCb experiment
GenerativePlugin.cpp
1 // (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration.
2 //
3 // This software is distributed under the terms of the GNU General Public
4 // Licence version 3 (GPL Version 3), copied verbatim in the file "LICENCE".
5 //
6 // In applying this licence, CERN does not waive the privileges and immunities
7 // granted to it by virtue of its status as an Intergovernmental Organization
8 // or submit itself to any jurisdiction.
9 
10 // Standard C
11 #include <dlfcn.h>
12 
13 // STL
14 #include <random>
15 
16 // SQLamarr
17 #include "SQLamarr/GenerativePlugin.h"
18 #include "SQLamarr/GlobalPRNG.h"
19 
20 #include <iostream>
21 
22 
23 namespace SQLamarr
24 {
25  void GenerativePlugin::eval_parametrization (float* output, const float* input)
26  {
27  std::vector<float> rnd(m_n_random);
28  auto generator = GlobalPRNG::get_or_create(m_database.get());
29  std::normal_distribution<float> gaussian;
30 
31  for (auto& r: rnd)
32  r = gaussian(*generator);
33 
34  m_func(output, input, rnd.data());
35  }
36 }
SQLite3DB & m_database
Reference to the SQLite database (not owned).
static PRNG * get_or_create(const sqlite3_context *db, uint64_t seed=no_seed)
Return a pointer to an initialized generator.
Definition: GlobalPRNG.h:99