9#include <analysis/DecayDescriptor/DecayDescriptor.h>
10#include <analysis/DecayDescriptor/ParticleListName.h>
11#include <analysis/dataobjects/ParticleList.h>
12#include <analysis/modules/ParticleMassHypothesesUpdater/ParticleMassHypothesesUpdaterModule.h>
13#include <analysis/utility/ParticleCopy.h>
14#include <framework/datastore/StoreObjPtr.h>
15#include <framework/gearbox/Const.h>
16#include <TDatabasePDG.h>
29 setDescription(
"This module updates the mass hypothesis of particleList to pdgCode. "
30 "The module creates a new particle list containing copies of the original particles, with updated mass hypotheses. "
31 "The newly created particle list is named after the input one plus the suffix ``_converted_from_`` and the old mass hypothesis, "
32 "e.g. ``e+:mylist`` to pdgCode = 13 becomes ``mu+:mylist_converted_from_e``. "
33 "The only supported mass hypotheses are electrons, muons, kaons, pions and protons (for both input and output lists).");
39 "If true, the output ParticleList will be saved by RootOutput. If false, it will be ignored when writing the file.",
false);
49 B2FATAL(
"ParticleMassHypothesesUpdaterModule::initialize Invalid input DecayString: " <<
m_particleList);
51 map<int, string> allowedPDGs = {
52 {11,
"e"}, {13,
"mu"}, {211,
"pi"}, {321,
"K"}, {2212,
"p"}
57 if (allowedPDGs.find(abs(pdgCode)) == allowedPDGs.end())
58 B2FATAL(
"ParticleMassHypothesesUpdaterModule::initialize Chosen particle list contains unsupported particles with PDG code " <<
61 B2FATAL(
"ParticleMassHypothesesUpdaterModule::initialize Chosen target PDG code " <<
m_newPdgCode <<
" not supported.");
64 string pName = mother->
getName();
85 if (originalList->getListSize() == 0)
91 B2FATAL(
"ParticleMassHypothesesUpdaterModule::initialize Invalid input DecayString: " <<
m_newParticleList);
98 B2WARNING(
"The new particle list already exists, and it should not. Did you call the module twice?");
107 B2ERROR(
"The particle list did not exist but the anti-list did. Something fishy is happening.");
111 newAntiList->bindAntiParticleList(*(newList));
113 for (
unsigned int i = 0; i < originalList->getListSize(); ++i) {
114 const Particle* originalParticle = originalList->getParticle(i);
115 if (originalParticle->getParticleSource() != Particle::c_Track) {
116 B2WARNING(
"Particle not built from a track. Skipping.");
123 if (TDatabasePDG::Instance()->GetParticle(
m_newPdgCode)->Charge() / 3.0 == charge)
128 newList->addParticle(newPart);
static const ChargedStable electron
electron particle
EStoreFlags
Flags describing behaviours of objects etc.
@ c_WriteOut
Object/array should be saved by output modules.
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Represents a particle in the DecayDescriptor.
int getPDGCode() const
Return PDG code.
std::string getName() const
evt.pdl name of the particle.
std::string getLabel() const
The label of this particle, "default" returned, when no label set.
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
const DecayDescriptorParticle * getMother() const
return mother.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
int m_newPdgCode
PDG code for mass reference.
virtual void initialize() override
Initialises the module.
virtual void event() override
Method called for each event.
virtual void terminate() override
Write TTree to file, and close file if necessary.
std::string m_newAntiParticleList
Name of the new created anti-list.
std::string m_particleList
Name of the list.
std::string m_newParticleList
Name of the new created list.
bool m_writeOut
Writeout flag.
ParticleMassHypothesesUpdaterModule()
Constructor.
Class to store reconstructed particles.
double getCharge(void) const
Returns particle charge.
void updateMass(const int pdgCode)
Updates particle mass with the mass of the particle corresponding to the given PDG.
void setPDGCode(const int pdg)
Sets PDG code.
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.
bool isValid() const
Check whether the object was created.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Particle * copyParticle(const Particle *original)
Function takes argument Particle and creates a copy of it and copies of all its (grand-)^n-daughters.
std::string antiParticleListName(const std::string &listName)
Returns name of anti-particle-list corresponding to listName.
Abstract base class for different kinds of events.