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.");
42
43 // Parameter definitions
44 addParam("particleListName", m_particleListName,
45 "Name of the ParticleList to be created and filled with signal side daughter Particle", std::string(""));
46 addParam("decayString", m_decayString, "DecayString specifying the daughter Particle to be included in the ParticleList",
47 std::string(""));
48
49}
50
52{
53 m_pdgCode = 0;
54
55 // check the validity of output ParticleList name
57 if (!valid)
58 B2ERROR("SignalSideParticleListCreatorModule::initialize Invalid output ParticleList name: " << m_particleListName);
59
60 // Output particle
62
63 m_pdgCode = mother->getPDGCode();
64
67
69 particleList.registerInDataStore(DataStore::c_DontWriteOut);
73 }
74
75 // check the decay descriptor
77 if (!valid)
78 B2ERROR("SignalSideParticleListCreatorModule::initialize Invalid Decay Descriptor: " << m_decayString);
79
80 std::vector<std::string> strNames = m_pDDescriptor.getSelectionNames();
81 int nDecayProducts = strNames.size();
82 if (nDecayProducts != 1)
83 B2ERROR("SignalSideParticleListCreatorModule::initialize Only one particle can be selected. The specified decayString " <<
84 m_decayString << " has " << nDecayProducts);
85
86}
87
89{
91 bool existingList = plist.isValid();
92
93 if (!existingList) {
94 // new particle list: create it
95 plist.create();
96 plist->initialize(m_pdgCode, m_particleListName);
97
100 antiPlist.create();
101 antiPlist->initialize(-1 * m_pdgCode, m_antiParticleListName);
102
103 antiPlist->bindAntiParticleList(*(plist));
104 }
105 }
106
107 StoreObjPtr<RestOfEvent> roe("RestOfEvent");
108 if (roe.isValid()) {
109 const Particle* particle = roe->getRelatedFrom<Particle>();
110 if (particle) {
111 std::vector<const Particle*> selparticles = m_pDDescriptor.getSelectionParticles(particle);
112
113 if (selparticles[0])
114 plist->addParticle(selparticles[0]);
115 }
116 }
117
118}
119
120
@ 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
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ 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
Class to store reconstructed particles.
Definition: Particle.h:76
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:95
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:110
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
std::string antiParticleListName(const std::string &listName)
Returns name of anti-particle-list corresponding to listName.
Abstract base class for different kinds of events.