Belle II Software  release-05-02-19
DecayDescriptor.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Christian Oswald, Yo Sato *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <analysis/DecayDescriptor/DecayString.h>
14 #include <analysis/DecayDescriptor/DecayDescriptorParticle.h>
15 #include <analysis/dataobjects/Particle.h>
16 
17 #include <vector>
18 #include <string>
19 
20 namespace Belle2 {
25  class MCParticle;
26  class Particle;
27 
35  class DecayDescriptor {
36  private:
38  DecayDescriptorParticle m_mother;
41  int m_iDaughter_p;
43  std::vector<DecayDescriptor> m_daughters;
45  int m_properties;
47  bool m_isNULL;
49  template <class T>
50  int match(const T* p, int iDaughter_p);
65  std::vector<std::vector<std::pair<int, std::string>>> m_hierarchy;
66 
68  bool m_isInitOK;
69 
70  public:
72  const static DecayDescriptor& s_NULL;
73 
75  operator DecayDescriptor* ()
76  {
77  return m_isNULL ? nullptr : this;
78  }
81 
83  DecayDescriptor(const DecayDescriptor&) = default;
84 
86  DecayDescriptor& operator=(const DecayDescriptor&) = default;
87 
89  std::vector<std::vector<std::pair<int, std::string>>> getHierarchyOfSelected();
90 
92  std::vector<std::vector<std::pair<int, std::string>>> getHierarchyOfSelected(const std::vector<std::pair<int, std::string>>&
93  currentPath);
94 
97  bool init(const std::string& str);
98 
102  bool init(const DecayString& s);
103 
110  int match(const Particle* p) {return match<Particle>(p, -1);}
111 
113  int match(const MCParticle* p) {return match<MCParticle>(p, -1);}
114 
116  int getMatchedDaughter() {return m_iDaughter_p;}
117 
119  void resetMatch();
120 
122  std::vector<const Particle*> getSelectionParticles(const Particle* particle);
126  std::vector<std::string> getSelectionNames();
128  const DecayDescriptorParticle* getMother() const
129  {
130  return &m_mother;
131  }
133  int getNDaughters() const
134  {
135  return m_daughters.size();
136  }
138  const DecayDescriptor* getDaughter(int i) const
139  {
140  return (i < getNDaughters()) ? &(m_daughters[i]) : NULL;
141  }
143  int getProperty() const
144  {
145  return m_properties;
146  }
148  bool isIgnoreRadiatedPhotons() const
149  {
150  return (m_properties & Particle::PropertyFlags::c_IsIgnoreRadiatedPhotons) > 0;
151  }
153  bool isIgnoreIntermediate() const
154  {
155  return (m_properties & Particle::PropertyFlags::c_IsIgnoreIntermediate) > 0;
156  }
158  bool isIgnoreMassive() const
159  {
160  return (m_properties & Particle::PropertyFlags::c_IsIgnoreMassive) > 0;
161  }
163  bool isIgnoreNeutrino() const
164  {
165  return (m_properties & Particle::PropertyFlags::c_IsIgnoreNeutrino) > 0;
166  }
168  bool isIgnoreGamma() const
169  {
170  return (m_properties & Particle::PropertyFlags::c_IsIgnoreGamma) > 0;
171  }
173  bool isIgnoreBrems() const
174  {
175  return (m_properties & Particle::PropertyFlags::c_IsIgnoreBrems) > 0;
176  }
177 
179  bool isSelfConjugated() const;
180 
182  bool isInitOK() const
183  {
184  return m_isInitOK;
185  }
186 
189  bool getSelectionParticlesAndNames(const Particle* particle,
190  std::vector<const Particle*>& selparticles,
191  std::vector<std::string>& selnames);
192  };
193 
195 }
196 
Belle2::DecayDescriptor::s_NULL
const static DecayDescriptor & s_NULL
Singleton object representing NULL.
Definition: DecayDescriptor.h:80
Belle2::DecayString
boost::variant< boost::recursive_wrapper< DecayStringDecay >, DecayStringParticle > DecayString
The DecayStringElement can be either a DecayStringDecay or a vector of mother particles.
Definition: DecayString.h:28
Belle2::DecayDescriptor::isIgnoreNeutrino
bool isIgnoreNeutrino() const
Check if missing neutrinos shall be ignored.
Definition: DecayDescriptor.h:171
Belle2::DecayDescriptor::isIgnoreGamma
bool isIgnoreGamma() const
Check if missing gammas shall be ignored.
Definition: DecayDescriptor.h:176
Belle2::DecayDescriptor::operator=
DecayDescriptor & operator=(const DecayDescriptor &)=default
Want the default assignment operator.
Belle2::DecayDescriptor::getSelectionNames
std::vector< std::string > getSelectionNames()
Return list of human readable names of selected particles.
Definition: DecayDescriptor.cc:343
Belle2::DecayDescriptor::m_daughters
std::vector< DecayDescriptor > m_daughters
Direct daughters of the decaying particle.
Definition: DecayDescriptor.h:51
Belle2::DecayDescriptor::init
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
Definition: DecayDescriptor.cc:47
Belle2::DecayDescriptor::match
int match(const T *p, int iDaughter_p)
Internally called by match(Particle*) and match(MCParticle*) function.
Definition: DecayDescriptor.cc:137
Belle2::DecayDescriptor::getMatchedDaughter
int getMatchedDaughter()
Particle daughter ID set by previous call of match(const Particle*) function.
Definition: DecayDescriptor.h:124
Belle2::DecayDescriptor::isInitOK
bool isInitOK() const
Check if the object initialized correctly.
Definition: DecayDescriptor.h:190
Belle2::DecayDescriptor::getSelectionParticlesAndNames
bool getSelectionParticlesAndNames(const Particle *particle, std::vector< const Particle * > &selparticles, std::vector< std::string > &selnames)
Takes as input argument a (reconstructed) Particle, tries to match with this DecayDescriptorElement a...
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DecayDescriptor::getSelectionParticles
std::vector< const Particle * > getSelectionParticles(const Particle *particle)
Get a vector of pointers with selected daughters in the decay tree.
Definition: DecayDescriptor.cc:284
Belle2::DecayDescriptor::DecayDescriptor
DecayDescriptor()
Default ctor.
Definition: DecayDescriptor.cc:37
Belle2::DecayDescriptor::getDaughter
const DecayDescriptor * getDaughter(int i) const
return i-th daughter (0 based index).
Definition: DecayDescriptor.h:146
Belle2::DecayDescriptor::m_hierarchy
std::vector< std::vector< std::pair< int, std::string > > > m_hierarchy
Collection of hierarchy pathes of selected particles.
Definition: DecayDescriptor.h:73
Belle2::DecayDescriptor::getNDaughters
int getNDaughters() const
return number of direct daughters.
Definition: DecayDescriptor.h:141
Belle2::DecayDescriptor::isIgnoreBrems
bool isIgnoreBrems() const
Check if added Brems gammas shall be ignored.
Definition: DecayDescriptor.h:181
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::DecayDescriptor::isIgnoreIntermediate
bool isIgnoreIntermediate() const
Check if intermediate resonances/particles shall be ignored.
Definition: DecayDescriptor.h:161
Belle2::DecayDescriptor::m_isInitOK
bool m_isInitOK
Is this object initialized correctly?
Definition: DecayDescriptor.h:76
Belle2::DecayDescriptor
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
Definition: DecayDescriptor.h:43
Belle2::DecayDescriptor::getProperty
int getProperty() const
return property of the particle.
Definition: DecayDescriptor.h:151
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::DecayDescriptor::isIgnoreRadiatedPhotons
bool isIgnoreRadiatedPhotons() const
Check if additional radiated photons shall be ignored.
Definition: DecayDescriptor.h:156
Belle2::DecayDescriptor::resetMatch
void resetMatch()
Reset results from previous call of the match() function.
Definition: DecayDescriptor.cc:277
Belle2::DecayDescriptor::isIgnoreMassive
bool isIgnoreMassive() const
Check if missing massive final state particles shall be ignored.
Definition: DecayDescriptor.h:166
Belle2::DecayDescriptor::m_mother
DecayDescriptorParticle m_mother
Mother of the decay ('left side').
Definition: DecayDescriptor.h:46
Belle2::DecayDescriptor::m_iDaughter_p
int m_iDaughter_p
ID of the Daughter Particle* matched to this DecayDescriptor.
Definition: DecayDescriptor.h:49
Belle2::DecayDescriptor::getMother
const DecayDescriptorParticle * getMother() const
return mother.
Definition: DecayDescriptor.h:136
Belle2::DecayDescriptor::isSelfConjugated
bool isSelfConjugated() const
Is the decay or the particle self conjugated.
Definition: DecayDescriptor.cc:325
Belle2::DecayDescriptor::getHierarchyOfSelected
std::vector< std::vector< std::pair< int, std::string > > > getHierarchyOfSelected()
Function to get hierarchy of selected particles and their names (for python use)
Definition: DecayDescriptor.cc:394
Belle2::DecayDescriptor::m_properties
int m_properties
Particle property.
Definition: DecayDescriptor.h:53
Belle2::DecayDescriptor::m_isNULL
bool m_isNULL
Is this the NULL object?
Definition: DecayDescriptor.h:55