Belle II Software  release-05-01-25
MCMatching.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * *
4  * Copyright(C) 2013-2018 - Belle II Collaboration *
5  * *
6  * Author: The Belle II Collaboration *
7  * Contributors: Anze Zupanc, Christian Pulvermacher, Yo Sato *
8  * *
9  * This software is provided "as is" without any warranty. *
10  **************************************************************************/
11 
12 #pragma once
13 
14 #include <vector>
15 #include <string>
16 
17 namespace Belle2 {
22  class Particle;
23  class MCParticle;
24 
31  struct MCMatching {
33  static const std::string c_extraInfoMCErrors;
34 
36  enum MCErrorFlags {
37  c_Correct = 0,
38  c_MissFSR = 1,
39  c_MissingResonance = 2,
41  c_MissNeutrino = 8,
42  c_MissGamma = 16,
44  c_MissKlong = 64,
45  c_MisID = 128,
48  c_MissPHOTOS = 1024,
50  };
51 
62  static std::string explainFlags(unsigned int flags);
63 
75  static bool setMCTruth(const Belle2::Particle* particle);
76 
92  static int getMCErrors(const Belle2::Particle* particle, const Belle2::MCParticle* mcParticle = nullptr);
93 
94 
99  static int setMCErrorsExtraInfo(Belle2::Particle* particle, const Belle2::MCParticle* mcParticle);
100 
107  static void fillGenMothers(const Belle2::MCParticle* mcP, std::vector<int>& genMCPMothers);
108 
122  static int findCommonMother(const Belle2::MCParticle* mcP, const std::vector<int>& firstMothers, int lastMother);
123 
127  static bool isFSP(int pdg);
128 
133  static bool isFSR(const Belle2::MCParticle* p);
134 
140  static bool isFSRLegacy(const Belle2::MCParticle* p);
141 
146  static bool isRadiativePhoton(const Belle2::MCParticle* p);
147 
154  static int getMissingParticleFlags(const Belle2::Particle* particle, const Belle2::MCParticle* mcParticle);
155 
163  static int getFlagsOfFSP(const Particle* particle, const MCParticle* mcParticle);
164 
172  static int getFlagsOfDaughters(const Particle* daughter, const MCParticle* mcParticle);
173 
182  static int getFlagsOfBremsPhotonDaughter(const Particle* daughter, const MCParticle* mcParticle,
183  const std::vector<const MCParticle*>& genParts);
184 
191  static int getNumberOfDaughtersWithoutNeutrinos(const MCParticle* mcParticle);
192 
197  static int countMissingParticle(const Belle2::Particle* particle, const Belle2::MCParticle* mcParticle,
198  const std::vector<int>& daughterPDG);
199 
205  static int getFlagsIgnoredByProperty(const Belle2::Particle* particle);
206 
211  static int makeDaughterAcceptMask(int daughterProperty);
212 
213  };
215 }
Belle2::MCMatching::setMCErrorsExtraInfo
static int setMCErrorsExtraInfo(Belle2::Particle *particle, const Belle2::MCParticle *mcParticle)
Sets error flags in extra-info (also returns it).
Definition: MCMatching.cc:293
Belle2::MCMatching::countMissingParticle
static int countMissingParticle(const Belle2::Particle *particle, const Belle2::MCParticle *mcParticle, const std::vector< int > &daughterPDG)
Count the number of missing daughters of the 'particle'.
Definition: MCMatching.cc:561
Belle2::MCMatching::getFlagsOfDaughters
static int getFlagsOfDaughters(const Particle *daughter, const MCParticle *mcParticle)
Returns flags of daughters of given particle.
Definition: MCMatching.cc:371
Belle2::MCMatching::isFSP
static bool isFSP(int pdg)
Returns true if given PDG code indicates a FSP.
Definition: MCMatching.cc:448
Belle2::MCMatching::findCommonMother
static int findCommonMother(const Belle2::MCParticle *mcP, const std::vector< int > &firstMothers, int lastMother)
Finds a mother of mcP that is in firstMothers, from [lastMother, end].
Definition: MCMatching.cc:73
Belle2::MCMatching::getFlagsOfBremsPhotonDaughter
static int getFlagsOfBremsPhotonDaughter(const Particle *daughter, const MCParticle *mcParticle, const std::vector< const MCParticle * > &genParts)
Returns flags of given daughter which is a brems photon.
Definition: MCMatching.cc:409
Belle2::MCMatching::isFSR
static bool isFSR(const Belle2::MCParticle *p)
Returns true if given MCParticle is a final state radiation (FSR) photon based on MCParticle::c_IsFSR...
Definition: MCMatching.cc:469
Belle2::MCMatching::c_AddedWrongParticle
@ c_AddedWrongParticle
A non-FSP Particle has wrong PDG code, meaning one of the daughters (or their daughters) belongs to a...
Definition: MCMatching.h:55
Belle2::MCMatching::c_extraInfoMCErrors
static const std::string c_extraInfoMCErrors
Name of extra-info field stored in Particle.
Definition: MCMatching.h:42
Belle2::MCMatching::c_InternalError
@ c_InternalError
There was an error in MC matching.
Definition: MCMatching.h:56
Belle2::MCMatching::c_DecayInFlight
@ c_DecayInFlight
A Particle was reconstructed from the secondary decay product of the actual particle.
Definition: MCMatching.h:49
Belle2::MCMatching::fillGenMothers
static void fillGenMothers(const Belle2::MCParticle *mcP, std::vector< int > &genMCPMothers)
Fills vector with array (1-based) indices of all generator ancestors of given MCParticle.
Definition: MCMatching.cc:64
Belle2::MCMatching::isRadiativePhoton
static bool isRadiativePhoton(const Belle2::MCParticle *p)
Returns true if given MCParticle is a radiative photon.
Definition: MCMatching.cc:495
Belle2::MCMatching::c_MissingResonance
@ c_MissingResonance
The associated MCParticle decay contained additional non-final-state particles (e....
Definition: MCMatching.h:48
Belle2::MCMatching::getFlagsIgnoredByProperty
static int getFlagsIgnoredByProperty(const Belle2::Particle *particle)
Returns the flags ignored by PropertyFlags of given particle.
Definition: MCMatching.cc:588
Belle2::MCMatching::explainFlags
static std::string explainFlags(unsigned int flags)
Return string with all human-readable flags, e.g.
Definition: MCMatching.cc:29
Belle2::MCMatching::c_MissPHOTOS
@ c_MissPHOTOS
A photon created by PHOTOS was not reconstructed (based on MCParticle::c_IsPHOTOSPhoton)
Definition: MCMatching.h:57
Belle2::MCMatching::c_MissNeutrino
@ c_MissNeutrino
A neutrino is missing (not reconstructed).
Definition: MCMatching.h:50
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::MCMatching::c_MissFSR
@ c_MissFSR
A Final State Radiation (FSR) photon is not reconstructed (based on MCParticle::c_IsFSRPhoton).
Definition: MCMatching.h:47
Belle2::MCMatching::isFSRLegacy
static bool isFSRLegacy(const Belle2::MCParticle *p)
Returns true if given MCParticle is a final state radiation (FSR) photon.
Definition: MCMatching.cc:474
Belle2::MCMatching::c_MissMassiveParticle
@ c_MissMassiveParticle
A generated massive FSP is missing (not reconstructed).
Definition: MCMatching.h:52
Belle2::MCMatching::MCErrorFlags
MCErrorFlags
Flags that describe different reconstruction errors.
Definition: MCMatching.h:45
Belle2::MCMatching::getMissingParticleFlags
static int getMissingParticleFlags(const Belle2::Particle *particle, const Belle2::MCParticle *mcParticle)
Determines which daughters of 'mcParticle' are not reconstructed by any daughter of 'particle'.
Definition: MCMatching.cc:502
Belle2::MCMatching::c_MissGamma
@ c_MissGamma
A photon (not FSR) is missing (not reconstructed).
Definition: MCMatching.h:51
Belle2::MCMatching::c_MisID
@ c_MisID
One of the charged final state particles is mis-identified.
Definition: MCMatching.h:54
Belle2::MCMatching::c_MissKlong
@ c_MissKlong
A Klong is missing (not reconstructed).
Definition: MCMatching.h:53
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::MCMatching::getFlagsOfFSP
static int getFlagsOfFSP(const Particle *particle, const MCParticle *mcParticle)
Returns flags of given Final State Particle.
Definition: MCMatching.cc:343
Belle2::MCMatching::setMCTruth
static bool setMCTruth(const Belle2::Particle *particle)
This is the main function of MC matching algorithm.
Definition: MCMatching.cc:89
Belle2::MCMatching::c_AddedRecoBremsPhoton
@ c_AddedRecoBremsPhoton
A photon added with the bremsstrahlung recovery tools (correctBrems or correctBremsBelle) has no MC p...
Definition: MCMatching.h:58
Belle2::MCMatching::getMCErrors
static int getMCErrors(const Belle2::Particle *particle, const Belle2::MCParticle *mcParticle=nullptr)
Returns quality indicator of the match as a bit pattern where the individual bits indicate the the ty...
Definition: MCMatching.cc:282
Belle2::MCMatching::getNumberOfDaughtersWithoutNeutrinos
static int getNumberOfDaughtersWithoutNeutrinos(const MCParticle *mcParticle)
Determines the number of daughter particles which are not neutrinos.
Definition: MCMatching.cc:435
Belle2::MCMatching::makeDaughterAcceptMask
static int makeDaughterAcceptMask(int daughterProperty)
Returns the daughter mask from given daughterProperty.
Definition: MCMatching.cc:597
Belle2::MCMatching::c_Correct
@ c_Correct
This Particle and all its daughters are perfectly reconstructed.
Definition: MCMatching.h:46