Belle II Software light-2406-ragdoll
DecayForest.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <analysis/utility/DecayForest.h>
10
11#include <cassert>
12#include <cstdint>
13
14using namespace Belle2;
15
16
17DecayForest::DecayForest(const std::string& full_decaystring, bool save_memory, bool removeRadiativeGammaFlag)
18{
19
21 unsigned int start = 0;
22 for (unsigned int i = 0; i < full_decaystring.size(); ++i) {
23 if (full_decaystring[i] == '|') {
24 forest.emplace_back(full_decaystring.substr(start, i - start), removeRadiativeGammaFlag);
25 start = i + 1;
26 if (save_memory and forest.back().isValid() and forest.size() > 1)
27 break;
28 }
29 }
30
31 if (not(save_memory and forest.back().isValid() and forest.size() > 1))
32 forest.emplace_back(full_decaystring.substr(start, full_decaystring.size() - start), removeRadiativeGammaFlag);
33
34 for (unsigned int j = 1; j < forest.size(); ++j) {
35 if (forest[j].isValid()) {
37 break;
38 }
39 }
40
41}
42
43
44int DecayForest::decayHashFloatToInt(float decayHash, float decayHashExtended)
45{
46
47 // Convert unsigned int decay hash into a float keeping the same bit pattern
48 assert(sizeof(float) == sizeof(uint32_t));
49
50 union convert {
51 uint32_t i;
52 float f;
53 };
54 convert bitconverter;
55
56 uint64_t integer = 0;
57
58 bitconverter.f = decayHash;
59 integer = static_cast<uint64_t>(bitconverter.i) << 32;
60 // cppcheck throws false positives here (doesn't understand this use of a union)
61 //
62 // cppcheck-suppress redundantAssignment
63 bitconverter.f = decayHashExtended;
64 integer += bitconverter.i;
65
66 return integer;
67
68}
std::vector< DecayTree > forest
vector of DecayTrees
Definition: DecayForest.h:66
size_t m_first_valid_original
The first valid DecayTree.
Definition: DecayForest.h:67
static int decayHashFloatToInt(float decayHash, float decayHashExtended)
Convert DecayHashes outputted by ParticleMCDecayString module to an integer.
Definition: DecayForest.cc:44
DecayForest(const std::string &full_decaystring, bool save_memory=true, bool removeRadiativeGammaFlag=false)
Create a DecayForest from a full decaystring outputted by ParticleMCDecayString.
Definition: DecayForest.cc:17
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24