Belle II Software development
MCV0MatcherModule.cc
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#include <tracking/modules/mcMatcher/MCV0MatcherModule.h>
9
10#include <framework/gearbox/Const.h>
11#include <framework/gearbox/Unit.h>
12#include <framework/logging/Logger.h>
13#include <mdst/dataobjects/TrackFitResult.h>
14
15using namespace Belle2;
16
17REG_MODULE(MCV0Matcher);
18
20{
21 setDescription("A module matching the V0s found by the V0Finder with MCParticles");
23
24 //input
25 addParam("TrackColName", m_TrackColName,
26 "Belle2::Track collection name (input). Note that the V0s use "
27 "pointers indices into these arrays, so all hell may break loose "
28 "if you change this.", std::string(""));
29 addParam("TFRColName", m_TFRColName,
30 "Belle2::TrackFitResult collection name (input). Note that the V0s "
31 "use pointers indices into these arrays, so all hell may break loose "
32 "if you change this.", std::string(""));
33 addParam("V0ColName", m_V0ColName, "V0 collection name (input)", std::string(""));
34 addParam("MCParticleColName", m_MCParticleColName, "MCParticle collection name (input)", std::string(""));
35}
36
37
41
42
44{
45 m_V0s.isRequired(m_V0ColName);
47
48 m_V0s.registerRelationTo(m_MCParticles);
49 B2WARNING("This module is supposed to be used only for the debugging\n \
50 of the V0Finder module, not as MC matching during analysis.");
51}
52
53
54
56{
57 B2DEBUG(20, (m_V0s.getEntries() != 0 ? "V0s has entries." : " No V0s."));
58
59 for (const auto& v0 : m_V0s) {
60 // Try to match the tracks of each V0 with the MC V0.
61 const Const::ParticleType v0hypothesis = v0.getV0Hypothesis();
62 const std::pair<Track*, Track*> trackPtrs = v0.getTracks();
63
64 const MCParticle* mcV0PartPlus = trackPtrs.first->getRelatedTo<MCParticle>(m_MCParticleColName);
65 const MCParticle* mcV0PartMinus = trackPtrs.second->getRelatedTo<MCParticle>(m_MCParticleColName);
66
67 if (mcV0PartPlus == nullptr or mcV0PartMinus == nullptr) {
68 B2DEBUG(20, "At least one track of the V0 does not have a MC related particle. It will be skipped for matching.");
69 continue;
70 }
71
72 const MCParticle* mcV0PartPlusMother = mcV0PartPlus->getMother();
73 const MCParticle* mcV0PartMinusMother = mcV0PartMinus->getMother();
74
75 if (!mcV0PartPlus->getMother() or !mcV0PartMinusMother) {
76 B2DEBUG(20, "At least one track of the V0 does not have a mother MCParticle, skipping.");
77 continue;
78 }
79
80 if (mcV0PartPlusMother != mcV0PartMinusMother) {
81 B2DEBUG(20, "The V0 is most likely built up from combinatoric background, thus no MC relation can be set.");
82 continue;
83 }
84
85 if (Const::ParticleType(mcV0PartPlusMother->getPDG()) == v0hypothesis) {
86 B2DEBUG(20, "V0 successfully matched.");
87 v0.addRelationTo(mcV0PartPlusMother);
88 } else {
89 B2DEBUG(20, "V0 did not match anything.");
90 }
91 }
92
93 B2DEBUG(20, "MC matching finished.");
94}
95
96
The ParticleType class for identifying different particle types.
Definition Const.h:409
A Class to store the Monte Carlo particle information.
Definition MCParticle.h:32
int getPDG() const
Return PDG code of particle.
Definition MCParticle.h:101
std::string m_TFRColName
Belle2::TrackFitResult collection name (input).
void initialize() override
Use this to initialize resources or memory your module needs.
void event() override
Called once for each event.
StoreArray< V0 > m_V0s
V0s StoreArray.
std::string m_TrackColName
Belle2::Track collection name (input).
~MCV0MatcherModule() override
Destructor (empty).
MCV0MatcherModule()
Constructor, for setting module description and parameters.
std::string m_MCParticleColName
MCParticle collection name (input).
StoreArray< MCParticle > m_MCParticles
MCParticles StoreArray.
std::string m_V0ColName
V0 collection name (input).
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
Module()
Constructor.
Definition Module.cc:30
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
MCParticle * getMother() const
Returns a pointer to the mother particle.
Definition MCParticle.h:591
Abstract base class for different kinds of events.