Project
Loading...
Searching...
No Matches
TopologyFastSimulation.cxx
Go to the documentation of this file.
1
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3
// All rights not expressly granted are reserved.
4
//
5
// This software is distributed under the terms of the GNU General Public
6
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7
//
8
// In applying this license CERN does not waive the privileges and immunities
9
// granted to it by virtue of its status as an Intergovernmental Organization
10
// or submit itself to any jurisdiction.
11
16
17
#include "
ITSMFTReconstruction/TopologyFastSimulation.h
"
18
#include <algorithm>
19
20
ClassImp
(
o2::itsmft::TopologyFastSimulation
);
21
22
namespace
o2
23
{
24
namespace
itsmft
25
{
26
TopologyFastSimulation::TopologyFastSimulation
(std::string fileName,
unsigned
seed)
27
{
28
mDictionary.
readFromFile
(fileName);
29
double
tot_freq = 0.;
30
int
dictSize = mDictionary.
getSize
();
31
mFreqArray.reserve(dictSize);
32
for
(
int
iKey = 0; iKey < dictSize; iKey++) {
33
tot_freq += mDictionary.
getFrequency
(iKey);
34
mFreqArray[iKey] = tot_freq;
35
}
36
mGenerator = std::mt19937(seed);
37
mDistribution = std::uniform_real_distribution<double>(0.0, 1.0);
38
}
39
40
int
TopologyFastSimulation::getRandom
()
41
{
42
double
rnd = mDistribution(mGenerator);
43
auto
ind = std::upper_bound(mFreqArray.begin(), mFreqArray.end(), rnd,
44
[](
const
double
& comp1,
const
double
& comp2) { return comp1 < comp2; });
45
return
std::distance(mFreqArray.begin(), ind);
46
}
47
}
// namespace itsmft
48
}
// namespace o2
ClassImp
ClassImp(o2::itsmft::TopologyFastSimulation)
TopologyFastSimulation.h
Definition of the TopologyFastSimulation class.
o2::itsmft::TopologyDictionary::getSize
int getSize() const
Returns the number of elements in the dicionary;.
Definition
TopologyDictionary.h:162
o2::itsmft::TopologyDictionary::readFromFile
int readFromFile(const std::string &fileName)
Definition
TopologyDictionary.cxx:78
o2::itsmft::TopologyDictionary::getFrequency
double getFrequency(int n) const
Returns the frequency of the n_th element;.
Definition
TopologyDictionary.h:141
o2::itsmft::TopologyFastSimulation
Definition
TopologyFastSimulation.h:33
o2::itsmft::TopologyFastSimulation::getRandom
int getRandom()
Definition
TopologyFastSimulation.cxx:40
o2::itsmft::TopologyFastSimulation::TopologyFastSimulation
TopologyFastSimulation(std::string fileName, unsigned seed=0xdeadbeef)
Definition
TopologyFastSimulation.cxx:26
o2
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Definition
BitstreamReader.h:24
Detectors
ITSMFT
common
reconstruction
src
TopologyFastSimulation.cxx
Generated on Tue Feb 25 2025 23:16:19 for Project by
1.9.8