Belle II Software development
AllParticleCombinerModule.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/AllParticleCombiner/AllParticleCombinerModule.h>
10#include <analysis/DecayDescriptor/ParticleListName.h>
11
12#include <Math/Vector4D.h>
13
14using namespace Belle2;
15
16//-----------------------------------------------------------------
17// Register the Module
18//-----------------------------------------------------------------
19REG_MODULE(AllParticleCombiner);
20
21//-----------------------------------------------------------------
22// Implementation
23//-----------------------------------------------------------------
24
26{
27 // Set module properties
28 setDescription(R"DOC(This module combines all particles of the provided list to one mother particle.
29 )DOC");
30
31 // Parameter definitions
32 addParam("inputListNames", m_inputListNames, "List of ParticleLists which are supposed to be combined", std::vector<std::string>());
33 addParam("cut", m_cutString, "Selection criteria for the output ParticleList", std::string(""));
34 addParam("writeOut", m_writeOut,
35 "If true, the output ParticleList will be saved by RootOutput. If false, it will be ignored when writing the file.", false);
36 addParam("outputListName", m_outputListName,
37 "Name of the output list created by the combination of all particles in the input lists.", std::string(""));
38
39 // initializing the rest of private members
40 m_pdgCode = 0;
42}
43
45{
47
49 if (!valid)
50 B2ERROR("Invalid output ListName: " << m_outputListName);
51
52 // Mother particle
54
55 m_pdgCode = mother->getPDGCode();
58
60 m_outputList.registerInDataStore(m_outputListName, flags);
62 m_outputAntiList.registerInDataStore(m_antiListName, flags);
63 }
64
66}
67
69{
70 m_outputList.create();
72
74 m_outputAntiList.create();
75 m_outputAntiList->initialize(-1 * m_pdgCode, m_antiListName);
76
77 m_outputList->bindAntiParticleList(*(m_outputAntiList));
78 }
79
80 unsigned short nParticleLists = m_inputListNames.size();
81 if (nParticleLists == 0)
82 B2ERROR("No particle lists found for AllParticleCombinerModule.");
83
84 double px = 0;
85 double py = 0;
86 double pz = 0;
87 double E = 0;
88 std::vector<int> daughterIndices;
89
90 for (unsigned short iList = 0; iList < nParticleLists; ++iList) {
91
93 for (unsigned int i = 0; i < plist->getListSize(); ++i) {
94 bool addParticle = true;
95 Particle* particle = plist->getParticle(i, true);
96 for (auto* daughter : particle->getFinalStateDaughters()) {
97 int particleArrayIndex = daughter->getArrayIndex();
98 if (std::find(daughterIndices.begin(), daughterIndices.end(), particleArrayIndex) != daughterIndices.end()) {
99 addParticle = false;
100 break;
101 }
102 }
103 if (addParticle) {
104 for (auto* daughter : particle->getFinalStateDaughters()) {
105 int particleArrayIndex = daughter->getArrayIndex();
106 daughterIndices.push_back(particleArrayIndex);
107 }
108 px += particle->getPx();
109 py += particle->getPy();
110 pz += particle->getPz();
111 E += particle->getEnergy();
112 }
113 }
114 }
115
116 const ROOT::Math::PxPyPzEVector vec(px, py, pz, E);
117
119 daughterIndices, m_particles.getPtr());
120
121 Particle* newParticle = m_particles.appendNew(combinedParticle);
122 if (m_cut->check(newParticle)) {
123 m_outputList->addParticle(newParticle);
124 }
125}
R E
internal precision of FFTW codelets
bool m_isSelfConjugatedParticle
flag that indicates whether an anti-particle mother does not exist and should not be reconstructed as...
std::string m_antiListName
output anti-particle list name
virtual void initialize() override
Register input and output data.
virtual void event() override
process event
std::vector< std::string > m_inputListNames
List of ParticleLists which are supposed to be combined.
StoreObjPtr< ParticleList > m_outputAntiList
output anti-particle list
StoreArray< Particle > m_particles
StoreArray of Particle objects.
StoreObjPtr< ParticleList > m_outputList
output particle list
AllParticleCombinerModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::string m_cutString
Selection criteria.
std::unique_ptr< Variable::Cut > m_cut
cut object which performs the cuts
DecayDescriptor m_decaydescriptor
Decay descriptor of the decay being reconstructed.
bool m_writeOut
If true, the output ParticleList will be saved by RootOutput.
int m_pdgCode
PDG code of the combined mother particle.
std::string m_outputListName
Name of the output list created by the combination of all particles in the input list.
EStoreFlags
Flags describing behaviours of objects etc.
Definition: DataStore.h:69
@ c_WriteOut
Object/array should be saved by output modules.
Definition: DataStore.h:70
@ 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.
std::string getFullName() const
returns the full name of the particle full_name = name:label
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
const DecayDescriptorParticle * getMother() const
return mother.
static std::unique_ptr< GeneralCut > compile(const std::string &cut)
Creates an instance of a cut and returns a unique_ptr to it, if you need a copy-able object instead y...
Definition: GeneralCut.h:84
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
@ c_Unflavored
Is its own antiparticle or we don't know whether it is a particle/antiparticle.
Definition: Particle.h:95
@ c_Flavored
Is either particle or antiparticle.
Definition: Particle.h:96
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
TClonesArray * getPtr() const
Raw access to the underlying TClonesArray.
Definition: StoreArray.h:311
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
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.