Belle II Software  release-05-02-19
ParticleMCDecayStringModule.h
1 /* BASF2 (Belle Analysis Framework 2) *
2  * Copyright(C) 2016 - Belle II Collaboration *
3  * *
4  * Author: The Belle II Collaboration *
5  * Contributors: Thomas Keck, Matt Barrett *
6  * *
7  * This software is provided "as is" without any warranty. *
8  **************************************************************************/
9 
10 #pragma once
11 
12 #include <framework/core/Module.h>
13 #include <framework/datastore/StoreObjPtr.h>
14 #include <framework/pcore/SetMergeable.h>
15 #include <framework/pcore/RootMergeable.h>
16 
17 #include <TTree.h>
18 #include <TFile.h>
19 
20 #include <string>
21 #include <unordered_set>
22 #include <cstdint>
23 
24 namespace Belle2 {
30  class Particle;
31  class MCParticle;
32 
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 
90  std::string m_listName;
92  std::string m_fileName;
93  std::string m_treeName;
95  TFile* m_file;
101  const std::string c_ExtraInfoName = "DecayHash";
102  const std::string c_ExtraInfoNameExtended = "DecayHashExtended";
104  float m_decayHash;
106  std::string m_decayString;
109  std::string m_identifiers;
111  std::hash<std::string> m_hasher;
112  };
113 
115 } // Belle2 namespace
116 
Belle2::ParticleMCDecayStringModule::m_tree
StoreObjPtr< RootMergeable< TTree > > m_tree
ROOT TNtuple containting the saved hashes and strings.
Definition: ParticleMCDecayStringModule.h:97
Belle2::ParticleMCDecayStringModule::m_file
TFile * m_file
ROOT file to store the hashes and strings.
Definition: ParticleMCDecayStringModule.h:95
Belle2::ParticleMCDecayStringModule::ParticleMCDecayStringModule
ParticleMCDecayStringModule()
Constructor.
Definition: ParticleMCDecayStringModule.cc:45
Belle2::ParticleMCDecayStringModule
Adds the Monte Carlo decay string to a Particle.
Definition: ParticleMCDecayStringModule.h:41
Belle2::ParticleMCDecayStringModule::c_ExtraInfoName
const std::string c_ExtraInfoName
Name of the extraInfo, which is stored in each Particle.
Definition: ParticleMCDecayStringModule.h:101
Belle2::ParticleMCDecayStringModule::m_decayHash
float m_decayHash
Decay hash -> The hash of the decay string of the mother particle.
Definition: ParticleMCDecayStringModule.h:104
Belle2::ParticleMCDecayStringModule::event
virtual void event() override
Called for each event.
Definition: ParticleMCDecayStringModule.cc:111
Belle2::ParticleMCDecayStringModule::getMCDecayStringFromParticle
std::string getMCDecayStringFromParticle(const Particle *p)
get mc decay string from particle
Definition: ParticleMCDecayStringModule.cc:251
Belle2::ParticleMCDecayStringModule::m_identifiers
std::string m_identifiers
Characters used to identify particles in the concise decay string format (default: alphabet).
Definition: ParticleMCDecayStringModule.h:109
Belle2::ParticleMCDecayStringModule::c_ExtraInfoNameExtended
const std::string c_ExtraInfoNameExtended
Name of the extraInfo, which is stored in each Particle.
Definition: ParticleMCDecayStringModule.h:102
Belle2::ParticleMCDecayStringModule::getDecayStringFromParticle
std::string getDecayStringFromParticle(const Particle *p)
get decay string of particle
Definition: ParticleMCDecayStringModule.cc:232
Belle2::ParticleMCDecayStringModule::initialize
virtual void initialize() override
Initialize the module.
Definition: ParticleMCDecayStringModule.cc:68
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::ParticleMCDecayStringModule::m_decayHashExtended
float m_decayHashExtended
Extended decay hash -> The hash of the decay string of all daughter particles.
Definition: ParticleMCDecayStringModule.h:105
Belle2::ParticleMCDecayStringModule::m_hashset
StoreObjPtr< SetMergeable< std::unordered_set< uint64_t > > > m_hashset
Mergeable unordered set containing the encountered hashes.
Definition: ParticleMCDecayStringModule.h:99
Belle2::ParticleMCDecayStringModule::getDecayString
std::string getDecayString(const Particle &p)
get the decay string for p.
Definition: ParticleMCDecayStringModule.cc:222
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::ParticleMCDecayStringModule::terminate
virtual void terminate() override
Terminate modules.
Definition: ParticleMCDecayStringModule.cc:169
Belle2::ParticleMCDecayStringModule::m_fileName
std::string m_fileName
Filename in which the hash strings are saved, if empty the strings are not saved.
Definition: ParticleMCDecayStringModule.h:92
Belle2::ParticleMCDecayStringModule::getInitialParticle
const MCParticle * getInitialParticle(const MCParticle *mcP)
search from mcP upwards for a particle that matches specified mother PDG codes.
Definition: ParticleMCDecayStringModule.cc:190
Belle2::ParticleMCDecayStringModule::convertToConciseString
void convertToConciseString(std::string &string)
Convert the extended string to a more concise format.
Definition: ParticleMCDecayStringModule.cc:307
Belle2::ParticleMCDecayStringModule::m_useConciseString
bool m_useConciseString
Switch to use concise format for the extended string.
Definition: ParticleMCDecayStringModule.h:108
Belle2::ParticleMCDecayStringModule::m_listName
std::string m_listName
Name of the particle list.
Definition: ParticleMCDecayStringModule.h:90
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::ParticleMCDecayStringModule::m_decayString
std::string m_decayString
The complete decay string.
Definition: ParticleMCDecayStringModule.h:106
Belle2::ParticleMCDecayStringModule::m_treeName
std::string m_treeName
Tree name in which the hash strings are saved.
Definition: ParticleMCDecayStringModule.h:93
Belle2::ParticleMCDecayStringModule::m_hasher
std::hash< std::string > m_hasher
Hash function.
Definition: ParticleMCDecayStringModule.h:111
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::ParticleMCDecayStringModule::buildMCDecayString
std::string buildMCDecayString(const MCParticle *mcPMother, const MCParticle *mcPMatched)
return decay string for mcPMother, highlight mcPMatched.
Definition: ParticleMCDecayStringModule.cc:285
Belle2::ParticleMCDecayStringModule::getMCDecayStringFromMCParticle
std::string getMCDecayStringFromMCParticle(const MCParticle *mcPMatched)
get mc decay string from mc particle
Definition: ParticleMCDecayStringModule.cc:268