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/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
43 public:
44
49
53 virtual void initialize() override;
54
58 virtual void event() override;
59
63 virtual void terminate() override;
64
65 private:
66
68 std::string getDecayString(const Particle& p);
69
71 std::string getDecayStringFromParticle(const Particle* p);
72
74 std::string getMCDecayStringFromParticle(const Particle* p);
75
77 std::string getMCDecayStringFromMCParticle(const MCParticle* mcPMatched);
78
80 const MCParticle* getInitialParticle(const MCParticle* mcP);
81
83 std::string buildMCDecayString(const MCParticle* mcPMother, const MCParticle* mcPMatched);
84
86 void convertToConciseString(std::string& string);
87
88
89 private:
90
94 std::string m_listName;
96 std::string m_fileName;
97 std::string m_treeName;
99 std::shared_ptr<TFile> m_file{nullptr};
105 const std::string c_ExtraInfoName = "DecayHash";
106 const std::string c_ExtraInfoNameExtended = "DecayHashExtended";
110 std::string m_decayString;
113 std::string m_identifiers;
115 std::hash<std::string> m_hasher;
116 };
117
119} // Belle2 namespace
120
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.