Belle II Software development
ParticleMCDecayStringModule.h
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#pragma once
10
11#include <analysis/dataobjects/ParticleList.h>
12#include <analysis/dataobjects/StringWrapper.h>
13
14#include <framework/core/Module.h>
15#include <framework/datastore/StoreArray.h>
16#include <framework/datastore/StoreObjPtr.h>
17#include <framework/pcore/SetMergeable.h>
18#include <framework/pcore/RootMergeable.h>
19
20#include <TTree.h>
21#include <TFile.h>
22
23#include <string>
24#include <unordered_set>
25#include <cstdint>
26
27namespace Belle2 {
32
33 class Particle;
34 class MCParticle;
35
40
42 public:
43
48
52 virtual void initialize() override;
53
57 virtual void event() override;
58
62 virtual void terminate() override;
63
64 private:
65
67 std::string getDecayString(const Particle& p);
68
70 std::string getDecayStringFromParticle(const Particle* p);
71
73 std::string getMCDecayStringFromParticle(const Particle* p);
74
76 std::string getMCDecayStringFromMCParticle(const MCParticle* mcPMatched);
77
79 const MCParticle* getInitialParticle(const MCParticle* mcP);
80
82 std::string buildMCDecayString(const MCParticle* mcPMother, const MCParticle* mcPMatched);
83
85 void convertToConciseString(std::string& string);
86
87
88 private:
89
92
93 std::string m_listName;
94
95 std::string m_fileName;
96 std::string m_treeName;
97
98 std::shared_ptr<TFile> m_file{nullptr};
99
101
103
104 const std::string c_ExtraInfoName = "DecayHash";
105 const std::string c_ExtraInfoNameExtended = "DecayHashExtended";
106
109 std::string m_decayString;
110
112 std::string m_identifiers;
113
114 std::hash<std::string> m_hasher;
115 };
116
118} // Belle2 namespace
119
A Class to store the Monte Carlo particle information.
Definition MCParticle.h:32
Module()
Constructor.
Definition Module.cc:30
float m_decayHash
Decay hash -> The hash of the decay string of the mother particle.
std::string getDecayStringFromParticle(const Particle *p)
get decay string of particle
virtual void initialize() override
Initialize the module.
const std::string c_ExtraInfoName
Name of the extraInfo, which is stored in each Particle.
virtual void event() override
Called for each event.
std::string m_decayString
The complete decay string.
std::string m_listName
Name of the particle list.
virtual void terminate() override
Terminate modules.
std::string m_fileName
Filename in which the hash strings are saved, if empty the strings are not saved.
std::string getMCDecayStringFromMCParticle(const MCParticle *mcPMatched)
get mc decay string from mc particle
std::hash< std::string > m_hasher
Hash function.
bool m_useConciseString
Switch to use concise format for the extended string.
StoreObjPtr< RootMergeable< TTree > > m_tree
ROOT TNtuple containing the saved hashes and strings.
std::shared_ptr< TFile > m_file
ROOT file to store the hashes and strings.
const std::string c_ExtraInfoNameExtended
Name of the extraInfo, which is stored in each Particle.
StoreObjPtr< SetMergeable< std::unordered_set< uint64_t > > > m_hashset
Mergeable unordered set containing the encountered hashes.
StoreArray< StringWrapper > m_stringWrapperArray
StoreArray of StringWrappers.
std::string m_treeName
Tree name in which the hash strings are saved.
std::string m_identifiers
Characters used to identify particles in the concise decay string format (default: alphabet).
void convertToConciseString(std::string &string)
Convert the extended string to a more concise format.
std::string buildMCDecayString(const MCParticle *mcPMother, const MCParticle *mcPMatched)
return decay string for mcPMother, highlight mcPMatched.
const MCParticle * getInitialParticle(const MCParticle *mcP)
search from mcP upwards for a particle that matches specified mother PDG codes.
float m_decayHashExtended
Extended decay hash -> The hash of the decay string of all daughter particles.
std::string getMCDecayStringFromParticle(const Particle *p)
get mc decay string from particle
StoreObjPtr< ParticleList > m_pList
input particle list
std::string getDecayString(const Particle &p)
get the decay string for p.
Class to store reconstructed particles.
Definition Particle.h:76
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
Abstract base class for different kinds of events.