Belle II Software development
SignalSideParticleListCreatorModule.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
9#include <analysis/modules/SignalSideParticleListCreator/SignalSideParticleListCreatorModule.h>
10
11// framework - DataStore
12#include <framework/datastore/DataStore.h>
13#include <framework/datastore/StoreObjPtr.h>
14
15// framework aux
16#include <framework/logging/Logger.h>
17
18// dataobjects
19#include <analysis/dataobjects/Particle.h>
20#include <analysis/dataobjects/ParticleList.h>
21#include <analysis/dataobjects/RestOfEvent.h>
22
23// utilities
24#include <analysis/DecayDescriptor/ParticleListName.h>
25
26using namespace Belle2;
27
28//-----------------------------------------------------------------
29// Register the Module
30//-----------------------------------------------------------------
31REG_MODULE(SignalSideParticleListCreator);
32
33//-----------------------------------------------------------------
34// Implementation
35//-----------------------------------------------------------------
36
38{
39 // Set module properties
40 setDescription("The module creates a ParticleList and fills it with one of the daughter Particles.");
41
42 // Parameter definitions
43 addParam("particleListName", m_particleListName,
44 "Name of the ParticleList to be created and filled with signal side daughter Particle", std::string(""));
45 addParam("decayString", m_decayString, "DecayString specifying the daughter Particle to be included in the ParticleList",
46 std::string(""));
47
48}
49
51{
52 m_pdgCode = 0;
53
54 // check the validity of output ParticleList name
56 if (!valid)
57 B2ERROR("SignalSideParticleListCreatorModule::initialize Invalid output ParticleList name: " << m_particleListName);
58
59 // Output particle
61
62 m_pdgCode = mother->getPDGCode();
63
66
68 particleList.registerInDataStore(DataStore::c_DontWriteOut);
72 }
73
74 // check the decay descriptor
76 if (!valid)
77 B2ERROR("SignalSideParticleListCreatorModule::initialize Invalid Decay Descriptor: " << m_decayString);
78
79 std::vector<std::string> strNames = m_pDDescriptor.getSelectionNames();
80 int nDecayProducts = strNames.size();
81 if (nDecayProducts != 1)
82 B2ERROR("SignalSideParticleListCreatorModule::initialize Only one particle can be selected. The specified decayString " <<
83 m_decayString << " has " << nDecayProducts);
84
85}
86
88{
90 bool existingList = plist.isValid();
91
92 if (!existingList) {
93 // new particle list: create it
94 plist.create();
95 plist->initialize(m_pdgCode, m_particleListName);
96
99 antiPlist.create();
100 antiPlist->initialize(-1 * m_pdgCode, m_antiParticleListName);
101
102 antiPlist->bindAntiParticleList(*(plist));
103 }
104 }
105
106 StoreObjPtr<RestOfEvent> roe("RestOfEvent");
107 if (roe.isValid()) {
108 const Particle* particle = roe->getRelatedFrom<Particle>();
109 if (particle) {
110 std::vector<const Particle*> selparticles = m_pDDescriptor.getSelectionParticles(particle);
111
112 if (selparticles[0])
113 plist->addParticle(selparticles[0]);
114 }
115 }
116
117}
118
119
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:71
Represents a particle in the DecayDescriptor.
int getPDGCode() const
Return PDG code.
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
std::vector< std::string > getSelectionNames()
Return list of human readable names of selected particles.
std::vector< const Particle * > getSelectionParticles(const Particle *particle)
Get a vector of pointers with selected daughters in the decay tree.
const DecayDescriptorParticle * getMother() const
return mother.
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
Class to store reconstructed particles.
Definition: Particle.h:75
bool m_isSelfConjugatedParticle
flag that indicates whether an anti-particle does not exist and therefore the output anti-ParticleLis...
SignalSideParticleListCreatorModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::string m_particleListName
Name of the ParticleList to be created and filled with signal side daughter Particle.
std::string m_antiParticleListName
Name of the anti-ParticleList to be created and filled with signal side daughter Particle.
DecayDescriptor m_pListDDescriptor
Decay descriptor of the particle list being selected.
std::string m_decayString
DecayString specifying the daughter Particle to be included in the ParticleList.
DecayDescriptor m_pDDescriptor
Decay descriptor of the particle being selected.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool create(bool replace=false)
Create a default object in the data store.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:111
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:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
std::string antiParticleListName(const std::string &listName)
Returns name of anti-particle-list corresponding to listName.
Abstract base class for different kinds of events.