Belle II Software  release-05-02-19
SignalSideParticleListCreatorModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Anze Zupanc *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <analysis/modules/SignalSideParticleListCreator/SignalSideParticleListCreatorModule.h>
12 
13 // framework - DataStore
14 #include <framework/datastore/DataStore.h>
15 #include <framework/datastore/StoreObjPtr.h>
16 
17 // framework aux
18 #include <framework/logging/Logger.h>
19 
20 // dataobjects
21 #include <analysis/dataobjects/Particle.h>
22 #include <analysis/dataobjects/ParticleList.h>
23 #include <analysis/dataobjects/RestOfEvent.h>
24 
25 // utilities
26 #include <analysis/DecayDescriptor/ParticleListName.h>
27 
28 using namespace Belle2;
29 
30 //-----------------------------------------------------------------
31 // Register the Module
32 //-----------------------------------------------------------------
33 REG_MODULE(SignalSideParticleListCreator)
34 
35 //-----------------------------------------------------------------
36 // Implementation
37 //-----------------------------------------------------------------
38 
40 {
41  // Set module properties
42  setDescription("The module creates a ParticleList and fills it with one of the daughter Particles.");
43 
44  // Parameter definitions
45  addParam("particleListName", m_particleListName,
46  "Name of the ParticleList to be created and filled with signal side daughter Particle", std::string(""));
47  addParam("decayString", m_decayString, "DecayString specifying the daughter Particle to be included in the ParticleList",
48  std::string(""));
49 
50 }
51 
53 {
54  m_pdgCode = 0;
55 
56  // check the validity of output ParticleList name
58  if (!valid)
59  B2ERROR("SignalSideParticleListCreatorModule::initialize Invalid output ParticleList name: " << m_particleListName);
60 
61  // Output particle
63 
64  m_pdgCode = mother->getPDGCode();
65 
68 
70  particleList.registerInDataStore(DataStore::c_DontWriteOut);
73  antiParticleList.registerInDataStore(m_antiParticleListName);
74  }
75 
76  // check the decay descriptor
78  if (!valid)
79  B2ERROR("SignalSideParticleListCreatorModule::initialize Invalid Decay Descriptor: " << m_decayString);
80 
81  std::vector<std::string> strNames = m_pDDescriptor.getSelectionNames();
82  int nDecayProducts = strNames.size();
83  if (nDecayProducts != 1)
84  B2ERROR("SignalSideParticleListCreatorModule::initialize Only one particle can be selected. The specified decayString " <<
85  m_decayString << " has " << nDecayProducts);
86 
87 }
88 
90 {
92  bool existingList = plist.isValid();
93 
94  if (!existingList) {
95  // new particle list: create it
96  plist.create();
97  plist->initialize(m_pdgCode, m_particleListName);
98 
101  antiPlist.create();
102  antiPlist->initialize(-1 * m_pdgCode, m_antiParticleListName);
103 
104  antiPlist->bindAntiParticleList(*(plist));
105  }
106  }
107 
108  StoreObjPtr<RestOfEvent> roe("RestOfEvent");
109  if (roe.isValid()) {
110  const Particle* particle = roe->getRelated<Particle>();
111  if (particle) {
112  std::vector<const Particle*> selparticles = m_pDDescriptor.getSelectionParticles(particle);
113 
114  if (selparticles[0])
115  plist->addParticle(selparticles[0]);
116  }
117  }
118 
119 }
120 
121 
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::SignalSideParticleListCreatorModule::m_decayString
std::string m_decayString
DecayString specifying the daughter Particle to be included in the ParticleList.
Definition: SignalSideParticleListCreatorModule.h:72
Belle2::SignalSideParticleListCreatorModule::m_antiParticleListName
std::string m_antiParticleListName
Name of the anti-ParticleList to be created and filled with signal side daughter Particle.
Definition: SignalSideParticleListCreatorModule.h:71
Belle2::DecayDescriptorParticle
Represents a particle in the DecayDescriptor.
Definition: DecayDescriptorParticle.h:37
Belle2::DataStore::c_DontWriteOut
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:73
Belle2::DecayDescriptor::getSelectionNames
std::vector< std::string > getSelectionNames()
Return list of human readable names of selected particles.
Definition: DecayDescriptor.cc:343
Belle2::DecayDescriptor::init
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
Definition: DecayDescriptor.cc:47
Belle2::ParticleListName::antiParticleListName
std::string antiParticleListName(const std::string &listName)
Returns name of anti-particle-list corresponding to listName.
Definition: ParticleListName.cc:10
Belle2::SignalSideParticleListCreatorModule::initialize
virtual void initialize() override
initialize method
Definition: SignalSideParticleListCreatorModule.cc:52
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::SignalSideParticleListCreatorModule::m_pDDescriptor
DecayDescriptor m_pDDescriptor
Decay descriptor of the particle being selected.
Definition: SignalSideParticleListCreatorModule.h:77
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::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::SignalSideParticleListCreatorModule::m_isSelfConjugatedParticle
bool m_isSelfConjugatedParticle
flag that indicates whether an anti-particle does not exist and therefore the output anti-ParticleLis...
Definition: SignalSideParticleListCreatorModule.h:79
Belle2::SignalSideParticleListCreatorModule::event
virtual void event() override
event method
Definition: SignalSideParticleListCreatorModule.cc:89
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::SignalSideParticleListCreatorModule::m_pListDDescriptor
DecayDescriptor m_pListDDescriptor
Decay descriptor of the particle list being selected.
Definition: SignalSideParticleListCreatorModule.h:76
Belle2::DecayDescriptor::getMother
const DecayDescriptorParticle * getMother() const
return mother.
Definition: DecayDescriptor.h:136
Belle2::SignalSideParticleListCreatorModule::m_pdgCode
int m_pdgCode
PDG code of the selected particle.
Definition: SignalSideParticleListCreatorModule.h:74
Belle2::SignalSideParticleListCreatorModule
The module creates a ParticleList and fills it with one of the daughter Particles.
Definition: SignalSideParticleListCreatorModule.h:51
Belle2::SignalSideParticleListCreatorModule::m_particleListName
std::string m_particleListName
Name of the ParticleList to be created and filled with signal side daughter Particle.
Definition: SignalSideParticleListCreatorModule.h:69
Belle2::StoreObjPtr::isValid
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:120