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>
32 setDescription(
"Updates an existing mask (map of boolean values) for tracks or eclClusters in RestOfEvent with an available property (e.g. after performing training).");
36 std::vector<std::string> emptyMaskVector;
37 std::string emptyCutString;
39 addParam(
"particleList",
m_inputListName,
"Name of the ParticleList which contains information that will be used for updating");
41 addParam(
"cutString",
m_selection,
"Cut string which will be used for updating masks", emptyCutString);
43 "Update the ROE mask by passing or discarding particles in the provided particle list, default is to pass",
false);
53 B2INFO(
"RestOfEventUpdater updated track/eclCluster ROEMask(s) with infoList: " <<
m_inputListName <<
" and cut: " <<
m_selection);
59 B2WARNING(
"Input list " <<
m_inputList.getName() <<
" was not created?");
64 B2WARNING(
"ROE list is not valid somehow, ROE masks are not updated!");
67 std::set<Particle::EParticleSourceObject> encounteredSources;
71 std::vector<const Particle*> particlesFromTracksToUpdate;
72 std::vector<const Particle*> particlesFromECLClustersToUpdate;
73 std::vector<const Particle*> particlesFromKLMClustersToUpdate;
74 std::vector<const Particle*> compositeParticlesToUpdate;
75 for (
unsigned j = 0; j <
m_inputList->getListSize(); j++) {
78 encounteredSources.insert(mdstSource);
79 if (
m_cut->check(partWithInfo)) {
80 if (mdstSource == Particle::EParticleSourceObject::c_Track) {
81 particlesFromTracksToUpdate.push_back(partWithInfo);
82 }
else if (mdstSource == Particle::EParticleSourceObject::c_ECLCluster) {
83 particlesFromECLClustersToUpdate.push_back(partWithInfo);
84 }
else if (mdstSource == Particle::EParticleSourceObject::c_KLMCluster) {
85 particlesFromKLMClustersToUpdate.push_back(partWithInfo);
86 }
else if (mdstSource == Particle::EParticleSourceObject::c_Composite or
87 mdstSource == Particle::EParticleSourceObject::c_V0) {
88 compositeParticlesToUpdate.push_back(partWithInfo);
92 if (encounteredSources.count(Particle::EParticleSourceObject::c_Track) > 0) {
95 if (encounteredSources.count(Particle::EParticleSourceObject::c_ECLCluster) > 0) {
98 if (encounteredSources.count(Particle::EParticleSourceObject::c_KLMCluster) > 0) {
106 const std::vector<const Particle*>& particlesToUpdate)
108 if (particlesToUpdate.size() == 0) {
109 B2DEBUG(10,
"No particles in list provided, nothing to do");
113 if (maskToUpdate ==
"") {
114 B2FATAL(
"Cannot update ROE mask with no name!");
116 for (
auto* particleV0 : particlesToUpdate) {
117 if (!roe->checkCompatibilityOfMaskAndV0(maskToUpdate, particleV0)) {
120 roe->updateMaskWithV0(maskToUpdate, particleV0);
129 if (maskToUpdate ==
"") {
130 B2FATAL(
"Cannot update ROE mask with no name!");
132 if (!roe->hasMask(maskToUpdate)) {
134 roe->initializeMask(maskToUpdate,
"ROEUpdaterModule");
136 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.