Belle II Software light-2406-ragdoll
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/Particle.h>
12#include <analysis/dataobjects/ParticleList.h>
13#include <analysis/dataobjects/StringWrapper.h>
14
15#include <framework/core/Module.h>
16#include <framework/datastore/StoreArray.h>
17#include <framework/datastore/StoreObjPtr.h>
18#include <framework/pcore/SetMergeable.h>
19#include <framework/pcore/RootMergeable.h>
20
21#include <TTree.h>
22#include <TFile.h>
23
24#include <string>
25#include <unordered_set>
26#include <cstdint>
27
28namespace Belle2 {
34 class Particle;
35 class MCParticle;
36
46 public:
47
52
56 virtual void initialize() override;
57
61 virtual void event() override;
62
66 virtual void terminate() override;
67
68 private:
69
71 std::string getDecayString(const Particle& p);
72
74 std::string getDecayStringFromParticle(const Particle* p);
75
77 std::string getMCDecayStringFromParticle(const Particle* p);
78
80 std::string getMCDecayStringFromMCParticle(const MCParticle* mcPMatched);
81
83 const MCParticle* getInitialParticle(const MCParticle* mcP);
84
86 std::string buildMCDecayString(const MCParticle* mcPMother, const MCParticle* mcPMatched);
87
89 void convertToConciseString(std::string& string);
90
91
92 private:
93
97 std::string m_listName;
99 std::string m_fileName;
100 std::string m_treeName;
102 std::shared_ptr<TFile> m_file{nullptr};
108 const std::string c_ExtraInfoName = "DecayHash";
109 const std::string c_ExtraInfoNameExtended = "DecayHashExtended";
113 std::string m_decayString;
116 std::string m_identifiers;
118 std::hash<std::string> m_hasher;
119 };
120
122} // Belle2 namespace
123
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Base class for Modules.
Definition: Module.h:72
Adds the Monte Carlo decay string to a Particle.
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:75
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.
Definition: ClusterUtils.h:24