9#include <analysis/modules/RestOfEventUpdater/RestOfEventUpdaterModule.h>
11#include <framework/datastore/StoreArray.h>
12#include <framework/datastore/StoreObjPtr.h>
14#include <framework/logging/Logger.h>
34 setDescription(
"Updates an existing mask (map of boolean values) for tracks or eclClusters in RestOfEvent with an available property (e.g. after performing training).");
38 std::vector<std::string> emptyMaskVector;
39 std::string emptyCutString;
41 addParam(
"particleList",
m_inputListName,
"Name of the ParticleList which contains information that will be used for updating");
43 addParam(
"cutString",
m_selection,
"Cut string which will be used for updating masks", emptyCutString);
45 "Update the ROE mask by passing or discarding particles in the provided particle list, default is to pass",
false);
55 B2INFO(
"RestOfEventUpdater updated track/eclCluster ROEMask(s) with infoList: " <<
m_inputListName <<
" and cut: " <<
m_selection);
61 B2WARNING(
"Input list " <<
m_inputList.getName() <<
" was not created?");
66 B2WARNING(
"ROE list is not valid somehow, ROE masks are not updated!");
69 std::set<Particle::EParticleSourceObject> encounteredSources;
73 std::vector<const Particle*> particlesFromTracksToUpdate;
74 std::vector<const Particle*> particlesFromECLClustersToUpdate;
75 std::vector<const Particle*> particlesFromKLMClustersToUpdate;
76 std::vector<const Particle*> compositeParticlesToUpdate;
77 for (
unsigned j = 0; j <
m_inputList->getListSize(); j++) {
80 encounteredSources.insert(mdstSource);
81 if (
m_cut->check(partWithInfo)) {
82 if (mdstSource == Particle::EParticleSourceObject::c_Track) {
83 particlesFromTracksToUpdate.push_back(partWithInfo);
84 }
else if (mdstSource == Particle::EParticleSourceObject::c_ECLCluster) {
85 particlesFromECLClustersToUpdate.push_back(partWithInfo);
86 }
else if (mdstSource == Particle::EParticleSourceObject::c_KLMCluster) {
87 particlesFromKLMClustersToUpdate.push_back(partWithInfo);
88 }
else if (mdstSource == Particle::EParticleSourceObject::c_Composite or
89 mdstSource == Particle::EParticleSourceObject::c_V0) {
90 compositeParticlesToUpdate.push_back(partWithInfo);
94 if (encounteredSources.count(Particle::EParticleSourceObject::c_Track) > 0) {
97 if (encounteredSources.count(Particle::EParticleSourceObject::c_ECLCluster) > 0) {
100 if (encounteredSources.count(Particle::EParticleSourceObject::c_KLMCluster) > 0) {
108 const std::vector<const Particle*>& particlesToUpdate)
110 if (particlesToUpdate.size() == 0) {
111 B2DEBUG(10,
"No particles in list provided, nothing to do");
115 if (maskToUpdate ==
"") {
116 B2FATAL(
"Cannot update ROE mask with no name!");
118 for (
auto* particleV0 : particlesToUpdate) {
119 if (!roe->checkCompatibilityOfMaskAndV0(maskToUpdate, particleV0)) {
122 roe->updateMaskWithV0(maskToUpdate, particleV0);
131 if (maskToUpdate ==
"") {
132 B2FATAL(
"Cannot update ROE mask with no name!");
134 if (!roe->hasMask(maskToUpdate)) {
136 roe->initializeMask(maskToUpdate,
"ROEUpdaterModule");
138 roe->excludeParticlesFromMask(maskToUpdate, particlesToUpdate, listType,
m_discard);
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...
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...
Class to store reconstructed particles.
EParticleSourceObject
particle source enumerators
EParticleSourceObject getParticleSource() const
Returns particle source as defined with enum EParticleSourceObject.
std::string m_selection
Cut string which will be used for updating masks.
virtual void initialize() override
Overridden initialize method.
virtual void event() override
Overridden event method.
std::shared_ptr< Variable::Cut > m_cut
Cut object which performs the cuts.
std::vector< std::string > m_maskNamesForUpdating
Container for all mask names which will be updated.
StoreObjPtr< ParticleList > m_inputList
ParticleList which contains information that will be used for updating.
void updateMasksWithParticles(const StoreObjPtr< RestOfEvent > &roe, std::vector< const Particle * > &particlesToUpdate, Particle::EParticleSourceObject listType)
Update ROE masks by excluding or keeping particles.
void updateMasksWithV0(const StoreObjPtr< RestOfEvent > &roe, const std::vector< const Particle * > &particlesToUpdate)
Update ROE masks with provided composite particle collection.
RestOfEventUpdaterModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::string m_inputListName
Name of the ParticleList which contains information that will be used for updating.
bool m_discard
Update the ROE mask by passing or discarding particles in the provided particle list.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored 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.
Abstract base class for different kinds of events.